diff --git a/.hgtags b/.hgtags index aed15434fbb94b4d85f90acd32b6510a348919d5..227c1a7f7f936316237bb899ff44e5b83f333ce2 100644 --- a/.hgtags +++ b/.hgtags @@ -1018,3 +1018,26 @@ d32fc856e071ff49c8a4c94682caad57f6c6874f jdk8u242-b01 b2865f7f557fcaec84445b034b2de2b27456b6c5 jdk8u242-b05 0d27e60569f7cf85cbdb0a83436e772e9256b5b0 jdk8u242-b06 034a65a05bfbfb06e14d3d39efa0c9f27683573a jdk8u242-b07 +c63c2923e1f99c1f350bd24b42daf885023f18b7 jdk8u242-b08 +c63c2923e1f99c1f350bd24b42daf885023f18b7 jdk8u242-ga +44c4cee50aeb94c4629e642681ff099ad9dcac12 jdk8u252-b00 +4dd113d7811ea6651c1c96f9c641b8bec8e31669 jdk8u252-b01 +8d39522b0f7573e69260eb3f7af360b72b27dfc3 jdk8u252-b02 +9099e882f08e33e091ff14239461047fc8ab787f jdk8u252-b03 +b67f77679d02d6634666578983103ce5d16a3a9b jdk8u252-b04 +b959971e0a5a609453c3a122755fc987c36f0566 jdk8u252-b05 +b959971e0a5a609453c3a122755fc987c36f0566 jdk8u262-b00 +6f7370a85071d54772615abab532264dba461c51 jdk8u252-b06 +2a93ed39a4e92e02bd59a02aac6cd9ed6defd386 jdk8u252-b07 +e17fe591a374d25725b077f5e99a87de6eb2ab5b jdk8u252-b08 +3ad9fa6a5a13fab2188de93bdaa38c1a7f8f5521 jdk8u252-b09 +3ad9fa6a5a13fab2188de93bdaa38c1a7f8f5521 jdk8u252-ga +f332bb3e282f082f2d386ea860fc5c4b4652f2bd jdk8u262-b01 +460f472657bd5e790e426f288d06a8e0c9922869 jdk8u262-b02 +7ea5c6fef715848a237323fc0e4f83b3dcd9d993 jdk8u262-b03 +63cecc0bd71d5226d7bdf81aeaa2e662dbad54c9 jdk8u262-b04 +4789a6a01301851b530fddbf7b0ce28f717f3de7 jdk8u262-b05 +097f47e7fe97b47dcb02603d9d592e1cba7f564e jdk8u262-b06 +745caf348aeec7b19f9f92ad283e3f8bd498dd02 jdk8u262-b07 +235d2e871a2ec6ddc97956caddd69f589a390649 jdk8u262-b08 +e36dcb7d407e9d4d739e03ce1dd2b641bd59ec30 jdk8u262-b09 diff --git a/THIRD_PARTY_README b/THIRD_PARTY_README index 643ea79ce6e2469ba63c072cb29d345611f45af2..a76235de290337682e8ba1678014ac7e405ab356 100644 --- a/THIRD_PARTY_README +++ b/THIRD_PARTY_README @@ -1643,7 +1643,7 @@ July 15, 2018 ------------------------------------------------------------------------------- -%% This notice is provided with respect to GIFLIB 5.1.8 & libungif 4.1.3, +%% This notice is provided with respect to GIFLIB 5.2.1 & libungif 4.1.3, which may be included with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- @@ -1712,10 +1712,60 @@ which may be included with JRE 8, JDK 8, and OpenJDK 8 source distributions. --- begin of LICENSE --- + Mesa 3-D Graphics Library v19.2.1 + + Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + +Attention, Contributors + +When contributing to the Mesa project you must agree to the licensing terms +of the component to which you're contributing. +The following section lists the primary components of the Mesa distribution +and their respective licenses. +Mesa Component Licenses + + + +Component Location License +------------------------------------------------------------------ +Main Mesa code src/mesa/ MIT +Device drivers src/mesa/drivers/* MIT, generally + +Gallium code src/gallium/ MIT + +Ext headers GL/glext.h Khronos + GL/glxext.h Khronos + GL/wglext.h Khronos + KHR/khrplatform.h Khronos + +***************************************************************************** + +---- +include/GL/gl.h : + + Mesa 3-D graphics library - Version: 5.0 - Copyright (C) 1999-2002 Brian Paul All Rights Reserved. + Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + Copyright (C) 2009 VMware, Inc. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -1730,9 +1780,67 @@ which may be included with JRE 8, JDK 8, and OpenJDK 8 source distributions. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. + + ***************************************************************************** + +---- +include/GL/glext.h +include/GL/glxext.h +include/GL/wglxext.h : + + + Copyright (c) 2013 - 2018 The Khronos Group Inc. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and/or associated documentation files (the + "Materials"), to deal in the Materials without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Materials, and to + permit persons to whom the Materials are furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Materials. + + THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + + ***************************************************************************** + +---- +include/KHR/khrplatform.h : + + Copyright (c) 2008 - 2018 The Khronos Group Inc. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and/or associated documentation files (the + "Materials"), to deal in the Materials without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Materials, and to + permit persons to whom the Materials are furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Materials. + + THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + + ***************************************************************************** --- end of LICENSE --- @@ -2790,23 +2898,21 @@ to do so,subject to the following conditions: ------------------------------------------------------------------------------- -%% This notice is provided with respect to X Window System 6.8.2, which may be +%% This notice is provided with respect to xwd v1.0.7, which may be included with JRE 8, JDK 8, and OpenJDK 8 on Linux and Solaris. +xwd utility + --- begin of LICENSE --- -This is the copyright for the files in src/solaris/native/sun/awt: list.h, -multiVis.h, wsutils.h, list.c, multiVis.c -Copyright (c) 1994 Hewlett-Packard Co. -Copyright (c) 1996 X Consortium +Copyright 1994 Hewlett-Packard Co. +Copyright 1996, 1998 The Open Group -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -2814,15 +2920,15 @@ in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -Except as contained in this notice, the name of the X Consortium shall +Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization -from the X Consortium. +from The Open Group. --- end of LICENSE --- _____________________________ diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/IOUtils.java b/jdk/test/lib/testlibrary/jdk/testlibrary/IOUtils.java deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/make/CompileLaunchers.gmk b/make/CompileLaunchers.gmk index d85815199d08bcceb5176b41d662ec2a4953efb8..9727ce1a315b4f144a4f5645e9f333b83afa1ead 100644 --- a/make/CompileLaunchers.gmk +++ b/make/CompileLaunchers.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. # 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,8 +163,7 @@ define SetupLauncher -DLAUNCHER_NAME='"$(LAUNCHER_NAME)"' \ -DPROGNAME='"$1"' $(DPACKAGEPATH) \ $2, \ - CFLAGS_linux := -fPIC, \ - CFLAGS_solaris := -KPIC -DHAVE_GETHRTIME, \ + CFLAGS_solaris := -KPIC, \ LDFLAGS := $(LDFLAGS_JDKEXE) \ $(ORIGIN_ARG) \ $$($1_LDFLAGS), \ @@ -303,6 +302,12 @@ $(eval $(call SetupLauncher,jdb, \ -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.example.debug.tty.TTY"$(COMMA) }' \ -DAPP_CLASSPATH='{ "/lib/tools.jar"$(COMMA) "/lib/sa-jdi.jar"$(COMMA) "/classes" }')) +ifeq ($(ENABLE_JFR), true) +$(eval $(call SetupLauncher,jfr, \ + -DEXPAND_CLASSPATH_WILDCARDS \ + -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "jdk.jfr.internal.tool.Main"$(COMMA) }')) +endif + $(eval $(call SetupLauncher,jhat, \ -DJAVA_ARGS='{ "-J-ms8m"$(COMMA) "com.sun.tools.hat.Main"$(COMMA) }')) diff --git a/make/CopyFiles.gmk b/make/CopyFiles.gmk index da6d4c53ea2461404d1b54a27f357aba05d568f6..59b0cdcd264bf1c682ab7e82f5bbfcfab45d7450 100644 --- a/make/CopyFiles.gmk +++ b/make/CopyFiles.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -408,13 +408,17 @@ COPY_FILES += $(POLICY_DST) ########################################################################################## +# CACERTS_FILE is optionally set in configure to override the default cacerts +# which is otherwise generated in GenerateData.gmk CACERTS_SRC := $(CACERTS_FILE) CACERTS_DST := $(JDK_OUTPUTDIR)/lib/security/cacerts $(CACERTS_DST): $(CACERTS_SRC) $(call install-file) -COPY_FILES += $(CACERTS_DST) +ifneq ($(CACERTS_FILE), ) + COPY_FILES += $(CACERTS_DST) +endif ########################################################################################## @@ -595,4 +599,15 @@ COPY_FILES += $(JDK_OUTPUTDIR)/lib/sound.properties ########################################################################################## +$(JDK_OUTPUTDIR)/lib/jfr/%: $(JDK_TOPDIR)/src/share/classes/jdk/jfr/conf/% + $(call install-file) + +ifeq ($(ENABLE_JFR), true) + COPY_FILES += $(subst $(JDK_TOPDIR)/src/share/classes/jdk/jfr/conf, \ + $(JDK_OUTPUTDIR)/lib/jfr, \ + $(wildcard $(JDK_TOPDIR)/src/share/classes/jdk/jfr/conf/*)) +endif + +########################################################################################## + -include $(CUSTOM_MAKE_DIR)/CopyFiles.gmk diff --git a/make/CopyIntoClasses.gmk b/make/CopyIntoClasses.gmk index 1f914d0e4f7f23240788ae01ceb94845300cead4..ff26f9a6a74a78b2f56b7de3dcd83c2e07786ce3 100644 --- a/make/CopyIntoClasses.gmk +++ b/make/CopyIntoClasses.gmk @@ -97,12 +97,6 @@ ifndef OPENJDK $(SWING_PLAF_WINDOWS_RESOURCES_DIR_CLOSED)/icons/JavaCup32.png endif -ifeq ($(ENABLE_JFR), true) - JFR_CONFIGURATION_DIR_CLOSED = $(JDK_TOPDIR)/src/closed/share/classes/oracle/jrockit/jfr/settings - COPY_FILES += \ - $(JFR_CONFIGURATION_DIR_CLOSED)/jfc.xsd -endif - SWING_PLAF_BASIC_RESOURCES_DIR = $(JDK_TOPDIR)/src/share/classes/javax/swing/plaf/basic COPY_FILES += \ $(wildcard $(SWING_PLAF_BASIC_RESOURCES_DIR)/icons/*.png) diff --git a/make/CreateJars.gmk b/make/CreateJars.gmk index 72b146de27b6a282f21167b024087f084247c20e..4fe038f64e036ede1b1b4339e9d53c44aa5656ee 100644 --- a/make/CreateJars.gmk +++ b/make/CreateJars.gmk @@ -211,10 +211,9 @@ RT_JAR_EXCLUDES += \ sun/util/cldr/CLDRLocaleDataMetaInfo.class \ sun/util/resources/cldr \ $(LOCALEDATA_INCLUDES) \ - com/oracle/jrockit/jfr \ - oracle/jrockit/jfr \ - jdk/jfr \ - com/alibaba/tenant/JGroupMain.class + com/alibaba/tenant/JGroupMain.class \ + jdk/management/jfr \ + jdk/jfr # Find all files in the classes dir to use as dependencies. This could be more fine granular. ALL_FILES_IN_CLASSES := $(call not-containing, _the., $(filter-out %javac_state, \ @@ -401,20 +400,17 @@ $(eval $(call SetupArchive,BUILD_CHARSETS_JAR, , \ ########################################################################################## -ifndef OPENJDK - ifeq ($(ENABLE_JFR), true) - $(eval $(call SetupArchive,BUILD_JFR_JAR, , \ - SRCS := $(JDK_OUTPUTDIR)/classes, \ - SUFFIXES := .class .jfc .xsd, \ - INCLUDES := com/oracle/jrockit/jfr \ - oracle/jrockit/jfr \ - jdk/jfr, \ - JAR := $(IMAGES_OUTPUTDIR)/lib/jfr.jar, \ - SKIP_METAINF := true, \ - MANIFEST := $(MAINMANIFEST), \ - CHECK_COMPRESS_JAR := true)) +ifeq ($(ENABLE_JFR), true) + $(eval $(call SetupArchive,BUILD_JFR_JAR, , \ + SRCS := $(JDK_OUTPUTDIR)/classes $(HOTSPOT_DIST)/jre/lib, \ + SUFFIXES := .class .jfc .xsd .xml, \ + INCLUDES := jdk/management/jfr \ + jdk/jfr, \ + JAR := $(IMAGES_OUTPUTDIR)/lib/jfr.jar, \ + SKIP_METAINF := true, \ + MANIFEST := $(MAINMANIFEST), \ + CHECK_COMPRESS_JAR := true)) - endif endif ########################################################################################## diff --git a/make/GenerateData.gmk b/make/GenerateData.gmk index 1dc18b3ee2123a29d92685c5bf09b9ee57e40b72..034acfd49ee50010b5c2c76921c239c514c3d78b 100644 --- a/make/GenerateData.gmk +++ b/make/GenerateData.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. # 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,6 +52,20 @@ GENDATA += $(GENDATA_HTML32DTD) ########################################################################################## +GENDATA_CACERTS_SRC := $(JDK_TOPDIR)/make/data/cacerts/ +GENDATA_CACERTS := $(JDK_OUTPUTDIR)/lib/security/cacerts + +$(GENDATA_CACERTS): $(BUILD_TOOLS) $(wildcard $(GENDATA_CACERTS_SRC)/*) + $(ECHO) $(LOG_INFO) "Generating cacerts" + $(MKDIR) -p $(@D) + $(TOOL_GENERATECACERTS) $(GENDATA_CACERTS_SRC) $@ + +ifeq ($(CACERTS_FILE), ) + GENDATA += $(GENDATA_CACERTS) +endif + +################################################################################ + GENDATA_UNINAME := $(JDK_OUTPUTDIR)/classes/java/lang/uniName.dat $(GENDATA_UNINAME): $(JDK_TOPDIR)/make/data/unicodedata/UnicodeData.txt $(BUILD_TOOLS) diff --git a/make/Images.gmk b/make/Images.gmk index 9ee3e19b6f781f99255b29a6c3587395abe7a641..b32a209dca56b186d6793b508ca3f2101f342413 100644 --- a/make/Images.gmk +++ b/make/Images.gmk @@ -127,7 +127,8 @@ ifeq ($(PROFILE), ) jsadebugd$(EXE_SUFFIX) \ jhat$(EXE_SUFFIX) \ clhsdb$(EXE_SUFFIX) \ - hsdb$(EXE_SUFFIX) + hsdb$(EXE_SUFFIX) \ + jfr$(EXE_SUFFIX) # jgroup is not included in JRE build ifeq ($(OPENJDK_TARGET_OS), linux) NOT_JRE_BIN_FILES += jgroup$(EXE_SUFFIX) diff --git a/make/Tools.gmk b/make/Tools.gmk index b03419a03f7b215067ae89bde5537f5cf94cac5a..8a9f127bba93df87f4472bfbfc65b0525f81ab74 100644 --- a/make/Tools.gmk +++ b/make/Tools.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. # 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,9 @@ TOOL_HASHER = $(JAVA_SMALL) -cp $(JDK_OUTPUTDIR)/btclasses \ TOOL_TZDB = $(JAVA_SMALL) -cp $(JDK_OUTPUTDIR)/btclasses \ build.tools.tzdb.TzdbZoneRulesCompiler +TOOL_GENERATECACERTS = $(JAVA_SMALL) -cp $(JDK_OUTPUTDIR)/btclasses \ + build.tools.generatecacerts.GenerateCacerts + # TODO: There are references to the jdwpgen.jar in jdk/make/netbeans/jdwpgen/build.xml # and nbproject/project.properties in the same dir. Needs to be looked at. diff --git a/make/data/cacerts/README b/make/data/cacerts/README new file mode 100644 index 0000000000000000000000000000000000000000..25d2d779007bf09366bca02e04de737982ab4553 --- /dev/null +++ b/make/data/cacerts/README @@ -0,0 +1,10 @@ +Each file in this directory (except for this README) contains a CA certificate in PEM format. It can be generated with + +keytool -J-Duser.timezone=GMT -printcert -file ca.cert | sed -n '1,4p;8,10p' +keytool -printcert -file ca.cert -rfc + +Please note the textual part before the "-----BEGIN CERTIFICATE-----" line is just a suggestion and not arbitrary. + +After any change in this directory, please remember to update the content of `test/jdk/sun/security/lib/cacerts/VerifyCACerts.java` as well. + +All changes to this directory need to be approved by the Security group. diff --git a/make/data/cacerts/actalisauthenticationrootca b/make/data/cacerts/actalisauthenticationrootca new file mode 100644 index 0000000000000000000000000000000000000000..9c1d9a939ecb6523cdb24ae1ca8365a642abd0cd --- /dev/null +++ b/make/data/cacerts/actalisauthenticationrootca @@ -0,0 +1,40 @@ +Owner: CN=Actalis Authentication Root CA, O=Actalis S.p.A./03358520967, L=Milan, C=IT +Issuer: CN=Actalis Authentication Root CA, O=Actalis S.p.A./03358520967, L=Milan, C=IT +Serial number: 570a119742c4e3cc +Valid from: Thu Sep 22 11:22:02 GMT 2011 until: Sun Sep 22 11:22:02 GMT 2030 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIFuzCCA6OgAwIBAgIIVwoRl0LE48wwDQYJKoZIhvcNAQELBQAwazELMAkGA1UE +BhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8w +MzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290 +IENBMB4XDTExMDkyMjExMjIwMloXDTMwMDkyMjExMjIwMlowazELMAkGA1UEBhMC +SVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8wMzM1 +ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290IENB +MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAp8bEpSmkLO/lGMWwUKNv +UTufClrJwkg4CsIcoBh/kbWHuUA/3R1oHwiD1S0eiKD4j1aPbZkCkpAW1V8IbInX +4ay8IMKx4INRimlNAJZaby/ARH6jDuSRzVju3PvHHkVH3Se5CAGfpiEd9UEtL0z9 +KK3giq0itFZljoZUj5NDKd45RnijMCO6zfB9E1fAXdKDa0hMxKufgFpbOr3JpyI/ +gCczWw63igxdBzcIy2zSekciRDXFzMwujt0q7bd9Zg1fYVEiVRvjRuPjPdA1Yprb +rxTIW6HMiRvhMCb8oJsfgadHHwTrozmSBp+Z07/T6k9QnBn+locePGX2oxgkg4YQ +51Q+qDp2JE+BIcXjDwL4k5RHILv+1A7TaLndxHqEguNTVHnd25zS8gebLra8Pu2F +be8lEfKXGkJh90qX6IuxEAf6ZYGyojnP9zz/GPvG8VqLWeICrHuS0E4UT1lF9gxe +KF+w6D9Fz8+vm2/7hNN3WpVvrJSEnu68wEqPSpP4RCHiMUVhUE4Q2OM1fEwZtN4F +v6MGn8i1zeQf1xcGDXqVdFUNaBr8EBtiZJ1t4JWgw5QHVw0U5r0F+7if5t+L4sbn +fpb2U8WANFAoWPASUHEXMLrmeGO89LKtmyuy/uE5jF66CyCU3nuDuP/jVo23Eek7 +jPKxwV2dpAtMK9myGPW1n0sCAwEAAaNjMGEwHQYDVR0OBBYEFFLYiDrIn3hm7Ynz +ezhwlMkCAjbQMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUUtiIOsifeGbt +ifN7OHCUyQICNtAwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBCwUAA4ICAQAL +e3KHwGCmSUyIWOYdiPcUZEim2FgKDk8TNd81HdTtBjHIgT5q1d07GjLukD0R0i70 +jsNjLiNmsGe+b7bAEzlgqqI0JZN1Ut6nna0Oh4lScWoWPBkdg/iaKWW+9D+a2fDz +WochcYBNy+A4mz+7+uAwTc+G02UQGRjRlwKxK3JCaKygvU5a2hi/a5iB0P2avl4V +SM0RFbnAKVy06Ij3Pjaut2L9HmLecHgQHEhb2rykOLpn7VU+Xlff1ANATIGk0k9j +pwlCCRT8AKnCgHNPLsBA2RF7SOp6AsDT6ygBJlh0wcBzIm2Tlf05fbsq4/aC4yyX +X04fkZT6/iyj2HYauE2yOE+b+h1IYHkm4vP9qdCa6HCPSXrW5b0KDtst842/6+Ok +fcvHlXHo2qN8xcL4dJIEG4aspCJTQLas/kx2z/uUMsA1n3Y/buWQbqCmJqK4LL7R +K4X9p2jIugErsWx0Hbhzlefut8cl8ABMALJ+tguLHPPAUJ4lueAI3jZm/zel0btU +ZCzJJ7VLkn5l/9Mt4blOvH+kQSGQQXemOR/qnuOf0GZvBeyqdn6/axag67XH/JJU +LysRJyU3eExRarDzzFhdFPFqSBX/wge2sY0PjlxQRrM9vwGYT7JZVEc+NHt4bVaT +LnPqZih4zR0Uv6CPLy64Lo7yFIrM6bV8+2ydDKXhlg== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/addtrustexternalca b/make/data/cacerts/addtrustexternalca new file mode 100644 index 0000000000000000000000000000000000000000..ad84cad9629b3b43488d3674c791a217a19d4b8a --- /dev/null +++ b/make/data/cacerts/addtrustexternalca @@ -0,0 +1,32 @@ +Owner: CN=AddTrust External CA Root, OU=AddTrust External TTP Network, O=AddTrust AB, C=SE +Issuer: CN=AddTrust External CA Root, OU=AddTrust External TTP Network, O=AddTrust AB, C=SE +Serial number: 1 +Valid from: Tue May 30 10:48:38 GMT 2000 until: Sat May 30 10:48:38 GMT 2020 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIENjCCAx6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBvMQswCQYDVQQGEwJTRTEU +MBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFkZFRydXN0IEV4dGVybmFs +IFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBFeHRlcm5hbCBDQSBSb290 +MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEwNDgzOFowbzELMAkGA1UEBhMCU0Ux +FDASBgNVBAoTC0FkZFRydXN0IEFCMSYwJAYDVQQLEx1BZGRUcnVzdCBFeHRlcm5h +bCBUVFAgTmV0d29yazEiMCAGA1UEAxMZQWRkVHJ1c3QgRXh0ZXJuYWwgQ0EgUm9v +dDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALf3GjPm8gAELTngTlvt +H7xsD821+iO2zt6bETOXpClMfZOfvUq8k+0DGuOPz+VtUFrWlymUWoCwSXrbLpX9 +uMq/NzgtHj6RQa1wVsfwTz/oMp50ysiQVOnGXw94nZpAPA6sYapeFI+eh6FqUNzX +mk6vBbOmcZSccbNQYArHE504B4YCqOmoaSYYkKtMsE8jqzpPhNjfzp/haW+710LX +a0Tkx63ubUFfclpxCDezeWWkWaCUN/cALw3CknLa0Dhy2xSoRcRdKn23tNbE7qzN +E0S3ySvdQwAl+mG5aWpYIxG3pzOPVnVZ9c0p10a3CitlttNCbxWyuHv77+ldU9U0 +WicCAwEAAaOB3DCB2TAdBgNVHQ4EFgQUrb2YejS0Jvf6xCZU7wO94CTLVBowCwYD +VR0PBAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wgZkGA1UdIwSBkTCBjoAUrb2YejS0 +Jvf6xCZU7wO94CTLVBqhc6RxMG8xCzAJBgNVBAYTAlNFMRQwEgYDVQQKEwtBZGRU +cnVzdCBBQjEmMCQGA1UECxMdQWRkVHJ1c3QgRXh0ZXJuYWwgVFRQIE5ldHdvcmsx +IjAgBgNVBAMTGUFkZFRydXN0IEV4dGVybmFsIENBIFJvb3SCAQEwDQYJKoZIhvcN +AQEFBQADggEBALCb4IUlwtYj4g+WBpKdQZic2YR5gdkeWxQHIzZlj7DYd7usQWxH +YINRsPkyPef89iYTx4AWpb9a/IfPeHmJIZriTAcKhjW88t5RxNKWt9x+Tu5w/Rw5 +6wwCURQtjr0W4MHfRnXnJK3s9EK0hZNwEGe6nQY1ShjTK3rMUUKhemPR5ruhxSvC +Nr4TDea9Y355e6cJDUCrat2PisP29owaQgVR1EX1n6diIWgVIEM8med8vSTYqZEX +c4g/VhsxOBi0cQ+azcgOno4uG+GMmIPLHzHxREzGBHNJdmAPx/i9F4BrLunMTA5a +mnkPIAou1Z5jJh5VkpTYghdae9C8x49OhgQ= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/addtrustqualifiedca b/make/data/cacerts/addtrustqualifiedca new file mode 100644 index 0000000000000000000000000000000000000000..0c62d44c7626da73fc5e1a4f25af2cb35cb8168f --- /dev/null +++ b/make/data/cacerts/addtrustqualifiedca @@ -0,0 +1,32 @@ +Owner: CN=AddTrust Qualified CA Root, OU=AddTrust TTP Network, O=AddTrust AB, C=SE +Issuer: CN=AddTrust Qualified CA Root, OU=AddTrust TTP Network, O=AddTrust AB, C=SE +Serial number: 1 +Valid from: Tue May 30 10:44:50 GMT 2000 until: Sat May 30 10:44:50 GMT 2020 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIEHjCCAwagAwIBAgIBATANBgkqhkiG9w0BAQUFADBnMQswCQYDVQQGEwJTRTEU +MBIGA1UEChMLQWRkVHJ1c3QgQUIxHTAbBgNVBAsTFEFkZFRydXN0IFRUUCBOZXR3 +b3JrMSMwIQYDVQQDExpBZGRUcnVzdCBRdWFsaWZpZWQgQ0EgUm9vdDAeFw0wMDA1 +MzAxMDQ0NTBaFw0yMDA1MzAxMDQ0NTBaMGcxCzAJBgNVBAYTAlNFMRQwEgYDVQQK +EwtBZGRUcnVzdCBBQjEdMBsGA1UECxMUQWRkVHJ1c3QgVFRQIE5ldHdvcmsxIzAh +BgNVBAMTGkFkZFRydXN0IFF1YWxpZmllZCBDQSBSb290MIIBIjANBgkqhkiG9w0B +AQEFAAOCAQ8AMIIBCgKCAQEA5B6a/twJWoekn0e+EV+vhDTbYjx5eLfpMLXsDBwq +xBb/4Oxx64r1EW7tTw2R0hIYLUkVAcKkIhPHEWT/IhKauY5cLwjPcWqzZwFZ8V1G +87B4pfYOQnrjfxvM0PC3KP0q6p6zsLkEqv32x7SxuCqg+1jxGaBvcCV+PmlKfw8i +2O+tCBGaKZnhqkRFmhJePp1tUvznoD1oL/BLcHwTOK28FSXx1s6rosAx1i+f4P8U +WfyEk9mHfExUE+uf0S0R+Bg6Ot4l2ffTQO2kBhLEO+GRwVY18BTcZTYJbqukB8c1 +0cIDMzZbdSZtQvESa0NvS3GU+jQd7RNuyoB/mC9suWXY6QIDAQABo4HUMIHRMB0G +A1UdDgQWBBQ5lYtii1zJ1IC6WA+XPxUIQ8yYpzALBgNVHQ8EBAMCAQYwDwYDVR0T +AQH/BAUwAwEB/zCBkQYDVR0jBIGJMIGGgBQ5lYtii1zJ1IC6WA+XPxUIQ8yYp6Fr +pGkwZzELMAkGA1UEBhMCU0UxFDASBgNVBAoTC0FkZFRydXN0IEFCMR0wGwYDVQQL +ExRBZGRUcnVzdCBUVFAgTmV0d29yazEjMCEGA1UEAxMaQWRkVHJ1c3QgUXVhbGlm +aWVkIENBIFJvb3SCAQEwDQYJKoZIhvcNAQEFBQADggEBABmrder4i2VhlRO6aQTv +hsoToMeqT2QbPxj2qC0sVY8FtzDqQmodwCVRLae/DLPt7wh/bDxGGuoYQ992zPlm +hpwsaPXpF/gxsxjE1kh9I0xowX67ARRvxdlu3rsEQmr49lx95dr6h+sNNVJn0J6X +dgWTP5XHAeZpVTh/EGGZyeNfpso+gmNIquIISD6q8rKFYqa0p9m9N5xotS1WfbC3 +P6CxB9bpT9zeRXEwMn8bLgn5v1Kh7sKAPgZcLlVAwRv1cEWw3F369nJad9Jjzc9Y +iQBCYz95OdBEsIJuQRno3eDBiFrRHnGTHyQwdOUeqN48Jzd/g66ed8/wMLH/S5no +xqE= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/affirmtrustcommercialca b/make/data/cacerts/affirmtrustcommercialca new file mode 100644 index 0000000000000000000000000000000000000000..5caddfd3a0a5a54acbc76e34975a8bbd97625777 --- /dev/null +++ b/make/data/cacerts/affirmtrustcommercialca @@ -0,0 +1,27 @@ +Owner: CN=AffirmTrust Commercial, O=AffirmTrust, C=US +Issuer: CN=AffirmTrust Commercial, O=AffirmTrust, C=US +Serial number: 7777062726a9b17c +Valid from: Fri Jan 29 14:06:06 GMT 2010 until: Tue Dec 31 14:06:06 GMT 2030 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDTDCCAjSgAwIBAgIId3cGJyapsXwwDQYJKoZIhvcNAQELBQAwRDELMAkGA1UE +BhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVz +dCBDb21tZXJjaWFsMB4XDTEwMDEyOTE0MDYwNloXDTMwMTIzMTE0MDYwNlowRDEL +MAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZp +cm1UcnVzdCBDb21tZXJjaWFsMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC +AQEA9htPZwcroRX1BiLLHwGy43NFBkRJLLtJJRTWzsO3qyxPxkEylFf6EqdbDuKP +Hx6GGaeqtS25Xw2Kwq+FNXkyLbscYjfysVtKPcrNcV/pQr6U6Mje+SJIZMblq8Yr +ba0F8PrVC8+a5fBQpIs7R6UjW3p6+DM/uO+Zl+MgwdYoic+U+7lF7eNAFxHUdPAL +MeIrJmqbTFeurCA+ukV6BfO9m2kVrn1OIGPENXY6BwLJN/3HR+7o8XYdcxXyl6S1 +yHp52UKqK39c/s4mT6NmgTWvRLpUHhwwMmWd5jyTXlBOeuM61G7MGvv50jeuJCqr +VwMiKA1JdX+3KNp1v47j3A55MQIDAQABo0IwQDAdBgNVHQ4EFgQUnZPGU4teyq8/ +nx4P5ZmVvCT2lI8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwDQYJ +KoZIhvcNAQELBQADggEBAFis9AQOzcAN/wr91LoWXym9e2iZWEnStB03TX8nfUYG +XUPGhi4+c7ImfU+TqbbEKpqrIZcUsd6M06uJFdhrJNTxFq7YpFzUf1GO7RgBsZNj +vbz4YYCanrHOQnDiqX0GJX0nof5v7LMeJNrjS1UaADs1tDvZ110w/YETifLCBivt +Z8SOyUOyXGsViQK8YvxO8rUzqrJv0wqiUOP2O+guRMLbZjipM1ZI8W0bM40NjD9g +N53Tym1+NH4Nn3J2ixufcv1SNUFFApYvHLKac0khsUlHRUe072o0EclNmsxZt9YC +nlpOZbWUrhvfKbAW8b8Angc6F2S1BLUjIZkKlTuXfO8= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/affirmtrustnetworkingca b/make/data/cacerts/affirmtrustnetworkingca new file mode 100644 index 0000000000000000000000000000000000000000..c773326d4b95072d5c6431b326278f448ade6fec --- /dev/null +++ b/make/data/cacerts/affirmtrustnetworkingca @@ -0,0 +1,27 @@ +Owner: CN=AffirmTrust Networking, O=AffirmTrust, C=US +Issuer: CN=AffirmTrust Networking, O=AffirmTrust, C=US +Serial number: 7c4f04391cd4992d +Valid from: Fri Jan 29 14:08:24 GMT 2010 until: Tue Dec 31 14:08:24 GMT 2030 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDTDCCAjSgAwIBAgIIfE8EORzUmS0wDQYJKoZIhvcNAQEFBQAwRDELMAkGA1UE +BhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVz +dCBOZXR3b3JraW5nMB4XDTEwMDEyOTE0MDgyNFoXDTMwMTIzMTE0MDgyNFowRDEL +MAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZp +cm1UcnVzdCBOZXR3b3JraW5nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC +AQEAtITMMxcua5Rsa2FSoOujz3mUTOWUgJnLVWREZY9nZOIG41w3SfYvm4SEHi3y +YJ0wTsyEheIszx6e/jarM3c1RNg1lho9Nuh6DtjVR6FqaYvZ/Ls6rnla1fTWcbua +kCNrmreIdIcMHl+5ni36q1Mr3Lt2PpNMCAiMHqIjHNRqrSK6mQEubWXLviRmVSRL +QESxG9fhwoXA3hA/Pe24/PHxI1Pcv2WXb9n5QHGNfb2V1M6+oF4nI979ptAmDgAp +6zxG8D1gvz9Q0twmQVGeFDdCBKNwV6gbh+0t+nvujArjqWaJGctB+d1ENmHP4ndG +yH329JKBNv3bNPFyfvMMFr20FQIDAQABo0IwQDAdBgNVHQ4EFgQUBx/S55zawm6i +QLSwelAQUHTEyL0wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwDQYJ +KoZIhvcNAQEFBQADggEBAIlXshZ6qML91tmbmzTCnLQyFE2npN/svqe++EPbkTfO +tDIuUFUaNU52Q3Eg75N3ThVwLofDwR1t3Mu1J9QsVtFSUzpE0nPIxBsFZVpikpzu +QY0x2+c06lkh1QF612S4ZDnNye2v7UsDSKegmQGA3GWjNq5lWUhPgkvIZfFXHeVZ +Lgo/bNjR9eUJtGxUAArgFU2HdW23WJZa3W3SAKD0m0i+wzekujbgfIeFlxoVot4u +olu9rxj5kFDNcFn4J2dHy8egBzp90SxdbBk6ZrV9/ZFvgrG+CJPbFEfxojfHRZ48 +x3evZKiT3/Zpg4Jg8klCNO1aAFSFHBY2kgxc+qatv9s= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/affirmtrustpremiumca b/make/data/cacerts/affirmtrustpremiumca new file mode 100644 index 0000000000000000000000000000000000000000..275b495a25e8451985b16d2a8a607d7587815f0b --- /dev/null +++ b/make/data/cacerts/affirmtrustpremiumca @@ -0,0 +1,38 @@ +Owner: CN=AffirmTrust Premium, O=AffirmTrust, C=US +Issuer: CN=AffirmTrust Premium, O=AffirmTrust, C=US +Serial number: 6d8c1446b1a60aee +Valid from: Fri Jan 29 14:10:36 GMT 2010 until: Mon Dec 31 14:10:36 GMT 2040 +Signature algorithm name: SHA384withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIFRjCCAy6gAwIBAgIIbYwURrGmCu4wDQYJKoZIhvcNAQEMBQAwQTELMAkGA1UE +BhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVz +dCBQcmVtaXVtMB4XDTEwMDEyOTE0MTAzNloXDTQwMTIzMTE0MTAzNlowQTELMAkG +A1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRydXN0MRwwGgYDVQQDDBNBZmZpcm1U +cnVzdCBQcmVtaXVtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAxBLf +qV/+Qd3d9Z+K4/as4Tx4mrzY8H96oDMq3I0gW64tb+eT2TZwamjPjlGjhVtnBKAQ +JG9dKILBl1fYSCkTtuG+kU3fhQxTGJoeJKJPj/CihQvL9Cl/0qRY7iZNyaqoe5rZ ++jjeRFcV5fiMyNlI4g0WJx0eyIOFJbe6qlVBzAMiSy2RjYvmia9mx+n/K+k8rNrS +s8PhaJyJ+HoAVt70VZVs+7pk3WKL3wt3MutizCaam7uqYoNMtAZ6MMgpv+0GTZe5 +HMQxK9VfvFMSF5yZVylmd2EhMQcuJUmdGPLu8ytxjLW6OQdJd/zvLpKQBY0tL3d7 +70O/Nbua2Plzpyzy0FfuKE4mX4+QaAkvuPjcBukumj5Rp9EixAqnOEhss/n/fauG +V+O61oV4d7pD6kh/9ti+I20ev9E2bFhc8e6kGVQa9QPSdubhjL08s9NIS+LI+H+S +qHZGnEJlPqQewQcDWkYtuJfzt9WyVSHvutxMAJf7FJUnM7/oQ0dG0giZFmA7mn7S +5u046uwBHjxIVkkJx0w3AJ6IDsBz4W9m6XJHMD4Q5QsDyZpCAGzFlH5hxIrff4Ia +C1nEWTJ3s7xgaVY5/bQGeyzWZDbZvUjthB9+pSKPKrhC9IK31FOQeE4tGv2Bb0TX +OwF0lkLgAOIua+rF7nKsu7/+6qqo+Nz2snmKtmcCAwEAAaNCMEAwHQYDVR0OBBYE +FJ3AZ6YMItkm9UWrpmVSESfYRaxjMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/ +BAQDAgEGMA0GCSqGSIb3DQEBDAUAA4ICAQCzV00QYk465KzquByvMiPIs0laUZx2 +KI15qldGF9X1Uva3ROgIRL8YhNILgM3FEv0AVQVhh0HctSSePMTYyPtwni94loMg +Nt58D2kTiKV1NpgIpsbfrM7jWNa3Pt668+s0QNiigfV4Py/VpfzZotReBA4Xrf5B +8OWycvpEgjNC6C1Y91aMYj+6QrCcDFx+LmUmXFNPALJ4fqENmS2NuB2OosSw/WDQ +MKSOyARiqcTtNd56l+0OOF6SL5Nwpamcb6d9Ex1+xghIsV5n61EIJenmJWtSKZGc +0jlzCFfemQa0W50QBuHCAKi4HEoCChTQwUHK+4w1IX2COPKpVJEZNZOUbWo6xbLQ +u4mGk+ibyQ86p3q4ofB4Rvr8Ny/lioTz3/4E2aFooC8k4gmVBtWVyuEklut89pMF +u+1z6S3RdTnX5yTb2E5fQ4+e0BQ5v1VwSJlXMbSc7kqYA5YwH2AG7hsj/oFgIxpH +YoWlzBk0gG+zrBrjn/B7SK3VAdlntqlyk+otZrWyuOQ9PLLvTIzq6we/qzWaVYa8 +GKa1qF60g2xraUDTn9zxw2lrueFtCfTxqlB2Cnp9ehehVZZCmTEJ3WARjQUwfuaO +RtGdFNrHF+QFlozEJLUbzxQHskD4o55BhrwE0GuWyCqANP2/7waj3VjFhT0+j/6e +KeC2uAloGRwYQw== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/affirmtrustpremiumeccca b/make/data/cacerts/affirmtrustpremiumeccca new file mode 100644 index 0000000000000000000000000000000000000000..d0fcc1e7793aa5d6534079667002eda45c706469 --- /dev/null +++ b/make/data/cacerts/affirmtrustpremiumeccca @@ -0,0 +1,20 @@ +Owner: CN=AffirmTrust Premium ECC, O=AffirmTrust, C=US +Issuer: CN=AffirmTrust Premium ECC, O=AffirmTrust, C=US +Serial number: 7497258ac73f7a54 +Valid from: Fri Jan 29 14:20:24 GMT 2010 until: Mon Dec 31 14:20:24 GMT 2040 +Signature algorithm name: SHA384withECDSA +Subject Public Key Algorithm: 384-bit EC (secp384r1) key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIB/jCCAYWgAwIBAgIIdJclisc/elQwCgYIKoZIzj0EAwMwRTELMAkGA1UEBhMC +VVMxFDASBgNVBAoMC0FmZmlybVRydXN0MSAwHgYDVQQDDBdBZmZpcm1UcnVzdCBQ +cmVtaXVtIEVDQzAeFw0xMDAxMjkxNDIwMjRaFw00MDEyMzExNDIwMjRaMEUxCzAJ +BgNVBAYTAlVTMRQwEgYDVQQKDAtBZmZpcm1UcnVzdDEgMB4GA1UEAwwXQWZmaXJt +VHJ1c3QgUHJlbWl1bSBFQ0MwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQNMF4bFZ0D +0KF5Nbc6PJJ6yhUczWLznCZcBz3lVPqj1swS6vQUX+iOGasvLkjmrBhDeKzQN8O9 +ss0s5kfiGuZjuD0uL3jET9v0D6RoTFVya5UdThhClXjMNzyR4ptlKymjQjBAMB0G +A1UdDgQWBBSaryl6wBE1NSZRMADDav5A1a7WPDAPBgNVHRMBAf8EBTADAQH/MA4G +A1UdDwEB/wQEAwIBBjAKBggqhkjOPQQDAwNnADBkAjAXCfOHiFBar8jAQr9HX/Vs +aobgxCd05DhT1wV/GzTjxi+zygk8N53X57hG8f2h4nECMEJZh0PUUd+60wkyWs6I +flc9nF9Ca/UHLbXwgpP5WW+uZPpY5Yse42O+tYHNbwKMeQ== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/amazonrootca1 b/make/data/cacerts/amazonrootca1 new file mode 100644 index 0000000000000000000000000000000000000000..9431a65c93e59ea10771d60731276dbefe13900b --- /dev/null +++ b/make/data/cacerts/amazonrootca1 @@ -0,0 +1,27 @@ +Owner: CN=Amazon Root CA 1, O=Amazon, C=US +Issuer: CN=Amazon Root CA 1, O=Amazon, C=US +Serial number: 66c9fcf99bf8c0a39e2f0788a43e696365bca +Valid from: Tue May 26 00:00:00 GMT 2015 until: Sun Jan 17 00:00:00 GMT 2038 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF +ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6 +b24gUm9vdCBDQSAxMB4XDTE1MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTEL +MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv +b3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALJ4gHHKeNXj +ca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgHFzZM +9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qw +IFAGbHrQgLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6 +VOujw5H5SNz/0egwLX0tdHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L +93FcXmn/6pUCyziKrlA4b9v7LWIbxcceVOF34GfID5yHI9Y/QCB/IIDEgEw+OyQm +jgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC +AYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3DQEBCwUA +A4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDI +U5PMCCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUs +N+gDS63pYaACbvXy8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vv +o/ufQJVtMVT8QtPHRh8jrdkPSHCa2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU +5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2xJNDd2ZhwLnoQdeXeGADbkpy +rqXRfboQnoZsG4q5WTP468SQvvG5 +-----END CERTIFICATE----- diff --git a/make/data/cacerts/amazonrootca2 b/make/data/cacerts/amazonrootca2 new file mode 100644 index 0000000000000000000000000000000000000000..95e6f3270a9de148f750eb0e9d3f7abe23e7a4e4 --- /dev/null +++ b/make/data/cacerts/amazonrootca2 @@ -0,0 +1,38 @@ +Owner: CN=Amazon Root CA 2, O=Amazon, C=US +Issuer: CN=Amazon Root CA 2, O=Amazon, C=US +Serial number: 66c9fd29635869f0a0fe58678f85b26bb8a37 +Valid from: Tue May 26 00:00:00 GMT 2015 until: Sat May 26 00:00:00 GMT 2040 +Signature algorithm name: SHA384withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIFQTCCAymgAwIBAgITBmyf0pY1hp8KD+WGePhbJruKNzANBgkqhkiG9w0BAQwF +ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6 +b24gUm9vdCBDQSAyMB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTEL +MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv +b3QgQ0EgMjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK2Wny2cSkxK +gXlRmeyKy2tgURO8TW0G/LAIjd0ZEGrHJgw12MBvIITplLGbhQPDW9tK6Mj4kHbZ +W0/jTOgGNk3Mmqw9DJArktQGGWCsN0R5hYGCrVo34A3MnaZMUnbqQ523BNFQ9lXg +1dKmSYXpN+nKfq5clU1Imj+uIFptiJXZNLhSGkOQsL9sBbm2eLfq0OQ6PBJTYv9K +8nu+NQWpEjTj82R0Yiw9AElaKP4yRLuH3WUnAnE72kr3H9rN9yFVkE8P7K6C4Z9r +2UXTu/Bfh+08LDmG2j/e7HJV63mjrdvdfLC6HM783k81ds8P+HgfajZRRidhW+me +z/CiVX18JYpvL7TFz4QuK/0NURBs+18bvBt+xa47mAExkv8LV/SasrlX6avvDXbR +8O70zoan4G7ptGmh32n2M8ZpLpcTnqWHsFcQgTfJU7O7f/aS0ZzQGPSSbtqDT6Zj +mUyl+17vIWR6IF9sZIUVyzfpYgwLKhbcAS4y2j5L9Z469hdAlO+ekQiG+r5jqFoz +7Mt0Q5X5bGlSNscpb/xVA1wf+5+9R+vnSUeVC06JIglJ4PVhHvG/LopyboBZ/1c6 ++XUyo05f7O0oYtlNc/LMgRdg7c3r3NunysV+Ar3yVAhU/bQtCSwXVEqY0VThUWcI +0u1ufm8/0i2BWSlmy5A5lREedCf+3euvAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMB +Af8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSwDPBMMPQFWAJI/TPlUq9LhONm +UjANBgkqhkiG9w0BAQwFAAOCAgEAqqiAjw54o+Ci1M3m9Zh6O+oAA7CXDpO8Wqj2 +LIxyh6mx/H9z/WNxeKWHWc8w4Q0QshNabYL1auaAn6AFC2jkR2vHat+2/XcycuUY ++gn0oJMsXdKMdYV2ZZAMA3m3MSNjrXiDCYZohMr/+c8mmpJ5581LxedhpxfL86kS +k5Nrp+gvU5LEYFiwzAJRGFuFjWJZY7attN6a+yb3ACfAXVU3dJnJUH/jWS5E4ywl +7uxMMne0nxrpS10gxdr9HIcWxkPo1LsmmkVwXqkLN1PiRnsn/eBG8om3zEK2yygm +btmlyTrIQRNg91CMFa6ybRoVGld45pIq2WWQgj9sAq+uEjonljYE1x2igGOpm/Hl +urR8FLBOybEfdF849lHqm/osohHUqS0nGkWxr7JOcQ3AWEbWaQbLU8uz/mtBzUF+ +fUwPfHJ5elnNXkoOrJupmHN5fLT0zLm4BwyydFy4x2+IoZCn9Kr5v2c69BoVYh63 +n749sSmvZ6ES8lgQGVMDMBu4Gon2nL2XA46jCfMdiyHxtN/kHNGfZQIG6lzWE7OE +76KlXIx3KadowGuuQNKotOrN8I1LOJwZmhsoVLiJkO/KdYE+HvJkJMcYr07/R54H +9jVlpNMKVv/1F2Rs76giJUmTtt8AF9pYfl3uxRuw0dFfIRDH+fO6AgonB8Xx1sfT +4PsJYGw= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/amazonrootca3 b/make/data/cacerts/amazonrootca3 new file mode 100644 index 0000000000000000000000000000000000000000..96a5c6313e2418277ec22cf87c898bf02c34f6b7 --- /dev/null +++ b/make/data/cacerts/amazonrootca3 @@ -0,0 +1,19 @@ +Owner: CN=Amazon Root CA 3, O=Amazon, C=US +Issuer: CN=Amazon Root CA 3, O=Amazon, C=US +Serial number: 66c9fd5749736663f3b0b9ad9e89e7603f24a +Valid from: Tue May 26 00:00:00 GMT 2015 until: Sat May 26 00:00:00 GMT 2040 +Signature algorithm name: SHA256withECDSA +Subject Public Key Algorithm: 256-bit EC key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIBtjCCAVugAwIBAgITBmyf1XSXNmY/Owua2eiedgPySjAKBggqhkjOPQQDAjA5 +MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g +Um9vdCBDQSAzMB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkG +A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJvb3Qg +Q0EgMzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCmXp8ZBf8ANm+gBG1bG8lKl +ui2yEujSLtf6ycXYqm0fc4E7O5hrOXwzpcVOho6AF2hiRVd9RFgdszflZwjrZt6j +QjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSr +ttvXBp43rDCGB5Fwx5zEGbF4wDAKBggqhkjOPQQDAgNJADBGAiEA4IWSoxe3jfkr +BqWTrBqYaGFy+uGh0PsceGCmQ5nFuMQCIQCcAu/xlJyzlvnrxir4tiz+OpAUFteM +YyRIHN8wfdVoOw== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/amazonrootca4 b/make/data/cacerts/amazonrootca4 new file mode 100644 index 0000000000000000000000000000000000000000..9a59ca249474566f241aa21e070f366b6d8cd109 --- /dev/null +++ b/make/data/cacerts/amazonrootca4 @@ -0,0 +1,20 @@ +Owner: CN=Amazon Root CA 4, O=Amazon, C=US +Issuer: CN=Amazon Root CA 4, O=Amazon, C=US +Serial number: 66c9fd7c1bb104c2943e5717b7b2cc81ac10e +Valid from: Tue May 26 00:00:00 GMT 2015 until: Sat May 26 00:00:00 GMT 2040 +Signature algorithm name: SHA384withECDSA +Subject Public Key Algorithm: 384-bit EC key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIB8jCCAXigAwIBAgITBmyf18G7EEwpQ+Vxe3ssyBrBDjAKBggqhkjOPQQDAzA5 +MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g +Um9vdCBDQSA0MB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkG +A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJvb3Qg +Q0EgNDB2MBAGByqGSM49AgEGBSuBBAAiA2IABNKrijdPo1MN/sGKe0uoe0ZLY7Bi +9i0b2whxIdIA6GO9mif78DluXeo9pcmBqqNbIJhFXRbb/egQbeOc4OO9X4Ri83Bk +M6DLJC9wuoihKqB1+IGuYgbEgds5bimwHvouXKNCMEAwDwYDVR0TAQH/BAUwAwEB +/zAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0OBBYEFNPsxzplbszh2naaVvuc84ZtV+WB +MAoGCCqGSM49BAMDA2gAMGUCMDqLIfG9fhGt0O9Yli/W651+kI0rz2ZVwyzjKKlw +CkcO8DdZEv8tmZQoTipPNU0zWgIxAOp1AE47xDqUEpHJWEadIRNyp4iciuRMStuW +1KyLa2tJElMzrdfkviT8tQp21KW8EA== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/baltimorecybertrustca b/make/data/cacerts/baltimorecybertrustca new file mode 100644 index 0000000000000000000000000000000000000000..b3cf6547c16614e92c03e3e6dc0ef65487bb8a1f --- /dev/null +++ b/make/data/cacerts/baltimorecybertrustca @@ -0,0 +1,28 @@ +Owner: CN=Baltimore CyberTrust Root, OU=CyberTrust, O=Baltimore, C=IE +Issuer: CN=Baltimore CyberTrust Root, OU=CyberTrust, O=Baltimore, C=IE +Serial number: 20000b9 +Valid from: Fri May 12 18:46:00 GMT 2000 until: Mon May 12 23:59:00 GMT 2025 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJ +RTESMBAGA1UEChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYD +VQQDExlCYWx0aW1vcmUgQ3liZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoX +DTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMCSUUxEjAQBgNVBAoTCUJhbHRpbW9y +ZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFsdGltb3JlIEN5YmVy +VHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKMEuyKr +mD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjr +IZ3AQSsBUnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeK +mpYcqWe4PwzV9/lSEy/CG9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSu +XmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9XbIGevOF6uvUA65ehD5f/xXtabz5OTZy +dc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjprl3RjM71oGDHweI12v/ye +jl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoIVDaGezq1 +BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3 +DQEBBQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT92 +9hkTI7gQCvlYpNRhcL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3Wgx +jkzSswF07r51XgdIGn9w/xZchMB5hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0 +Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsaY71k5h+3zvDyny67G7fyUIhz +ksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9HRCwBXbsdtTLS +R9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp +-----END CERTIFICATE----- diff --git a/make/data/cacerts/buypassclass2ca b/make/data/cacerts/buypassclass2ca new file mode 100644 index 0000000000000000000000000000000000000000..a2e9b2fd0149be53236b0e67d2f03ed50a4ff056 --- /dev/null +++ b/make/data/cacerts/buypassclass2ca @@ -0,0 +1,38 @@ +Owner: CN=Buypass Class 2 Root CA, O=Buypass AS-983163327, C=NO +Issuer: CN=Buypass Class 2 Root CA, O=Buypass AS-983163327, C=NO +Serial number: 2 +Valid from: Tue Oct 26 08:38:03 GMT 2010 until: Fri Oct 26 08:38:03 GMT 2040 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEd +MBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3Mg +Q2xhc3MgMiBSb290IENBMB4XDTEwMTAyNjA4MzgwM1oXDTQwMTAyNjA4MzgwM1ow +TjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1eXBhc3MgQVMtOTgzMTYzMzI3MSAw +HgYDVQQDDBdCdXlwYXNzIENsYXNzIDIgUm9vdCBDQTCCAiIwDQYJKoZIhvcNAQEB +BQADggIPADCCAgoCggIBANfHXvfBB9R3+0Mh9PT1aeTuMgHbo4Yf5FkNuud1g1Lr +6hxhFUi7HQfKjK6w3Jad6sNgkoaCKHOcVgb/S2TwDCo3SbXlzwx87vFKu3MwZfPV +L4O2fuPn9Z6rYPnT8Z2SdIrkHJasW4DptfQxh6NR/Md+oW+OU3fUl8FVM5I+GC91 +1K2GScuVr1QGbNgGE41b/+EmGVnAJLqBcXmQRFBoJJRfuLMR8SlBYaNByyM21cHx +MlAQTn/0hpPshNOOvEu/XAFOBz3cFIqUCqTqc/sLUegTBxj6DvEr0VQVfTzh97QZ +QmdiXnfgolXsttlpF9U6r0TtSsWe5HonfOV116rLJeffawrbD02TTqigzXsu8lkB +arcNuAeBfos4GzjmCleZPe4h6KP1DBbdi+w0jpwqHAAVF41og9JwnxgIzRFo1clr +Us3ERo/ctfPYV3Me6ZQ5BL/T3jjetFPsaRyifsSP5BtwrfKi+fv3FmRmaZ9JUaLi +FRhnBkp/1Wy1TbMz4GHrXb7pmA8y1x1LPC5aAVKRCfLf6o3YBkBjqhHk/sM3nhRS +P/TizPJhk9H9Z2vXUq6/aKtAQ6BXNVN48FP4YUIHZMbXb5tMOA1jrGKvNouicwoN +9SG9dKpN6nIDSdvHXx1iY8f93ZHsM+71bbRuMGjeyNYmsHVee7QHIJihdjK4TWxP +AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFMmAd+BikoL1Rpzz +uvdMw964o605MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsFAAOCAgEAU18h +9bqwOlI5LJKwbADJ784g7wbylp7ppHR/ehb8t/W2+xUbP6umwHJdELFx7rxP462s +A20ucS6vxOOto70MEae0/0qyexAQH6dXQbLArvQsWdZHEIjzIVEpMMpghq9Gqx3t +OluwlN5E40EIosHsHdb9T7bWR9AUC8rmyrV7d35BH16Dx7aMOZawP5aBQW9gkOLo ++fsicdl9sz1Gv7SEr5AcD48Saq/v7h56rgJKihcrdv6sVIkkLE8/trKnToyokZf7 +KcZ7XC25y2a2t6hbElGFtQl+Ynhw/qlqYLYdDnkM/crqJIByw5c/8nerQyIKx+u2 +DISCLIBrQYoIwOula9+ZEsuK1V6ADJHgJgg2SMX6OBE1/yWDLfJ6v9r9jv6ly0Us +H8SIU653DtmadsWOLB2jutXsMq7Aqqz30XpN69QH4kj3Io6wpJ9qzo6ysmD0oyLQ +I+uUWnpp3Q+/QFesa1lQ2aOZ4W7+jQF5JyMV3pKdewlNWudLSDBaGOYKbeaP4NK7 +5t98biGCwWg5TbSYWGZizEqQXsP6JwSxeRV0mcy+rSDeJmAc61ZRpqPq5KM/p/9h +3PFaTWwyI0PurKju7koSCTxdccK+efrCh2gdC/1cacwG0Jp9VJkqyTkaGa9LKkPz +Y11aWOIv4x3kqdbQCtCev9eBCfHJxyYNrJgWVqA= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/buypassclass3ca b/make/data/cacerts/buypassclass3ca new file mode 100644 index 0000000000000000000000000000000000000000..f74c6c2498f7f19ee7b240e8bb02d6a6287c6b3c --- /dev/null +++ b/make/data/cacerts/buypassclass3ca @@ -0,0 +1,38 @@ +Owner: CN=Buypass Class 3 Root CA, O=Buypass AS-983163327, C=NO +Issuer: CN=Buypass Class 3 Root CA, O=Buypass AS-983163327, C=NO +Serial number: 2 +Valid from: Tue Oct 26 08:28:58 GMT 2010 until: Fri Oct 26 08:28:58 GMT 2040 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEd +MBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3Mg +Q2xhc3MgMyBSb290IENBMB4XDTEwMTAyNjA4Mjg1OFoXDTQwMTAyNjA4Mjg1OFow +TjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1eXBhc3MgQVMtOTgzMTYzMzI3MSAw +HgYDVQQDDBdCdXlwYXNzIENsYXNzIDMgUm9vdCBDQTCCAiIwDQYJKoZIhvcNAQEB +BQADggIPADCCAgoCggIBAKXaCpUWUOOV8l6ddjEGMnqb8RB2uACatVI2zSRHsJ8Y +ZLya9vrVediQYkwiL944PdbgqOkcLNt4EemOaFEVcsfzM4fkoF0LXOBXByow9c3E +N3coTRiR5r/VUv1xLXA+58bEiuPwKAv0dpihi4dVsjoT/Lc+JzeOIuOoTyrvYLs9 +tznDDgFHmV0ST9tD+leh7fmdvhFHJlsTmKtdFoqwNxxXnUX/iJY2v7vKB3tvh2PX +0DJq1l1sDPGzbjniazEuOQAnFN44wOwZZoYS6J1yFhNkUsepNxz9gjDthBgd9K5c +/3ATAOux9TN6S9ZV+AWNS2mw9bMoNlwUxFFzTWsL8TQH2xc519woe2v1n/MuwU8X +KhDzzMro6/1rqy6any2CbgTUUgGTLT2G/H783+9CHaZr77kgxve9oKeV/afmiSTY +zIw0bOIjL9kSGiG5VZFvC5F5GQytQIgLcOJ60g7YaEi7ghM5EFjp2CoHxhLbWNvS +O1UQRwUVZ2J+GGOmRj8JDlQyXr8NYnon74Do29lLBlo3WiXQCBJ31G8JUJc9yB3D +34xFMFbG02SrZvPAXpacw8Tvw3xrizp5f7NJzz3iiZ+gMEuFuZyUJHmPfWupRWgP +K9Dx2hzLabjKSWJtyNBjYt1gD1iqj6G8BaVmos8bdrKEZLFMOVLAMLrwjEsCsLa3 +AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFEe4zf/lb+74suwv +Tg75JbCOPGvDMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsFAAOCAgEAACAj +QTUEkMJAYmDv4jVM1z+s4jSQuKFvdvoWFqRINyzpkMLyPPgKn9iB5btb2iUspKdV +cSQy9sgL8rxq+JOssgfCX5/bzMiKqr5qb+FJEMwx14C7u8jYog5kV+qi9cKpMRXS +IGrs/CIBKM+GuIAeqcwRpTzyFrNHnfzSgCHEy9BHcEGhyoMZCCxt8l13nIoUE9Q2 +HJLw5QY33KbmkJs4j1xrG0aGQ0JfPgEHU1RdZX33inOhmlRaHylDFCfChQ+1iHsa +O5S3HWCntZznKWlXWpuTekMwGwPXYshApqr8ZORK15FTAaggiG6cX0S5y2CBNOxv +033aSF/rtJC8LakcC6wc1aJoIIAE1vyxjy+7SjENSoYc6+I2KSb12tjE8nVhz36u +dmNKekBlk4f4HoCMhuWG1o8O/FMsYOgWYRqiPkN7zTlgVGr18okmAWiDSKIz6MkE +kbIRNBE+6tBDGR8Dk5AM/1E9V/RBbuHLoL7ryWPNbczk+DaqaJ3tvV2XcEQNtg41 +3OEMXbugUZTLfhbrES+jkkXITHHZvMmZUldGL1DPvTVp9D0VzgalLA8+9oG6lLvD +u79leNKGef9JOxqDDPDeeOzI8k1MGt6CKfjBWtrt7uYnXuhF0J0cUahoq0Tj0Itq +4/g7u9xN12TyUb7mqqta6THuBrxzvxNiCp/HuZc= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/camerfirmachambersca b/make/data/cacerts/camerfirmachambersca new file mode 100644 index 0000000000000000000000000000000000000000..70d793e25ab33d079b63ccb437ab815b6f664a7f --- /dev/null +++ b/make/data/cacerts/camerfirmachambersca @@ -0,0 +1,49 @@ +Owner: CN=Chambers of Commerce Root - 2008, O=AC Camerfirma S.A., SERIALNUMBER=A82743287, L=Madrid (see current address at www.camerfirma.com/address), C=EU +Issuer: CN=Chambers of Commerce Root - 2008, O=AC Camerfirma S.A., SERIALNUMBER=A82743287, L=Madrid (see current address at www.camerfirma.com/address), C=EU +Serial number: a3da427ea4b1aeda +Valid from: Fri Aug 01 12:29:50 GMT 2008 until: Sat Jul 31 12:29:50 GMT 2038 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIHTzCCBTegAwIBAgIJAKPaQn6ksa7aMA0GCSqGSIb3DQEBBQUAMIGuMQswCQYD +VQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0 +IHd3dy5jYW1lcmZpcm1hLmNvbS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3 +MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMuQS4xKTAnBgNVBAMTIENoYW1iZXJz +IG9mIENvbW1lcmNlIFJvb3QgLSAyMDA4MB4XDTA4MDgwMTEyMjk1MFoXDTM4MDcz +MTEyMjk1MFowga4xCzAJBgNVBAYTAkVVMUMwQQYDVQQHEzpNYWRyaWQgKHNlZSBj +dXJyZW50IGFkZHJlc3MgYXQgd3d3LmNhbWVyZmlybWEuY29tL2FkZHJlc3MpMRIw +EAYDVQQFEwlBODI3NDMyODcxGzAZBgNVBAoTEkFDIENhbWVyZmlybWEgUy5BLjEp +MCcGA1UEAxMgQ2hhbWJlcnMgb2YgQ29tbWVyY2UgUm9vdCAtIDIwMDgwggIiMA0G +CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCvAMtwNyuAWko6bHiUfaN/Gh/2NdW9 +28sNRHI+JrKQUrpjOyhYb6WzbZSm891kDFX29ufyIiKAXuFixrYp4YFs8r/lfTJq +VKAyGVn+H4vXPWCGhSRv4xGzdz4gljUha7MI2XAuZPeEklPWDrCQiorjh40G072Q +DuKZoRuGDtqaCrsLYVAGUvGef3bsyw/QHg3PmTA9HMRFEFis1tPo1+XqxQEHd9ZR +5gN/ikilTWh1uem8nk4ZcfUyS5xtYBkL+8ydddy/Js2Pk3g5eXNeJQ7KXOt3EgfL +ZEFHcpOrUMPrCXZkNNI5t3YRCQ12RcSprj1qr7V9ZS+UWBDsXHyvfuK2GNnQm05a +Sd+pZgvMPMZ4fKecHePOjlO+Bd5gD2vlGts/4+EhySnB8esHnFIbAURRPHsl18Tl +UlRdJQfKFiC4reRB7noI/plvg6aRArBsNlVq5331lubKgdaX8ZSD6e2wsWsSaR6s ++12pxZjptFtYer49okQ6Y1nUCyXeG0+95QGezdIp1Z8XGQpvvwyQ0wlf2eOKNcx5 +Wk0ZN5K3xMGtr/R5JJqyAQuxr1yW84Ay+1w9mPGgP0revq+ULtlVmhduYJ1jbLhj +ya6BXBg14JC7vjxPNyK5fuvPnnchpj04gftI2jE9K+OJ9dC1vX7gUMQSibMjmhAx +hduub+84Mxh2EQIDAQABo4IBbDCCAWgwEgYDVR0TAQH/BAgwBgEB/wIBDDAdBgNV +HQ4EFgQU+SSsD7K1+HnA+mCIG8TZTQKeFxkwgeMGA1UdIwSB2zCB2IAU+SSsD7K1 ++HnA+mCIG8TZTQKeFxmhgbSkgbEwga4xCzAJBgNVBAYTAkVVMUMwQQYDVQQHEzpN +YWRyaWQgKHNlZSBjdXJyZW50IGFkZHJlc3MgYXQgd3d3LmNhbWVyZmlybWEuY29t +L2FkZHJlc3MpMRIwEAYDVQQFEwlBODI3NDMyODcxGzAZBgNVBAoTEkFDIENhbWVy +ZmlybWEgUy5BLjEpMCcGA1UEAxMgQ2hhbWJlcnMgb2YgQ29tbWVyY2UgUm9vdCAt +IDIwMDiCCQCj2kJ+pLGu2jAOBgNVHQ8BAf8EBAMCAQYwPQYDVR0gBDYwNDAyBgRV +HSAAMCowKAYIKwYBBQUHAgEWHGh0dHA6Ly9wb2xpY3kuY2FtZXJmaXJtYS5jb20w +DQYJKoZIhvcNAQEFBQADggIBAJASryI1wqM58C7e6bXpeHxIvj99RZJe6dqxGfwW +PJ+0W2aeaufDuV2I6A+tzyMP3iU6XsxPpcG1Lawk0lgH3qLPaYRgM+gQDROpI9CF +5Y57pp49chNyM/WqfcZjHwj0/gF/JM8rLFQJ3uIrbZLGOU8W6jx+ekbURWpGqOt1 +glanq6B8aBMz9p0w8G8nOSQjKpD9kCk18pPfNKXG9/jvjA9iSnyu0/VU+I22mlaH +FoI6M6taIgj3grrqLuBHmrS1RaMFO9ncLkVAO+rcf+g769HsJtg1pDDFOqxXnrN2 +pSB7+R5KBWIBpih1YJeSDW4+TTdDDZIVnBgizVGZoCkaPF+KMjNbMMeJL0eYD6MD +xvbxrN8y8NmBGuScvfaAFPDRLLmF9dijscilIeUcE5fuDr3fKanvNFNb0+RqE4QG +tjICxFKuItLcsiFCGtpA8CnJ7AoMXOLQusxI0zcKzBIKinmwPQN/aUv0NCB9szTq +jktk9T79syNnFQ0EuPAtwQlRPLJsFfClI9eDdOTlLsn+mCdCxqvGnrDQWzilm1De +fhiYtUU79nm06PcaewaD+9CL2rvHvRirCG88gGtAPxkZumWK5r7VXNM21+9AUiRg +OGcEMeyP84LG3rlV8zsxkVrctQgVrXYlCg17LofiDKYGvCYQbTed7N14jHyAxfDZ +d0jQ +-----END CERTIFICATE----- diff --git a/make/data/cacerts/camerfirmachamberscommerceca b/make/data/cacerts/camerfirmachamberscommerceca new file mode 100644 index 0000000000000000000000000000000000000000..b92255f770cdf784fac9dbb8f40094eeac51bd32 --- /dev/null +++ b/make/data/cacerts/camerfirmachamberscommerceca @@ -0,0 +1,35 @@ +Owner: CN=Chambers of Commerce Root, OU=http://www.chambersign.org, O=AC Camerfirma SA CIF A82743287, C=EU +Issuer: CN=Chambers of Commerce Root, OU=http://www.chambersign.org, O=AC Camerfirma SA CIF A82743287, C=EU +Serial number: 0 +Valid from: Tue Sep 30 16:13:43 GMT 2003 until: Wed Sep 30 16:13:44 GMT 2037 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIEvTCCA6WgAwIBAgIBADANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJFVTEn +MCUGA1UEChMeQUMgQ2FtZXJmaXJtYSBTQSBDSUYgQTgyNzQzMjg3MSMwIQYDVQQL +ExpodHRwOi8vd3d3LmNoYW1iZXJzaWduLm9yZzEiMCAGA1UEAxMZQ2hhbWJlcnMg +b2YgQ29tbWVyY2UgUm9vdDAeFw0wMzA5MzAxNjEzNDNaFw0zNzA5MzAxNjEzNDRa +MH8xCzAJBgNVBAYTAkVVMScwJQYDVQQKEx5BQyBDYW1lcmZpcm1hIFNBIENJRiBB +ODI3NDMyODcxIzAhBgNVBAsTGmh0dHA6Ly93d3cuY2hhbWJlcnNpZ24ub3JnMSIw +IAYDVQQDExlDaGFtYmVycyBvZiBDb21tZXJjZSBSb290MIIBIDANBgkqhkiG9w0B +AQEFAAOCAQ0AMIIBCAKCAQEAtzZV5aVdGDDg2olUkfzIx1L4L1DZ77F1c2VHfRtb +unXF/KGIJPov7coISjlUxFF6tdpg6jg8gbLL8bvZkSM/SAFwdakFKq0fcfPJVD0d +BmpAPrMMhe5cG3nCYsS4No41XQEMIwRHNaqbYE6gZj3LJgqcQKH0XZi/caulAGgq +7YN6D6IUtdQis4CwPAxaUWktWBiP7Zme8a7ileb2R6jWDA+wWFjbw2Y3npuRVDM3 +0pQcakjJyfKl2qUMI/cjDpwyVV5xnIQFUZot/eZOKjRa3spAN2cMVCFVd9oKDMyX +roDclDZK9D7ONhMeU+SsTjoF7Nuucpw4i9A5O4kKPnf+dQIBA6OCAUQwggFAMBIG +A1UdEwEB/wQIMAYBAf8CAQwwPAYDVR0fBDUwMzAxoC+gLYYraHR0cDovL2NybC5j +aGFtYmVyc2lnbi5vcmcvY2hhbWJlcnNyb290LmNybDAdBgNVHQ4EFgQU45T1sU3p +26EpW1eLTXYGduHRooowDgYDVR0PAQH/BAQDAgEGMBEGCWCGSAGG+EIBAQQEAwIA +BzAnBgNVHREEIDAegRxjaGFtYmVyc3Jvb3RAY2hhbWJlcnNpZ24ub3JnMCcGA1Ud +EgQgMB6BHGNoYW1iZXJzcm9vdEBjaGFtYmVyc2lnbi5vcmcwWAYDVR0gBFEwTzBN +BgsrBgEEAYGHLgoDATA+MDwGCCsGAQUFBwIBFjBodHRwOi8vY3BzLmNoYW1iZXJz +aWduLm9yZy9jcHMvY2hhbWJlcnNyb290Lmh0bWwwDQYJKoZIhvcNAQEFBQADggEB +AAxBl8IahsAifJ/7kPMa0QOx7xP5IV8EnNrJpY0nbJaHkb5BkAFyk+cefV/2icZd +p0AJPaxJRUXcLo0waLIJuvvDL8y6C98/d3tGfToSJI6WjzwFCm/SlCgdbQzALogi +1djPHRPH8EjX1wWnz8dHnjs8NMiAT9QUu/wNUPf6s+xCX6ndbcj0dc97wXImsQEc +XCz9ek60AcUFV7nnPKoF2YjpB0ZBzu9Bga5Y34OirsrXdx/nADydb47kMgkdTXg0 +eDQ8lJsm7U9xxhl6vSAiSFr+S30Dt+dYvsYyTnQeaN2oaFuzPu5ifdmA6Ap1erfu +tGWaIZDgqtCYvDi1czyL+Nw= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/camerfirmachambersignca b/make/data/cacerts/camerfirmachambersignca new file mode 100644 index 0000000000000000000000000000000000000000..935eea9c2121ee964864703d01a1c054b140bea1 --- /dev/null +++ b/make/data/cacerts/camerfirmachambersignca @@ -0,0 +1,48 @@ +Owner: CN=Global Chambersign Root - 2008, O=AC Camerfirma S.A., SERIALNUMBER=A82743287, L=Madrid (see current address at www.camerfirma.com/address), C=EU +Issuer: CN=Global Chambersign Root - 2008, O=AC Camerfirma S.A., SERIALNUMBER=A82743287, L=Madrid (see current address at www.camerfirma.com/address), C=EU +Serial number: c9cdd3e9d57d23ce +Valid from: Fri Aug 01 12:31:40 GMT 2008 until: Sat Jul 31 12:31:40 GMT 2038 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIHSTCCBTGgAwIBAgIJAMnN0+nVfSPOMA0GCSqGSIb3DQEBBQUAMIGsMQswCQYD +VQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0 +IHd3dy5jYW1lcmZpcm1hLmNvbS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3 +MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMuQS4xJzAlBgNVBAMTHkdsb2JhbCBD +aGFtYmVyc2lnbiBSb290IC0gMjAwODAeFw0wODA4MDExMjMxNDBaFw0zODA3MzEx +MjMxNDBaMIGsMQswCQYDVQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUgY3Vy +cmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNvbS9hZGRyZXNzKTESMBAG +A1UEBRMJQTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMuQS4xJzAl +BgNVBAMTHkdsb2JhbCBDaGFtYmVyc2lnbiBSb290IC0gMjAwODCCAiIwDQYJKoZI +hvcNAQEBBQADggIPADCCAgoCggIBAMDfVtPkOpt2RbQT2//BthmLN0EYlVJH6xed +KYiONWwGMi5HYvNJBL99RDaxccy9Wglz1dmFRP+RVyXfXjaOcNFccUMd2drvXNL7 +G706tcuto8xEpw2uIRU/uXpbknXYpBI4iRmKt4DS4jJvVpyR1ogQC7N0ZJJ0YPP2 +zxhPYLIj0Mc7zmFLmY/CDNBAspjcDahOo7kKrmCgrUVSY7pmvWjg+b4aqIG7HkF4 +ddPB/gBVsIdU6CeQNR1MM62X/JcumIS/LMmjv9GYERTtY/jKmIhYF5ntRQOXfjyG +HoiMvvKRhI9lNNgATH23MRdaKXoKGCQwoze1eqkBfSbW+Q6OWfH9GzO1KTsXO0G2 +Id3UwD2ln58fQ1DJu7xsepeY7s2MH/ucUa6LcL0nn3HAa6x9kGbo1106DbDVwo3V +yJ2dwW3Q0L9R5OP4wzg2rtandeavhENdk5IMagfeOx2YItaswTXbo6Al/3K1dh3e +beksZixShNBFks4c5eUzHdwHU1SjqoI7mjcv3N2gZOnm3b2u/GSFHTynyQbehP9r +6GsaPMWis0L7iwk+XwhSx2LE1AVxv8Rk5Pihg+g+EpuoHtQ2TS9x9o0o9oOpE9Jh +wZG7SMA0j0GMS0zbaRL/UJScIINZc+18ofLx/d33SdNDWKBWY8o9PeU1VlnpDsog +zCtLkykPAgMBAAGjggFqMIIBZjASBgNVHRMBAf8ECDAGAQH/AgEMMB0GA1UdDgQW +BBS5CcqcHtvTbDprru1U8VuTBjUuXjCB4QYDVR0jBIHZMIHWgBS5CcqcHtvTbDpr +ru1U8VuTBjUuXqGBsqSBrzCBrDELMAkGA1UEBhMCRVUxQzBBBgNVBAcTOk1hZHJp +ZCAoc2VlIGN1cnJlbnQgYWRkcmVzcyBhdCB3d3cuY2FtZXJmaXJtYS5jb20vYWRk +cmVzcykxEjAQBgNVBAUTCUE4Mjc0MzI4NzEbMBkGA1UEChMSQUMgQ2FtZXJmaXJt +YSBTLkEuMScwJQYDVQQDEx5HbG9iYWwgQ2hhbWJlcnNpZ24gUm9vdCAtIDIwMDiC +CQDJzdPp1X0jzjAOBgNVHQ8BAf8EBAMCAQYwPQYDVR0gBDYwNDAyBgRVHSAAMCow +KAYIKwYBBQUHAgEWHGh0dHA6Ly9wb2xpY3kuY2FtZXJmaXJtYS5jb20wDQYJKoZI +hvcNAQEFBQADggIBAICIf3DekijZBZRG/5BXqfEv3xoNa/p8DhxJJHkn2EaqbylZ +UohwEurdPfWbU1Rv4WCiqAm57OtZfMY18dwY6fFn5a+6ReAJ3spED8IXDneRRXoz +X1+WLGiLwUePmJs9wOzL9dWCkoQ10b42OFZyMVtHLaoXpGNR6woBrX/sdZ7LoR/x +fxKxueRkf2fWIyr0uDldmOghp+G9PUIadJpwr2hsUF1Jz//7Dl3mLEfXgTpZALVz +a2Mg9jFFCDkO9HB+QHBaP9BrQql0PSgvAm11cpUJjUhjxsYjV5KTXjXBjfkK9yyd +Yhz2rXzdpjEetrHHfoUm+qRqtdpjMNHvkzeyZi99Bffnt0uYlDXA2TopwZ2yUDMd +SqlapskD7+3056huirRXhOukP9DuqqqHW2Pok+JrqNS4cnhrG+055F3Lm6qH1U9O +AP7Zap88MQ8oAgF9mOinsKJknnn4SPIVqczmyETrP3iZ8ntxPjzxmKfFGBI/5rso +M0LpRQp8bfKGeS/Fghl9CYl8slR2iK7ewfPM4W7bMdaTrpmg7yVqc5iJWzouE4ge +v8CSlDQb4ye3ix5vQv/n6TebUB0tovkC7stYWDpxvGjjqsGvHCgfotwjZT+B6q6Z +09gwzxMNTxXJhLynSC34MCN32EZLeW32jO06f2ARePTpm67VVMB0gNELQp/B +-----END CERTIFICATE----- diff --git a/make/data/cacerts/certumca b/make/data/cacerts/certumca new file mode 100644 index 0000000000000000000000000000000000000000..4149653397b7bf4b56ad7e789303780e33822161 --- /dev/null +++ b/make/data/cacerts/certumca @@ -0,0 +1,26 @@ +Owner: CN=Certum CA, O=Unizeto Sp. z o.o., C=PL +Issuer: CN=Certum CA, O=Unizeto Sp. z o.o., C=PL +Serial number: 10020 +Valid from: Tue Jun 11 10:46:39 GMT 2002 until: Fri Jun 11 10:46:39 GMT 2027 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDDDCCAfSgAwIBAgIDAQAgMA0GCSqGSIb3DQEBBQUAMD4xCzAJBgNVBAYTAlBM +MRswGQYDVQQKExJVbml6ZXRvIFNwLiB6IG8uby4xEjAQBgNVBAMTCUNlcnR1bSBD +QTAeFw0wMjA2MTExMDQ2MzlaFw0yNzA2MTExMDQ2MzlaMD4xCzAJBgNVBAYTAlBM +MRswGQYDVQQKExJVbml6ZXRvIFNwLiB6IG8uby4xEjAQBgNVBAMTCUNlcnR1bSBD +QTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAM6xwS7TT3zNJc4YPk/E +jG+AanPIW1H4m9LcuwBcsaD8dQPugfCI7iNS6eYVM42sLQnFdvkrOYCJ5JdLkKWo +ePhzQ3ukYbDYWMzhbGZ+nPMJXlVjhNWo7/OxLjBos8Q82KxujZlakE403Daaj4GI +ULdtlkIJ89eVgw1BS7Bqa/j8D35in2fE7SZfECYPCE/wpFcozo+47UX2bu4lXapu +Ob7kky/ZR6By6/qmW6/KUz/iDsaWVhFu9+lmqSbYf5VT7QqFiLpPKaVCjF62/IUg +AKpoC6EahQGcxEZjgoi2IrHu/qpGWX7PNSzVttpd90gzFFS269lvzs2I1qsb2pY7 +HVkCAwEAAaMTMBEwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEA +uI3O7+cUus/usESSbLQ5PqKEbq24IXfS1HeCh+YgQYHu4vgRt2PRFze+GXYkHAQa +TOs9qmdvLdTN/mUxcMUbpgIKumB7bVjCmkn+YzILa+M6wKyrO7Do0wlRjBCDxjTg +xSvgGrZgFCdsMneMvLJymM/NzD+5yCRCFNZX/OYmQ6kd5YCQzgNUKD73P9P4Te1q +CjqTE5s7FCMTY5w/0YcneeVMUeMBrYVdGjux1XMQpNPyvG5k9VpWkKjHDkx0Dy5x +O/fIR/RpbxXyEV6DHpx8Uq79AtoSqFlnGNu8cN2bsWntgM6JQEhqDjXKKWYVIZQs +6GAqm4VKQPNriiTsBhYscw== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/certumtrustednetworkca b/make/data/cacerts/certumtrustednetworkca new file mode 100644 index 0000000000000000000000000000000000000000..db35af834ba1ae411a686d4c27d96dd9fab56080 --- /dev/null +++ b/make/data/cacerts/certumtrustednetworkca @@ -0,0 +1,29 @@ +Owner: CN=Certum Trusted Network CA, OU=Certum Certification Authority, O=Unizeto Technologies S.A., C=PL +Issuer: CN=Certum Trusted Network CA, OU=Certum Certification Authority, O=Unizeto Technologies S.A., C=PL +Serial number: 444c0 +Valid from: Wed Oct 22 12:07:37 GMT 2008 until: Mon Dec 31 12:07:37 GMT 2029 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDuzCCAqOgAwIBAgIDBETAMA0GCSqGSIb3DQEBBQUAMH4xCzAJBgNVBAYTAlBM +MSIwIAYDVQQKExlVbml6ZXRvIFRlY2hub2xvZ2llcyBTLkEuMScwJQYDVQQLEx5D +ZXJ0dW0gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxIjAgBgNVBAMTGUNlcnR1bSBU +cnVzdGVkIE5ldHdvcmsgQ0EwHhcNMDgxMDIyMTIwNzM3WhcNMjkxMjMxMTIwNzM3 +WjB+MQswCQYDVQQGEwJQTDEiMCAGA1UEChMZVW5pemV0byBUZWNobm9sb2dpZXMg +Uy5BLjEnMCUGA1UECxMeQ2VydHVtIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MSIw +IAYDVQQDExlDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENBMIIBIjANBgkqhkiG9w0B +AQEFAAOCAQ8AMIIBCgKCAQEA4/t9o3K6wvDJFIf1awFO4W5AB7ptJ11/91sts1rH +UV+rpDKmYYe2bg+G0jACl/jXaVehGDldamR5xgFZrDwxSjh80gTSSyjoIF87B6LM +TXPb865Px1bVWqeWifrzq2jUI4ZZJ88JJ7ysbnKDHDBy3+Ci6dLhdHUZvSqeexVU +BBvXQzmtVSjF4hq79MDkrjhJM8x2hZ85RdKknvISjFH4fOQtf/WsX+sWn7Et0brM +kUJ3TCXJkDhv2/DM+44el1k+1WBO5gUo7Ul5E0u6SNsv+XLTOcr+H9g0cvW0QM8x +AcPs3hEtF10fuFDRXhmnad4HMyjKUJX5p1TLVIZQRan5SQIDAQABo0IwQDAPBgNV +HRMBAf8EBTADAQH/MB0GA1UdDgQWBBQIds3LB/8k9sXN7buQvOKEN0Z19zAOBgNV +HQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQEFBQADggEBAKaorSLOAT2mo/9i0Eidi15y +sHhE49wcrwn9I0j6vSrEuVUEtRCjjSfeC4Jj0O7eDDd5QVsisrCaQVymcODU0HfL +I9MA4GxWL+FpDQ3Zqr8hgVDZBqWo/5U30Kr+4rP1mS1FhIrlQgnXdAIv94nYmem8 +J9RHjboNRhx3zxSkHLmkMcScKHQDNP8zGSal6Q10tz6XxnboJ5ajZt3hrvJBW8qY +VoNzcOSGGtIxQbovvi0TWnZvTuhOgQ4/WwMioBK+ZlgRSssDxLQqKi2WF+A5VLxI +03YnnZotBqbJ7DnSq9ufmgsnAjUpsUCV5/nonFWIGUbWtzT1fs45mtk48VH3Tyw= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/chunghwaepkirootca b/make/data/cacerts/chunghwaepkirootca new file mode 100644 index 0000000000000000000000000000000000000000..a755a44f30a2dd0a377451c9c75e7d24b6df5f51 --- /dev/null +++ b/make/data/cacerts/chunghwaepkirootca @@ -0,0 +1,40 @@ +Owner: OU=ePKI Root Certification Authority, O="Chunghwa Telecom Co., Ltd.", C=TW +Issuer: OU=ePKI Root Certification Authority, O="Chunghwa Telecom Co., Ltd.", C=TW +Serial number: 15c8bd65475cafb897005ee406d2bc9d +Valid from: Mon Dec 20 02:31:27 GMT 2004 until: Wed Dec 20 02:31:27 GMT 2034 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIFsDCCA5igAwIBAgIQFci9ZUdcr7iXAF7kBtK8nTANBgkqhkiG9w0BAQUFADBe +MQswCQYDVQQGEwJUVzEjMCEGA1UECgwaQ2h1bmdod2EgVGVsZWNvbSBDby4sIEx0 +ZC4xKjAoBgNVBAsMIWVQS0kgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAe +Fw0wNDEyMjAwMjMxMjdaFw0zNDEyMjAwMjMxMjdaMF4xCzAJBgNVBAYTAlRXMSMw +IQYDVQQKDBpDaHVuZ2h3YSBUZWxlY29tIENvLiwgTHRkLjEqMCgGA1UECwwhZVBL +SSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0BAQEF +AAOCAg8AMIICCgKCAgEA4SUP7o3biDN1Z82tH306Tm2d0y8U82N0ywEhajfqhFAH +SyZbCUNsIZ5qyNUD9WBpj8zwIuQf5/dqIjG3LBXy4P4AakP/h2XGtRrBp0xtInAh +ijHyl3SJCRImHJ7K2RKilTza6We/CKBk49ZCt0Xvl/T29de1ShUCWH2YWEtgvM3X +DZoTM1PRYfl61dd4s5oz9wCGzh1NlDivqOx4UXCKXBCDUSH3ET00hl7lSM2XgYI1 +TBnsZfZrxQWh7kcT1rMhJ5QQCtkkO7q+RBNGMD+XPNjX12ruOzjjK9SXDrkb5wdJ +fzcq+Xd4z1TtW0ado4AOkUPB1ltfFLqfpo0kR0BZv3I4sjZsN/+Z0V0OWQqraffA +sgRFelQArr5T9rXn4fg8ozHSqf4hUmTFpmfwdQcGlBSBVcYn5AGPF8Fqcde+S/uU +WH1+ETOxQvdibBjWzwloPn9s9h6PYq2lY9sJpx8iQkEeb5mKPtf5P0B6ebClAZLS +nT0IFaUQAS2zMnaolQ2zepr7BxB4EW/hj8e6DyUadCrlHJhBmd8hh+iVBmoKs2pH +dmX2Os+PYhcZewoozRrSgx4hxyy/vv9haLdnG7t4TY3OZ+XkwY63I2binZB1NJip +NiuKmpS5nezMirH4JYlcWrYvjB9teSSnUmjDhDXiZo1jDiVN1Rmy5nk3pyKdVDEC +AwEAAaNqMGgwHQYDVR0OBBYEFB4M97Zn8uGSJglFwFU5Lnc/QkqiMAwGA1UdEwQF +MAMBAf8wOQYEZyoHAAQxMC8wLQIBADAJBgUrDgMCGgUAMAcGBWcqAwAABBRFsMLH +ClZ87lt4DJX5GFPBphzYEDANBgkqhkiG9w0BAQUFAAOCAgEACbODU1kBPpVJufGB +uvl2ICO1J2B01GqZNF5sAFPZn/KmsSQHRGoqxqWOeBLoR9lYGxMqXnmbnwoqZ6Yl +PwZpVnPDimZI+ymBV3QGypzqKOg4ZyYr8dW1P2WT+DZdjo2NQCCHGervJ8A9tDkP +JXtoUHRVnAxZfVo9QZQlUgjgRywVMRnVvwdVxrsStZf0X4OFunHB2WyBEXYKCrC/ +gpf36j36+uwtqSiUO1bd0lEursC9CBWMd1I0ltabrNMdjmEPNXubrjlpC2JgQCA2 +j6/7Nu4tCEoduL+bXPjqpRugc6bY+G7gMwRfaKonh+3ZwZCc7b3jajWvY9+rGNm6 +5ulK6lCKD2GTHuItGeIwlDWSXQ62B68ZgI9HkFFLLk3dheLSClIKF5r8GrBQAuUB +o2M3IUxExJtRmREOc5wGj1QupyheRDmHVi03vYVElOEMSyycw5KFNGHLD7ibSkNS +/jQ6fbjpKdx2qcgw+BRxgMYeNkh0IkFch4LoGHGLQYlE535YW6i4jRPpp2zDR+2z +Gp1iro2C6pSe3VkQw63d4k3jMdXH7OjysP6SHhYKGvzZ8/gntsm+HbRsZJB/9OTE +W9c3rkIO3aQab3yIVMUWbuF6aC74Or8NpDyJO3inTmODBCEIZ43ygknQW/2xzQ+D +hNQ+IIX3Sj0rnP0qCglN6oH4EZw= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/comodoaaaca b/make/data/cacerts/comodoaaaca new file mode 100644 index 0000000000000000000000000000000000000000..76fc7fcf5f6ab266c7703200cfb37b4ce9089353 --- /dev/null +++ b/make/data/cacerts/comodoaaaca @@ -0,0 +1,32 @@ +Owner: CN=AAA Certificate Services, O=Comodo CA Limited, L=Salford, ST=Greater Manchester, C=GB +Issuer: CN=AAA Certificate Services, O=Comodo CA Limited, L=Salford, ST=Greater Manchester, C=GB +Serial number: 1 +Valid from: Thu Jan 01 00:00:00 GMT 2004 until: Sun Dec 31 23:59:59 GMT 2028 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIEMjCCAxqgAwIBAgIBATANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJHQjEb +MBkGA1UECAwSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRow +GAYDVQQKDBFDb21vZG8gQ0EgTGltaXRlZDEhMB8GA1UEAwwYQUFBIENlcnRpZmlj +YXRlIFNlcnZpY2VzMB4XDTA0MDEwMTAwMDAwMFoXDTI4MTIzMTIzNTk1OVowezEL +MAkGA1UEBhMCR0IxGzAZBgNVBAgMEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE +BwwHU2FsZm9yZDEaMBgGA1UECgwRQ29tb2RvIENBIExpbWl0ZWQxITAfBgNVBAMM +GEFBQSBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczCCASIwDQYJKoZIhvcNAQEBBQADggEP +ADCCAQoCggEBAL5AnfRu4ep2hxxNRUSOvkbIgwadwSr+GB+O5AL686tdUIoWMQua +BtDFcCLNSS1UY8y2bmhGC1Pqy0wkwLxyTurxFa70VJoSCsN6sjNg4tqJVfMiWPPe +3M/vg4aijJRPn2jymJBGhCfHdr/jzDUsi14HZGWCwEiwqJH5YZ92IFCokcdmtet4 +YgNW8IoaE+oxox6gmf049vYnMlhvB/VruPsUK6+3qszWY19zjNoFmag4qMsXeDZR +rOme9Hg6jc8P2ULimAyrL58OAd7vn5lJ8S3frHRNG5i1R8XlKdH5kBjHYpy+g8cm +ez6KJcfA3Z3mNWgQIJ2P2N7Sw4ScDV7oL8kCAwEAAaOBwDCBvTAdBgNVHQ4EFgQU +oBEKIz6W8Qfs4q8p74Klf9AwpLQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQF +MAMBAf8wewYDVR0fBHQwcjA4oDagNIYyaHR0cDovL2NybC5jb21vZG9jYS5jb20v +QUFBQ2VydGlmaWNhdGVTZXJ2aWNlcy5jcmwwNqA0oDKGMGh0dHA6Ly9jcmwuY29t +b2RvLm5ldC9BQUFDZXJ0aWZpY2F0ZVNlcnZpY2VzLmNybDANBgkqhkiG9w0BAQUF +AAOCAQEACFb8AvCb6P+k+tZ7xkSAzk/ExfYAWMymtrwUSWgEdujm7l3sAg9g1o1Q +GE8mTgHj5rCl7r+8dFRBv/38ErjHT1r0iWAFf2C3BUrz9vHCv8S5dIa2LX1rzNLz +Rt0vxuBqw8M0Ayx9lt1awg6nCpnBBYurDC/zXDrPbDdVCYfeU0BsWO/8tqtlbgT2 +G9w84FoVxp7Z8VlIMCFlA2zs6SFz7JsDoeA3raAVGI/6ugLOpyypEBMs1OUIJqsi +l2D4kF501KKaU73yqWjgom7C12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3 +smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/comodoeccca b/make/data/cacerts/comodoeccca new file mode 100644 index 0000000000000000000000000000000000000000..19f9f0b7ec2d81fb4120b9fa39eaf9d63be1b98b --- /dev/null +++ b/make/data/cacerts/comodoeccca @@ -0,0 +1,23 @@ +Owner: CN=COMODO ECC Certification Authority, O=COMODO CA Limited, L=Salford, ST=Greater Manchester, C=GB +Issuer: CN=COMODO ECC Certification Authority, O=COMODO CA Limited, L=Salford, ST=Greater Manchester, C=GB +Serial number: 1f47afaa62007050544c019e9b63992a +Valid from: Thu Mar 06 00:00:00 GMT 2008 until: Mon Jan 18 23:59:59 GMT 2038 +Signature algorithm name: SHA384withECDSA +Subject Public Key Algorithm: 384-bit EC (secp384r1) key +Version: 3 +-----BEGIN CERTIFICATE----- +MIICiTCCAg+gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTEL +MAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE +BxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMT +IkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDgwMzA2MDAw +MDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdy +ZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09N +T0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlv +biBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSR +FtSrYpn1PlILBs5BAH+X4QokPB0BBO490o0JlwzgdeT6+3eKKvUDYEs2ixYjFq0J +cfRK9ChQtP6IHG4/bC8vCVlbpVsLM5niwz2J+Wos77LTBumjQjBAMB0GA1UdDgQW +BBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/ +BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf/7VGFAkK+qDm +fQjGGoe9GKhzvSbKYAydzpmfz1wPMOG+FDHqAjAU9JM8SaczepBGR7NjfRObTrdv +GDeAU/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/comodorsaca b/make/data/cacerts/comodorsaca new file mode 100644 index 0000000000000000000000000000000000000000..f396f6d27d341d6d0cd2cd07485fb5e28bcffdf7 --- /dev/null +++ b/make/data/cacerts/comodorsaca @@ -0,0 +1,41 @@ +Owner: CN=COMODO RSA Certification Authority, O=COMODO CA Limited, L=Salford, ST=Greater Manchester, C=GB +Issuer: CN=COMODO RSA Certification Authority, O=COMODO CA Limited, L=Salford, ST=Greater Manchester, C=GB +Serial number: 4caaf9cadb636fe01ff74ed85b03869d +Valid from: Tue Jan 19 00:00:00 GMT 2010 until: Mon Jan 18 23:59:59 GMT 2038 +Signature algorithm name: SHA384withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwFADCB +hTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G +A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNV +BAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAwMTE5 +MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0IxGzAZBgNVBAgT +EkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR +Q09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNh +dGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCR +6FSS0gpWsawNJN3Fz0RndJkrN6N9I3AAcbxT38T6KhKPS38QVr2fcHK3YX/JSw8X +pz3jsARh7v8Rl8f0hj4K+j5c+ZPmNHrZFGvnnLOFoIJ6dq9xkNfs/Q36nGz637CC +9BR++b7Epi9Pf5l/tfxnQ3K9DADWietrLNPtj5gcFKt+5eNu/Nio5JIk2kNrYrhV +/erBvGy2i/MOjZrkm2xpmfh4SDBF1a3hDTxFYPwyllEnvGfDyi62a+pGx8cgoLEf +Zd5ICLqkTqnyg0Y3hOvozIFIQ2dOciqbXL1MGyiKXCJ7tKuY2e7gUYPDCUZObT6Z ++pUX2nwzV0E8jVHtC7ZcryxjGt9XyD+86V3Em69FmeKjWiS0uqlWPc9vqv9JWL7w +qP/0uK3pN/u6uPQLOvnoQ0IeidiEyxPx2bvhiWC4jChWrBQdnArncevPDt09qZah +SL0896+1DSJMwBGB7FY79tOi4lu3sgQiUpWAk2nojkxl8ZEDLXB0AuqLZxUpaVIC +u9ffUGpVRr+goyhhf3DQw6KqLCGqR84onAZFdr+CGCe01a60y1Dma/RMhnEw6abf +Fobg2P9A3fvQQoh/ozM6LlweQRGBY84YcWsr7KaKtzFcOmpH4MN5WdYgGq/yapiq +crxXStJLnbsQ/LBMQeXtHT1eKJ2czL+zUdqnR+WEUwIDAQABo0IwQDAdBgNVHQ4E +FgQUu69+Aj36pvE8hI6t7jiY7NkyMtQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB +/wQFMAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAArx1UaEt65Ru2yyTUEUAJNMnMvl +wFTPoCWOAvn9sKIN9SCYPBMtrFaisNZ+EZLpLrqeLppysb0ZRGxhNaKatBYSaVqM +4dc+pBroLwP0rmEdEBsqpIt6xf4FpuHA1sj+nq6PK7o9mfjYcwlYRm6mnPTXJ9OV +2jeDchzTc+CiR5kDOF3VSXkAKRzH7JsgHAckaVd4sjn8OoSgtZx8jb8uk2Intzna +FxiuvTwJaP+EmzzV1gsD41eeFPfR60/IvYcjt7ZJQ3mFXLrrkguhxuhoqEwWsRqZ +CuhTLJK7oQkYdQxlqHvLI7cawiiFwxv/0Cti76R7CZGYZ4wUAc1oBmpjIXUDgIiK +boHGhfKppC3n9KUkEEeDys30jXlYsQab5xoq2Z0B15R97QNKyvDb6KkBPvVWmcke +jkk9u+UJueBPSZI9FoJAzMxZxuY67RIuaTxslbH9qh17f4a+Hg4yRvv7E491f0yL +S0Zj/gA0QHDBw7mh3aZw4gSzQbzpgJHqZJx64SIDqZxubw5lT2yHh17zbqD5daWb +QOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk527RH89elWsn2/x20Kk4yl +0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7ILaZRfyHB +NVOFBkpdn627G190 +-----END CERTIFICATE----- diff --git a/make/data/cacerts/digicertassuredidg2 b/make/data/cacerts/digicertassuredidg2 new file mode 100644 index 0000000000000000000000000000000000000000..8b53c2c49f680fadce239ac851b3cb78a3a63c1b --- /dev/null +++ b/make/data/cacerts/digicertassuredidg2 @@ -0,0 +1,29 @@ +Owner: CN=DigiCert Assured ID Root G2, OU=www.digicert.com, O=DigiCert Inc, C=US +Issuer: CN=DigiCert Assured ID Root G2, OU=www.digicert.com, O=DigiCert Inc, C=US +Serial number: b931c3ad63967ea6723bfc3af9af44b +Valid from: Thu Aug 01 12:00:00 GMT 2013 until: Fri Jan 15 12:00:00 GMT 2038 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDljCCAn6gAwIBAgIQC5McOtY5Z+pnI7/Dr5r0SzANBgkqhkiG9w0BAQsFADBl +MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 +d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJv +b3QgRzIwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1MTIwMDAwWjBlMQswCQYDVQQG +EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNl +cnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIwggEi +MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDZ5ygvUj82ckmIkzTz+GoeMVSA +n61UQbVH35ao1K+ALbkKz3X9iaV9JPrjIgwrvJUXCzO/GU1BBpAAvQxNEP4Htecc +biJVMWWXvdMX0h5i89vqbFCMP4QMls+3ywPgym2hFEwbid3tALBSfK+RbLE4E9Hp +EgjAALAcKxHad3A2m67OeYfcgnDmCXRwVWmvo2ifv922ebPynXApVfSr/5Vh88lA +bx3RvpO704gqu52/clpWcTs/1PPRCv4o76Pu2ZmvA9OPYLfykqGxvYmJHzDNw6Yu +YjOuFgJ3RFrngQo8p0Quebg/BLxcoIfhG69Rjs3sLPr4/m3wOnyqi+RnlTGNAgMB +AAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQW +BBTOw0q5mVXyuNtgv6l+vVa1lzan1jANBgkqhkiG9w0BAQsFAAOCAQEAyqVVjOPI +QW5pJ6d1Ee88hjZv0p3GeDgdaZaikmkuOGybfQTUiaWxMTeKySHMq2zNixya1r9I +0jJmwYrA8y8678Dj1JGG0VDjA9tzd29KOVPt3ibHtX2vK0LRdWLjSisCx1BL4Gni +lmwORGYQRI+tBev4eaymG+g3NJ1TyWGqolKvSnAWhsI6yLETcDbYz+70CjTVW0z9 +B5yiutkBclzzTcHdDrEcDcRjvq30FPuJ7KJBDkzMyFdA0G4Dqs0MjomZmWzwPDCv +ON9vvKO+KSAnq3T/EyJ43pdSVR6DtVQgA+6uwE9W3jfMw3+qBCe703e4YtsXfJwo +IhNzbM8m9Yop5w== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/digicertassuredidg3 b/make/data/cacerts/digicertassuredidg3 new file mode 100644 index 0000000000000000000000000000000000000000..120e0a5fff24cbea3c51daae603f74d82e4587ad --- /dev/null +++ b/make/data/cacerts/digicertassuredidg3 @@ -0,0 +1,22 @@ +Owner: CN=DigiCert Assured ID Root G3, OU=www.digicert.com, O=DigiCert Inc, C=US +Issuer: CN=DigiCert Assured ID Root G3, OU=www.digicert.com, O=DigiCert Inc, C=US +Serial number: ba15afa1ddfa0b54944afcd24a06cec +Valid from: Thu Aug 01 12:00:00 GMT 2013 until: Fri Jan 15 12:00:00 GMT 2038 +Signature algorithm name: SHA384withECDSA +Subject Public Key Algorithm: 384-bit EC (secp384r1) key +Version: 3 +-----BEGIN CERTIFICATE----- +MIICRjCCAc2gAwIBAgIQC6Fa+h3foLVJRK/NJKBs7DAKBggqhkjOPQQDAzBlMQsw +CQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cu +ZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3Qg +RzMwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1MTIwMDAwWjBlMQswCQYDVQQGEwJV +UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQu +Y29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwdjAQBgcq +hkjOPQIBBgUrgQQAIgNiAAQZ57ysRGXtzbg/WPuNsVepRC0FFfLvC/8QdJ+1YlJf +Zn4f5dwbRXkLzMZTCp2NXQLZqVneAlr2lSoOjThKiknGvMYDOAdfVdp+CW7if17Q +RSAPWXYQ1qAk8C3eNvJsKTmjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/ +BAQDAgGGMB0GA1UdDgQWBBTL0L2p4ZgFUaFNN6KDec6NHSrkhDAKBggqhkjOPQQD +AwNnADBkAjAlpIFFAmsSS3V0T8gj43DydXLefInwz5FyYZ5eEJJZVrmDxxDnOOlY +JjZ91eQ0hjkCMHw2U/Aw5WJjOpnitqM7mzT6HtoQknFekROn3aRukswy1vUhZscv +6pZjamVFkpUBtA== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/digicertassuredidrootca b/make/data/cacerts/digicertassuredidrootca new file mode 100644 index 0000000000000000000000000000000000000000..41edfc558097746559433d42a72e6292c7d51efa --- /dev/null +++ b/make/data/cacerts/digicertassuredidrootca @@ -0,0 +1,29 @@ +Owner: CN=DigiCert Assured ID Root CA, OU=www.digicert.com, O=DigiCert Inc, C=US +Issuer: CN=DigiCert Assured ID Root CA, OU=www.digicert.com, O=DigiCert Inc, C=US +Serial number: ce7e0e517d846fe8fe560fc1bf03039 +Valid from: Fri Nov 10 00:00:00 GMT 2006 until: Mon Nov 10 00:00:00 GMT 2031 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDtzCCAp+gAwIBAgIQDOfg5RfYRv6P5WD8G/AwOTANBgkqhkiG9w0BAQUFADBl +MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 +d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJv +b3QgQ0EwHhcNMDYxMTEwMDAwMDAwWhcNMzExMTEwMDAwMDAwWjBlMQswCQYDVQQG +EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNl +cnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0EwggEi +MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtDhXO5EOAXLGH87dg+XESpa7c +JpSIqvTO9SA5KFhgDPiA2qkVlTJhPLWxKISKityfCgyDF3qPkKyK53lTXDGEKvYP +mDI2dsze3Tyoou9q+yHyUmHfnyDXH+Kx2f4YZNISW1/5WBg1vEfNoTb5a3/UsDg+ +wRvDjDPZ2C8Y/igPs6eD1sNuRMBhNZYW/lmci3Zt1/GiSw0r/wty2p5g0I6QNcZ4 +VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpyoeb6pNnVFzF1roV9Iq4/ +AUaG9ih5yLHa5FcXxH4cDrC0kqZWs72yl+2qp/C3xag/lRbQ/6GW6whfGHdPAgMB +AAGjYzBhMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQW +BBRF66Kv9JLLgjEtUYunpyGd823IDzAfBgNVHSMEGDAWgBRF66Kv9JLLgjEtUYun +pyGd823IDzANBgkqhkiG9w0BAQUFAAOCAQEAog683+Lt8ONyc3pklL/3cmbYMuRC +dWKuh+vy1dneVrOfzM4UKLkNl2BcEkxY5NM9g0lFWJc1aRqoR+pWxnmrEthngYTf +fwk8lOa4JiwgvT2zKIn3X/8i4peEH+ll74fg38FnSbNd67IJKusm7Xi+fT8r87cm +NW1fiQG2SVufAQWbqz0lwcy2f8Lxb4bG+mRo64EtlOtCt/qMHt1i8b5QZ7dsvfPx +H2sMNgcWfzd8qVttevESRmCD1ycEvkvOl77DZypoEd+A5wwzZr8TDRRu838fYxAe ++o0bJW1sj6W3YQGx0qMmoRBxna3iw/nDmVG3KwcIzi7mULKn+gpFL6Lw8g== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/digicertglobalrootca b/make/data/cacerts/digicertglobalrootca new file mode 100644 index 0000000000000000000000000000000000000000..2838b8ead5848b180843939050f9dcb1c7cd01b7 --- /dev/null +++ b/make/data/cacerts/digicertglobalrootca @@ -0,0 +1,29 @@ +Owner: CN=DigiCert Global Root CA, OU=www.digicert.com, O=DigiCert Inc, C=US +Issuer: CN=DigiCert Global Root CA, OU=www.digicert.com, O=DigiCert Inc, C=US +Serial number: 83be056904246b1a1756ac95991c74a +Valid from: Fri Nov 10 00:00:00 GMT 2006 until: Mon Nov 10 00:00:00 GMT 2031 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh +MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 +d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD +QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT +MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j +b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG +9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB +CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97 +nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt +43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P +T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4 +gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO +BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR +TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw +DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/Esr +hMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg +06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF +PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls +YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk +CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/digicertglobalrootg2 b/make/data/cacerts/digicertglobalrootg2 new file mode 100644 index 0000000000000000000000000000000000000000..99bc121c03c666c523f5c247a5f6f7b200b007b8 --- /dev/null +++ b/make/data/cacerts/digicertglobalrootg2 @@ -0,0 +1,29 @@ +Owner: CN=DigiCert Global Root G2, OU=www.digicert.com, O=DigiCert Inc, C=US +Issuer: CN=DigiCert Global Root G2, OU=www.digicert.com, O=DigiCert Inc, C=US +Serial number: 33af1e6a711a9a0bb2864b11d09fae5 +Valid from: Thu Aug 01 12:00:00 GMT 2013 until: Fri Jan 15 12:00:00 GMT 2038 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBh +MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 +d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBH +MjAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAwMDBaMGExCzAJBgNVBAYTAlVT +MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j +b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEcyMIIBIjANBgkqhkiG +9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuzfNNNx7a8myaJCtSnX/RrohCgiN9RlUyfuI +2/Ou8jqJkTx65qsGGmvPrC3oXgkkRLpimn7Wo6h+4FR1IAWsULecYxpsMNzaHxmx +1x7e/dfgy5SDN67sH0NO3Xss0r0upS/kqbitOtSZpLYl6ZtrAGCSYP9PIUkY92eQ +q2EGnI/yuum06ZIya7XzV+hdG82MHauVBJVJ8zUtluNJbd134/tJS7SsVQepj5Wz +tCO7TG1F8PapspUwtP1MVYwnSlcUfIKdzXOS0xZKBgyMUNGPHgm+F6HmIcr9g+UQ +vIOlCsRnKPZzFBQ9RnbDhxSJITRNrw9FDKZJobq7nMWxM4MphQIDAQABo0IwQDAP +BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUTiJUIBiV +5uNu5g/6+rkS7QYXjzkwDQYJKoZIhvcNAQELBQADggEBAGBnKJRvDkhj6zHd6mcY +1Yl9PMWLSn/pvtsrF9+wX3N3KjITOYFnQoQj8kVnNeyIv/iPsGEMNKSuIEyExtv4 +NeF22d+mQrvHRAiGfzZ0JFrabA0UWTW98kndth/Jsw1HKj2ZL7tcu7XUIOGZX1NG +Fdtom/DzMNU+MeKNhJ7jitralj41E6Vf8PlwUHBHQRFXGU7Aj64GxJUTFy8bJZ91 +8rGOmaFvE7FBcf6IKshPECBV1/MUReXgRPTqh5Uykw7+U0b6LJ3/iyK5S9kJRaTe +pLiaWN0bfVKfjllDiIGknibVb63dDcY3fe0Dkhvld1927jyNxF1WW6LZZm6zNTfl +MrY= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/digicertglobalrootg3 b/make/data/cacerts/digicertglobalrootg3 new file mode 100644 index 0000000000000000000000000000000000000000..fbcfd3fc6e24c11ec6f3ebeef5bf0cb4e7aa3849 --- /dev/null +++ b/make/data/cacerts/digicertglobalrootg3 @@ -0,0 +1,22 @@ +Owner: CN=DigiCert Global Root G3, OU=www.digicert.com, O=DigiCert Inc, C=US +Issuer: CN=DigiCert Global Root G3, OU=www.digicert.com, O=DigiCert Inc, C=US +Serial number: 55556bcf25ea43535c3a40fd5ab4572 +Valid from: Thu Aug 01 12:00:00 GMT 2013 until: Fri Jan 15 12:00:00 GMT 2038 +Signature algorithm name: SHA384withECDSA +Subject Public Key Algorithm: 384-bit EC (secp384r1) key +Version: 3 +-----BEGIN CERTIFICATE----- +MIICPzCCAcWgAwIBAgIQBVVWvPJepDU1w6QP1atFcjAKBggqhkjOPQQDAzBhMQsw +CQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cu +ZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMzAe +Fw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAwMDBaMGExCzAJBgNVBAYTAlVTMRUw +EwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20x +IDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEczMHYwEAYHKoZIzj0CAQYF +K4EEACIDYgAE3afZu4q4C/sLfyHS8L6+c/MzXRq8NOrexpu80JX28MzQC7phW1FG +fp4tn+6OYwwX7Adw9c+ELkCDnOg/QW07rdOkFFk2eJ0DQ+4QE2xy3q6Ip6FrtUPO +Z9wj/wMco+I+o0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAd +BgNVHQ4EFgQUs9tIpPmhxdiuNkHMEWNpYim8S8YwCgYIKoZIzj0EAwMDaAAwZQIx +AK288mw/EkrRLTnDCgmXc/SINoyIJ7vmiI1Qhadj+Z4y3maTD/HMsQmP3Wyr+mt/ +oAIwOWZbwmSNuJ5Q3KjVSaLtx9zRSX8XAbjIho9OjIgrqJqpisXRAL34VOKa5Vt8 +sycX +-----END CERTIFICATE----- diff --git a/make/data/cacerts/digicerthighassuranceevrootca b/make/data/cacerts/digicerthighassuranceevrootca new file mode 100644 index 0000000000000000000000000000000000000000..13e6d85a546b2a3107856703f3114303cf56771f --- /dev/null +++ b/make/data/cacerts/digicerthighassuranceevrootca @@ -0,0 +1,30 @@ +Owner: CN=DigiCert High Assurance EV Root CA, OU=www.digicert.com, O=DigiCert Inc, C=US +Issuer: CN=DigiCert High Assurance EV Root CA, OU=www.digicert.com, O=DigiCert Inc, C=US +Serial number: 2ac5c266a0b409b8f0b79f2ae462577 +Valid from: Fri Nov 10 00:00:00 GMT 2006 until: Mon Nov 10 00:00:00 GMT 2031 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBs +MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 +d3cuZGlnaWNlcnQuY29tMSswKQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5j +ZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAwMFoXDTMxMTExMDAwMDAwMFowbDEL +MAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZMBcGA1UECxMQd3d3 +LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFuY2Ug +RVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm ++9S75S0tMqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTW +PNt0OKRKzE0lgvdKpVMSOO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEM +xChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFB +Ik5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQNAQTXKFx01p8VdteZOE3 +hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUeh10aUAsg +EsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQF +MAMBAf8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaA +FLE+w2kD+L9HAdSYJhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3Nec +nzyIZgYIVyHbIUf4KmeqvxgydkAQV8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6z +eM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFpmyPInngiK3BD41VHMWEZ71jF +hS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkKmNEVX58Svnw2 +Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe +vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep ++OkuE6N36B9K +-----END CERTIFICATE----- diff --git a/make/data/cacerts/digicerttrustedrootg4 b/make/data/cacerts/digicerttrustedrootg4 new file mode 100644 index 0000000000000000000000000000000000000000..3079e552a1e3222d50c3f5827b6cb77a19b13152 --- /dev/null +++ b/make/data/cacerts/digicerttrustedrootg4 @@ -0,0 +1,39 @@ +Owner: CN=DigiCert Trusted Root G4, OU=www.digicert.com, O=DigiCert Inc, C=US +Issuer: CN=DigiCert Trusted Root G4, OU=www.digicert.com, O=DigiCert Inc, C=US +Serial number: 59b1b579e8e2132e23907bda777755c +Valid from: Thu Aug 01 12:00:00 GMT 2013 until: Fri Jan 15 12:00:00 GMT 2038 +Signature algorithm name: SHA384withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIFkDCCA3igAwIBAgIQBZsbV56OITLiOQe9p3d1XDANBgkqhkiG9w0BAQwFADBi +MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 +d3cuZGlnaWNlcnQuY29tMSEwHwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3Qg +RzQwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1MTIwMDAwWjBiMQswCQYDVQQGEwJV +UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQu +Y29tMSEwHwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwggIiMA0GCSqG +SIb3DQEBAQUAA4ICDwAwggIKAoICAQC/5pBzaN675F1KPDAiMGkz7MKnJS7JIT3y +ithZwuEppz1Yq3aaza57G4QNxDAf8xukOBbrVsaXbR2rsnnyyhHS5F/WBTxSD1If +xp4VpX6+n6lXFllVcq9ok3DCsrp1mWpzMpTREEQQLt+C8weE5nQ7bXHiLQwb7iDV +ySAdYyktzuxeTsiT+CFhmzTrBcZe7FsavOvJz82sNEBfsXpm7nfISKhmV1efVFiO +DCu3T6cw2Vbuyntd463JT17lNecxy9qTXtyOj4DatpGYQJB5w3jHtrHEtWoYOAMQ +jdjUN6QuBX2I9YI+EJFwq1WCQTLX2wRzKm6RAXwhTNS8rhsDdV14Ztk6MUSaM0C/ +CNdaSaTC5qmgZ92kJ7yhTzm1EVgX9yRcRo9k98FpiHaYdj1ZXUJ2h4mXaXpI8OCi +EhtmmnTK3kse5w5jrubU75KSOp493ADkRSWJtppEGSt+wJS00mFt6zPZxd9LBADM +fRyVw4/3IbKyEbe7f/LVjHAsQWCqsWMYRJUadmJ+9oCw++hkpjPRiQfhvbfmQ6QY +uKZ3AeEPlAwhHbJUKSWJbOUOUlFHdL4mrLZBdd56rF+NP8m800ERElvlEFDrMcXK +chYiCd98THU/Y+whX8QgUWtvsauGi0/C1kVfnSD8oR7FwI+isX4KJpn15GkvmB0t +9dmpsh3lGwIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIB +hjAdBgNVHQ4EFgQU7NfjgtJxXWRM3y5nP+e6mK4cD08wDQYJKoZIhvcNAQEMBQAD +ggIBALth2X2pbL4XxJEbw6GiAI3jZGgPVs93rnD5/ZpKmbnJeFwMDF/k5hQpVgs2 +SV1EY+CtnJYYZhsjDT156W1r1lT40jzBQ0CuHVD1UvyQO7uYmWlrx8GnqGikJ9yd ++SeuMIW59mdNOj6PWTkiU0TryF0Dyu1Qen1iIQqAyHNm0aAFYF/opbSnr6j3bTWc +fFqK1qI4mfN4i/RN0iAL3gTujJtHgXINwBQy7zBZLq7gcfJW5GqXb5JQbZaNaHqa +sjYUegbyJLkJEVDXCLG4iXqEI2FCKeWjzaIgQdfRnGTZ6iahixTXTBmyUEFxPT9N +cCOGDErcgdLMMpSEDQgJlxxPwO5rIHQw0uA5NBCFIRUBCOhVMt5xSdkoF1BN5r5N +0XWs0Mr7QbhDparTwwVETyw2m+L64kW4I1NsBm9nVX9GtUw/bihaeSbSpKhil9Ie +4u1Ki7wb/UdKDd9nZn6yW0HQO+T0O/QEY+nvwlQAUaCKKsnOeMzV6ocEGLPOr0mI +r/OSmbaz5mEP0oUA51Aa5BuVnRmhuZyxm7EAHu/QD09CbMkKvO5D+jpxpchNJqU1 +/YldvIViHTLSoCtU7ZpXwdv6EM8Zt4tKG48BtieVU+i2iW1bvGjUI+iLUaJW+fCm +gKDWHrO8Dw9TdSmq6hN35N6MgSGtBxBHEa2HPQfRdbzP82Z+ +-----END CERTIFICATE----- diff --git a/make/data/cacerts/dtrustclass3ca2 b/make/data/cacerts/dtrustclass3ca2 new file mode 100644 index 0000000000000000000000000000000000000000..321c8fd002cad0e73af26cabcaf0678bb79c0012 --- /dev/null +++ b/make/data/cacerts/dtrustclass3ca2 @@ -0,0 +1,32 @@ +Owner: CN=D-TRUST Root Class 3 CA 2 2009, O=D-Trust GmbH, C=DE +Issuer: CN=D-TRUST Root Class 3 CA 2 2009, O=D-Trust GmbH, C=DE +Serial number: 983f3 +Valid from: Thu Nov 05 08:35:58 GMT 2009 until: Mon Nov 05 08:35:58 GMT 2029 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIEMzCCAxugAwIBAgIDCYPzMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNVBAYTAkRF +MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBD +bGFzcyAzIENBIDIgMjAwOTAeFw0wOTExMDUwODM1NThaFw0yOTExMDUwODM1NTha +ME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxELVRydXN0IEdtYkgxJzAlBgNVBAMM +HkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTCCASIwDQYJKoZIhvcNAQEB +BQADggEPADCCAQoCggEBANOySs96R+91myP6Oi/WUEWJNTrGa9v+2wBoqOADER03 +UAifTUpolDWzU9GUY6cgVq/eUXjsKj3zSEhQPgrfRlWLJ23DEE0NkVJD2IfgXU42 +tSHKXzlABF9bfsyjxiupQB7ZNoTWSPOSHjRGICTBpFGOShrvUD9pXRl/RcPHAY9R +ySPocq60vFYJfxLLHLGvKZAKyVXMD9O0Gu1HNVpK7ZxzBCHQqr0ME7UAyiZsxGsM +lFqVlNpQmvH/pStmMaTJOKDfHR+4CS7zp+hnUquVH+BGPtikw8paxTGA6Eian5Rp +/hnd2HN8gcqW3o7tszIFZYQ05ub9VxC1X3a/L7AQDcUCAwEAAaOCARowggEWMA8G +A1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFP3aFMSfMN4hvR5COfyrYyNJ4PGEMA4G +A1UdDwEB/wQEAwIBBjCB0wYDVR0fBIHLMIHIMIGAoH6gfIZ6bGRhcDovL2RpcmVj +dG9yeS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwUm9vdCUyMENsYXNzJTIwMyUy +MENBJTIwMiUyMDIwMDksTz1ELVRydXN0JTIwR21iSCxDPURFP2NlcnRpZmljYXRl +cmV2b2NhdGlvbmxpc3QwQ6BBoD+GPWh0dHA6Ly93d3cuZC10cnVzdC5uZXQvY3Js +L2QtdHJ1c3Rfcm9vdF9jbGFzc18zX2NhXzJfMjAwOS5jcmwwDQYJKoZIhvcNAQEL +BQADggEBAH+X2zDI36ScfSF6gHDOFBJpiBSVYEQBrLLpME+bUMJm2H6NMLVwMeni +acfzcNsgFYbQDfC+rAF1hM5+n02/t2A7nPPKHeJeaNijnZflQGDSNiH+0LS4F9p0 +o3/U37CYAqxva2ssJSRyoWXuJVrl5jLn8t+rSfrzkGkj2wTZ51xY/GXUl77M/C4K +zCUqNQT4YJEVdT1B/yMfGchs64JTBKbkTCJNjYy6zltz7GRUUG3RnFX7acM2w4y8 +PIWmawomDeCTmGCufsYkl4phX5GOZpIJhzbNi5stPvZR1FDUWSi9g/LMKHtThm3Y +Johw1+qRzT65ysCQblrGXnRl11z+o+I= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/dtrustclass3ca2ev b/make/data/cacerts/dtrustclass3ca2ev new file mode 100644 index 0000000000000000000000000000000000000000..191a1882a3beb0b96547c4e9768a3726edff8d1d --- /dev/null +++ b/make/data/cacerts/dtrustclass3ca2ev @@ -0,0 +1,32 @@ +Owner: CN=D-TRUST Root Class 3 CA 2 EV 2009, O=D-Trust GmbH, C=DE +Issuer: CN=D-TRUST Root Class 3 CA 2 EV 2009, O=D-Trust GmbH, C=DE +Serial number: 983f4 +Valid from: Thu Nov 05 08:50:46 GMT 2009 until: Mon Nov 05 08:50:46 GMT 2029 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIEQzCCAyugAwIBAgIDCYP0MA0GCSqGSIb3DQEBCwUAMFAxCzAJBgNVBAYTAkRF +MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBD +bGFzcyAzIENBIDIgRVYgMjAwOTAeFw0wOTExMDUwODUwNDZaFw0yOTExMDUwODUw +NDZaMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxELVRydXN0IEdtYkgxKjAoBgNV +BAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAwOTCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAJnxhDRwui+3MKCOvXwEz75ivJn9gpfSegpn +ljgJ9hBOlSJzmY3aFS3nBfwZcyK3jpgAvDw9rKFs+9Z5JUut8Mxk2og+KbgPCdM0 +3TP1YtHhzRnp7hhPTFiu4h7WDFsVWtg6uMQYZB7jM7K1iXdODL/ZlGsTl28So/6Z +qQTMFexgaDbtCHu39b+T7WYxg4zGcTSHThfqr4uRjRxWQa4iN1438h3Z0S0NL2lR +p75mpoo6Kr3HGrHhFPC+Oh25z1uxav60sUYgovseO3Dvk5h9jHOW8sXvhXCtKSb8 +HgQ+HKDYD8tSg2J87otTlZCpV6LqYQXY+U3EJ/pure3511H3a6UCAwEAAaOCASQw +ggEgMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFNOUikxiEyoZLsyvcop9Ntea +HNxnMA4GA1UdDwEB/wQEAwIBBjCB3QYDVR0fBIHVMIHSMIGHoIGEoIGBhn9sZGFw +Oi8vZGlyZWN0b3J5LmQtdHJ1c3QubmV0L0NOPUQtVFJVU1QlMjBSb290JTIwQ2xh +c3MlMjAzJTIwQ0ElMjAyJTIwRVYlMjAyMDA5LE89RC1UcnVzdCUyMEdtYkgsQz1E +RT9jZXJ0aWZpY2F0ZXJldm9jYXRpb25saXN0MEagRKBChkBodHRwOi8vd3d3LmQt +dHJ1c3QubmV0L2NybC9kLXRydXN0X3Jvb3RfY2xhc3NfM19jYV8yX2V2XzIwMDku +Y3JsMA0GCSqGSIb3DQEBCwUAA4IBAQA07XtaPKSUiO8aEXUHL7P+PPoeUSbrh/Yp +3uDx1MYkCenBz1UbtDDZzhr+BlGmFaQt77JLvyAoJUnRpjZ3NOhk31KxEcdzes05 +nsKtjHEh8lprr988TlWvsoRlFIm5d8sqMb7Po23Pb0iUMkZv53GMoKaEGTcH8gNF +CSuGdXzfX2lXANtu2KZyIktQ1HWYVt+3GP9DQ1CuekR78HlR10M9p9OB0/DJT7na +xpeG0ILD5EJt/rDiZE4OJudANCa1CInXCGNjOCd1HjPqbqjdn5lPdE2BiYBL3ZqX +KVwvvoFBuYz/6n1gBp7N1z3TLqMVvKjmJuVvw9y4AyHqnxbxLFS1 +-----END CERTIFICATE----- diff --git a/make/data/cacerts/entrust2048ca b/make/data/cacerts/entrust2048ca new file mode 100644 index 0000000000000000000000000000000000000000..0dd198d3404dc801e90081a5e3f2f4d5d2ab3124 --- /dev/null +++ b/make/data/cacerts/entrust2048ca @@ -0,0 +1,32 @@ +Owner: CN=Entrust.net Certification Authority (2048), OU=(c) 1999 Entrust.net Limited, OU=www.entrust.net/CPS_2048 incorp. by ref. (limits liab.), O=Entrust.net +Issuer: CN=Entrust.net Certification Authority (2048), OU=(c) 1999 Entrust.net Limited, OU=www.entrust.net/CPS_2048 incorp. by ref. (limits liab.), O=Entrust.net +Serial number: 3863def8 +Valid from: Fri Dec 24 17:50:51 GMT 1999 until: Tue Jul 24 14:15:12 GMT 2029 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIEKjCCAxKgAwIBAgIEOGPe+DANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UEChML +RW50cnVzdC5uZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9DUFNfMjA0OCBp +bmNvcnAuIGJ5IHJlZi4gKGxpbWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAxOTk5 +IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNVBAMTKkVudHJ1c3QubmV0IENlcnRp +ZmljYXRpb24gQXV0aG9yaXR5ICgyMDQ4KTAeFw05OTEyMjQxNzUwNTFaFw0yOTA3 +MjQxNDE1MTJaMIG0MRQwEgYDVQQKEwtFbnRydXN0Lm5ldDFAMD4GA1UECxQ3d3d3 +LmVudHJ1c3QubmV0L0NQU18yMDQ4IGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxp +YWIuKTElMCMGA1UECxMcKGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDEzMDEG +A1UEAxMqRW50cnVzdC5uZXQgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgKDIwNDgp +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArU1LqRKGsuqjIAcVFmQq +K0vRvwtKTY7tgHalZ7d4QMBzQshowNtTK91euHaYNZOLGp18EzoOH1u3Hs/lJBQe +sYGpjX24zGtLA/ECDNyrpUAkAH90lKGdCCmziAv1h3edVc3kw37XamSrhRSGlVuX +MlBvPci6Zgzj/L24ScF2iUkZ/cCovYmjZy/Gn7xxGWC4LeksyZB2ZnuU4q941mVT +XTzWnLLPKQP5L6RQstRIzgUyVYr9smRMDuSYB3Xbf9+5CFVghTAp+XtIpGmG4zU/ +HoZdenoVve8AjhUiVBcAkCaTvA5JaJG/+EfTnZVCwQ5N328mz8MYIWJmQ3DW1cAH +4QIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNV +HQ4EFgQUVeSB0RGAvtiJuQijMfmhJAkWuXAwDQYJKoZIhvcNAQEFBQADggEBADub +j1abMOdTmXx6eadNl9cZlZD7Bh/KM3xGY4+WZiT6QBshJ8rmcnPyT/4xmf3IDExo +U8aAghOY+rat2l098c5u9hURlIIM7j+VrxGrD9cv3h8Dj1csHsm7mhpElesYT6Yf +zX1XEC+bBAlahLVu2B064dae0Wx5XnkcFMXj0EyTO2U87d89vqbllRrDtRnDvV5b +u/8j72gZyxKTJ1wDLW8w0B62GqzeWvfRqqgnpv55gcR5mTNXuhKwqeBCbJPKVt7+ +bYQLCIt+jerXmCHG8+c8eS9enNFMFY3h7CI3zJpDC5fcgJCNs2ebb0gIFVbPv/Er +fF6adulZkMV8gzURZVE= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/entrustevca b/make/data/cacerts/entrustevca new file mode 100644 index 0000000000000000000000000000000000000000..6c2c50968b9688c6bf55e227a7221094fab620d0 --- /dev/null +++ b/make/data/cacerts/entrustevca @@ -0,0 +1,34 @@ +Owner: CN=Entrust Root Certification Authority, OU="(c) 2006 Entrust, Inc.", OU=www.entrust.net/CPS is incorporated by reference, O="Entrust, Inc.", C=US +Issuer: CN=Entrust Root Certification Authority, OU="(c) 2006 Entrust, Inc.", OU=www.entrust.net/CPS is incorporated by reference, O="Entrust, Inc.", C=US +Serial number: 456b5054 +Valid from: Mon Nov 27 20:23:42 GMT 2006 until: Fri Nov 27 20:53:42 GMT 2026 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIEkTCCA3mgAwIBAgIERWtQVDANBgkqhkiG9w0BAQUFADCBsDELMAkGA1UEBhMC +VVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0 +Lm5ldC9DUFMgaXMgaW5jb3Jwb3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMW +KGMpIDIwMDYgRW50cnVzdCwgSW5jLjEtMCsGA1UEAxMkRW50cnVzdCBSb290IENl +cnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2MTEyNzIwMjM0MloXDTI2MTEyNzIw +NTM0MlowgbAxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMTkw +NwYDVQQLEzB3d3cuZW50cnVzdC5uZXQvQ1BTIGlzIGluY29ycG9yYXRlZCBieSBy +ZWZlcmVuY2UxHzAdBgNVBAsTFihjKSAyMDA2IEVudHJ1c3QsIEluYy4xLTArBgNV +BAMTJEVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASIwDQYJ +KoZIhvcNAQEBBQADggEPADCCAQoCggEBALaVtkNC+sZtKm9I35RMOVcF7sN5EUFo +Nu3s/poBj6E4KPz3EEZmLk0eGrEaTsbRwJWIsMn/MYszA9u3g3s+IIRe7bJWKKf4 +4LlAcTfFy0cOlypowCKVYhXbR9n10Cv/gkvJrT7eTNuQgFA/CYqEAOwwCj0Yzfv9 +KlmaI5UXLEWeH25DeW0MXJj+SKfFI0dcXv1u5x609mhF0YaDW6KKjbHjKYD+JXGI +rb68j6xSlkuqUY3kEzEZ6E5Nn9uss2rVvDlUccp6en+Q3X0dgNmBu1kmwhH+5pPi +94DkZfs0Nw4pgHBNrziGLp5/V6+eF67rHMsoIV+2HNjnogQi+dPa2MsCAwEAAaOB +sDCBrTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zArBgNVHRAEJDAi +gA8yMDA2MTEyNzIwMjM0MlqBDzIwMjYxMTI3MjA1MzQyWjAfBgNVHSMEGDAWgBRo +kORnpKZTgMeGZqTx90tD+4S9bTAdBgNVHQ4EFgQUaJDkZ6SmU4DHhmak8fdLQ/uE +vW0wHQYJKoZIhvZ9B0EABBAwDhsIVjcuMTo0LjADAgSQMA0GCSqGSIb3DQEBBQUA +A4IBAQCT1DCw1wMgKtD5Y+iRDAUgqV8ZyntyTtSx29CW+1RaGSwMCPeyvIWonX9t +O1KzKtvn1ISMY/YPyyYBkVBs9F8U4pN0wBOeMDpQ47RgxRzwIkSNcUesyBrJ6Zua +AGAT/3B+XxFNSRuzFVJ7yVTav52Vr2ua2J7p8eRDjeIRRDq/r72DQnNSi6q7pynP +9WQcCk3RvKqsnyrQ/39/2n3qse0wJcGE2jTSW3iDVuycNsMm4hH2Z0kdkquM++v/ +eu6FSqdQgPCnXEqULl8FmTxSQeDNtGPPAUO6nIPcj2A781q0tHuu2guQOHXvgR1m +0vdXcDazv/wor3ElhVsT/h5/WrQ8 +-----END CERTIFICATE----- diff --git a/make/data/cacerts/entrustrootcaec1 b/make/data/cacerts/entrustrootcaec1 new file mode 100644 index 0000000000000000000000000000000000000000..58d29d53ed4f9131aa823c3f627176fb864b7f3b --- /dev/null +++ b/make/data/cacerts/entrustrootcaec1 @@ -0,0 +1,25 @@ +Owner: CN=Entrust Root Certification Authority - EC1, OU="(c) 2012 Entrust, Inc. - for authorized use only", OU=See www.entrust.net/legal-terms, O="Entrust, Inc.", C=US +Issuer: CN=Entrust Root Certification Authority - EC1, OU="(c) 2012 Entrust, Inc. - for authorized use only", OU=See www.entrust.net/legal-terms, O="Entrust, Inc.", C=US +Serial number: a68b79290000000050d091f9 +Valid from: Tue Dec 18 15:25:36 GMT 2012 until: Fri Dec 18 15:55:36 GMT 2037 +Signature algorithm name: SHA384withECDSA +Subject Public Key Algorithm: 384-bit EC (secp384r1) key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIC+TCCAoCgAwIBAgINAKaLeSkAAAAAUNCR+TAKBggqhkjOPQQDAzCBvzELMAkG +A1UEBhMCVVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3 +d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVybXMxOTA3BgNVBAsTMChjKSAyMDEyIEVu +dHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25seTEzMDEGA1UEAxMq +RW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRUMxMB4XDTEy +MTIxODE1MjUzNloXDTM3MTIxODE1NTUzNlowgb8xCzAJBgNVBAYTAlVTMRYwFAYD +VQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0 +L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxMiBFbnRydXN0LCBJbmMuIC0g +Zm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxMzAxBgNVBAMTKkVudHJ1c3QgUm9vdCBD +ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEVDMTB2MBAGByqGSM49AgEGBSuBBAAi +A2IABIQTydC6bUF74mzQ61VfZgIaJPRbiWlH47jCffHyAsWfoPZb1YsGGYZPUxBt +ByQnoaD41UcZYUx9ypMn6nQM72+WCf5j7HBdNq1nd67JnXxVRDqiY1Ef9eNi1KlH +Bz7MIKNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0O +BBYEFLdj5xrdjekIplWDpOBqUEFlEUJJMAoGCCqGSM49BAMDA2cAMGQCMGF52OVC +R98crlOZF7ZvHH3hvxGU0QOIdeSNiaSKd0bebWHvAvX7td/M/k7//qnmpwIwW5nX +hTcGtXsI/esni0qU+eH6p44mCOh8kmhtc9hvJqwhAriZtyZBWyVgrtBIGu4G +-----END CERTIFICATE----- diff --git a/make/data/cacerts/entrustrootcag2 b/make/data/cacerts/entrustrootcag2 new file mode 100644 index 0000000000000000000000000000000000000000..48ac89267b9295c83cccf7808febc3473df1335a --- /dev/null +++ b/make/data/cacerts/entrustrootcag2 @@ -0,0 +1,32 @@ +Owner: CN=Entrust Root Certification Authority - G2, OU="(c) 2009 Entrust, Inc. - for authorized use only", OU=See www.entrust.net/legal-terms, O="Entrust, Inc.", C=US +Issuer: CN=Entrust Root Certification Authority - G2, OU="(c) 2009 Entrust, Inc. - for authorized use only", OU=See www.entrust.net/legal-terms, O="Entrust, Inc.", C=US +Serial number: 4a538c28 +Valid from: Tue Jul 07 17:25:54 GMT 2009 until: Sat Dec 07 17:55:54 GMT 2030 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIEPjCCAyagAwIBAgIESlOMKDANBgkqhkiG9w0BAQsFADCBvjELMAkGA1UEBhMC +VVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50 +cnVzdC5uZXQvbGVnYWwtdGVybXMxOTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3Qs +IEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25seTEyMDAGA1UEAxMpRW50cnVz +dCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIwHhcNMDkwNzA3MTcy +NTU0WhcNMzAxMjA3MTc1NTU0WjCBvjELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUVu +dHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwt +dGVybXMxOTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0 +aG9yaXplZCB1c2Ugb25seTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmlj +YXRpb24gQXV0aG9yaXR5IC0gRzIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK +AoIBAQC6hLZy254Ma+KZ6TABp3bqMriVQRrJ2mFOWHLP/vaCeb9zYQYKpSfYs1/T +RU4cctZOMvJyig/3gxnQaoCAAEUesMfnmr8SVycco2gvCoe9amsOXmXzHHfV1IWN +cCG0szLni6LVhjkCsbjSR87kyUnEO6fe+1R9V77w6G7CebI6C1XiUJgWMhNcL3hW +wcKUs/Ja5CeanyTXxuzQmyWC48zCxEXFjJd6BmsqEZ+pCm5IO2/b1BEZQvePB7/1 +U1+cPvQXLOZprE4yTGJ36rfo5bs0vBmLrpxR57d+tVOxMyLlbc9wPBr64ptntoP0 +jaWvYkxN4FisZDQSA/i2jZRjJKRxAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAP +BgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqciZ60B7vfec7aVHUbI2fkBJmqzAN +BgkqhkiG9w0BAQsFAAOCAQEAeZ8dlsa2eT8ijYfThwMEYGprmi5ZiXMRrEPR9RP/ +jTkrwPK9T3CMqS/qF8QLVJ7UG5aYMzyorWKiAHarWWluBh1+xLlEjZivEtRh2woZ +Rkfz6/djwUAFQKXSt/S1mja/qYh2iARVBCuch38aNzx+LaUa2NSJXsq9rD1s2G2v +1fN2D807iDginWyTmsQ9v4IbZT+mD12q/OWyFcq1rca8PdCE6OoGcrBNOTJ4vz4R +nAuknZoh8/CbCzB428Hch0P+vGOaysXCHMnHjf87ElgI5rY97HosTvuDls4MPGmH +VHOkc8KT/1EQrBVUAdj8BbGJoX90g5pJ19xOe4pIb4tF9g== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/geotrustglobalca b/make/data/cacerts/geotrustglobalca new file mode 100644 index 0000000000000000000000000000000000000000..7f8bf9a6634488e352dc5986b1394a30afb13581 --- /dev/null +++ b/make/data/cacerts/geotrustglobalca @@ -0,0 +1,27 @@ +Owner: CN=GeoTrust Global CA, O=GeoTrust Inc., C=US +Issuer: CN=GeoTrust Global CA, O=GeoTrust Inc., C=US +Serial number: 23456 +Valid from: Tue May 21 04:00:00 GMT 2002 until: Sat May 21 04:00:00 GMT 2022 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT +MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i +YWwgQ0EwHhcNMDIwNTIxMDQwMDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQG +EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEbMBkGA1UEAxMSR2VvVHJ1c3Qg +R2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2swYYzD9 +9BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9mOSm9BXiLnTjoBbdq +fnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDv +iS2Aelet8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU +1XupGc1V3sjs0l44U+VcT4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+ +bw8HHa8sHo9gOeL6NlMTOdReJivbPagUvTLrGAMoUgRx5aszPeE4uwc2hGKceeoW +MPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTA +ephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVkDBF9qn1l +uMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKIn +Z57QzxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfS +tQWVYrmm3ok9Nns4d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcF +PseKUgzbFbS9bZvlxrFUaKnjaZC2mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Un +hw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6pXE0zX5IJL4hmXXeXxx12E6nV +5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvmMw== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/geotrustprimaryca b/make/data/cacerts/geotrustprimaryca new file mode 100644 index 0000000000000000000000000000000000000000..0f680ca16a92d3040ba6fb1e9eb3e1ca2584e18a --- /dev/null +++ b/make/data/cacerts/geotrustprimaryca @@ -0,0 +1,28 @@ +Owner: CN=GeoTrust Primary Certification Authority, O=GeoTrust Inc., C=US +Issuer: CN=GeoTrust Primary Certification Authority, O=GeoTrust Inc., C=US +Serial number: 18acb56afd69b6153a636cafdafac4a1 +Valid from: Mon Nov 27 00:00:00 GMT 2006 until: Wed Jul 16 23:59:59 GMT 2036 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDfDCCAmSgAwIBAgIQGKy1av1pthU6Y2yv2vrEoTANBgkqhkiG9w0BAQUFADBY +MQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjExMC8GA1UEAxMo +R2VvVHJ1c3QgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjEx +MjcwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMFgxCzAJBgNVBAYTAlVTMRYwFAYDVQQK +Ew1HZW9UcnVzdCBJbmMuMTEwLwYDVQQDEyhHZW9UcnVzdCBQcmltYXJ5IENlcnRp +ZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC +AQEAvrgVe//UfH1nrYNke8hCUy3f9oQIIGHWAVlqnEQRr+92/ZV+zmEwu3qDXwK9 +AWbK7hWNb6EwnL2hhZ6UOvNWiAAxz9juapYC2e0DjPt1befquFUWBRaa9OBesYjA +ZIVcFU2Ix7e64HXprQU9nceJSOC7KMgD4TCTZF5SwFlwIjVXiIrxlQqD17wxcwE0 +7e9GceBrAqg1cmuXm2bgyxx5X9gaBGgeRwLmnWDiNpcB3841kt++Z8dtd1k7j53W +kBWUvEI0EME5+bEnPn7WinXFsq+W06Lem+SYvn3h6YGttm/81w7a4DSwDRp35+MI +mO9Y+pyEtzavwt+s0vQQBnBxNQIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4G +A1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQULNVQQZcVi/CPNmFbSvtr2ZnJM5IwDQYJ +KoZIhvcNAQEFBQADggEBAFpwfyzdtzRP9YZRqSa+S7iq8XEN3GHHoOo0Hnp3DwQ1 +6CePbJC/kRYkRj5KTs4rFtULUh38H2eiAkUxT87z+gOneZ1TatnaYzr4gNfTmeGl +4b7UVXGYNTq+k+qurUKykG/g/CFNNWMziUnWm07Kx+dOCQD32sfvmWKZd7aVIl6K +oKv0uHiYyjgZmclynnjNS6yvGaBzEi38wkG6gZHaFloxt/m0cYASSJlyc1pZU8Fj +UjPtp8nSOQJw+uCxQmYpqptR7TBUIhRf2asdweSU8Pj1K/fqynhG1riR/aYNKxoU +AT6A8EKglQdebc3MS6RFjasS6LPeWuWgfOgPIh1a6Vk= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/geotrustprimarycag2 b/make/data/cacerts/geotrustprimarycag2 new file mode 100644 index 0000000000000000000000000000000000000000..0d1020aac8879a5c3382d2f600a54a7ff77de160 --- /dev/null +++ b/make/data/cacerts/geotrustprimarycag2 @@ -0,0 +1,24 @@ +Owner: CN=GeoTrust Primary Certification Authority - G2, OU=(c) 2007 GeoTrust Inc. - For authorized use only, O=GeoTrust Inc., C=US +Issuer: CN=GeoTrust Primary Certification Authority - G2, OU=(c) 2007 GeoTrust Inc. - For authorized use only, O=GeoTrust Inc., C=US +Serial number: 3cb2f4480a00e2feeb243b5e603ec36b +Valid from: Mon Nov 05 00:00:00 GMT 2007 until: Mon Jan 18 23:59:59 GMT 2038 +Signature algorithm name: SHA384withECDSA +Subject Public Key Algorithm: 384-bit EC (secp384r1) key +Version: 3 +-----BEGIN CERTIFICATE----- +MIICrjCCAjWgAwIBAgIQPLL0SAoA4v7rJDteYD7DazAKBggqhkjOPQQDAzCBmDEL +MAkGA1UEBhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsTMChj +KSAyMDA3IEdlb1RydXN0IEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTE2 +MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0 +eSAtIEcyMB4XDTA3MTEwNTAwMDAwMFoXDTM4MDExODIzNTk1OVowgZgxCzAJBgNV +BAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAoYykgMjAw +NyBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0BgNV +BAMTLUdlb1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBH +MjB2MBAGByqGSM49AgEGBSuBBAAiA2IABBWx6P0DFUPlrOuHNxFi79KDNlJ9RVcL +So17VDs6bl8VAsBQps8lL33KSLjHUGMcKiEIfJo22Av+0SbFWDEwKCXzXV2juLal +tJLtbCyf691DiaI8S0iRHVDsJt/WYC69IaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO +BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFBVfNVdRVfslsq0DafwBo/q+EVXVMAoG +CCqGSM49BAMDA2cAMGQCMGSWWaboCd6LuvpaiIjwH5HTRqjySkwCY/tsXzjbLkGT +qQ7mndwxHLKgpxgceeHHNgIwOlavmnRs9vuD4DPTCF+hnMJbn0bWtsuRBmOiBucz +rD6ogRLQy7rQkgu2npaqBA+K +-----END CERTIFICATE----- diff --git a/make/data/cacerts/geotrustprimarycag3 b/make/data/cacerts/geotrustprimarycag3 new file mode 100644 index 0000000000000000000000000000000000000000..1ccb56fb1726b23487ccc8bbd7bf4930309171e4 --- /dev/null +++ b/make/data/cacerts/geotrustprimarycag3 @@ -0,0 +1,31 @@ +Owner: CN=GeoTrust Primary Certification Authority - G3, OU=(c) 2008 GeoTrust Inc. - For authorized use only, O=GeoTrust Inc., C=US +Issuer: CN=GeoTrust Primary Certification Authority - G3, OU=(c) 2008 GeoTrust Inc. - For authorized use only, O=GeoTrust Inc., C=US +Serial number: 15ac6e9419b2794b41f627a9c3180f1f +Valid from: Wed Apr 02 00:00:00 GMT 2008 until: Tue Dec 01 23:59:59 GMT 2037 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIID/jCCAuagAwIBAgIQFaxulBmyeUtB9iepwxgPHzANBgkqhkiG9w0BAQsFADCB +mDELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsT +MChjKSAyMDA4IEdlb1RydXN0IEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25s +eTE2MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhv +cml0eSAtIEczMB4XDTA4MDQwMjAwMDAwMFoXDTM3MTIwMTIzNTk1OVowgZgxCzAJ +BgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAoYykg +MjAwOCBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0 +BgNVBAMTLUdlb1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkg +LSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANziXmJYHTNXOTIz ++uvLh4yn1ErdBojqZI4xmKU4kB6Yzy5jK/BGvESyiaHAKAxJcCGVn2TAppMSAmUm +hsalifD614SgcK9PGpc/BkTVyetyEH3kMSj7HGHmKAdEc5IiaacDiGydY8hS2pgn +5whMcD60yRLBxWeDXTPzAxHsatBT4tG6NmCUgLthY2xbF37fQJQeqw3CIShwiP/W +JmxsYAQlTlV+fe+/lEjetx3dcI0FX4ilm/LC7urRQEFtYjgdVgbFA0dRIBn8exAL +DmKudlW/X3e+PkkBUz2YJQN2JFodtNuJ6nnltrM7P7pMKEF/BqxqjsHQ9gUdfeZC +huOl1UcCAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYw +HQYDVR0OBBYEFMR5yo6hTgMdHNxr2zFblD4/MH8tMA0GCSqGSIb3DQEBCwUAA4IB +AQAtxRPPVoB7eni9n64smefv2t+UXglpp+duaIy9cr5HqQ6XErhK8WTTOd8lNNTB +zU6B8A8ExCSzNJbGpqow32hhc9f5joWJ7w5elShKKiePEI4ufIbEAp7aDHdlDkQN +kv39sxY2+hENHYwOB4lqKVb3cvTdFZx3NWZXqxNT2I7BQMXXExZacse3aQHEerGD +AWh9jUGhlBjBJVz88P6DAod8DQ3PLghcSkANPuyBYeYk28rgDi0Hsj5W3I31QYUH +SJsMC8tJP33st/3LjWeJGqvtux6jAAgIFyqCXDFdRootD4abdNlF+9RAsXqqaC2G +spki4cErx5z481+oghLrGREt +-----END CERTIFICATE----- diff --git a/make/data/cacerts/geotrustuniversalca b/make/data/cacerts/geotrustuniversalca new file mode 100644 index 0000000000000000000000000000000000000000..6e049bf707c4d3a4c36ef341b460ccc7d450d9e6 --- /dev/null +++ b/make/data/cacerts/geotrustuniversalca @@ -0,0 +1,38 @@ +Owner: CN=GeoTrust Universal CA, O=GeoTrust Inc., C=US +Issuer: CN=GeoTrust Universal CA, O=GeoTrust Inc., C=US +Serial number: 1 +Valid from: Thu Mar 04 05:00:00 GMT 2004 until: Sun Mar 04 05:00:00 GMT 2029 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIFaDCCA1CgAwIBAgIBATANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJVUzEW +MBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEeMBwGA1UEAxMVR2VvVHJ1c3QgVW5pdmVy +c2FsIENBMB4XDTA0MDMwNDA1MDAwMFoXDTI5MDMwNDA1MDAwMFowRTELMAkGA1UE +BhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xHjAcBgNVBAMTFUdlb1RydXN0 +IFVuaXZlcnNhbCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKYV +VaCjxuAfjJ0hUNfBvitbtaSeodlyWL0AG0y/YckUHUWCq8YdgNY96xCcOq9tJPi8 +cQGeBvV8Xx7BDlXKg5pZMK4ZyzBIle0iN430SppyZj6tlcDgFgDgEB8rMQ7XlFTT +QjOgNB0eRXbdT8oYN+yFFXoZCPzVx5zw8qkuEKmS5j1YPakWaDwvdSEYfyh3peFh +F7em6fgemdtzbvQKoiFs7tqqhZJmr/Z6a4LauiIINQ/PQvE1+mrufislzDoR5G2v +c7J2Ha3QsnhnGqQ5HFELZ1aD/ThdDc7d8Lsrlh/eezJS/R27tQahsiFepdaVaH/w +mZ7cRQg+59IJDTWU3YBOU5fXtQlEIGQWFwMCTFMNaN7VqnJNk22CDtucvc+081xd +VHppCZbW2xHBjXWotM85yM48vCR85mLK4b19p71XZQvk/iXttmkQ3CgaRr0BHdCX +teGYO8A3ZNY9lO4L4fUorgtWv3GLIylBjobFS1J72HGrH4oVpjuDWtdYAVHGTEHZ +f9hBZ3KiKN9gg6meyHv8U3NyWfWTehd2Ds735VzZC1U0oqpbtWpU5xPKV+yXbfRe +Bi9Fi1jUIxaS5BZuKGNZMN9QAZxjiRqf2xeUgnA3wySemkfWWspOqGmJch+RbNt+ +nhutxx9z3SxPGWX9f5NAEC7S8O08ni4oPmkmM8V7AgMBAAGjYzBhMA8GA1UdEwEB +/wQFMAMBAf8wHQYDVR0OBBYEFNq7LqqwDLiIJlF0XG0D08DYj3rWMB8GA1UdIwQY +MBaAFNq7LqqwDLiIJlF0XG0D08DYj3rWMA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG +9w0BAQUFAAOCAgEAMXjmx7XfuJRAyXHEqDXsRh3ChfMoWIawC/yOsjmPRFWrZIRc +aanQmjg8+uUfNeVE44B5lGiku8SfPeE0zTBGi1QrlaXv9z+ZhP015s8xxtxqv6fX +IwjhmF7DWgh2qaavdy+3YL1ERmrvl/9zlcGO6JP7/TG37FcREUWbMPEaiDnBTzyn +ANXH/KttgCJwpQzgXQQpAvvLoJHRfNbDflDVnVi+QTjruXU8FdmbyUqDWcDaU/0z +uzYYm4UPFd3uLax2k7nZAY1IEKj79TiG8dsKxr2EoyNB3tZ3b4XUhRxQ4K5RirqN +Pnbiucon8l+f725ZDQbYKxek0nxru18UGkiPGkzns0ccjkxFKyDuSN/n3QmOGKja +QI2SJhFTYXNd673nxE0pN2HrrDktZy4W1vUAg4WhzH92xH3kt0tm7wNFYGm2DFKW +koRepqO1pD4r2czYG0eq8kTaT/kD6PAUyz/zg97QwVTjt+gKN02LIFkDMBmhLMi9 +ER/frslKxfMnZmaGrGiR/9nmUxwPi1xpZQomyB40w11Re9epnAahNt3ViZS82eQt +DF4JbAiXfKM9fJP/P6EUp8+1Xevb2xzEdt+Iub1FBZUbrvxGakyvSOPOrg/Sfuvm +bJxPgWp6ZKy7PtXny3YuxadIwVyQD8vIP/rmMuGNG2+k5o7Y+SlIis5z/iw= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/globalsignca b/make/data/cacerts/globalsignca new file mode 100644 index 0000000000000000000000000000000000000000..48a7dec957087422d22a7e4047cc1f03a672d4db --- /dev/null +++ b/make/data/cacerts/globalsignca @@ -0,0 +1,28 @@ +Owner: CN=GlobalSign Root CA, OU=Root CA, O=GlobalSign nv-sa, C=BE +Issuer: CN=GlobalSign Root CA, OU=Root CA, O=GlobalSign nv-sa, C=BE +Serial number: 40000000001154b5ac394 +Valid from: Tue Sep 01 12:00:00 GMT 1998 until: Fri Jan 28 12:00:00 GMT 2028 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkG +A1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jv +b3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAw +MDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9i +YWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJHbG9iYWxT +aWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaDuaZ +jc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavp +xy0Sy6scTHAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp +1Wrjsok6Vjk4bwY8iGlbKk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdG +snUOhugZitVtbNV4FpWi6cgKOOvyJBNPc1STE4U6G7weNLWLBYy5d4ux2x8gkasJ +U26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrXgzT/LCrBbBlDSgeF59N8 +9iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8E +BTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0B +AQUFAAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOz +yj1hTdNGCbM+w6DjY1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE +38NflNUVyRRBnMRddWQVDf9VMOyGj/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymP +AbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhHhm4qxFYxldBniYUr+WymXUad +DKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveCX4XSQRjbgbME +HMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/globalsigneccrootcar4 b/make/data/cacerts/globalsigneccrootcar4 new file mode 100644 index 0000000000000000000000000000000000000000..135c0c046a94c779c718e5a7b4c302a48194de99 --- /dev/null +++ b/make/data/cacerts/globalsigneccrootcar4 @@ -0,0 +1,20 @@ +Owner: CN=GlobalSign, O=GlobalSign, OU=GlobalSign ECC Root CA - R4 +Issuer: CN=GlobalSign, O=GlobalSign, OU=GlobalSign ECC Root CA - R4 +Serial number: 2a38a41c960a04de42b228a50be8349802 +Valid from: Tue Nov 13 00:00:00 GMT 2012 until: Tue Jan 19 03:14:07 GMT 2038 +Signature algorithm name: SHA256withECDSA +Subject Public Key Algorithm: 256-bit EC (secp256r1) key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIB4TCCAYegAwIBAgIRKjikHJYKBN5CsiilC+g0mAIwCgYIKoZIzj0EAwIwUDEk +MCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpH +bG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoX +DTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBD +QSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWdu +MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEuMZ5049sJQ6fLjkZHAOkrprlOQcJ +FspjsbmG+IpXwVfOQvpzofdlQv8ewQCybnMO/8ch5RikqtlxP6jUuc6MHaNCMEAw +DgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFFSwe61F +uOJAf/sKbvu+M8k8o4TVMAoGCCqGSM49BAMCA0gAMEUCIQDckqGgE6bPA7DmxCGX +kPoUVy0D7O48027KqGx2vKLeuwIgJ6iFJzWbVsaj8kfSt24bAgAXqmemFZHe+pTs +ewv4n4Q= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/globalsigneccrootcar5 b/make/data/cacerts/globalsigneccrootcar5 new file mode 100644 index 0000000000000000000000000000000000000000..7156e83b9f9bdaeaf30c882fb5236b19c3d232a3 --- /dev/null +++ b/make/data/cacerts/globalsigneccrootcar5 @@ -0,0 +1,21 @@ +Owner: CN=GlobalSign, O=GlobalSign, OU=GlobalSign ECC Root CA - R5 +Issuer: CN=GlobalSign, O=GlobalSign, OU=GlobalSign ECC Root CA - R5 +Serial number: 605949e0262ebb55f90a778a71f94ad86c +Valid from: Tue Nov 13 00:00:00 GMT 2012 until: Tue Jan 19 03:14:07 GMT 2038 +Signature algorithm name: SHA384withECDSA +Subject Public Key Algorithm: 384-bit EC (secp384r1) key +Version: 3 +-----BEGIN CERTIFICATE----- +MIICHjCCAaSgAwIBAgIRYFlJ4CYuu1X5CneKcflK2GwwCgYIKoZIzj0EAwMwUDEk +MCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpH +bG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoX +DTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBD +QSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWdu +MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAER0UOlvt9Xb/pOdEh+J8LttV7HpI6SFkc +8GIxLcB6KP4ap1yztsyX50XUWPrRd21DosCHZTQKH3rd6zwzocWdTaRvQZU4f8ke +hOvRnkmSh5SHDDqFSmafnVmTTZdhBoZKo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYD +VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUPeYpSJvqB8ohREom3m7e0oPQn1kwCgYI +KoZIzj0EAwMDaAAwZQIxAOVpEslu28YxuglB4Zf4+/2a4n0Sye18ZNPLBSWLVtmg +515dTguDnFt2KaAJJiFqYgIwcdK1j1zqO+F4CYWodZI7yFz9SO8NdCKoCOJuxUnO +xwy8p2Fp8fc74SrL+SvzZpA3 +-----END CERTIFICATE----- diff --git a/make/data/cacerts/globalsignr2ca b/make/data/cacerts/globalsignr2ca new file mode 100644 index 0000000000000000000000000000000000000000..746d1fab985190af92c00223bbae1cae4ee4d4b8 --- /dev/null +++ b/make/data/cacerts/globalsignr2ca @@ -0,0 +1,29 @@ +Owner: CN=GlobalSign, O=GlobalSign, OU=GlobalSign Root CA - R2 +Issuer: CN=GlobalSign, O=GlobalSign, OU=GlobalSign Root CA - R2 +Serial number: 400000000010f8626e60d +Valid from: Fri Dec 15 08:00:00 GMT 2006 until: Wed Dec 15 08:00:00 GMT 2021 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4G +A1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNp +Z24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1 +MDgwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMjETMBEG +A1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAKbPJA6+Lm8omUVCxKs+IVSbC9N/hHD6ErPL +v4dfxn+G07IwXNb9rfF73OX4YJYJkhD10FPe+3t+c4isUoh7SqbKSaZeqKeMWhG8 +eoLrvozps6yWJQeXSpkqBy+0Hne/ig+1AnwblrjFuTosvNYSuetZfeLQBoZfXklq +tTleiDTsvHgMCJiEbKjNS7SgfQx5TfC4LcshytVsW33hoCmEofnTlEnLJGKRILzd +C9XZzPnqJworc5HGnRusyMvo4KD0L5CLTfuwNhv2GXqF4G3yYROIXJ/gkwpRl4pa +zq+r1feqCapgvdzZX99yqWATXgAByUr6P6TqBwMhAo6CygPCm48CAwEAAaOBnDCB +mTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUm+IH +V2ccHsBqBt5ZtJot39wZhi4wNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL2NybC5n +bG9iYWxzaWduLm5ldC9yb290LXIyLmNybDAfBgNVHSMEGDAWgBSb4gdXZxwewGoG +3lm0mi3f3BmGLjANBgkqhkiG9w0BAQUFAAOCAQEAmYFThxxol4aR7OBKuEQLq4Gs +J0/WwbgcQ3izDJr86iw8bmEbTUsp9Z8FHSbBuOmDAGJFtqkIk7mpM0sYmsL4h4hO +291xNBrBVNpGP+DTKqttVCL1OmLNIG+6KYnX3ZHu01yiPqFbQfXf5WRDLenVOavS +ot+3i9DAgBkcRcAtjOj4LaR0VknFBbVPFd5uRHg5h6h+u/N5GJG79G+dwfCMNYxd +AfvDbbnvRG15RjF+Cv6pgsH/76tuIMRQyV+dTZsXjAzlAcmgQWpzU/qlULRuJQ/7 +TBj0/VLZjmmx6BEP3ojY+x1J96relc8geMJgEtslQIxq/H5COEBkEveegeGTLg== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/globalsignr3ca b/make/data/cacerts/globalsignr3ca new file mode 100644 index 0000000000000000000000000000000000000000..44dce028abdefcfc73bbeb935595aca056cd044e --- /dev/null +++ b/make/data/cacerts/globalsignr3ca @@ -0,0 +1,28 @@ +Owner: CN=GlobalSign, O=GlobalSign, OU=GlobalSign Root CA - R3 +Issuer: CN=GlobalSign, O=GlobalSign, OU=GlobalSign Root CA - R3 +Serial number: 4000000000121585308a2 +Valid from: Wed Mar 18 10:00:00 GMT 2009 until: Sun Mar 18 10:00:00 GMT 2029 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4G +A1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNp +Z24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4 +MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEG +A1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWtiHL8 +RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsT +gHeMCOFJ0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmm +KPZpO/bLyCiR5Z2KYVc3rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zd +QQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjlOCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZ +XriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2xmmFghcCAwEAAaNCMEAw +DgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFI/wS3+o +LkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZU +RUm7lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMp +jjM5RcOO5LlXbKr8EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK +6fBdRoyV3XpYKBovHd7NADdBj+1EbddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQX +mcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18YIvDQVETI53O9zJrlAGomecs +Mx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7rkpeDMdmztcpH +WD9f +-----END CERTIFICATE----- diff --git a/make/data/cacerts/globalsignrootcar6 b/make/data/cacerts/globalsignrootcar6 new file mode 100644 index 0000000000000000000000000000000000000000..50f748df2285833234ac06d52463a9ffd0499af4 --- /dev/null +++ b/make/data/cacerts/globalsignrootcar6 @@ -0,0 +1,39 @@ +Owner: CN=GlobalSign, O=GlobalSign, OU=GlobalSign Root CA - R6 +Issuer: CN=GlobalSign, O=GlobalSign, OU=GlobalSign Root CA - R6 +Serial number: 45e6bb038333c3856548e6ff4551 +Valid from: Wed Dec 10 00:00:00 GMT 2014 until: Sun Dec 10 00:00:00 GMT 2034 +Signature algorithm name: SHA384withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIFgzCCA2ugAwIBAgIORea7A4Mzw4VlSOb/RVEwDQYJKoZIhvcNAQEMBQAwTDEg +MB4GA1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjYxEzARBgNVBAoTCkdsb2Jh +bFNpZ24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMTQxMjEwMDAwMDAwWhcNMzQx +MjEwMDAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSNjET +MBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCAiIwDQYJ +KoZIhvcNAQEBBQADggIPADCCAgoCggIBAJUH6HPKZvnsFMp7PPcNCPG0RQssgrRI +xutbPK6DuEGSMxSkb3/pKszGsIhrxbaJ0cay/xTOURQh7ErdG1rG1ofuTToVBu1k +ZguSgMpE3nOUTvOniX9PeGMIyBJQbUJmL025eShNUhqKGoC3GYEOfsSKvGRMIRxD +aNc9PIrFsmbVkJq3MQbFvuJtMgamHvm566qjuL++gmNQ0PAYid/kD3n16qIfKtJw +LnvnvJO7bVPiSHyMEAc4/2ayd2F+4OqMPKq0pPbzlUoSB239jLKJz9CgYXfIWHSw +1CM69106yqLbnQneXUQtkPGBzVeS+n68UARjNN9rkxi+azayOeSsJDa38O+2HBNX +k7besvjihbdzorg1qkXy4J02oW9UivFyVm4uiMVRQkQVlO6jxTiWm05OWgtH8wY2 +SXcwvHE35absIQh1/OZhFj931dmRl4QKbNQCTXTAFO39OfuD8l4UoQSwC+n+7o/h +bguyCLNhZglqsQY6ZZZZwPA1/cnaKI0aEYdwgQqomnUdnjqGBQCe24DWJfncBZ4n +WUx2OVvq+aWh2IMP0f/fMBH5hc8zSPXKbWQULHpYT9NLCEnFlWQaYw55PfWzjMpY +rZxCRXluDocZXFSxZba/jJvcE+kNb7gu3GduyYsRtYQUigAZcIN5kZeR1Bonvzce +MgfYFGM8KEyvAgMBAAGjYzBhMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTAD +AQH/MB0GA1UdDgQWBBSubAWjkxPioufi1xzWx/B/yGdToDAfBgNVHSMEGDAWgBSu +bAWjkxPioufi1xzWx/B/yGdToDANBgkqhkiG9w0BAQwFAAOCAgEAgyXt6NH9lVLN +nsAEoJFp5lzQhN7craJP6Ed41mWYqVuoPId8AorRbrcWc+ZfwFSY1XS+wc3iEZGt +Ixg93eFyRJa0lV7Ae46ZeBZDE1ZXs6KzO7V33EByrKPrmzU+sQghoefEQzd5Mr61 +55wsTLxDKZmOMNOsIeDjHfrYBzN2VAAiKrlNIC5waNrlU/yDXNOd8v9EDERm8tLj +vUYAGm0CuiVdjaExUd1URhxN25mW7xocBFymFe944Hn+Xds+qkxV/ZoVqW/hpvvf +cDDpw+5CRu3CkwWJ+n1jez/QcYF8AOiYrg54NMMl+68KnyBr3TsTjxKM4kEaSHpz +oHdpx7Zcf4LIHv5YGygrqGytXm3ABdJ7t+uA/iU3/gKbaKxCXcPu9czc8FB10jZp +nOZ7BN9uBmm23goJSFmH63sUYHpkqmlD75HHTOwY3WzvUy2MmeFe8nI+z1TIvWfs +pA9MRf/TuTAjB0yPEL+GltmZWrSZVxykzLsViVO6LAUP5MSeGbEYNNVMnbrt9x+v +JJUEeKgDu+6B5dpffItKoZB0JaezPkvILFa9x8jvOOJckvB595yEunQtYQEgfn7R +8k8HWV+LLUNS60YMlOH1Zkd5d9VUWx+tJDfLRVpOoERIyNiwmcUVhAn21klJwGW4 +5hpxbqCo8YLoRT5s1gLXCmeDBVrJpBA= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/godaddyclass2ca b/make/data/cacerts/godaddyclass2ca new file mode 100644 index 0000000000000000000000000000000000000000..a5f5746563a11f243421b664996b809d0283d409 --- /dev/null +++ b/make/data/cacerts/godaddyclass2ca @@ -0,0 +1,31 @@ +Owner: OU=Go Daddy Class 2 Certification Authority, O="The Go Daddy Group, Inc.", C=US +Issuer: OU=Go Daddy Class 2 Certification Authority, O="The Go Daddy Group, Inc.", C=US +Serial number: 0 +Valid from: Tue Jun 29 17:06:20 GMT 2004 until: Thu Jun 29 17:06:20 GMT 2034 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEh +MB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBE +YWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3 +MDYyMFoXDTM0MDYyOTE3MDYyMFowYzELMAkGA1UEBhMCVVMxITAfBgNVBAoTGFRo +ZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28gRGFkZHkgQ2xhc3Mg +MiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQADggEN +ADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XCA +PVYYYwhv2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux6w +wdhFJ2+qN1j3hybX2C32qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLOtXi +EqITLdiOr18SPaAIBQi2XKVlOARFmR6jYGB0xUGlcmIbYsUfb18aQr4CUWWoriMY +avx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmYvLEHZ6IVDd2gWMZEewo+ +YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjgcAwgb0wHQYDVR0OBBYEFNLE +sNKR1EwRcbNhyz2h/t2oatTjMIGNBgNVHSMEgYUwgYKAFNLEsNKR1EwRcbNhyz2h +/t2oatTjoWekZTBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYVGhlIEdvIERhZGR5 +IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRpZmlj +YXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQAD +ggEBADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wimPQoZ+YeAEW5p5JYXMP80kWNy +OO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKtI3lpjbi2Tc7P +TMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ +HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mER +dEr/VxqHD3VILs9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5Cuf +ReYNnyicsbkqWletNw+vHX/bvZ8= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/godaddyrootg2ca b/make/data/cacerts/godaddyrootg2ca new file mode 100644 index 0000000000000000000000000000000000000000..5d60b3619361834da9748cbabb36f87219c45b44 --- /dev/null +++ b/make/data/cacerts/godaddyrootg2ca @@ -0,0 +1,30 @@ +Owner: CN=Go Daddy Root Certificate Authority - G2, O="GoDaddy.com, Inc.", L=Scottsdale, ST=Arizona, C=US +Issuer: CN=Go Daddy Root Certificate Authority - G2, O="GoDaddy.com, Inc.", L=Scottsdale, ST=Arizona, C=US +Serial number: 0 +Valid from: Tue Sep 01 00:00:00 GMT 2009 until: Thu Dec 31 23:59:59 GMT 2037 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMx +EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoT +EUdvRGFkZHkuY29tLCBJbmMuMTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRp +ZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIz +NTk1OVowgYMxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQH +EwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjExMC8GA1UE +AxMoR28gRGFkZHkgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIw +DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9xYgjx+lk09xvJGKP3gElY6SKD +E6bFIEMBO4Tx5oVJnyfq9oQbTqC023CYxzIBsQU+B07u9PpPL1kwIuerGVZr4oAH +/PMWdYA5UXvl+TW2dE6pjYIT5LY/qQOD+qK+ihVqf94Lw7YZFAXK6sOoBJQ7Rnwy +DfMAZiLIjWltNowRGLfTshxgtDj6AozO091GB94KPutdfMh8+7ArU6SSYmlRJQVh +GkSBjCypQ5Yj36w6gZoOKcUcqeldHraenjAKOc7xiID7S13MMuyFYkMlNAJWJwGR +tDtwKj9useiciAF9n9T521NtYJ2/LOdYq7hfRvzOxBsDPAnrSTFcaUaz4EcCAwEA +AaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE +FDqahQcQZyi27/a9BUFuIMGU2g/eMA0GCSqGSIb3DQEBCwUAA4IBAQCZ21151fmX +WWcDYfF+OwYxdS2hII5PZYe096acvNjpL9DbWu7PdIxztDhC2gV7+AJ1uP2lsdeu +9tfeE8tTEH6KRtGX+rcuKxGrkLAngPnon1rpN5+r5N9ss4UXnT3ZJE95kTXWXwTr +gIOrmgIttRD02JDHBHNA7XIloKmf7J6raBKZV8aPEjoJpL1E/QYVN8Gb5DKj7Tjo +2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO +LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI +4uJEvlz36hz1 +-----END CERTIFICATE----- diff --git a/make/data/cacerts/identrustcommercial b/make/data/cacerts/identrustcommercial new file mode 100644 index 0000000000000000000000000000000000000000..8623d4b9b5868396914cd44d5c78793ec8bc405a --- /dev/null +++ b/make/data/cacerts/identrustcommercial @@ -0,0 +1,38 @@ +Owner: CN=IdenTrust Commercial Root CA 1, O=IdenTrust, C=US +Issuer: CN=IdenTrust Commercial Root CA 1, O=IdenTrust, C=US +Serial number: a0142800000014523c844b500000002 +Valid from: Thu Jan 16 18:12:23 GMT 2014 until: Mon Jan 16 18:12:23 GMT 2034 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIFYDCCA0igAwIBAgIQCgFCgAAAAUUjyES1AAAAAjANBgkqhkiG9w0BAQsFADBK +MQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVu +VHJ1c3QgQ29tbWVyY2lhbCBSb290IENBIDEwHhcNMTQwMTE2MTgxMjIzWhcNMzQw +MTE2MTgxMjIzWjBKMQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0MScw +JQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBSb290IENBIDEwggIiMA0GCSqG +SIb3DQEBAQUAA4ICDwAwggIKAoICAQCnUBneP5k91DNG8W9RYYKyqU+PZ4ldhNlT +3Qwo2dfw/66VQ3KZ+bVdfIrBQuExUHTRgQ18zZshq0PirK1ehm7zCYofWjK9ouuU ++ehcCuz/mNKvcbO0U59Oh++SvL3sTzIwiEsXXlfEU8L2ApeN2WIrvyQfYo3fw7gp +S0l4PJNgiCL8mdo2yMKi1CxUAGc1bnO/AljwpN3lsKImesrgNqUZFvX9t++uP0D1 +bVoE/c40yiTcdCMbXTMTEl3EASX2MN0CXZ/g1Ue9tOsbobtJSdifWwLziuQkkORi +T0/Br4sOdBeo0XKIanoBScy0RnnGF7HamB4HWfp1IYVl3ZBWzvurpWCdxJ35UrCL +vYf5jysjCiN2O/cz4ckA82n5S6LgTrx+kzmEB/dEcH7+B1rlsazRGMzyNeVJSQjK +Vsk9+w8YfYs7wRPCTY/JTw436R+hDmrfYi7LNQZReSzIJTj0+kuniVyc0uMNOYZK +dHzVWYfCP04MXFL0PfdSgvHqo6z9STQaKPNBiDoT7uje/5kdX7rL6B7yuVBgwDHT +c+XvvqDtMwt0viAgxGds8AgDelWAf0ZOlqf0Hj7h9tgJ4TNkK2PXMl6f+cB7D3hv +l7yTmvmcEpB4eoCHFddydJxVdHixuuFucAS6T6C6aMN7/zHwcz09lCqxC0EOoP5N +iGVreTO01wIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB +/zAdBgNVHQ4EFgQU7UQZwNPwBovupHu+QucmVMiONnYwDQYJKoZIhvcNAQELBQAD +ggIBAA2ukDL2pkt8RHYZYR4nKM1eVO8lvOMIkPkp165oCOGUAFjvLi5+U1KMtlwH +6oi6mYtQlNeCgN9hCQCTrQ0U5s7B8jeUeLBfnLOic7iPBZM4zY0+sLj7wM+x8uwt +LRvM7Kqas6pgghstO8OEPVeKlh6cdbjTMM1gCIOQ045U8U1mwF10A0Cj7oV+wh93 +nAbowacYXVKV7cndJZ5t+qntozo00Fl72u1Q8zW/7esUTTHHYPTa8Yec4kjixsU3 ++wYQ+nVZZjFHKdp2mhzpgq7vmrlR94gjmmmVYjzlVYA211QC//G5Xc7UI2/YRYRK +W2XviQzdFKcgyxilJbQN+QHwotL0AMh0jqEqSI5l2xPE4iUXfeu+h1sXIFRRk0pT +AwvsXcoz7WL9RccvW9xYoIA55vrX/hMUpu09lEpCdNTDd1lzzY9GvlU47/rokTLq +l1gEIt44w8y8bckzOmoKaT+gyOpyj4xjhiO9bTyWnpXgSUyqorkqG5w2gXjtw+hG +4iZZRHUe2XWJUc0QhJ1hYMtd+ZciTY6Y5uN/9lu7rs3KSoFrXgvzUeF0K+l+J6fZ +mUlO+KWA2yUPHGNiiskzZ2s8EIPGrd6ozRaOjfAHN3Gf8qv8QfXBi+wAN10J5U6A +7/qxXDgGpRtK4dw4LTzcqx+QGtVKnO7RcGzM7vRX+Bi6hG6H +-----END CERTIFICATE----- diff --git a/make/data/cacerts/identrustdstx3 b/make/data/cacerts/identrustdstx3 new file mode 100644 index 0000000000000000000000000000000000000000..87a0d0c4f60f0f423a1d44070c9aea19c6796198 --- /dev/null +++ b/make/data/cacerts/identrustdstx3 @@ -0,0 +1,27 @@ +Owner: CN=DST Root CA X3, O=Digital Signature Trust Co. +Issuer: CN=DST Root CA X3, O=Digital Signature Trust Co. +Serial number: 44afb080d6a327ba893039862ef8406b +Valid from: Sat Sep 30 21:12:19 GMT 2000 until: Thu Sep 30 14:01:15 GMT 2021 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/ +MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT +DkRTVCBSb290IENBIFgzMB4XDTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVow +PzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QgQ28uMRcwFQYDVQQD +Ew5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB +AN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmTrE4O +rz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEq +OLl5CjH9UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9b +xiqKqy69cK3FCxolkHRyxXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw +7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40dutolucbY38EVAjqr2m7xPi71XAicPNaD +aeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV +HQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQMA0GCSqG +SIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69 +ikugdB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXr +AvHRAosZy5Q6XkjEGB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZz +R8srzJmwN0jP41ZL9c8PDHIyh8bwRLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5 +JDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubSfZGL+T0yjWW06XyxV3bqxbYo +Ob8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ +-----END CERTIFICATE----- diff --git a/make/data/cacerts/identrustpublicca b/make/data/cacerts/identrustpublicca new file mode 100644 index 0000000000000000000000000000000000000000..f4034ea6d8b49e8d1b5a971faf213ee1547b634f --- /dev/null +++ b/make/data/cacerts/identrustpublicca @@ -0,0 +1,38 @@ +Owner: CN=IdenTrust Public Sector Root CA 1, O=IdenTrust, C=US +Issuer: CN=IdenTrust Public Sector Root CA 1, O=IdenTrust, C=US +Serial number: a0142800000014523cf467c00000002 +Valid from: Thu Jan 16 17:53:32 GMT 2014 until: Mon Jan 16 17:53:32 GMT 2034 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIFZjCCA06gAwIBAgIQCgFCgAAAAUUjz0Z8AAAAAjANBgkqhkiG9w0BAQsFADBN +MQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVu +VHJ1c3QgUHVibGljIFNlY3RvciBSb290IENBIDEwHhcNMTQwMTE2MTc1MzMyWhcN +MzQwMTE2MTc1MzMyWjBNMQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0 +MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3RvciBSb290IENBIDEwggIi +MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2IpT8pEiv6EdrCvsnduTyP4o7 +ekosMSqMjbCpwzFrqHd2hCa2rIFCDQjrVVi7evi8ZX3yoG2LqEfpYnYeEe4IFNGy +RBb06tD6Hi9e28tzQa68ALBKK0CyrOE7S8ItneShm+waOh7wCLPQ5CQ1B5+ctMlS +bdsHyo+1W/CD80/HLaXIrcuVIKQxKFdYWuSNG5qrng0M8gozOSI5Cpcu81N3uURF +/YTLNiCBWS2ab21ISGHKTN9T0a9SvESfqy9rg3LvdYDaBjMbXcjaY8ZNzaxmMc3R +3j6HEDbhuaR672BQssvKplbgN6+rNBM5Jeg5ZuSYeqoSmJxZZoY+rfGwyj4GD3vw +EUs3oERte8uojHH01bWRNszwFcYr3lEXsZdMUD2xlVl8BX0tIdUAvwFnol57plzy +9yLxkA2T26pEUWbMfXYD62qoKjgZl3YNa4ph+bz27nb9cCvdKTz4Ch5bQhyLVi9V +GxyhLrXHFub4qjySjmm2AcG1hp2JDws4lFTo6tyePSW8Uybt1as5qsVATFSrsrTZ +2fjXctscvG29ZV/viDUqZi/u9rNl8DONfJhBaUYPQxxp+pu10GFqzcpL2UyQRqsV +WaFHVCkugyhfHMKiq3IXAAaOReyL4jM9f9oZRORicsPfIsbyVtTdX5Vy7W1f90gD +W/3FKqD2cyOEEBsB5wIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/ +BAUwAwEB/zAdBgNVHQ4EFgQU43HgntinQtnbcZFrlJPrw6PRFKMwDQYJKoZIhvcN +AQELBQADggIBAEf63QqwEZE4rU1d9+UOl1QZgkiHVIyqZJnYWv6IAcVYpZmxI1Qj +t2odIFflAWJBF9MJ23XLblSQdf4an4EKwt3X9wnQW3IV5B4Jaj0z8yGa5hV+rVHV +DRDtfULAj+7AmgjVQdZcDiFpboBhDhXAuM/FSRJSzL46zNQuOAXeNf0fb7iAaJg9 +TaDKQGXSc3z1i9kKlT/YPyNtGtEqJBnZhbMX73huqVjRI9PHE+1yJX9dsXNw0H8G +lwmEKYBhHfpe/3OsoOOJuBxxFcbeMX8S3OFtm6/n6J91eEyrRjuazr8FGF1NFTwW +mhlQBJqymm9li1JfPFgEKCXAZmExfrngdbkaqIHWchezxQMxNRF4eKLg6TCMf4Df +WN88uieW4oA0beOY02QnrEh+KHdcxiVhJfiFDGX6xDIvpZgF5PgLZxYWxoK4Mhn5 ++bl53B/N66+rDt0b20XkeucC4pVd/GnwU2lhlXV5C15V5jgclKlZM57IcXR5f1GJ +tshquDDIajjDbp7hNxbqBWJMWxJH7ae0s1hWx0nzfxJoCTFx8G34Tkf71oXuxVhA +GaQdp/lLQzfcaFpPz+vCZHTetBXZ9FRUGi8c15dxVJCO2SCdUyt/q4/i6jC8UDfv +8Ue1fXwsBOxonbRJRBD0ckscZOf85muQ3Wl9af0AVqW3rLatt8o+Ae+c +-----END CERTIFICATE----- diff --git a/make/data/cacerts/letsencryptisrgx1 b/make/data/cacerts/letsencryptisrgx1 new file mode 100644 index 0000000000000000000000000000000000000000..9364e1df5d70ddcf3e3126225002a12a697103ba --- /dev/null +++ b/make/data/cacerts/letsencryptisrgx1 @@ -0,0 +1,38 @@ +Owner: CN=ISRG Root X1, O=Internet Security Research Group, C=US +Issuer: CN=ISRG Root X1, O=Internet Security Research Group, C=US +Serial number: 8210cfb0d240e3594463e0bb63828b00 +Valid from: Thu Jun 04 11:04:38 GMT 2015 until: Mon Jun 04 11:04:38 GMT 2035 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw +TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh +cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4 +WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu +ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY +MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc +h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+ +0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U +A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sW +T8KOEUt+zwvo/7V3LvSye0rgTBIlDHCNAymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyH +B5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ4Q7e2RCOFvu396j3x+UC +B5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf1b0SHzUv +KBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWn +OlFuhjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTn +jh8BCNAw1FtxNrQHusEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbw +qHyGO0aoSCqI3Haadr8faqU9GY/rOPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CI +rU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV +HRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY9umbbjANBgkq +hkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL +ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ +3BebYhtF8GaV0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KK +NFtY2PwByVS5uCbMiogziUwthDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5 +ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJwTdwJx4nLCgdNbOhdjsnvzqvHu7Ur +TkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nxe5AW0wdeRlN8NwdC +jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc +oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq +4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA +mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d +emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/luxtrustglobalroot2ca b/make/data/cacerts/luxtrustglobalroot2ca new file mode 100644 index 0000000000000000000000000000000000000000..e04c3998ab7c6e88032abb7c3f90aa5049b4cb21 --- /dev/null +++ b/make/data/cacerts/luxtrustglobalroot2ca @@ -0,0 +1,40 @@ +Owner: CN=LuxTrust Global Root 2, O=LuxTrust S.A., C=LU +Issuer: CN=LuxTrust Global Root 2, O=LuxTrust S.A., C=LU +Serial number: a7ea6df4b449eda6a24859ee6b815d3167fbbb1 +Valid from: Thu Mar 05 13:21:57 GMT 2015 until: Mon Mar 05 13:21:57 GMT 2035 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIFwzCCA6ugAwIBAgIUCn6m30tEntpqJIWe5rgV0xZ/u7EwDQYJKoZIhvcNAQEL +BQAwRjELMAkGA1UEBhMCTFUxFjAUBgNVBAoMDUx1eFRydXN0IFMuQS4xHzAdBgNV +BAMMFkx1eFRydXN0IEdsb2JhbCBSb290IDIwHhcNMTUwMzA1MTMyMTU3WhcNMzUw +MzA1MTMyMTU3WjBGMQswCQYDVQQGEwJMVTEWMBQGA1UECgwNTHV4VHJ1c3QgUy5B +LjEfMB0GA1UEAwwWTHV4VHJ1c3QgR2xvYmFsIFJvb3QgMjCCAiIwDQYJKoZIhvcN +AQEBBQADggIPADCCAgoCggIBANeFl78RmOnwYoNMPIf5U2o3C/IPPIfOb9wmKb3F +ibrJgz337spbxm1Jc7TJRqMbNBM/wYlFV/TZsfs2ZUv7COJIcRHIbjuend+JZTem +hfY7RBi2xjcwYkSSl2l9QjAk5A0MiWtj3sXh306pFGxT4GHO9hcvHTy95iJMHZP1 +EMShduxq3sVs35a0VkBCwGKSMKEtFZSg0iAGCW5qbeXrt77U8PEVfIvmTroTzEsn +Xpk8F12PgX8zPU/TPxvsXD/wPEx1bvKm1Z3aLQdjAsZy6ZS8TEmVT4hSyNvoaYL4 +zDRbIvCGp4m9SAptZoFtyMhk+wHh9OHe2Z7d21vUKpkmFRseTJIpgp7VkoGSQXAZ +96Tlk0u8d2cx3Rz9MXANF5kM+Qw5GSoXtTBxVdUPrljhPS80m8+f9niFwpN6cj5m +j5wWEWCPnolvZ77gR1o7DJpni89Gxq44o/KnvObWhWszJHAiS8sIm7vI+AIpHb4g +DEa/a4ebsypmQjVGbKq6rfmYe+lQVRQxv7HaLe2ArWgk+2mr2HETMOZns4dA/Yl+ +8kPREd8vZS9kzl8UubG/Mb2HeFpZZYiq/FkySIbWTLkpS5XTdvN3JW1CHDiDTf2j +X5t/Lax5Gw5CMZdjpPuKadUiDTSQMC6otOBttpSsvItO13D8xTiOZCXhTTmQzsmH +hFhxAgMBAAGjgagwgaUwDwYDVR0TAQH/BAUwAwEB/zBCBgNVHSAEOzA5MDcGByuB +KwEBAQowLDAqBggrBgEFBQcCARYeaHR0cHM6Ly9yZXBvc2l0b3J5Lmx1eHRydXN0 +Lmx1MA4GA1UdDwEB/wQEAwIBBjAfBgNVHSMEGDAWgBT/GCh2+UgFLKGu8SsbK7JT ++Et8szAdBgNVHQ4EFgQU/xgodvlIBSyhrvErGyuyU/hLfLMwDQYJKoZIhvcNAQEL +BQADggIBAGoZFO1uecEsh9QNcH7X9njJCwROxLHOk3D+sFTAMs2ZMGQXvw/l4jP9 +BzZAcg4atmpZ1gDlaCDdLnINH2pkMSCEfUmmWjfrRcmF9dTHF5kH5ptV5AzoqbTO +jFu1EVzPig4N1qx3gf4ynCSecs5U89BvolbW7MM3LGVYvlcAGvI1+ut7MV3CwRI9 +loGIlonBWVx65n9wNOeD4rHh4bhY79SV5GCc8JaXcozrhAIuZY+kt9J/Z93I055c +qqmkoCUUBpvsT34tC38ddfEz2O3OuHVtPlu5mB0xDVbYQw8wkbIEa91WvpWAVWe+ +2M2D2RjuLg+GLZKecBPs3lHJQ3gCpU3I+V/EkVhGFndadKpAvAefMLmx9xIX3eP/ +JEAdemrRTxgKqpAd60Ae36EeRJIQmvKN4dFLRp7oRUKX6kWZ8+xm1QL68qZKJKre +zrnK+T+Tb/mjuuqlPpmt/f97mfVl7vBZKGfXkJWkE4SphMHozs51k2MavDzq1WQf +LSoSOcbDWjLtR5EWDrw4wVDej8oqkDQc7kGUnF4ZLvhFSZl0kbAEb+MEWrGrKqv+ +x9CWttrhSmQGbmBNvUJO/3jaJMobtNeWOWyu8Q6qp31IiyBMz2TWuJdGsE7RKlY6 +oJO9r4Ak4Ap+58rVyuiFVdw2KuGUaJPHZnJED4AhMmwlxyOAgwrr +-----END CERTIFICATE----- diff --git a/make/data/cacerts/luxtrustglobalrootca b/make/data/cacerts/luxtrustglobalrootca new file mode 100644 index 0000000000000000000000000000000000000000..7fb3d818f807925dffd78565fea402aec32d5ce8 --- /dev/null +++ b/make/data/cacerts/luxtrustglobalrootca @@ -0,0 +1,28 @@ +Owner: CN=LuxTrust Global Root, O=LuxTrust s.a., C=LU +Issuer: CN=LuxTrust Global Root, O=LuxTrust s.a., C=LU +Serial number: bb8 +Valid from: Thu Mar 17 09:51:37 GMT 2011 until: Wed Mar 17 09:51:37 GMT 2021 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDZDCCAkygAwIBAgICC7gwDQYJKoZIhvcNAQELBQAwRDELMAkGA1UEBhMCTFUx +FjAUBgNVBAoTDUx1eFRydXN0IHMuYS4xHTAbBgNVBAMTFEx1eFRydXN0IEdsb2Jh +bCBSb290MB4XDTExMDMxNzA5NTEzN1oXDTIxMDMxNzA5NTEzN1owRDELMAkGA1UE +BhMCTFUxFjAUBgNVBAoTDUx1eFRydXN0IHMuYS4xHTAbBgNVBAMTFEx1eFRydXN0 +IEdsb2JhbCBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsn+n +QPAiygz267Hxyw6VV0B1r6A/Ps7sqjJX5hmxZ0OYWmt8s7j6eJyqpoSyYBuAQc5j +zR8XCJmk9e8+EsdMsFeaXHhAePxFjdqRZ9w6Ubltc+a3OY52OrQfBfVpVfmTz3iI +Sr6qm9d7R1tGBEyCFqY19vx039a0r9jitScRdFmiwmYsaArhmIiIPIoFdRTjuK7z +CISbasE/MRivJ6VLm6T9eTHemD0OYcqHmMH4ijCc+j4z1aXEAwfh95Z0GAAnOCfR +K6qq4UFFi2/xJcLcopeVx0IUM115hCNq52XAV6DYXaljAeew5Ivo+MVjuOVsdJA9 +x3f8K7p56aTGEnin/wIDAQABo2AwXjAMBgNVHRMEBTADAQH/MA4GA1UdDwEB/wQE +AwIBBjAfBgNVHSMEGDAWgBQXFYWJCS8kh28/HRvk8pZ5g0gTzjAdBgNVHQ4EFgQU +FxWFiQkvJIdvPx0b5PKWeYNIE84wDQYJKoZIhvcNAQELBQADggEBAFrwHNDUUM9B +fua4nX3DcNBeNv9ujnov3kgR1TQuPLdFwlQlp+HBHjeDtpSutkVIA+qVvuucarQ3 +XB8u02uCgUNbCj8RVWOs+nwIAjegPDkEM/6XMshS5dklTbDG7mgfcKpzzlcD3H0K +DTPy0lrfCmw7zBFRlxqkIaKFNQLXgCLShLL4wKpov9XrqsMLq6F8K/f1O4fhVFfs +BSTveUJO84ton+Ruy4KZycwq3FPCH3CDqyEPVrRI/98HIrOM+R2mBN8tAza53W/+ +MYhm/2xtRDSvCHc+JtJy9LtHVpM8mGPhM7uZI5K1g3noHZ9nrWLWidb2/CfeMifL +hNp3hSGhEiE= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/quovadisrootca b/make/data/cacerts/quovadisrootca new file mode 100644 index 0000000000000000000000000000000000000000..0c195ff51fcda7846cd8fefa174cc9a186d9ef07 --- /dev/null +++ b/make/data/cacerts/quovadisrootca @@ -0,0 +1,41 @@ +Owner: CN=QuoVadis Root Certification Authority, OU=Root Certification Authority, O=QuoVadis Limited, C=BM +Issuer: CN=QuoVadis Root Certification Authority, OU=Root Certification Authority, O=QuoVadis Limited, C=BM +Serial number: 3ab6508b +Valid from: Mon Mar 19 18:33:33 GMT 2001 until: Wed Mar 17 18:33:33 GMT 2021 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIF0DCCBLigAwIBAgIEOrZQizANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJC +TTEZMBcGA1UEChMQUXVvVmFkaXMgTGltaXRlZDElMCMGA1UECxMcUm9vdCBDZXJ0 +aWZpY2F0aW9uIEF1dGhvcml0eTEuMCwGA1UEAxMlUXVvVmFkaXMgUm9vdCBDZXJ0 +aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wMTAzMTkxODMzMzNaFw0yMTAzMTcxODMz +MzNaMH8xCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMSUw +IwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MS4wLAYDVQQDEyVR +dW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG +9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv2G1lVO6V/z68mcLOhrfEYBklbTRvM16z/Yp +li4kVEAkOPcahdxYTMukJ0KX0J+DisPkBgNbAKVRHnAEdOLB1Dqr1607BxgFjv2D +rOpm2RgbaIr1VxqYuvXtdj182d6UajtLF8HVj71lODqV0D1VNk7feVcxKh7YWWVJ +WCCYfqtffp/p1k3sg3Spx2zY7ilKhSoGFPlU5tPaZQeLYzcS19Dsw3sgQUSj7cug +F+FxZc4dZjH3dgEZyH0DWLaVSR2mEiboxgx24ONmy+pdpibu5cxfvWenAScOospU +xbF6lR1xHkopigPcakXBpBlebzbNw6Kwt/5cOOJSvPhEQ+aQuwIDAQABo4ICUjCC +Ak4wPQYIKwYBBQUHAQEEMTAvMC0GCCsGAQUFBzABhiFodHRwczovL29jc3AucXVv +dmFkaXNvZmZzaG9yZS5jb20wDwYDVR0TAQH/BAUwAwEB/zCCARoGA1UdIASCAREw +ggENMIIBCQYJKwYBBAG+WAABMIH7MIHUBggrBgEFBQcCAjCBxxqBxFJlbGlhbmNl +IG9uIHRoZSBRdW9WYWRpcyBSb290IENlcnRpZmljYXRlIGJ5IGFueSBwYXJ0eSBh +c3N1bWVzIGFjY2VwdGFuY2Ugb2YgdGhlIHRoZW4gYXBwbGljYWJsZSBzdGFuZGFy +ZCB0ZXJtcyBhbmQgY29uZGl0aW9ucyBvZiB1c2UsIGNlcnRpZmljYXRpb24gcHJh +Y3RpY2VzLCBhbmQgdGhlIFF1b1ZhZGlzIENlcnRpZmljYXRlIFBvbGljeS4wIgYI +KwYBBQUHAgEWFmh0dHA6Ly93d3cucXVvdmFkaXMuYm0wHQYDVR0OBBYEFItLbe3T +KbkGGew5Oanwl4Rqy+/fMIGuBgNVHSMEgaYwgaOAFItLbe3TKbkGGew5Oanwl4Rq +y+/foYGEpIGBMH8xCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1p +dGVkMSUwIwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MS4wLAYD +VQQDEyVRdW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggQ6tlCL +MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOCAQEAitQUtf70mpKnGdSk +fnIYj9lofFIk3WdvOXrEql494liwTXCYhGHoG+NpGA7O+0dQoE7/8CQfvbLO9Sf8 +7C9TqnN7Az10buYWnuulLsS/VidQK2K6vkscPFVcQR0kvoIgR13VRH56FmjffU1R +cHhXHTMe/QKZnAzNCgVPx7uOpHX6Sm2xgI4JVrmcGmD+XcHXetwReNDWXcG31a0y +mQM6isxUJTkxgXsTIlG6Rmyhu576BGxJJnSP0nPrzDCi5upZIof4l/UO/erMkqQW +xFIY6iHOsfHmhIHluqmGKPJDWl0Snawe2ajlCmqnf6CHKc/yiU3U7MXi5nrQNiOK +SnQ2+Q== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/quovadisrootca1g3 b/make/data/cacerts/quovadisrootca1g3 new file mode 100644 index 0000000000000000000000000000000000000000..26e23ab8dc3bbd34c32663e09cbfccd30271b38e --- /dev/null +++ b/make/data/cacerts/quovadisrootca1g3 @@ -0,0 +1,38 @@ +Owner: CN=QuoVadis Root CA 1 G3, O=QuoVadis Limited, C=BM +Issuer: CN=QuoVadis Root CA 1 G3, O=QuoVadis Limited, C=BM +Serial number: 78585f2ead2c194be3370735341328b596d46593 +Valid from: Thu Jan 12 17:27:44 GMT 2012 until: Sun Jan 12 17:27:44 GMT 2042 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIFYDCCA0igAwIBAgIUeFhfLq0sGUvjNwc1NBMotZbUZZMwDQYJKoZIhvcNAQEL +BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc +BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMSBHMzAeFw0xMjAxMTIxNzI3NDRaFw00 +MjAxMTIxNzI3NDRaMEgxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM +aW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDEgRzMwggIiMA0GCSqG +SIb3DQEBAQUAA4ICDwAwggIKAoICAQCgvlAQjunybEC0BJyFuTHK3C3kEakEPBtV +wedYMB0ktMPvhd6MLOHBPd+C5k+tR4ds7FtJwUrVu4/sh6x/gpqG7D0DmVIB0jWe +rNrwU8lmPNSsAgHaJNM7qAJGr6Qc4/hzWHa39g6QDbXwz8z6+cZM5cOGMAqNF341 +68Xfuw6cwI2H44g4hWf6Pser4BOcBRiYz5P1sZK0/CPTz9XEJ0ngnjybCKOLXSoh +4Pw5qlPafX7PGglTvF0FBM+hSo+LdoINofjSxxR3W5A2B4GbPgb6Ul5jxaYA/qXp +UhtStZI5cgMJYr2wYBZupt0lwgNm3fME0UDiTouG9G/lg6AnhF4EwfWQvTA9xO+o +abw4m6SkltFi2mnAAZauy8RRNOoMqv8hjlmPSlzkYZqn0ukqeI1RPToV7qJZjqlc +3sX5kCLliEVx3ZGZbHqfPT2YfF72vhZooF6uCyP8Wg+qInYtyaEQHeTTRCOQiJ/G +KubX9ZqzWB4vMIkIG1SitZgj7Ah3HJVdYdHLiZxfokqRmu8hqkkWCKi9YSgxyXSt +hfbZxbGL0eUQMk1fiyA6PEkfM4VZDdvLCXVDaXP7a3F98N/ETH3Goy7IlXnLc6KO +Tk0k+17kBL5yG6YnLUlamXrXXAkgt3+UuU/xDRxeiEIbEbfnkduebPRq34wGmAOt +zCjvpUfzUwIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIB +BjAdBgNVHQ4EFgQUo5fW816iEOGrRZ88F2Q87gFwnMwwDQYJKoZIhvcNAQELBQAD +ggIBABj6W3X8PnrHX3fHyt/PX8MSxEBd1DKquGrX1RUVRpgjpeaQWxiZTOOtQqOC +MTaIzen7xASWSIsBx40Bz1szBpZGZnQdT+3Btrm0DWHMY37XLneMlhwqI2hrhVd2 +cDMT/uFPpiN3GPoajOi9ZcnPP/TJF9zrx7zABC4tRi9pZsMbj/7sPtPKlL92CiUN +qXsCHKnQO18LwIE6PWThv6ctTr1NxNgpxiIY0MWscgKCP6o6ojoilzHdCGPDdRS5 +YCgtW2jgFqlmgiNR9etT2DGbe+m3nUvriBbP+V04ikkwj+3x6xn0dxoxGE1nVGwv +b2X52z3sIexe9PSLymBlVNFxZPT5pqOBMzYzcfCkeF9OrYMh3jRJjehZrJ3ydlo2 +8hP0r+AJx2EqbPfgna67hkooby7utHnNkDPDs3b69fBsnQGQ+p6Q9pxyz0fawx/k +NSBT8lTR32GDpgLiJTjehTItXnOQUl1CxM49S+H5GYQd1aJQzEH7QRTDvdbJWqNj +ZgKAvQU6O0ec7AAmTPWIUb+oI38YB7AL7YsmoWTTYUrrXJ/es69nA7Mf3W1daWhp +q1467HxpvMc7hU6eFbm0FU/DlXpY18ls6Wy58yljXrQs8C097Vpl4KlbQMJImYFt +nh8GKjwStIsPm6Ik8KaN1nrgS7ZklmOVhMJKzRwuJIczYOXD +-----END CERTIFICATE----- diff --git a/make/data/cacerts/quovadisrootca2 b/make/data/cacerts/quovadisrootca2 new file mode 100644 index 0000000000000000000000000000000000000000..c5b1f0709fcca220139001dc5df7b5668f46e64f --- /dev/null +++ b/make/data/cacerts/quovadisrootca2 @@ -0,0 +1,40 @@ +Owner: CN=QuoVadis Root CA 2, O=QuoVadis Limited, C=BM +Issuer: CN=QuoVadis Root CA 2, O=QuoVadis Limited, C=BM +Serial number: 509 +Valid from: Fri Nov 24 18:27:00 GMT 2006 until: Mon Nov 24 18:23:33 GMT 2031 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIFtzCCA5+gAwIBAgICBQkwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0x +GTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJv +b3QgQ0EgMjAeFw0wNjExMjQxODI3MDBaFw0zMTExMjQxODIzMzNaMEUxCzAJBgNV +BAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMRswGQYDVQQDExJRdW9W +YWRpcyBSb290IENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCa +GMpLlA0ALa8DKYrwD4HIrkwZhR0In6spRIXzL4GtMh6QRr+jhiYaHv5+HBg6XJxg +Fyo6dIMzMH1hVBHL7avg5tKifvVrbxi3Cgst/ek+7wrGsxDp3MJGF/hd/aTa/55J +WpzmM+Yklvc/ulsrHHo1wtZn/qtmUIttKGAr79dgw8eTvI02kfN/+NsRE8Scd3bB +rrcCaoF6qUWD4gXmuVbBlDePSHFjIuwXZQeVikvfj8ZaCuWw419eaxGrDPmF60Tp ++ARz8un+XJiM9XOva7R+zdRcAitMOeGylZUtQofX1bOQQ7dsE/He3fbE+Ik/0XX1 +ksOR1YqI0JDs3G3eicJlcZaLDQP9nL9bFqyS2+r+eXyt66/3FsvbzSUr5R/7mp/i +Ucw6UwxI5g69ybR2BlLmEROFcmMDBOAENisgGQLodKcftslWZvB1JdxnwQ5hYIiz +PtGo/KPaHbDRsSNU30R2be1B2MGyIrZTHN81Hdyhdyox5C315eXbyOD/5YDXC2Og +/zOhD7osFRXql7PSorW+8oyWHhqPHWykYTe5hnMz15eWniN9gqRMgeKh0bpnX5UH +oycR7hYQe7xFSkyyBNKr79X9DFHOUGoIMfmR2gyPZFwDwzqLID9ujWc9Otb+fVuI +yV77zGHcizN300QyNQliBJIWENieJ0f7OyHj+OsdWwIDAQABo4GwMIGtMA8GA1Ud +EwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1UdDgQWBBQahGK8SEwzJQTU7tD2 +A8QZRtGUazBuBgNVHSMEZzBlgBQahGK8SEwzJQTU7tD2A8QZRtGUa6FJpEcwRTEL +MAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMT +ElF1b1ZhZGlzIFJvb3QgQ0EgMoICBQkwDQYJKoZIhvcNAQEFBQADggIBAD4KFk2f +BluornFdLwUvZ+YTRYPENvbzwCYMDbVHZF34tHLJRqUDGCdViXh9duqWNIAXINzn +g/iN/Ae42l9NLmeyhP3ZRPx3UIHmfLTJDQtyU/h2BwdBR5YM++CCJpNVjP4iH2Bl +fF/nJrP3MpCYUNQ3cVX2kiF495V5+vgtJodmVjB3pjd4M1IQWK4/YY7yarHvGH5K +WWPKjaJW1acvvFYfzznB4vsKqBUsfU16Y8Zsl0Q80m/DShcK+JDSV6IZUaUtl0Ha +B0+pUNqQjZRG4T7wlP0QADj1O+hA4bRuVhogzG9Yje0uRY/W6ZM/57Es3zrWIozc +hLsib9D45MY56QSIPMO661V6bYCZJPVsAfv4l7CUW+v90m/xd2gNNWQjrLhVoQPR +TUIZ3Ph1WVaj+ahJefivDrkRoHy3au000LYmYjgahwz46P0u05B/B5EqHdZ+XIWD +mbA4CD/pXvk1B+TJYm5Xf6dQlfe6yJvmjqIBxdZmv3lh8zwc4bmCXF2gw+nYSL0Z +ohEUGW6yhhtoPkg3Goi3XZZenMfvJ2II4pEZXNLxId26F0KCl3GBUzGpn/Z9Yr9y +4aOTHcyKJloJONDO1w2AFrR4pTqHTI2KpdVGl/IsELm8VCLAAVBpQ570su9t+Oza +8eOx79+Rj1QqCyXBJhnEUhAFZdWCEOrCMc0u +-----END CERTIFICATE----- diff --git a/make/data/cacerts/quovadisrootca2g3 b/make/data/cacerts/quovadisrootca2g3 new file mode 100644 index 0000000000000000000000000000000000000000..6d370f546b5ea256df0ca789ea771f9e09eb8337 --- /dev/null +++ b/make/data/cacerts/quovadisrootca2g3 @@ -0,0 +1,38 @@ +Owner: CN=QuoVadis Root CA 2 G3, O=QuoVadis Limited, C=BM +Issuer: CN=QuoVadis Root CA 2 G3, O=QuoVadis Limited, C=BM +Serial number: 445734245b81899b35f2ceb82b3b5ba726f07528 +Valid from: Thu Jan 12 18:59:32 GMT 2012 until: Sun Jan 12 18:59:32 GMT 2042 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIFYDCCA0igAwIBAgIURFc0JFuBiZs18s64KztbpybwdSgwDQYJKoZIhvcNAQEL +BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc +BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMiBHMzAeFw0xMjAxMTIxODU5MzJaFw00 +MjAxMTIxODU5MzJaMEgxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM +aW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDIgRzMwggIiMA0GCSqG +SIb3DQEBAQUAA4ICDwAwggIKAoICAQChriWyARjcV4g/Ruv5r+LrI3HimtFhZiFf +qq8nUeVuGxbULX1QsFN3vXg6YOJkApt8hpvWGo6t/x8Vf9WVHhLL5hSEBMHfNrMW +n4rjyduYNM7YMxcoRvynyfDStNVNCXJJ+fKH46nafaF9a7I6JaltUkSs+L5u+9ym +c5GQYaYDFCDy54ejiK2toIz/pgslUiXnFgHVy7g1gQyjO/Dh4fxaXc6AcW34Sas+ +O7q414AB+6XrW7PFXmAqMaCvN+ggOp+oMiwMzAkd056OXbxMmO7FGmh77FOm6RQ1 +o9/NgJ8MSPsc9PG/Srj61YxxSscfrf5BmrODXfKEVu+lV0POKa2Mq1W/xPtbAd0j +IaFYAI7D0GoT7RPjEiuA3GfmlbLNHiJuKvhB1PLKFAeNilUSxmn1uIZoL1NesNKq +IcGY5jDjZ1XHm26sGahVpkUG0CM62+tlXSoREfA7T8pt9DTEceT/AFr2XK4jYIVz +8eQQsSWu1ZK7E8EM4DnatDlXtas1qnIhO4M15zHfeiFuuDIIfR0ykRVKYnLP43eh +vNURG3YBZwjgQQvD6xVu+KQZ2aKrr+InUlYrAoosFCT5v0ICvybIxo/gbjh9Uy3l +7ZizlWNof/k19N+IxWA1ksB8aRxhlRbQ694Lrz4EEEVlWFA4r0jyWbYW8jwNkALG +cC4BrTwV1wIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIB +BjAdBgNVHQ4EFgQU7edvdlq/YOxJW8ald7tyFnGbxD0wDQYJKoZIhvcNAQELBQAD +ggIBAJHfgD9DCX5xwvfrs4iP4VGyvD11+ShdyLyZm3tdquXK4Qr36LLTn91nMX66 +AarHakE7kNQIXLJgapDwyM4DYvmL7ftuKtwGTTwpD4kWilhMSA/ohGHqPHKmd+RC +roijQ1h5fq7KpVMNqT1wvSAZYaRsOPxDMuHBR//47PERIjKWnML2W2mWeyAMQ0Ga +W/ZZGYjeVYg3UQt4XAoeo0L9x52ID8DyeAIkVJOviYeIyUqAHerQbj5hLja7NQ4n +lv1mNDthcnPxFlxHBlRJAHpYErAK74X9sbgzdWqTHBLmYF5vHX/JHyPLhGGfHoJE ++V+tYlUkmlKY7VHnoX6XOuYvHxHaU4AshZ6rNRDbIl9qxV6XU/IyAgkwo1jwDQHV +csaxfGl7w/U2Rcxhbl5MlMVerugOXou/983g7aEOGzPuVBj+D77vfoRrQ+NwmNtd +dbINWQeFFSM51vHfqSYP1kjHs6Yi9TM3WpVHn3u6GBVv/9YUZINJ0gpnIdsPNWNg +KCLjsZWDzYWm3S8P52dSbrsvhXz1SnPnxT7AvSESBT/8twNJAlvIJebiVDj1eYeM +HVOyToV7BjjHLPj4sHKNJeV3UvQDHEimUF+IIDBu8oJDqz2XhOdT+yHBTw8imoa4 +WSr2Rz0ZiC3oheGe7IUIarFsNMkd7EgrO3jtZsSOeWmD3n+M +-----END CERTIFICATE----- diff --git a/make/data/cacerts/quovadisrootca3 b/make/data/cacerts/quovadisrootca3 new file mode 100644 index 0000000000000000000000000000000000000000..0452ad92181aacb40bfa064f0ca49c7b67fa3dcb --- /dev/null +++ b/make/data/cacerts/quovadisrootca3 @@ -0,0 +1,45 @@ +Owner: CN=QuoVadis Root CA 3, O=QuoVadis Limited, C=BM +Issuer: CN=QuoVadis Root CA 3, O=QuoVadis Limited, C=BM +Serial number: 5c6 +Valid from: Fri Nov 24 19:11:23 GMT 2006 until: Mon Nov 24 19:06:44 GMT 2031 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIGnTCCBIWgAwIBAgICBcYwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0x +GTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJv +b3QgQ0EgMzAeFw0wNjExMjQxOTExMjNaFw0zMTExMjQxOTA2NDRaMEUxCzAJBgNV +BAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMRswGQYDVQQDExJRdW9W +YWRpcyBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDM +V0IWVJzmmNPTTe7+7cefQzlKZbPoFog02w1ZkXTPkrgEQK0CSzGrvI2RaNggDhoB +4hp7Thdd4oq3P5kazethq8Jlph+3t723j/z9cI8LoGe+AaJZz3HmDyl2/7FWeUUr +H556VOijKTVopAFPD6QuN+8bv+OPEKhyq1hX51SGyMnzW9os2l2ObjyjPtr7guXd +8lyyBTNvijbO0BNO/79KDDRMpsMhvVAEVeuxu537RR5kFd5VAYwCdrXLoT9Cabwv +vWhDFlaJKjdhkf2mrk7AyxRllDdLkgbvBNDInIjbC3uBr7E9KsRlOni27tyAsdLT +mZw67mtaa7ONt9XOnMK+pUsvFrGeaDsGb659n/je7Mwpp5ijJUMv7/FfJuGITfhe +btfZFG4ZM2mnO4SJk8RTVROhUXhA+LjJou57ulJCg54U7QVSWllWp5f8nT8KKdjc +T5EOE7zelaTfi5m+rJsziO+1ga8bxiJTyPbH7pcUsMV8eFLI8M5ud2CEpukqdiDt +WAEXMJPpGovgc2PZapKUSU60rUqFxKMiMPwJ7Wgic6aIDFUhWMXhOp8q3crhkODZ +c6tsgLjoC2SToJyMGf+z0gzskSaHirOi4XCPLArlzW1oUevaPwV/izLmE1xr/l9A +4iLItLRkT9a6fUg+qGkM17uGcclzuD87nSVL2v9A6wIDAQABo4IBlTCCAZEwDwYD +VR0TAQH/BAUwAwEB/zCB4QYDVR0gBIHZMIHWMIHTBgkrBgEEAb5YAAMwgcUwgZMG +CCsGAQUFBwICMIGGGoGDQW55IHVzZSBvZiB0aGlzIENlcnRpZmljYXRlIGNvbnN0 +aXR1dGVzIGFjY2VwdGFuY2Ugb2YgdGhlIFF1b1ZhZGlzIFJvb3QgQ0EgMyBDZXJ0 +aWZpY2F0ZSBQb2xpY3kgLyBDZXJ0aWZpY2F0aW9uIFByYWN0aWNlIFN0YXRlbWVu +dC4wLQYIKwYBBQUHAgEWIWh0dHA6Ly93d3cucXVvdmFkaXNnbG9iYWwuY29tL2Nw +czALBgNVHQ8EBAMCAQYwHQYDVR0OBBYEFPLAE+CCQz777i9nMpY1XNu4ywLQMG4G +A1UdIwRnMGWAFPLAE+CCQz777i9nMpY1XNu4ywLQoUmkRzBFMQswCQYDVQQGEwJC +TTEZMBcGA1UEChMQUXVvVmFkaXMgTGltaXRlZDEbMBkGA1UEAxMSUXVvVmFkaXMg +Um9vdCBDQSAzggIFxjANBgkqhkiG9w0BAQUFAAOCAgEAT62gLEz6wPJv92ZVqyM0 +7ucp2sNbtrCD2dDQ4iH782CnO11gUyeim/YIIirnv6By5ZwkajGxkHon24QRiSem +d1o417+shvzuXYO8BsbRd2sPbSQvS3pspweWyuOEn62Iix2rFo1bZhfZFvSLgNLd ++LJ2w/w4E6oM3kJpK27zPOuAJ9v1pkQNn1pVWQvVDVJIxa6f8i+AxeoyUDUSly7B +4f/xI4hROJ/yZlZ25w9Rl6VSDE1JUZU2Pb+iSwwQHYaZTKrzchGT5Or2m9qoXadN +t54CrnMAyNojA+j56hl0YgCUyyIgvpSnWbWCar6ZeXqp8kokUvd0/bpO5qgdAm6x +DYBEwa7TIzdfu4V8K5Iu6H6li92Z4b8nby1dqnuH/grdS/yO9SbkbnBCbjPsMZ57 +k8HkyWkaPcBrTiJt7qtYTcbQQcEr6k8Sh17rRdhs9ZgC06DYVYoGmRmioHfRMJ6s +zHXug/WwYjnPbFfiTNKRCw51KBuav/0aQ/HKd/s7j2G4aSgWQgRecCocIdiP4b0j +Wy10QJLZYxkNc91pvGJHvOB0K7Lrfb5BG7XARsWhIstfTsEokt4YutUqKLsRixeT +mJlglFwjz1onl14LBQaTNx47aTbrqZ5hHY8y2o4M1nQ+ewkk2gF3R8Q7zTSMmfXK +4SVhM7JZG+Ju1zdXtg2pEto= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/quovadisrootca3g3 b/make/data/cacerts/quovadisrootca3g3 new file mode 100644 index 0000000000000000000000000000000000000000..b4eccae9c1193e9ab5b8a409d2f941756b6f3f15 --- /dev/null +++ b/make/data/cacerts/quovadisrootca3g3 @@ -0,0 +1,38 @@ +Owner: CN=QuoVadis Root CA 3 G3, O=QuoVadis Limited, C=BM +Issuer: CN=QuoVadis Root CA 3 G3, O=QuoVadis Limited, C=BM +Serial number: 2ef59b0228a7db7affd5a3a9eebd03a0cf126a1d +Valid from: Thu Jan 12 20:26:32 GMT 2012 until: Sun Jan 12 20:26:32 GMT 2042 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIFYDCCA0igAwIBAgIULvWbAiin23r/1aOp7r0DoM8Sah0wDQYJKoZIhvcNAQEL +BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc +BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMyBHMzAeFw0xMjAxMTIyMDI2MzJaFw00 +MjAxMTIyMDI2MzJaMEgxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM +aW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDMgRzMwggIiMA0GCSqG +SIb3DQEBAQUAA4ICDwAwggIKAoICAQCzyw4QZ47qFJenMioKVjZ/aEzHs286IxSR +/xl/pcqs7rN2nXrpixurazHb+gtTTK/FpRp5PIpM/6zfJd5O2YIyC0TeytuMrKNu +FoM7pmRLMon7FhY4futD4tN0SsJiCnMK3UmzV9KwCoWdcTzeo8vAMvMBOSBDGzXR +U7Ox7sWTaYI+FrUoRqHe6okJ7UO4BUaKhvVZR74bbwEhELn9qdIoyhA5CcoTNs+c +ra1AdHkrAj80//ogaX3T7mH1urPnMNA3I4ZyYUUpSFlob3emLoG+B01vr87ERROR +FHAGjx+f+IdpsQ7vw4kZ6+ocYfx6bIrc1gMLnia6Et3UVDmrJqMz6nWB2i3ND0/k +A9HvFZcba5DFApCTZgIhsUfei5pKgLlVj7WiL8DWM2fafsSntARE60f75li59wzw +eyuxwHApw0BiLTtIadwjPEjrewl5qW3aqDCYz4ByA4imW0aucnl8CAMhZa634Ryl +sSqiMd5mBPfAdOhx3v89WcyWJhKLhZVXGqtrdQtEPREoPHtht+KPZ0/l7DxMYIBp +VzgeAVuNVejH38DMdyM0SXV89pgR6y3e7UEuFAUCf+D+IOs15xGsIs5XPd7JMG0Q +A4XN8f+MFrXBsj6IbGB/kE+V9/YtrQE5BwT6dYB9v0lQ7e/JxHwc64B+27bQ3RP+ +ydOc17KXqQIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIB +BjAdBgNVHQ4EFgQUxhfQvKjqAkPyGwaZXSuQILnXnOQwDQYJKoZIhvcNAQELBQAD +ggIBADRh2Va1EodVTd2jNTFGu6QHcrxfYWLopfsLN7E8trP6KZ1/AvWkyaiTt3px +KGmPc+FSkNrVvjrlt3ZqVoAh313m6Tqe5T72omnHKgqwGEfcIHB9UqM+WXzBusnI +FUBhynLWcKzSt/Ac5IYp8M7vaGPQtSCKFWGafoaYtMnCdvvMujAWzKNhxnQT5Wvv +oxXqA/4Ti2Tk08HS6IT7SdEQTXlm66r99I0xHnAUrdzeZxNMgRVhvLfZkXdxGYFg +u/BYpbWcC/ePIlUnwEsBbTuZDdQdm2NnL9DuDcpmvJRPpq3t/O5jrFc/ZSXPsoaP +0Aj/uHYUbt7lJ+yreLVTubY/6CD50qi+YUbKh4yE8/nxoGibIh6BJpsQBJFxwAYf +3KDTuVan45gtf4Od34wrnDKOMpTwATwiKp9Dwi7DmDkHOHv8XgBCH/MyJnmDhPbl +8MFREsALHgQjDFSlTC9JxUrRtm5gDWv8a4uFJGS3iQ6rJUdbPM9+Sb3H6QrG2vd+ +DhcI00iX0HGS8A85PjRqHH3Y8iKuu2n0M7SmSFXRDw4m6Oy2Cy2nhTXN/VnIn9HN +PlopNLk9hM6xZdRZkZFWdSHBd575euFgndOtBBj0fOtek49TSiIp+EgrPk2GrFt/ +ywaZWWDYWGWVjUTR939+J399roD1B0y2PpxxVJkES/1Y+Zj0 +-----END CERTIFICATE----- diff --git a/make/data/cacerts/secomscrootca1 b/make/data/cacerts/secomscrootca1 new file mode 100644 index 0000000000000000000000000000000000000000..d300e31195d34382a81a1d3b5dc0a6f0ceb11ec9 --- /dev/null +++ b/make/data/cacerts/secomscrootca1 @@ -0,0 +1,27 @@ +Owner: OU=Security Communication RootCA1, O=SECOM Trust.net, C=JP +Issuer: OU=Security Communication RootCA1, O=SECOM Trust.net, C=JP +Serial number: 0 +Valid from: Tue Sep 30 04:20:49 GMT 2003 until: Sat Sep 30 04:20:49 GMT 2023 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDWjCCAkKgAwIBAgIBADANBgkqhkiG9w0BAQUFADBQMQswCQYDVQQGEwJKUDEY +MBYGA1UEChMPU0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21t +dW5pY2F0aW9uIFJvb3RDQTEwHhcNMDMwOTMwMDQyMDQ5WhcNMjMwOTMwMDQyMDQ5 +WjBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMPU0VDT00gVHJ1c3QubmV0MScwJQYD +VQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEwggEiMA0GCSqGSIb3 +DQEBAQUAA4IBDwAwggEKAoIBAQCzs/5/022x7xZ8V6UMbXaKL0u/ZPtM7orw8yl8 +9f/uKuDp6bpbZCKamm8sOiZpUQWZJtzVHGpxxpp9Hp3dfGzGjGdnSj74cbAZJ6kJ +DKaVv0uMDPpVmDvY6CKhS3E4eayXkmmziX7qIWgGmBSWh9JhNrxtJ1aeV+7AwFb9 +Ms+k2Y7CI9eNqPPYJayX5HA49LY6tJ07lyZDo6G8SVlyTCMwhwFY9k6+HGhWZq/N +QV3Is00qVUarH9oe4kA92819uZKAnDfdDJZkndwi92SL32HeFZRSFaB9UslLqCHJ +xrHty8OVYNEP8Ktw+N/LTX7s1vqr2b1/VPKl6Xn62dZ2JChzAgMBAAGjPzA9MB0G +A1UdDgQWBBSgc0mZaNyFW2XjmygvV5+9M7wHSDALBgNVHQ8EBAMCAQYwDwYDVR0T +AQH/BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAaECpqLvkT115swW1F7NgE+vG +kl3g0dNq/vu+m22/xwVtWSDEHPC32oRYAmP6SBbvT6UL90qY8j+eG61Ha2POCEfr +Uj94nK9NrvjVT8+amCoQQTlSxN3Zmw7vkwGusi7KaEIkQmywszo+zenaSMQVy+n5 +Bw+SUEmK3TGXX8npN6o7WWWXlDLJs58+OmJYxUmtYg5xpTKqL8aJdkNAExNnPaJU +JRDL8Try2frbSVa7pv6nQTXD4IhhyYjH3zYQIphZ6rBK+1YWc26sTfcioU+tHXot +RSflMMFe8toTyyVCUZVHA4xsIcx0Qu1T/zOLjw9XARYvz6buyXAiFL39vmwLAw== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/secomscrootca2 b/make/data/cacerts/secomscrootca2 new file mode 100644 index 0000000000000000000000000000000000000000..d80846d9f2dad5e533a3f433eb6a6f7f11eda6e2 --- /dev/null +++ b/make/data/cacerts/secomscrootca2 @@ -0,0 +1,28 @@ +Owner: OU=Security Communication RootCA2, O="SECOM Trust Systems CO.,LTD.", C=JP +Issuer: OU=Security Communication RootCA2, O="SECOM Trust Systems CO.,LTD.", C=JP +Serial number: 0 +Valid from: Fri May 29 05:00:39 GMT 2009 until: Tue May 29 05:00:39 GMT 2029 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDdzCCAl+gAwIBAgIBADANBgkqhkiG9w0BAQsFADBdMQswCQYDVQQGEwJKUDEl +MCMGA1UEChMcU0VDT00gVHJ1c3QgU3lzdGVtcyBDTy4sTFRELjEnMCUGA1UECxMe +U2VjdXJpdHkgQ29tbXVuaWNhdGlvbiBSb290Q0EyMB4XDTA5MDUyOTA1MDAzOVoX +DTI5MDUyOTA1MDAzOVowXTELMAkGA1UEBhMCSlAxJTAjBgNVBAoTHFNFQ09NIFRy +dXN0IFN5c3RlbXMgQ08uLExURC4xJzAlBgNVBAsTHlNlY3VyaXR5IENvbW11bmlj +YXRpb24gUm9vdENBMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANAV +OVKxUrO6xVmCxF1SrjpDZYBLx/KWvNs2l9amZIyoXvDjChz335c9S672XewhtUGr +zbl+dp+++T42NKA7wfYxEUV0kz1XgMX5iZnK5atq1LXaQZAQwdbWQonCv/Q4EpVM +VAX3NuRFg3sUZdbcDE3R3n4MqzvEFb46VqZab3ZpUql6ucjrappdUtAtCms1FgkQ +hNBqyjoGADdH5H5XTz+L62e4iKrFvlNVspHEfbmwhRkGeC7bYRr6hfVKkaHnFtWO +ojnflLhwHyg/i/xAXmODPIMqGplrz95Zajv8bxbXH/1KEOtOghY6rCcMU/Gt1SSw +awNQwS08Ft1ENCcadfsCAwEAAaNCMEAwHQYDVR0OBBYEFAqFqXdlBZh8QIH4D5cs +OPEK7DzPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3 +DQEBCwUAA4IBAQBMOqNErLlFsceTfsgLCkLfZOoc7llsCLqJX2rKSpWeeo8HxdpF +coJxDjrSzG+ntKEju/Ykn8sX/oymzsLS28yN/HH8AynBbF0zX2S2ZTuJbxh2ePXc +okgfGT+Ok+vx+hfuzU7jBBJV1uXk3fs+BXziHV7Gp7yXT2g69ekuCkO2r1dcYmh8 +t/2jioSgrGK+KwmHNPBqAbubKVY8/gA3zyNs8U6qtnRGEmyR7jTV7JqR50S+kDFy +1UkC9gLl9B/rfNmWVan/7Ir5mUf/NVoCqgTLiluHcSmRvaS0eg29mvVXIwAHIRc/ +SjnRBUkLp7Y3gaVdjKozXoEofKd9J+sAro03 +-----END CERTIFICATE----- diff --git a/make/data/cacerts/securetrustca b/make/data/cacerts/securetrustca new file mode 100644 index 0000000000000000000000000000000000000000..a08e2467f4afa5b6367f15568f07794374a5188f --- /dev/null +++ b/make/data/cacerts/securetrustca @@ -0,0 +1,29 @@ +Owner: CN=SecureTrust CA, O=SecureTrust Corporation, C=US +Issuer: CN=SecureTrust CA, O=SecureTrust Corporation, C=US +Serial number: cf08e5c0816a5ad427ff0eb271859d0 +Valid from: Tue Nov 07 19:31:18 GMT 2006 until: Mon Dec 31 19:40:55 GMT 2029 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDuDCCAqCgAwIBAgIQDPCOXAgWpa1Cf/DrJxhZ0DANBgkqhkiG9w0BAQUFADBI +MQswCQYDVQQGEwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24x +FzAVBgNVBAMTDlNlY3VyZVRydXN0IENBMB4XDTA2MTEwNzE5MzExOFoXDTI5MTIz +MTE5NDA1NVowSDELMAkGA1UEBhMCVVMxIDAeBgNVBAoTF1NlY3VyZVRydXN0IENv +cnBvcmF0aW9uMRcwFQYDVQQDEw5TZWN1cmVUcnVzdCBDQTCCASIwDQYJKoZIhvcN +AQEBBQADggEPADCCAQoCggEBAKukgeWVzfX2FI7CT8rU4niVWJxB4Q2ZQCQXOZEz +Zum+4YOvYlyJ0fwkW2Gz4BERQRwdbvC4u/jep4G6pkjGnx29vo6pQT64lO0pGtSO +0gMdA+9tDWccV9cGrcrI9f4Or2YlSASWC12juhbDCE/RRvgUXPLIXgGZbf2IzIao +wW8xQmxSPmjL8xk037uHGFaAJsTQ3MBv396gwpEWoGQRS0S8Hvbn+mPeZqx2pHGj +7DaUaHp3pLHnDi+BeuK1cobvomuL8A/b01k/unK8RCSc43Oz969XL0Imnal0ugBS +8kvNU3xHCzaFDmapCJcWNFfBZveA4+1wVMeT4C4oFVmHursCAwEAAaOBnTCBmjAT +BgkrBgEEAYI3FAIEBh4EAEMAQTALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB +/zAdBgNVHQ4EFgQUQjK2FvoE/f5dS3rD/fdMQB1aQ68wNAYDVR0fBC0wKzApoCeg +JYYjaHR0cDovL2NybC5zZWN1cmV0cnVzdC5jb20vU1RDQS5jcmwwEAYJKwYBBAGC +NxUBBAMCAQAwDQYJKoZIhvcNAQEFBQADggEBADDtT0rhWDpSclu1pqNlGKa7UTt3 +6Z3q059c4EVlew3KW+JwULKUBRSuSceNQQcSc5R+DCMh/bwQf2AQWnL1mA6s7Ll/ +3XpvXdMc9P+IBWlCqQVxyLesJugutIxq/3HcuLHfmbx8IVQr5Fiiu1cprp6poxkm +D5kuCLDv/WnPmRoJjeOnnyvJNjR7JLN4TJUXpAYmHrZkUjZfYGfZnMUFdAvnZyPS +CPyI6a6Lf+Ew9Dd+/cYy2i2eRDAwbO4H3tI0/NL/QPZL9GZGBlSm8jIKYyYwa5vR +3ItHuuG51WLQoqD0ZwV4KWMabwTW+MZMo5qxN7SN5ShLHZ4swrhovO0C7jE= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/soneraclass2ca b/make/data/cacerts/soneraclass2ca new file mode 100644 index 0000000000000000000000000000000000000000..43faa5e211dfeeb59bacafb305aaa9c65a5c294f --- /dev/null +++ b/make/data/cacerts/soneraclass2ca @@ -0,0 +1,26 @@ +Owner: CN=Sonera Class2 CA, O=Sonera, C=FI +Issuer: CN=Sonera Class2 CA, O=Sonera, C=FI +Serial number: 1d +Valid from: Fri Apr 06 07:29:40 GMT 2001 until: Tue Apr 06 07:29:40 GMT 2021 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDIDCCAgigAwIBAgIBHTANBgkqhkiG9w0BAQUFADA5MQswCQYDVQQGEwJGSTEP +MA0GA1UEChMGU29uZXJhMRkwFwYDVQQDExBTb25lcmEgQ2xhc3MyIENBMB4XDTAx +MDQwNjA3Mjk0MFoXDTIxMDQwNjA3Mjk0MFowOTELMAkGA1UEBhMCRkkxDzANBgNV +BAoTBlNvbmVyYTEZMBcGA1UEAxMQU29uZXJhIENsYXNzMiBDQTCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAJAXSjWdyvANlsdE+hY3/Ei9vX+ALTU74W+o +Z6m/AxxNjG8yR9VBaKQTBME1DJqEQ/xcHf+Js+gXGM2RX/uJ4+q/Tl18GybTdXnt +5oTjV+WtKcT0OijnpXuENmmz/V52vaMtmdOQTiMofRhj8VQ7Jp12W5dCsv+u8E7s +3TmVToMGf+dJQMjFAbJUWmYdPfz56TwKnoG4cPABi+QjVHzIrviQHgCWctRUz2Ej +vOr7nQKV0ba5cTppCD8PtOFCx4j1P5iop7oc4HFx71hXgVB6XGt0Rg6DA5jDjqhu +8nYybieDwnPz3BjotJPqdURrBGAgcVeHnfO+oJAjPYok4doh28MCAwEAAaMzMDEw +DwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4ECgQISqCqWITTXjwwCwYDVR0PBAQDAgEG +MA0GCSqGSIb3DQEBBQUAA4IBAQBazof5FnIVV0sd2ZvnoiYw7JNn39Yt0jSv9zil +zqsWuasvfDXLrNAPtEwr/IDva4yRXzZ299uzGxnq9LIR/WFxRL8oszodv7ND6J+/ +3DEIcbCdjdY0RzKQxmUk96BKfARzjzlvF4xytb1LyHr4e4PDKE6cCepnP7JnBBvD +FNr450kkkdAdavphOe9r5yF1BgfYErQhIHBCcYHaPJo2vqZbDWpsmh+Re/n570K6 +Tk6ezAyNlNzZRZxe7EJQY670XcSxEtzKO6gunRRaBXW37Ndj4ro1tgQIkejanZz2 +ZrUYrAqmVCY0M9IbwdR/GjqOC6oybtv8TyWf2TLHllpwrN9M +-----END CERTIFICATE----- diff --git a/make/data/cacerts/starfieldclass2ca b/make/data/cacerts/starfieldclass2ca new file mode 100644 index 0000000000000000000000000000000000000000..d87e609ee37caf0ad3396153a01a54ad3df56448 --- /dev/null +++ b/make/data/cacerts/starfieldclass2ca @@ -0,0 +1,31 @@ +Owner: OU=Starfield Class 2 Certification Authority, O="Starfield Technologies, Inc.", C=US +Issuer: OU=Starfield Class 2 Certification Authority, O="Starfield Technologies, Inc.", C=US +Serial number: 0 +Valid from: Tue Jun 29 17:39:16 GMT 2004 until: Thu Jun 29 17:39:16 GMT 2034 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzEl +MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMp +U3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQw +NjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBoMQswCQYDVQQGEwJVUzElMCMGA1UE +ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZp +ZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqGSIb3 +DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf +8MOh2tTYbitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN ++lq2cwQlZut3f+dZxkqZJRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0 +X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVmepsZGD3/cVE8MC5fvj13c7JdBmzDI1aa +K4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSNF4Azbl5KXZnJHoe0nRrA +1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HFMIHCMB0G +A1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fR +zt0fhvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0 +YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBD +bGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8w +DQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1epoXkJKtv3 +L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D +eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl +xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp +VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY +WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/starfieldrootg2ca b/make/data/cacerts/starfieldrootg2ca new file mode 100644 index 0000000000000000000000000000000000000000..bea888c4a99a67807a55e6cef42eb335906979b4 --- /dev/null +++ b/make/data/cacerts/starfieldrootg2ca @@ -0,0 +1,30 @@ +Owner: CN=Starfield Root Certificate Authority - G2, O="Starfield Technologies, Inc.", L=Scottsdale, ST=Arizona, C=US +Issuer: CN=Starfield Root Certificate Authority - G2, O="Starfield Technologies, Inc.", L=Scottsdale, ST=Arizona, C=US +Serial number: 0 +Valid from: Tue Sep 01 00:00:00 GMT 2009 until: Thu Dec 31 23:59:59 GMT 2037 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMx +EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT +HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVs +ZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAw +MFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6 +b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQgVGVj +aG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZp +Y2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC +ggEBAL3twQP89o/8ArFvW59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMg +nLRJdzIpVv257IzdIvpy3Cdhl+72WoTsbhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1 +HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNkN3mSwOxGXn/hbVNMYq/N +Hwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7NfZTD4p7dN +dloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0 +HZbUJtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO +BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0G +CSqGSIb3DQEBCwUAA4IBAQARWfolTwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjU +sHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx4mcujJUDJi5DnUox9g61DLu3 +4jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUwF5okxBDgBPfg +8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K +pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1 +mMpYjn0q7pBZc2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0 +-----END CERTIFICATE----- diff --git a/make/data/cacerts/starfieldservicesrootg2ca b/make/data/cacerts/starfieldservicesrootg2ca new file mode 100644 index 0000000000000000000000000000000000000000..7303f09f6c8f654e590e8c7615607f7a9fc32884 --- /dev/null +++ b/make/data/cacerts/starfieldservicesrootg2ca @@ -0,0 +1,31 @@ +Owner: CN=Starfield Services Root Certificate Authority - G2, O="Starfield Technologies, Inc.", L=Scottsdale, ST=Arizona, C=US +Issuer: CN=Starfield Services Root Certificate Authority - G2, O="Starfield Technologies, Inc.", L=Scottsdale, ST=Arizona, C=US +Serial number: 0 +Valid from: Tue Sep 01 00:00:00 GMT 2009 until: Thu Dec 31 23:59:59 GMT 2037 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIID7zCCAtegAwIBAgIBADANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UEBhMCVVMx +EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT +HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xOzA5BgNVBAMTMlN0YXJmaWVs +ZCBTZXJ2aWNlcyBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5 +MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgZgxCzAJBgNVBAYTAlVTMRAwDgYD +VQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFy +ZmllbGQgVGVjaG5vbG9naWVzLCBJbmMuMTswOQYDVQQDEzJTdGFyZmllbGQgU2Vy +dmljZXMgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBANUMOsQq+U7i9b4Zl1+OiFOxHz/Lz58gE20p +OsgPfTz3a3Y4Y9k2YKibXlwAgLIvWX/2h/klQ4bnaRtSmpDhcePYLQ1Ob/bISdm2 +8xpWriu2dBTrz/sm4xq6HZYuajtYlIlHVv8loJNwU4PahHQUw2eeBGg6345AWh1K +Ts9DkTvnVtYAcMtS7nt9rjrnvDH5RfbCYM8TWQIrgMw0R9+53pBlbQLPLJGmpufe +hRhJfGZOozptqbXuNC66DQO4M99H67FrjSXZm86B0UVGMpZwh94CDklDhbZsc7tk +6mFBrMnUVN+HL8cisibMn1lUaJ/8viovxFUcdUBgF4UCVTmLfwUCAwEAAaNCMEAw +DwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJxfAN+q +AdcwKziIorhtSpzyEZGDMA0GCSqGSIb3DQEBCwUAA4IBAQBLNqaEd2ndOxmfZyMI +bw5hyf2E3F/YNoHN2BtBLZ9g3ccaaNnRbobhiCPPE95Dz+I0swSdHynVv/heyNXB +ve6SbzJ08pGCL72CQnqtKrcgfU28elUSwhXqvfdqlS5sdJ/PHLTyxQGjhdByPq1z +qwubdQxtRbeOlKyWN7Wg0I8VRw7j6IPdj/3vQQF3zCepYoUz8jcI73HPdwbeyBkd +iEDPfUYd/x7H4c7/I9vG+o1VTqkC50cRRj70/b17KSa7qWFiNyi2LSr2EIZkyXCn +0q23KXB56jzaYyWf/Wi3MOxw+3WKt21gZ7IeyLnp2KhvAotnDU0mV3HaIPzBSlCN +sSi6 +-----END CERTIFICATE----- diff --git a/make/data/cacerts/swisssigngoldg2ca b/make/data/cacerts/swisssigngoldg2ca new file mode 100644 index 0000000000000000000000000000000000000000..3558909b89ec6a9a1fa313d5535853386d5855b1 --- /dev/null +++ b/make/data/cacerts/swisssigngoldg2ca @@ -0,0 +1,40 @@ +Owner: CN=SwissSign Gold CA - G2, O=SwissSign AG, C=CH +Issuer: CN=SwissSign Gold CA - G2, O=SwissSign AG, C=CH +Serial number: bb401c43f55e4fb0 +Valid from: Wed Oct 25 08:30:35 GMT 2006 until: Sat Oct 25 08:30:35 GMT 2036 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIFujCCA6KgAwIBAgIJALtAHEP1Xk+wMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV +BAYTAkNIMRUwEwYDVQQKEwxTd2lzc1NpZ24gQUcxHzAdBgNVBAMTFlN3aXNzU2ln +biBHb2xkIENBIC0gRzIwHhcNMDYxMDI1MDgzMDM1WhcNMzYxMDI1MDgzMDM1WjBF +MQswCQYDVQQGEwJDSDEVMBMGA1UEChMMU3dpc3NTaWduIEFHMR8wHQYDVQQDExZT +d2lzc1NpZ24gR29sZCBDQSAtIEcyMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC +CgKCAgEAr+TufoskDhJuqVAtFkQ7kpJcyrhdhJJCEyq8ZVeCQD5XJM1QiyUqt2/8 +76LQwB8CJEoTlo8jE+YoWACjR8cGp4QjK7u9lit/VcyLwVcfDmJlD909Vopz2q5+ +bbqBHH5CjCA12UNNhPqE21Is8w4ndwtrvxEvcnifLtg+5hg3Wipy+dpikJKVyh+c +6bM8K8vzARO/Ws/BtQpgvd21mWRTuKCWs2/iJneRjOBiEAKfNA+k1ZIzUd6+jbqE +emA8atufK+ze3gE/bk3lUIbLtK/tREDFylqM2tIrfKjuvqblCqoOpd8FUrdVxyJd +MmqXl2MT28nbeTZ7hTpKxVKJ+STnnXepgv9VHKVxaSvRAiTysybUa9oEVeXBCsdt +MDeQKuSeFDNeFhdVxVu1yzSJkvGdJo+hB9TGsnhQ2wwMC3wLjEHXuendjIj3o02y +MszYF9rNt85mndT9Xv+9lz4pded+p2JYryU0pUHHPbwNUMoDAw8IWh+Vc3hiv69y +FGkOpeUDDniOJihC8AcLYiAQZzlG+qkDzAQ4embvIIO1jEpWjpEA/I5cgt6IoMPi +aG59je883WX0XaxR7ySArqpWl2/5rX3aYT+YdzylkbYcjCbaZaIJbcHiVOO5ykxM +gI93e2CaHt+28kgeDrpOVG2Y4OGiGqJ3UM/EY5LsRxmd6+ZrzsECAwEAAaOBrDCB +qTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUWyV7 +lqRlUX64OfPAeGZe6Drn8O4wHwYDVR0jBBgwFoAUWyV7lqRlUX64OfPAeGZe6Drn +8O4wRgYDVR0gBD8wPTA7BglghXQBWQECAQEwLjAsBggrBgEFBQcCARYgaHR0cDov +L3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBACe6 +45R88a7A3hfm5djV9VSwg/S7zV4Fe0+fdWavPOhWfvxyeDgD2StiGwC5+OlgzczO +UYrHUDFu4Up+GC9pWbY9ZIEr44OE5iKHjn3g7gKZYbge9LgriBIWhMIxkziWMaa5 +O1M/wySTVltpkuzFwbs4AOPsF6m43Md8AYOfMke6UiI0HTJ6CVanfCU2qT1L2sCC +bwq7EsiHSycR+R4tx5M/nttfJmtS2S6K8RTGRI0Vqbe/vd6mGu6uLftIdxf+u+yv +GPUqUfA5hJeVbG4bwyvEdGB5JbAKJ9/fXtI5z0V9QkvfsywexcZdylU6oJxpmo/a +77KwPJ+HbBIrZXAVUjEaJM9vMSNQH4xPjyPDdEFjHFWoFN0+4FFQz/EbMFYOkrCC +hdiDyyJkvC24JdVUorgG6q2SpCSgwYa1ShNqR88uC1aVVMvOmttqtKay20EIhid3 +92qgQmwLOM7XdVAyksLfKzAiSNDVQTglXaTpXZ/GlHXQRf0wl0OPkKsKx4ZzYEpp +Ld6leNcG2mqeSz53OiATIgHQv2ieY2BrNU0LbbqhPcCT4H8js1WtciVORvnSFu+w +ZMEBnunKoGqYDs/YYPIvSbjkQuE4NRb0yG5P94FW6LqjviOvrv1vA+ACOzB2+htt +Qc8Bsem4yWb02ybzOqR08kkkW8mw0FfB+j564ZfJ +-----END CERTIFICATE----- diff --git a/make/data/cacerts/swisssignplatinumg2ca b/make/data/cacerts/swisssignplatinumg2ca new file mode 100644 index 0000000000000000000000000000000000000000..774bef80dbc6852e54f01bf24193ac9f8482a634 --- /dev/null +++ b/make/data/cacerts/swisssignplatinumg2ca @@ -0,0 +1,40 @@ +Owner: CN=SwissSign Platinum CA - G2, O=SwissSign AG, C=CH +Issuer: CN=SwissSign Platinum CA - G2, O=SwissSign AG, C=CH +Serial number: 4eb200670c035d4f +Valid from: Wed Oct 25 08:36:00 GMT 2006 until: Sat Oct 25 08:36:00 GMT 2036 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIFwTCCA6mgAwIBAgIITrIAZwwDXU8wDQYJKoZIhvcNAQEFBQAwSTELMAkGA1UE +BhMCQ0gxFTATBgNVBAoTDFN3aXNzU2lnbiBBRzEjMCEGA1UEAxMaU3dpc3NTaWdu +IFBsYXRpbnVtIENBIC0gRzIwHhcNMDYxMDI1MDgzNjAwWhcNMzYxMDI1MDgzNjAw +WjBJMQswCQYDVQQGEwJDSDEVMBMGA1UEChMMU3dpc3NTaWduIEFHMSMwIQYDVQQD +ExpTd2lzc1NpZ24gUGxhdGludW0gQ0EgLSBHMjCCAiIwDQYJKoZIhvcNAQEBBQAD +ggIPADCCAgoCggIBAMrfogLi2vj8Bxax3mCq3pZcZB/HL37PZ/pEQtZ2Y5Wu669y +IIpFR4ZieIbWIDkm9K6j/SPnpZy1IiEZtzeTIsBQnIJ71NUERFzLtMKfkr4k2Htn +IuJpX+UFeNSH2XFwMyVTtIc7KZAoNppVRDBopIOXfw0enHb/FZ1glwCNioUD7IC+ +6ixuEFGSzH7VozPY1kneWCqv9hbrS3uQMpe5up1Y8fhXSQQeol0GcN1x2/ndi5ob +jM89o03Oy3z2u5yg+gnOI2Ky6Q0f4nIoj5+saCB9bzuohTEJfwvH6GXp43gOCWcw +izSC+13gzJ2BbWLuCB4ELE6b7P6pT1/9aXjvCR+htL/68++QHkwFix7qepF6w9fl ++zC8bBsQWJj3Gl/QKTIDE0ZNYWqFTFJ0LwYfexHihJfGmfNtf9dng34TaNhxKFrY +zt3oEBSa/m0jh26OWnA81Y0JAKeqvLAxN23IhBQeW71FYyBrS3SMvds6DsHPWhaP +pZjydomyExI7C3d3rLvlPClKknLKYRorXkzig3R3+jVIeoVNjZpTxN94ypeRSCtF +KwH3HBqi7Ri6Cr2D+m+8jVeTO9TUps4e8aCxzqv9KyiaTxvXw3LbpMS/XUz13XuW +ae5ogObnmLo2t/5u7Su9IPhlGdpVCX4l3P5hYnL5fhgC72O00Puv5TtjjGePAgMB +AAGjgawwgakwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0O +BBYEFFCvzAeHFUdvOMW0ZdHelarp35zMMB8GA1UdIwQYMBaAFFCvzAeHFUdvOMW0 +ZdHelarp35zMMEYGA1UdIAQ/MD0wOwYJYIV0AVkBAQEBMC4wLAYIKwYBBQUHAgEW +IGh0dHA6Ly9yZXBvc2l0b3J5LnN3aXNzc2lnbi5jb20vMA0GCSqGSIb3DQEBBQUA +A4ICAQAIhab1Fgz8RBrBY+D5VUYI/HAcQiiWjrfFwUF1TglxeeVtlspLpYhg0DB0 +uMoI3LQwnkAHFmtllXcBrqS3NQuB2nEVqXQXOHtYyvkv+8Bldo1bAbl93oI9ZLi+ +FHSjClTTLJUYFzX1UWs/j6KWYTl4a0vlpqD4U99REJNi54Av4tHgvI42Rncz7Lj7 +jposiU0xEQ8mngS7twSNC/K5/FqdOxa3L8iYq/6KUFkuozv8KV2LwUvJ4ooTHbG/ +u0IdUt1O2BReEMYxB+9xJ/cbOQncguqLs5WGXv312l0xpuAxtpTmREl0xRbl9x8D +YSjFyMsSoEJL+WuICI20MhjzdZ/EfwBPBZWcoxcCw7NTm6ogOSkrZvqdr16zktK1 +puEa+S1BaYEUtLS17Yk9zvupnTVCRLEcFHOBzyoBNZox1S2PbYTfgE1X4z/FhHXa +icYwu+uPyyIIoK6q8QNsOktNCaUOcsZWayFCTiMlFGiudgp8DAdwZPmaL/YFOSbG +DI8Zf0NebvRbFS/bYV3mZy8/CJT5YLSYMdp08YSTcU1f+2BY0fvEwW2JorsgH51x +kcsymxM9Pn2SUjWskpSi0xjCfMfqr3YFFt1nJ8J+HAciIfNAChs0B0QTwoRqjt8Z +Wr9/6x3iGjjRXK9HkmuAtTClyY3YqzGBH9/CZjfTk6mFhnll0g== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/swisssignsilverg2ca b/make/data/cacerts/swisssignsilverg2ca new file mode 100644 index 0000000000000000000000000000000000000000..7a1eed1c0f2e425358c82ef4b9fe4d9fe9495ce1 --- /dev/null +++ b/make/data/cacerts/swisssignsilverg2ca @@ -0,0 +1,40 @@ +Owner: CN=SwissSign Silver CA - G2, O=SwissSign AG, C=CH +Issuer: CN=SwissSign Silver CA - G2, O=SwissSign AG, C=CH +Serial number: 4f1bd42f54bb2f4b +Valid from: Wed Oct 25 08:32:46 GMT 2006 until: Sat Oct 25 08:32:46 GMT 2036 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIFvTCCA6WgAwIBAgIITxvUL1S7L0swDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UE +BhMCQ0gxFTATBgNVBAoTDFN3aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWdu +IFNpbHZlciBDQSAtIEcyMB4XDTA2MTAyNTA4MzI0NloXDTM2MTAyNTA4MzI0Nlow +RzELMAkGA1UEBhMCQ0gxFTATBgNVBAoTDFN3aXNzU2lnbiBBRzEhMB8GA1UEAxMY +U3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A +MIICCgKCAgEAxPGHf9N4Mfc4yfjDmUO8x/e8N+dOcbpLj6VzHVxumK4DV644N0Mv +Fz0fyM5oEMF4rhkDKxD6LHmD9ui5aLlV8gREpzn5/ASLHvGiTSf5YXu6t+WiE7br +YT7QbNHm+/pe7R20nqA1W6GSy/BJkv6FCgU+5tkL4k+73JU3/JHpMjUi0R86TieF +nbAVlDLaYQ1HTWBCrpJH6INaUFjpiou5XaHc3ZlKHzZnu0jkg7Y360g6rw9njxcH +6ATK72oxh9TAtvmUcXtnZLi2kUpCe2UuMGoM9ZDulebyzYLs2aFK7PayS+VFheZt +eJMELpyCbTapxDFkH4aDCyr0NQp4yVXPQbBH6TCfmb5hqAaEuSh6XzjZG6k4sIN/ +c8HDO0gqgg8hm7jMqDXDhBuDsz6+pJVpATqJAHgE2cn0mRmrVn5bi4Y5FZGkECwJ +MoBgs5PAKrYYC51+jUnyEEp/+dVGLxmSo5mnJqy7jDzmDrxHB9xzUfFwZC8I+bRH +HTBsROopN4WSaGa8gzj+ezku01DwH/teYLappvonQfGbGHLy9YR0SslnxFSuSGTf +jNFusB3hB48IHpmccelM2KX3RxIfdNFRnobzwqIjQAtz20um53MGjMGg6cFZrEb6 +5i/4z3GcRm25xBWNOHkDRUjvxF3XCO6HOSKGsg0PWEP3calILv3q1h8CAwEAAaOB +rDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU +F6DNweRBtjpbO8tFnb0cwpj6hlgwHwYDVR0jBBgwFoAUF6DNweRBtjpbO8tFnb0c +wpj6hlgwRgYDVR0gBD8wPTA7BglghXQBWQEDAQEwLjAsBggrBgEFBQcCARYgaHR0 +cDovL3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIB +AHPGgeAn0i0P4JUw4ppBf1AsX19iYamGamkYDHRJ1l2E6kFSGG9YrVBWIGrGvShp +WJHckRE1qTodvBqlYJ7YH39FkWnZfrt4csEGDyrOj4VwYaygzQu4OSlWhDJOhrs9 +xCrZ1x9y7v5RoSJBsXECYxqCsGKrXlcSH9/L3XWgwF15kIwb4FDm3jH+mHtwX6WQ +2K34ArZv02DdQEsixT2tOnqfGhpHkXkzuoLcMmkDlm4fS/Bx/uNncqCxv1yL5PqZ +IseEuRuNI5c/7SXgz2W79WEE790eslpBIlqhn10s6FvJbakMDHiqYMZWjwFaDGi8 +aRl5xB9+lwW/xekkUV7U1UtT7dkjWjYDZaPBA61BMPNGG4WQr2W11bHkFlt4dR2X +em1ZqSqPe97Dh4kQmUlzeMg9vVE1dCrV8X5pGyq7O70luJpaPXJhkGaH7gzWTdQR +dAtq/gsD/KNVV4n+SsuuWxcFyPKNIzFTONItaj+CuY0IavdeQXRuwxF+B6wpYJE/ +OMpXEA29MC/HpeZBoNquBYeaoKRlbEwJDIm6uNO5wJOKMPqN5ZprFQFOZ6raYlY+ +hAhm0sQ2fac+EPyI4NSA5QC9qvNOBqN6avlicuMJT+ubDgEj8Z+7fNzcbBGXJbLy +tGMU0gYqZ4yD9c7qB9iaah7s5Aq7KkzrCWA5zspi2C5u +-----END CERTIFICATE----- diff --git a/make/data/cacerts/teliasonerarootcav1 b/make/data/cacerts/teliasonerarootcav1 new file mode 100644 index 0000000000000000000000000000000000000000..26512c9b110e90356f7e4dbd811f865f4b2a47f3 --- /dev/null +++ b/make/data/cacerts/teliasonerarootcav1 @@ -0,0 +1,37 @@ +Owner: CN=TeliaSonera Root CA v1, O=TeliaSonera +Issuer: CN=TeliaSonera Root CA v1, O=TeliaSonera +Serial number: 95be16a0f72e46f17b398272fa8bcd96 +Valid from: Thu Oct 18 12:00:50 GMT 2007 until: Mon Oct 18 12:00:50 GMT 2032 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIFODCCAyCgAwIBAgIRAJW+FqD3LkbxezmCcvqLzZYwDQYJKoZIhvcNAQEFBQAw +NzEUMBIGA1UECgwLVGVsaWFTb25lcmExHzAdBgNVBAMMFlRlbGlhU29uZXJhIFJv +b3QgQ0EgdjEwHhcNMDcxMDE4MTIwMDUwWhcNMzIxMDE4MTIwMDUwWjA3MRQwEgYD +VQQKDAtUZWxpYVNvbmVyYTEfMB0GA1UEAwwWVGVsaWFTb25lcmEgUm9vdCBDQSB2 +MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMK+6yfwIaPzaSZVfp3F +VRaRXP3vIb9TgHot0pGMYzHw7CTww6XScnwQbfQ3t+XmfHnqjLWCi65ItqwA3GV1 +7CpNX8GH9SBlK4GoRz6JI5UwFpB/6FcHSOcZrr9FZ7E3GwYq/t75rH2D+1665I+X +Z75Ljo1kB1c4VWk0Nj0TSO9P4tNmHqTPGrdeNjPUtAa9GAH9d4RQAEX1jF3oI7x+ +/jXh7VB7qTCNGdMJjmhnXb88lxhTuylixcpecsHHltTbLaC0H2kD7OriUPEMPPCs +81Mt8Bz17Ww5OXOAFshSsCPN4D7c3TxHoLs1iuKYaIu+5b9y7tL6pe0S7fyYGKkm +dtwoSxAgHNN/Fnct7W+A90m7UwW7XWjH1Mh1Fj+JWov3F0fUTPHSiXk+TT2YqGHe +Oh7S+F4D4MHJHIzTjU3TlTazN19jY5szFPAtJmtTfImMMsJu7D0hADnJoWjiUIMu +sDor8zagrC/kb2HCUQk5PotTubtn2txTuXZZNp1D5SDgPTJghSJRt8czu90VL6R4 +pgd7gUY2BIbdeTXHlSw7sKMXNeVzH7RcWe/a6hBle3rQf5+ztCo3O3CLm1u5K7fs +slESl1MpWtTwEhDcTwK7EpIvYtQ/aUN8Ddb8WHUBiJ1YFkveupD/RwGJBmr2X7KQ +arMCpgKIv7NHfirZ1fpoeDVNAgMBAAGjPzA9MA8GA1UdEwEB/wQFMAMBAf8wCwYD +VR0PBAQDAgEGMB0GA1UdDgQWBBTwj1k4ALP1j5qWDNXr+nuqF+gTEjANBgkqhkiG +9w0BAQUFAAOCAgEAvuRcYk4k9AwI//DTDGjkk0kiP0Qnb7tt3oNmzqjMDfz1mgbl +dxSR651Be5kqhOX//CHBXfDkH1e3damhXwIm/9fH907eT/j3HEbAek9ALCI18Bmx +0GtnLLCo4MBANzX2hFxc469CeP6nyQ1Q6g2EdvZR74NTxnr/DlZJLo961gzmJ1Tj +TQpgcmLNkQfWpb/ImWvtxBnmq0wROMVvMeJuScg/doAmAyYp4Db29iBT4xdwNBed +Y2gea+zDTYa4EzAvXUYNR0PVG6pZDrlcjQZIrXSHX8f8MVRBE+LHIQ6e4B4N4cB7 +Q4WQxYpYxmUKeFfyxiMPAdkgS94P+5KFdSpcc41teyWRyu5FrgZLAMzTsVlQ2jqI +OylDRl6XK1TOU2+NSueW+r9xDkKLfP0ooNBIytrEgUy7onOTJsjrDNYmiLbAJM+7 +vVvrdX3pCI6GMyx5dwlppYn8s3CQh3aP0yK7Qs69cwsgJirQmz1wHiRszYd2qReW +t88NkvuOGKmYSdGe/mBEciG5Ge3C9THxOUiIkCR1VBatzvT4aRRkOfujuLpwQMcn +HL/EVlP6Y2XQ8xwOFvVrhlhNGNTkDY6lnVuR3HYkUD/GKvvZt5y11ubQ2egZixVx +SK236thZiNSQvxaz2emsWWFUyBy6ysHK4bkgTI86k4mloMy/0/Z1pHWWbVY= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/thawtepremiumserverca b/make/data/cacerts/thawtepremiumserverca new file mode 100644 index 0000000000000000000000000000000000000000..2df456ab076143b701bcbe05f657b4ffce01b29e --- /dev/null +++ b/make/data/cacerts/thawtepremiumserverca @@ -0,0 +1,27 @@ +Owner: EMAILADDRESS=premium-server@thawte.com, CN=Thawte Premium Server CA, OU=Certification Services Division, O=Thawte Consulting cc, L=Cape Town, ST=Western Cape, C=ZA +Issuer: EMAILADDRESS=premium-server@thawte.com, CN=Thawte Premium Server CA, OU=Certification Services Division, O=Thawte Consulting cc, L=Cape Town, ST=Western Cape, C=ZA +Serial number: 36122296c5e338a520a1d25f4cd70954 +Valid from: Thu Aug 01 00:00:00 GMT 1996 until: Fri Jan 01 23:59:59 GMT 2021 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 1024-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDNjCCAp+gAwIBAgIQNhIilsXjOKUgodJfTNcJVDANBgkqhkiG9w0BAQUFADCB +zjELMAkGA1UEBhMCWkExFTATBgNVBAgTDFdlc3Rlcm4gQ2FwZTESMBAGA1UEBxMJ +Q2FwZSBUb3duMR0wGwYDVQQKExRUaGF3dGUgQ29uc3VsdGluZyBjYzEoMCYGA1UE +CxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjEhMB8GA1UEAxMYVGhh +d3RlIFByZW1pdW0gU2VydmVyIENBMSgwJgYJKoZIhvcNAQkBFhlwcmVtaXVtLXNl +cnZlckB0aGF3dGUuY29tMB4XDTk2MDgwMTAwMDAwMFoXDTIxMDEwMTIzNTk1OVow +gc4xCzAJBgNVBAYTAlpBMRUwEwYDVQQIEwxXZXN0ZXJuIENhcGUxEjAQBgNVBAcT +CUNhcGUgVG93bjEdMBsGA1UEChMUVGhhd3RlIENvbnN1bHRpbmcgY2MxKDAmBgNV +BAsTH0NlcnRpZmljYXRpb24gU2VydmljZXMgRGl2aXNpb24xITAfBgNVBAMTGFRo +YXd0ZSBQcmVtaXVtIFNlcnZlciBDQTEoMCYGCSqGSIb3DQEJARYZcHJlbWl1bS1z +ZXJ2ZXJAdGhhd3RlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA0jY2 +aovXwlue2oFBYo847kkEVdbQ7xwblRZH7xhINTpS9CtqBo87L+pW46+GjZ4X9560 +ZXUCTe/LCaIhUdib0GfQug2SBhRz1JPLlyoAnFxODLz6FVL88kRu2hFKbgifLy3j ++ao6hnO2RlNYyIkFvYMRuHM/qgeN9EJN50CdHDcCAwEAAaMTMBEwDwYDVR0TAQH/ +BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQBlkKyID1bZ5jA01CbH0FDxkt5r1DmI +CSLGpmODA/eZd9iy5Ri4XWPz1HP7bJyZePFLeH0ZJMMrAoT4vCLZiiLXoPxx7JGH +IPG47LHlVYCsPVLIOQ7C8MAFT9aCdYy9X9LcdpoFEsmvcsPcJX6kTY4XpeCHf+Ga +WuFg3GQjPEIuTQ== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/thawteprimaryrootca b/make/data/cacerts/thawteprimaryrootca new file mode 100644 index 0000000000000000000000000000000000000000..9dc4dd8552c1ffeedf6f486c6c56151675db97b8 --- /dev/null +++ b/make/data/cacerts/thawteprimaryrootca @@ -0,0 +1,32 @@ +Owner: CN=thawte Primary Root CA, OU="(c) 2006 thawte, Inc. - For authorized use only", OU=Certification Services Division, O="thawte, Inc.", C=US +Issuer: CN=thawte Primary Root CA, OU="(c) 2006 thawte, Inc. - For authorized use only", OU=Certification Services Division, O="thawte, Inc.", C=US +Serial number: 344ed55720d5edec49f42fce37db2b6d +Valid from: Fri Nov 17 00:00:00 GMT 2006 until: Wed Jul 16 23:59:59 GMT 2036 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIEIDCCAwigAwIBAgIQNE7VVyDV7exJ9C/ON9srbTANBgkqhkiG9w0BAQUFADCB +qTELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMf +Q2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIw +MDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxHzAdBgNV +BAMTFnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwHhcNMDYxMTE3MDAwMDAwWhcNMzYw +NzE2MjM1OTU5WjCBqTELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5j +LjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYG +A1UECxMvKGMpIDIwMDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl +IG9ubHkxHzAdBgNVBAMTFnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwggEiMA0GCSqG +SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCsoPD7gFnUnMekz52hWXMJEEUMDSxuaPFs +W0hoSVk3/AszGcJ3f8wQLZU0HObrTQmnHNK4yZc2AreJ1CRfBsDMRJSUjQJib+ta +3RGNKJpchJAQeg29dGYvajig4tVUROsdB58Hum/u6f1OCyn1PoSgAfGcq/gcfomk +6KHYcWUNo1F77rzSImANuVud37r8UVsLr5iy6S7pBOhih94ryNdOwUxkHt3Ph1i6 +Sk/KaAcdHJ1KxtUvkcx8cXIcxcBn6zL9yZJclNqFwJu/U30rCfSMnZEfl2pSy94J +NqR32HuHUETVPm4pafs5SSYeCaWAe0At6+gnhcn+Yf1+5nyXHdWdAgMBAAGjQjBA +MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBR7W0XP +r87Lev0xkhpqtvNG61dIUDANBgkqhkiG9w0BAQUFAAOCAQEAeRHAS7ORtvzw6WfU +DW5FvlXok9LOAz/t2iWwHVfLHjp2oEzsUHboZHIMpKnxuIvW1oeEuzLlQRHAd9mz +YJ3rG9XRbkREqaYB7FViHXe4XI5ISXycO1cRrK1zN44veFyQaEfZYGDm/Ac9IiAX +xPcW6cTYcvnIc3zfFi8VqT79aie2oetaupgf1eNNZAqdE8hhuvU5HIe6uL17In/2 +/qxAeeWsEG89jxt5dovEN7MhGITlNgDrYyCZuen+MwS7QcjBAvlEYyCegc5C09Y/ +LHbTY5xZ3Y+m4Q6gLkH3LpVHz7z9M/P2C2F+fpErgUfCJzDupxBdN49cOSvkBPB7 +jVaMaA== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/thawteprimaryrootcag2 b/make/data/cacerts/thawteprimaryrootcag2 new file mode 100644 index 0000000000000000000000000000000000000000..d604e2f345fc57c443adebaca117e776d60dab47 --- /dev/null +++ b/make/data/cacerts/thawteprimaryrootcag2 @@ -0,0 +1,23 @@ +Owner: CN=thawte Primary Root CA - G2, OU="(c) 2007 thawte, Inc. - For authorized use only", O="thawte, Inc.", C=US +Issuer: CN=thawte Primary Root CA - G2, OU="(c) 2007 thawte, Inc. - For authorized use only", O="thawte, Inc.", C=US +Serial number: 35fc265cd9844fc93d263d579baed756 +Valid from: Mon Nov 05 00:00:00 GMT 2007 until: Mon Jan 18 23:59:59 GMT 2038 +Signature algorithm name: SHA384withECDSA +Subject Public Key Algorithm: 384-bit EC (secp384r1) key +Version: 3 +-----BEGIN CERTIFICATE----- +MIICiDCCAg2gAwIBAgIQNfwmXNmET8k9Jj1Xm67XVjAKBggqhkjOPQQDAzCBhDEL +MAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjE4MDYGA1UECxMvKGMp +IDIwMDcgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxJDAi +BgNVBAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EgLSBHMjAeFw0wNzExMDUwMDAw +MDBaFw0zODAxMTgyMzU5NTlaMIGEMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMdGhh +d3RlLCBJbmMuMTgwNgYDVQQLEy8oYykgMjAwNyB0aGF3dGUsIEluYy4gLSBGb3Ig +YXV0aG9yaXplZCB1c2Ugb25seTEkMCIGA1UEAxMbdGhhd3RlIFByaW1hcnkgUm9v +dCBDQSAtIEcyMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEotWcgnuVnfFSeIf+iha/ +BebfowJPDQfGAFG6DAJSLSKkQjnE/o/qycG+1E3/n3qe4rF8mq2nhglzh9HnmuN6 +papu+7qzcMBniKI11KOasf2twu8x+qi58/sIxpHR+ymVo0IwQDAPBgNVHRMBAf8E +BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUmtgAMADna3+FGO6Lts6K +DPgR4bswCgYIKoZIzj0EAwMDaQAwZgIxAN344FdHW6fmCsO99YCKlzUNG4k8VIZ3 +KMqh9HneteY4sPBlcIx/AlTCv//YoT7ZzwIxAMSNlPzcU9LcnXgWHxUzI1NS41ox +XZ3Krr0TKUQNJ1uo52icEvdYPy5yAlejj6EULg== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/thawteprimaryrootcag3 b/make/data/cacerts/thawteprimaryrootcag3 new file mode 100644 index 0000000000000000000000000000000000000000..396fc17a0d3074fb1d5581efaa3aad835f80f6e9 --- /dev/null +++ b/make/data/cacerts/thawteprimaryrootcag3 @@ -0,0 +1,32 @@ +Owner: CN=thawte Primary Root CA - G3, OU="(c) 2008 thawte, Inc. - For authorized use only", OU=Certification Services Division, O="thawte, Inc.", C=US +Issuer: CN=thawte Primary Root CA - G3, OU="(c) 2008 thawte, Inc. - For authorized use only", OU=Certification Services Division, O="thawte, Inc.", C=US +Serial number: 600197b746a7eab4b49ad64b2ff790fb +Valid from: Wed Apr 02 00:00:00 GMT 2008 until: Tue Dec 01 23:59:59 GMT 2037 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIEKjCCAxKgAwIBAgIQYAGXt0an6rS0mtZLL/eQ+zANBgkqhkiG9w0BAQsFADCB +rjELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMf +Q2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIw +MDggdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxJDAiBgNV +BAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EgLSBHMzAeFw0wODA0MDIwMDAwMDBa +Fw0zNzEyMDEyMzU5NTlaMIGuMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMdGhhd3Rl +LCBJbmMuMSgwJgYDVQQLEx9DZXJ0aWZpY2F0aW9uIFNlcnZpY2VzIERpdmlzaW9u +MTgwNgYDVQQLEy8oYykgMjAwOCB0aGF3dGUsIEluYy4gLSBGb3IgYXV0aG9yaXpl +ZCB1c2Ugb25seTEkMCIGA1UEAxMbdGhhd3RlIFByaW1hcnkgUm9vdCBDQSAtIEcz +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsr8nLPvb2FvdeHsbnndm +gcs+vHyu86YnmjSjaDFxODNi5PNxZnmxqWWjpYvVj2AtP0LMqmsywCPLLEHd5N/8 +YZzic7IilRFDGF/Eth9XbAoFWCLINkw6fKXRz4aviKdEAhN0cXMKQlkC+BsUa0Lf +b1+6a4KinVvnSr0eAXLbS3ToO39/fR8EtCab4LRarEc9VbjXsCZSKAExQGbY2SS9 +9irY7CFJXJv2eul/VTV+lmuNk5Mny5K76qxAwJ/C+IDPXfRa3M50hqY+bAtTyr2S +zhkGcuYMXDhpxwTWvGzOW/b3aJzcJRVIiKHpqfiYnODz1TEoYRFsZ5aNOZnLwkUk +OQIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNV +HQ4EFgQUrWyqlGCc7eT/+j4KdCtjA/e2Wb8wDQYJKoZIhvcNAQELBQADggEBABpA +2JVlrAmSicY59BDlqQ5mU1143vokkbvnRFHfxhY0Cu9qRFHqKweKA3rD6z8KLFIW +oCtDuSWQP3CpMyVtRRooOyfPqsMpQhvfO0zAMzRbQYi/aytlryjvsvXDqmbOe1bu +t8jLZ8HJnBoYuMTDSQPxYA5QzUbF83d597YV4Djbxy8ooAw/dyZ02SUS2jHaGh7c +KUGRIjxpp7sC8rZcJwOJ9Abqm+RyguOhCcHpABnTPtRwa7pxpqpYrvS76Wy274fM +m7v/OeZWYdMKp8RcTGB7BXcmer/YB1IsYvdwY9k5vG8cwnncdimvzsUsZAReiDZu +MdRAGmI0Nj81Aa6sY6A= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/ttelesecglobalrootclass2ca b/make/data/cacerts/ttelesecglobalrootclass2ca new file mode 100644 index 0000000000000000000000000000000000000000..1e057df874b0bacde9fa2095969d1a471923bd9c --- /dev/null +++ b/make/data/cacerts/ttelesecglobalrootclass2ca @@ -0,0 +1,30 @@ +Owner: CN=T-TeleSec GlobalRoot Class 2, OU=T-Systems Trust Center, O=T-Systems Enterprise Services GmbH, C=DE +Issuer: CN=T-TeleSec GlobalRoot Class 2, OU=T-Systems Trust Center, O=T-Systems Enterprise Services GmbH, C=DE +Serial number: 1 +Valid from: Wed Oct 01 10:40:14 GMT 2008 until: Sat Oct 01 23:59:59 GMT 2033 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUx +KzApBgNVBAoMIlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAd +BgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNl +YyBHbG9iYWxSb290IENsYXNzIDIwHhcNMDgxMDAxMTA0MDE0WhcNMzMxMDAxMjM1 +OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lzdGVtcyBFbnRlcnBy +aXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBDZW50 +ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwggEiMA0G +CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCqX9obX+hzkeXaXPSi5kfl82hVYAUd +AqSzm1nzHoqvNK38DcLZSBnuaY/JIPwhqgcZ7bBcrGXHX+0CfHt8LRvWurmAwhiC +FoT6ZrAIxlQjgeTNuUk/9k9uN0goOA/FvudocP05l03Sx5iRUKrERLMjfTlH6VJi +1hKTXrcxlkIF+3anHqP1wvzpesVsqXFP6st4vGCvx9702cu+fjOlbpSD8DT6Iavq +jnKgP6TeMFvvhk1qlVtDRKgQFRzlAVfFmPHmBiiRqiDFt1MmUUOyCxGVWOHAD3bZ +wI18gfNycJ5v/hqO2V81xrJvNHy+SE/iWjnX2J14np+GPgNeGYtEotXHAgMBAAGj +QjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS/ +WSA2AHmgoCJrjNXyYdK4LMuCSjANBgkqhkiG9w0BAQsFAAOCAQEAMQOiYQsfdOhy +NsZt+U2e+iKo4YFWz827n+qrkRk4r6p8FU3ztqONpfSO9kSpp+ghla0+AGIWiPAC +uvxhI+YzmzB6azZie60EI4RYZeLbK4rnJVM3YlNfvNoBYimipidx5joifsFvHZVw +IEoHNN/q/xWA5brXethbdXwFeilHfkCoMRN3zUA7tFFHei4R40cR3p1m0IvVVGb6 +g1XqfMIpiRvpb7PO4gWEyS8+eIVibslfwXhjdFjASBgMmTnrpMwatXlajRWc2BQN +9noHV8cigwUtPJslJj0Ys6lDfMjIq2SPDqO/nBudMNva0Bkuqjzx+zOAduTNrRlP +BSeOE6Fuwg== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/ttelesecglobalrootclass3ca b/make/data/cacerts/ttelesecglobalrootclass3ca new file mode 100644 index 0000000000000000000000000000000000000000..8985014b09a7ee261e73de19ae9e6a1703b51809 --- /dev/null +++ b/make/data/cacerts/ttelesecglobalrootclass3ca @@ -0,0 +1,30 @@ +Owner: CN=T-TeleSec GlobalRoot Class 3, OU=T-Systems Trust Center, O=T-Systems Enterprise Services GmbH, C=DE +Issuer: CN=T-TeleSec GlobalRoot Class 3, OU=T-Systems Trust Center, O=T-Systems Enterprise Services GmbH, C=DE +Serial number: 1 +Valid from: Wed Oct 01 10:29:56 GMT 2008 until: Sat Oct 01 23:59:59 GMT 2033 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUx +KzApBgNVBAoMIlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAd +BgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNl +YyBHbG9iYWxSb290IENsYXNzIDMwHhcNMDgxMDAxMTAyOTU2WhcNMzMxMDAxMjM1 +OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lzdGVtcyBFbnRlcnBy +aXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBDZW50 +ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwggEiMA0G +CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC9dZPwYiJvJK7genasfb3ZJNW4t/zN +8ELg63iIVl6bmlQdTQyK9tPPcPRStdiTBONGhnFBSivwKixVA9ZIw+A5OO3yXDw/ +RLyTPWGrTs0NvvAgJ1gORH8EGoel15YUNpDQSXuhdfsaa3Ox+M6pCSzyU9XDFES4 +hqX2iys52qMzVNn6chr3IhUciJFrf2blw2qAsCTz34ZFiP0Zf3WHHx+xGwpzJFu5 +ZeAsVMhg02YXP+HMVDNzkQI6pn97djmiH5a2OK61yJN0HZ65tOVgnS9W0eDrXltM +EnAMbEQgqxHY9Bn20pxSN+f6tsIxO0rUFJmtxxr1XV/6B7h8DR/Wgx6zAgMBAAGj +QjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS1 +A/d2O2GCahKqGFPrAyGUv/7OyjANBgkqhkiG9w0BAQsFAAOCAQEAVj3vlNW92nOy +WL6ukK2YJ5f+AbGwUgC4TeQbIXQbfsDuXmkqJa9c1h3a0nnJ85cp4IaH3gRZD/FZ +1GSFS5mvJQQeyUapl96Cshtwn5z2r3Ex3XsFpSzTucpH9sry9uetuUg/vBa3wW30 +6gmv7PO15wWeph6KU1HWk4HMdJP2udqmJQV0eVp+QD6CSyYRMG7hP0HHRwA11fXT +91Q+gT3aSWqas+8QPebrb9HIIkfLzM8BMZLZGOMivgkeGj5asuRrDFR6fUNOuIml +e9eiPZaGzPImNC1qkp2aGtAw4l1OBLBfiyB+d8E9lYLRRpo7PHi4b6HQDWSieB4p +TpPDpFQUWw== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/usertrusteccca b/make/data/cacerts/usertrusteccca new file mode 100644 index 0000000000000000000000000000000000000000..9af9c946cf5bfc3503c7e3d62a07458d4e334413 --- /dev/null +++ b/make/data/cacerts/usertrusteccca @@ -0,0 +1,23 @@ +Owner: CN=USERTrust ECC Certification Authority, O=The USERTRUST Network, L=Jersey City, ST=New Jersey, C=US +Issuer: CN=USERTrust ECC Certification Authority, O=The USERTRUST Network, L=Jersey City, ST=New Jersey, C=US +Serial number: 5c8b99c55a94c5d27156decd8980cc26 +Valid from: Mon Feb 01 00:00:00 GMT 2010 until: Mon Jan 18 23:59:59 GMT 2038 +Signature algorithm name: SHA384withECDSA +Subject Public Key Algorithm: 384-bit EC (secp384r1) key +Version: 3 +-----BEGIN CERTIFICATE----- +MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDEL +MAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNl +eSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMT +JVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAwMjAx +MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMCVVMxEzARBgNVBAgT +Ck5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVUaGUg +VVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlm +aWNhdGlvbiBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQarFRaqflo +I+d61SRvU8Za2EurxtW20eZzca7dnNYMYf3boIkDuAUU7FfO7l0/4iGzzvfUinng +o4N+LZfQYcTxmdwlkWOrfzCjtHDix6EznPO/LlxTsV+zfTJ/ijTjeXmjQjBAMB0G +A1UdDgQWBBQ64QmG1M8ZwpZ2dEl23OA1xmNjmjAOBgNVHQ8BAf8EBAMCAQYwDwYD +VR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjA2Z6EWCNzklwBBHU6+4WMB +zzuqQhFkoJ2UOQIReVx7Hfpkue4WQrO/isIJxOzksU0CMQDpKmFHjFJKS04YcPbW +RNZu9YO6bVi9JNlWSOrvxKJGgYhqOkbRqZtNyWHa0V1Xahg= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/usertrustrsaca b/make/data/cacerts/usertrustrsaca new file mode 100644 index 0000000000000000000000000000000000000000..fe9ae79029b25d955272f253b71a095da16384a4 --- /dev/null +++ b/make/data/cacerts/usertrustrsaca @@ -0,0 +1,41 @@ +Owner: CN=USERTrust RSA Certification Authority, O=The USERTRUST Network, L=Jersey City, ST=New Jersey, C=US +Issuer: CN=USERTrust RSA Certification Authority, O=The USERTRUST Network, L=Jersey City, ST=New Jersey, C=US +Serial number: 1fd6d30fca3ca51a81bbc640e35032d +Valid from: Mon Feb 01 00:00:00 GMT 2010 until: Mon Jan 18 23:59:59 GMT 2038 +Signature algorithm name: SHA384withRSA +Subject Public Key Algorithm: 4096-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCB +iDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0pl +cnNleSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNV +BAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAw +MjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMCVVMxEzARBgNV +BAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU +aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2Vy +dGlmaWNhdGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIK +AoICAQCAEmUXNg7D2wiz0KxXDXbtzSfTTK1Qg2HiqiBNCS1kCdzOiZ/MPans9s/B +3PHTsdZ7NygRK0faOca8Ohm0X6a9fZ2jY0K2dvKpOyuR+OJv0OwWIJAJPuLodMkY +tJHUYmTbf6MG8YgYapAiPLz+E/CHFHv25B+O1ORRxhFnRghRy4YUVD+8M/5+bJz/ +Fp0YvVGONaanZshyZ9shZrHUm3gDwFA66Mzw3LyeTP6vBZY1H1dat//O+T23LLb2 +VN3I5xI6Ta5MirdcmrS3ID3KfyI0rn47aGYBROcBTkZTmzNg95S+UzeQc0PzMsNT +79uq/nROacdrjGCT3sTHDN/hMq7MkztReJVni+49Vv4M0GkPGw/zJSZrM233bkf6 +c0Plfg6lZrEpfDKEY1WJxA3Bk1QwGROs0303p+tdOmw1XNtB1xLaqUkL39iAigmT +Yo61Zs8liM2EuLE/pDkP2QKe6xJMlXzzawWpXhaDzLhn4ugTncxbgtNMs+1b/97l +c6wjOy0AvzVVdAlJ2ElYGn+SNuZRkg7zJn0cTRe8yexDJtC/QV9AqURE9JnnV4ee +UB9XVKg+/XRjL7FQZQnmWEIuQxpMtPAlR1n6BB6T1CZGSlCBst6+eLf8ZxXhyVeE +Hg9j1uliutZfVS7qXMYoCAQlObgOK6nyTJccBz8NUvXt7y+CDwIDAQABo0IwQDAd +BgNVHQ4EFgQUU3m/WqorSs9UgOHYm8Cd8rIDZsswDgYDVR0PAQH/BAQDAgEGMA8G +A1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAFzUfA3P9wF9QZllDHPF +Up/L+M+ZBn8b2kMVn54CVVeWFPFSPCeHlCjtHzoBN6J2/FNQwISbxmtOuowhT6KO +VWKR82kV2LyI48SqC/3vqOlLVSoGIG1VeCkZ7l8wXEskEVX/JJpuXior7gtNn3/3 +ATiUFJVDBwn7YKnuHKsSjKCaXqeYalltiz8I+8jRRa8YFWSQEg9zKC7F4iRO/Fjs +8PRF/iKz6y+O0tlFYQXBl2+odnKPi4w2r78NBc5xjeambx9spnFixdjQg3IM8WcR +iQycE0xyNN+81XHfqnHd4blsjDwSXWXavVcStkNr/+XeTWYRUc+ZruwXtuhxkYze +Sf7dNXGiFSeUHM9h4ya7b6NnJSFd5t0dCy5oGzuCr+yDZ4XUmFF0sbmZgIn/f3gZ +XHlKYC6SQK5MNyosycdiyA5d9zZbyuAlJQG03RoHnHcAP9Dc1ew91Pq7P8yF1m9/ +qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9cJ2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRB +VXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGwsAvgnEzDHNb842m1R0aB +L6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gxQ+6IHdfG +jjxDah2nGN59PRbxYvnKkKj9 +-----END CERTIFICATE----- diff --git a/make/data/cacerts/utnuserfirstobjectca b/make/data/cacerts/utnuserfirstobjectca new file mode 100644 index 0000000000000000000000000000000000000000..80a0b5c23cd227ff85a4753be9edfa5baeeb751f --- /dev/null +++ b/make/data/cacerts/utnuserfirstobjectca @@ -0,0 +1,33 @@ +Owner: CN=UTN-USERFirst-Object, OU=http://www.usertrust.com, O=The USERTRUST Network, L=Salt Lake City, ST=UT, C=US +Issuer: CN=UTN-USERFirst-Object, OU=http://www.usertrust.com, O=The USERTRUST Network, L=Salt Lake City, ST=UT, C=US +Serial number: 44be0c8b500024b411d3362de0b35f1b +Valid from: Fri Jul 09 18:31:20 GMT 1999 until: Tue Jul 09 18:40:36 GMT 2019 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIEZjCCA06gAwIBAgIQRL4Mi1AAJLQR0zYt4LNfGzANBgkqhkiG9w0BAQUFADCB +lTELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug +Q2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExho +dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xHTAbBgNVBAMTFFVUTi1VU0VSRmlyc3Qt +T2JqZWN0MB4XDTk5MDcwOTE4MzEyMFoXDTE5MDcwOTE4NDAzNlowgZUxCzAJBgNV +BAYTAlVTMQswCQYDVQQIEwJVVDEXMBUGA1UEBxMOU2FsdCBMYWtlIENpdHkxHjAc +BgNVBAoTFVRoZSBVU0VSVFJVU1QgTmV0d29yazEhMB8GA1UECxMYaHR0cDovL3d3 +dy51c2VydHJ1c3QuY29tMR0wGwYDVQQDExRVVE4tVVNFUkZpcnN0LU9iamVjdDCC +ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAM6qgT+jo2F4qjEAVZURnicP +HxzfOpuCaDDASmEd8S8O+r5596Uj71VRloTN2+O5bj4x2AogZ8f02b+U60cEPgLO +KqJdhwQJ9jCdGIqXsqoc/EHSoTbL+z2RuufZcDX65OeQw5ujm9M89RKZd7G3CeBo +5hy485RjiGpq/gt2yb70IuRnuasaXnfBhQfdDWy/7gbHd2pBnqcP1/vulBe3/IW+ +pKvEHDHd17bR5PDv3xaPslKT16HUiaEHLr/hARJCHhrh2JU022R5KP+6LhHC5ehb +kkj7RwvCbNqtMoNB86XlQXD9ZZBt+vpRxPm9lisZBCzTbafc8H9vg2XiaquHhnUC +AwEAAaOBrzCBrDALBgNVHQ8EBAMCAcYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4E +FgQU2u1kdBScFDyr3ZmpvVsoTYs8ydgwQgYDVR0fBDswOTA3oDWgM4YxaHR0cDov +L2NybC51c2VydHJ1c3QuY29tL1VUTi1VU0VSRmlyc3QtT2JqZWN0LmNybDApBgNV +HSUEIjAgBggrBgEFBQcDAwYIKwYBBQUHAwgGCisGAQQBgjcKAwQwDQYJKoZIhvcN +AQEFBQADggEBAAgfUrE3RHjb/c652pWWmKpVZIC1WkDdIaXFwfNfLEzIR1pp6ujw +NTX00CXzyKakh0q9G7FzCL3Uw8q2NbtZhncxzaeAFK4T7/yxSPlrJSUtUbYsbUXB +mMiKVl0+7kNOPmsnjtA6S4ULX9Ptaqd1y9Fahy85dRNacrACgZ++8A+EVCBibGnU +4U3GDZlDAQ0Slox4nb9QorFEqmrPF3rPbw/U+CRVX/A0FklmPlBGyWNxODFiuGK5 +81OtbLUrohKqGU8J2l7nk8aOFAj+8DCAGKCGhU3IfdeLA/5u1fedFqySLKAj5ZyR +Uh+U3xeUc8OzwcFxBSAAeL0TUh2oPs0AH8g= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/verisignclass2g2ca b/make/data/cacerts/verisignclass2g2ca new file mode 100644 index 0000000000000000000000000000000000000000..a0922a7fc34aa869f746490b73d43a31b9edceba --- /dev/null +++ b/make/data/cacerts/verisignclass2g2ca @@ -0,0 +1,26 @@ +Owner: OU=VeriSign Trust Network, OU="(c) 1998 VeriSign, Inc. - For authorized use only", OU=Class 2 Public Primary Certification Authority - G2, O="VeriSign, Inc.", C=US +Issuer: OU=VeriSign Trust Network, OU="(c) 1998 VeriSign, Inc. - For authorized use only", OU=Class 2 Public Primary Certification Authority - G2, O="VeriSign, Inc.", C=US +Serial number: b92f60cc889fa17a4609b85b706c8aaf +Valid from: Mon May 18 00:00:00 GMT 1998 until: Tue Aug 01 23:59:59 GMT 2028 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 1024-bit RSA key +Version: 1 +-----BEGIN CERTIFICATE----- +MIIDAzCCAmwCEQC5L2DMiJ+hekYJuFtwbIqvMA0GCSqGSIb3DQEBBQUAMIHBMQsw +CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xPDA6BgNVBAsTM0Ns +YXNzIDIgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBH +MjE6MDgGA1UECxMxKGMpIDE5OTggVmVyaVNpZ24sIEluYy4gLSBGb3IgYXV0aG9y +aXplZCB1c2Ugb25seTEfMB0GA1UECxMWVmVyaVNpZ24gVHJ1c3QgTmV0d29yazAe +Fw05ODA1MTgwMDAwMDBaFw0yODA4MDEyMzU5NTlaMIHBMQswCQYDVQQGEwJVUzEX +MBUGA1UEChMOVmVyaVNpZ24sIEluYy4xPDA6BgNVBAsTM0NsYXNzIDIgUHVibGlj +IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMjE6MDgGA1UECxMx +KGMpIDE5OTggVmVyaVNpZ24sIEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25s +eTEfMB0GA1UECxMWVmVyaVNpZ24gVHJ1c3QgTmV0d29yazCBnzANBgkqhkiG9w0B +AQEFAAOBjQAwgYkCgYEAp4gBIXQs5xoD8JjhlzwPIQjxnNuX6Zr8wgQGE75fUsjM +HiwSViy4AWkszJkfrbCWrnkE8hM5wXuYuggs6MKEEyyqaekJ9MepAqRCwiNPStjw +DqL7MWzJ5m+ZJwf15vRMeJ5t60aG+rmGyVTyssSv1EYcWskVMP8NbPUtDm3Of3cC +AwEAATANBgkqhkiG9w0BAQUFAAOBgQByLvl/0fFx+8Se9sVeUYpAmLho+Jscg9ji +nb3/7aHmZuovCfTK1+qlK5X2JGCGTUQug6XELaDTrnhpb3LabK4I8GOSN+a7xDAX +rXfMSTWqz9iP0b63GJZHc2pUIjRkLbYWm1lbtFFZOrMLFPQS32eg9K0yZF6xRnIn +jBJ7xUS0rg== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/verisignclass3ca b/make/data/cacerts/verisignclass3ca new file mode 100644 index 0000000000000000000000000000000000000000..247b233555dab753e9c4680f935bce332e1c9df0 --- /dev/null +++ b/make/data/cacerts/verisignclass3ca @@ -0,0 +1,21 @@ +Owner: OU=Class 3 Public Primary Certification Authority, O="VeriSign, Inc.", C=US +Issuer: OU=Class 3 Public Primary Certification Authority, O="VeriSign, Inc.", C=US +Serial number: 3c9131cb1ff6d01b0e9ab8d044bf12be +Valid from: Mon Jan 29 00:00:00 GMT 1996 until: Wed Aug 02 23:59:59 GMT 2028 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 1024-bit RSA key +Version: 1 +-----BEGIN CERTIFICATE----- +MIICPDCCAaUCEDyRMcsf9tAbDpq40ES/Er4wDQYJKoZIhvcNAQEFBQAwXzELMAkG +A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz +cyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2 +MDEyOTAwMDAwMFoXDTI4MDgwMjIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV +BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmlt +YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN +ADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhE +BarsAx94f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/is +I19wKTakyYbnsZogy1Olhec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0G +CSqGSIb3DQEBBQUAA4GBABByUqkFFBkyCEHwxWsKzH4PIRnN5GfcX6kb5sroc50i +2JhucwNhkcV8sEVAbkSdjbCxlnRhLQ2pRdKkkirWmnWXbj9T/UWZYB2oK0z5XqcJ +2HUw19JlYD1n1khVdWk/kfVIC0dpImmClr7JyDiGSnoscxlIaU5rfGW/D/xwzoiQ +-----END CERTIFICATE----- diff --git a/make/data/cacerts/verisignclass3g2ca b/make/data/cacerts/verisignclass3g2ca new file mode 100644 index 0000000000000000000000000000000000000000..1b932e5945cb9102eb33d38deaad1ab290c9928e --- /dev/null +++ b/make/data/cacerts/verisignclass3g2ca @@ -0,0 +1,26 @@ +Owner: OU=VeriSign Trust Network, OU="(c) 1998 VeriSign, Inc. - For authorized use only", OU=Class 3 Public Primary Certification Authority - G2, O="VeriSign, Inc.", C=US +Issuer: OU=VeriSign Trust Network, OU="(c) 1998 VeriSign, Inc. - For authorized use only", OU=Class 3 Public Primary Certification Authority - G2, O="VeriSign, Inc.", C=US +Serial number: 7dd9fe07cfa81eb7107967fba78934c6 +Valid from: Mon May 18 00:00:00 GMT 1998 until: Tue Aug 01 23:59:59 GMT 2028 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 1024-bit RSA key +Version: 1 +-----BEGIN CERTIFICATE----- +MIIDAjCCAmsCEH3Z/gfPqB63EHln+6eJNMYwDQYJKoZIhvcNAQEFBQAwgcExCzAJ +BgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xh +c3MgMyBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcy +MTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3Jp +emVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMB4X +DTk4MDUxODAwMDAwMFoXDTI4MDgwMTIzNTk1OVowgcExCzAJBgNVBAYTAlVTMRcw +FQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMg +UHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEo +YykgMTk5OCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5 +MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMIGfMA0GCSqGSIb3DQEB +AQUAA4GNADCBiQKBgQDMXtERXVxp0KvTuWpMmR9ZmDCOFoUgRm1HP9SFIIThbbP4 +pO0M8RcPO/mn+SXXwc+EY/J8Y8+iR/LGWzOOZEAEaMGAuWQcRXfH2G71lSk8UOg0 +13gfqLptQ5GVj0VXXn7F+8qkBOvqlzdUMG+7AUcyM83cV5tkaWH4mx0ciU9cZwID +AQABMA0GCSqGSIb3DQEBBQUAA4GBAFFNzb5cy5gZnBWyATl4Lk0PZ3BwmcYQWpSk +U01UbSuvDV1Ai2TT1+7eVmGSX6bEHRBhNtMsJzzoKQm5EWR0zLVznxxIqbxhAe7i +F6YM40AIOw7n60RzKprxaZLvcRTDOaxxp5EJb+RxBrO6WVcmeQD2+A2iMzAo1KpY +oJ2daZH9 +-----END CERTIFICATE----- diff --git a/make/data/cacerts/verisignclass3g3ca b/make/data/cacerts/verisignclass3g3ca new file mode 100644 index 0000000000000000000000000000000000000000..b9c36ed50f468aaee939df6076549ad17906b1e3 --- /dev/null +++ b/make/data/cacerts/verisignclass3g3ca @@ -0,0 +1,31 @@ +Owner: CN=VeriSign Class 3 Public Primary Certification Authority - G3, OU="(c) 1999 VeriSign, Inc. - For authorized use only", OU=VeriSign Trust Network, O="VeriSign, Inc.", C=US +Issuer: CN=VeriSign Class 3 Public Primary Certification Authority - G3, OU="(c) 1999 VeriSign, Inc. - For authorized use only", OU=VeriSign Trust Network, O="VeriSign, Inc.", C=US +Serial number: 9b7e0649a33e62b9d5ee90487129ef57 +Valid from: Fri Oct 01 00:00:00 GMT 1999 until: Wed Jul 16 23:59:59 GMT 2036 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 1 +-----BEGIN CERTIFICATE----- +MIIEGjCCAwICEQCbfgZJoz5iudXukEhxKe9XMA0GCSqGSIb3DQEBBQUAMIHKMQsw +CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZl +cmlTaWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWdu +LCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlT +aWduIENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3Jp +dHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQswCQYD +VQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlT +aWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJ +bmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWdu +IENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkg +LSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMu6nFL8eB8aHm8b +N3O9+MlrlBIwT/A2R/XQkQr1F8ilYcEWQE37imGQ5XYgwREGfassbqb1EUGO+i2t +KmFZpGcmTNDovFJbcCAEWNF6yaRpvIMXZK0Fi7zQWM6NjPXr8EJJC52XJ2cybuGu +kxUccLwgTS8Y3pKI6GyFVxEa6X7jJhFUokWWVYPKMIno3Nij7SqAP395ZVc+FSBm +CC+Vk7+qRy+oRpfwEuL+wgorUeZ25rdGt+INpsyow0xZVYnm6FNcHOqd8GIWC6fJ +Xwzw3sJ2zq/3avL6QaaiMxTJ5Xpj055iN9WFZZ4O5lMkdBteHRJTW8cs54NJOxWu +imi5V5cCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAERSWwauSCPc/L8my/uRan2Te +2yFPhpk0djZX3dAVL8WtfxUfN2JzPtTnX84XA9s1+ivbrmAJXx5fj267Cz3qWhMe +DGBvtcC1IyIuBwvLqXTLR7sdwdela8wv0kL9Sd2nic9TutoAWii/gt/4uhMdUIaC +/Y4wjylGsB49Ndo4YhYYSq3mtlFs3q9i6wHQHiT+eo8SGhJouPtmmRQURVyu565p +F4ErWjfJXir0xuKhXFSbplQAz/DxwceYMBo7Nhbbo27q/a2ywtrvAkcTisDxszGt +TxzhT5yvDwyd93gN2PQ1VoDat20Xj50egWTh/sVFuq1ruQp6Tk9LhO5L8X3dEQ== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/verisignclass3g4ca b/make/data/cacerts/verisignclass3g4ca new file mode 100644 index 0000000000000000000000000000000000000000..b52ee80d50e0fb138e82251a82ed22979dd9f539 --- /dev/null +++ b/make/data/cacerts/verisignclass3g4ca @@ -0,0 +1,28 @@ +Owner: CN=VeriSign Class 3 Public Primary Certification Authority - G4, OU="(c) 2007 VeriSign, Inc. - For authorized use only", OU=VeriSign Trust Network, O="VeriSign, Inc.", C=US +Issuer: CN=VeriSign Class 3 Public Primary Certification Authority - G4, OU="(c) 2007 VeriSign, Inc. - For authorized use only", OU=VeriSign Trust Network, O="VeriSign, Inc.", C=US +Serial number: 2f80fe238c0e220f486712289187acb3 +Valid from: Mon Nov 05 00:00:00 GMT 2007 until: Mon Jan 18 23:59:59 GMT 2038 +Signature algorithm name: SHA384withECDSA +Subject Public Key Algorithm: 384-bit EC (secp384r1) key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIDhDCCAwqgAwIBAgIQL4D+I4wOIg9IZxIokYesszAKBggqhkjOPQQDAzCByjEL +MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZW +ZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2ln +biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJp +U2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9y +aXR5IC0gRzQwHhcNMDcxMTA1MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCByjELMAkG +A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJp +U2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwg +SW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2ln +biBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5 +IC0gRzQwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAASnVnp8Utpkmw4tXNherJI9/gHm +GUo9FANL+mAnINmDiWn6VMaaGF5VKmTeBvaNSjutEDxlPZCIBIngMGGzrl0Bp3ve +fLK+ymVhAIau2o970ImtTR1ZmkGxvEeA3J5iw/mjgbIwga8wDwYDVR0TAQH/BAUw +AwEB/zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJ +aW1hZ2UvZ2lmMCEwHzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYj +aHR0cDovL2xvZ28udmVyaXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFLMW +kf3upm7ktS5Jj4d4gYDs5bG1MAoGCCqGSM49BAMDA2gAMGUCMGYhDBgmYFo4e1ZC +4Kf8NoRRkSAsdk1DPcQdhCPQrNZ8NQbOzWm9kA3bbEhCHQ6qQgIxAJw9SDkjOVga +FRJZap7v1VmyHVIsmXHNxynfGyphe3HR3vPA5Q06Sqotp9iGKt0uEA== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/verisignclass3g5ca b/make/data/cacerts/verisignclass3g5ca new file mode 100644 index 0000000000000000000000000000000000000000..417c8915171585c84e8f7624817628e3c6f173aa --- /dev/null +++ b/make/data/cacerts/verisignclass3g5ca @@ -0,0 +1,35 @@ +Owner: CN=VeriSign Class 3 Public Primary Certification Authority - G5, OU="(c) 2006 VeriSign, Inc. - For authorized use only", OU=VeriSign Trust Network, O="VeriSign, Inc.", C=US +Issuer: CN=VeriSign Class 3 Public Primary Certification Authority - G5, OU="(c) 2006 VeriSign, Inc. - For authorized use only", OU=VeriSign Trust Network, O="VeriSign, Inc.", C=US +Serial number: 18dad19e267de8bb4a2158cdcc6b3b4a +Valid from: Wed Nov 08 00:00:00 GMT 2006 until: Wed Jul 16 23:59:59 GMT 2036 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCB +yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL +ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJp +U2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxW +ZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0 +aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCByjEL +MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZW +ZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2ln +biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJp +U2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9y +aXR5IC0gRzUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvJAgIKXo1 +nmAMqudLO07cfLw8RRy7K+D+KQL5VwijZIUVJ/XxrcgxiV0i6CqqpkKzj/i5Vbex +t0uz/o9+B1fs70PbZmIVYc9gDaTY3vjgw2IIPVQT60nKWVSFJuUrjxuf6/WhkcIz +SdhDY2pSS9KP6HBRTdGJaXvHcPaz3BJ023tdS1bTlr8Vd6Gw9KIl8q8ckmcY5fQG +BO+QueQA5N06tRn/Arr0PO7gi+s3i+z016zy9vA9r911kTMZHRxAy3QkGSGT2RT+ +rCpSx4/VBEnkjWNHiDxpg8v+R70rfk/Fla4OndTRQ8Bnc+MUCH7lP59zuDMKz10/ +NIeWiu5T6CUVAgMBAAGjgbIwga8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8E +BAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2UvZ2lmMCEwHzAH +BgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVy +aXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFH/TZafC3ey78DAJ80M5+gKv +MzEzMA0GCSqGSIb3DQEBBQUAA4IBAQCTJEowX2LP2BqYLz3q3JktvXf2pXkiOOzE +p6B4Eq1iDkVwZMXnl2YtmAl+X6/WzChl8gGqCBpH3vn5fJJaCGkgDdk+bW48DW7Y +5gaRQBi5+MHt39tBquCWIMnNZBU4gcmU7qKEKQsTb47bDN0lAtukixlE0kF6BWlK +WE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiCKm0oHw0LxOXnGiYZ +4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vEZV8N +hnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq +-----END CERTIFICATE----- diff --git a/make/data/cacerts/verisigntsaca b/make/data/cacerts/verisigntsaca new file mode 100644 index 0000000000000000000000000000000000000000..9813ddaea22ecff73a980c50d15e6c7fc825db71 --- /dev/null +++ b/make/data/cacerts/verisigntsaca @@ -0,0 +1,24 @@ +Owner: CN=Thawte Timestamping CA, OU=Thawte Certification, O=Thawte, L=Durbanville, ST=Western Cape, C=ZA +Issuer: CN=Thawte Timestamping CA, OU=Thawte Certification, O=Thawte, L=Durbanville, ST=Western Cape, C=ZA +Serial number: 67c8e1e8e3be1cbdfc913b8ea6238749 +Valid from: Wed Jan 01 00:00:00 GMT 1997 until: Fri Jan 01 23:59:59 GMT 2021 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 1024-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIICsDCCAhmgAwIBAgIQZ8jh6OO+HL38kTuOpiOHSTANBgkqhkiG9w0BAQUFADCB +izELMAkGA1UEBhMCWkExFTATBgNVBAgTDFdlc3Rlcm4gQ2FwZTEUMBIGA1UEBxML +RHVyYmFudmlsbGUxDzANBgNVBAoTBlRoYXd0ZTEdMBsGA1UECxMUVGhhd3RlIENl +cnRpZmljYXRpb24xHzAdBgNVBAMTFlRoYXd0ZSBUaW1lc3RhbXBpbmcgQ0EwHhcN +OTcwMTAxMDAwMDAwWhcNMjEwMTAxMjM1OTU5WjCBizELMAkGA1UEBhMCWkExFTAT +BgNVBAgTDFdlc3Rlcm4gQ2FwZTEUMBIGA1UEBxMLRHVyYmFudmlsbGUxDzANBgNV +BAoTBlRoYXd0ZTEdMBsGA1UECxMUVGhhd3RlIENlcnRpZmljYXRpb24xHzAdBgNV +BAMTFlRoYXd0ZSBUaW1lc3RhbXBpbmcgQ0EwgZ8wDQYJKoZIhvcNAQEBBQADgY0A +MIGJAoGBANYrWHhhRYZT6jR7UZztsOYuGA7+4F+oJ9O0yeB8WU4WDnNUYMF/9p8u +6TqFJBU820cEY8OexJQaWt9MevPZQx08EHp5JduQ/vBR5zDWQQD9nyjfeb6Uu522 +FOMjhdepQeBMpHmwKxqL8vg7ij5FrHGSALSQQZj7X+36ty6K+Ig3AgMBAAGjEzAR +MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAS+mqF4EF+3kKMZ/F +QfRWVKvpwuWXjhj+kckMPiZkyaFMJ2SnvQGTVXFuF0853BvcSTUQOSP/ypvIz2Y/ +3Ewa1IEGQlIf4SaxFhe65nByMUToTo1b5NP50OOPJWQx5yr4GIg2GlLFDUE1G2m3 +JvUXzMEZXkt8XOKDgJH6L/uatxY= +-----END CERTIFICATE----- diff --git a/make/data/cacerts/verisignuniversalrootca b/make/data/cacerts/verisignuniversalrootca new file mode 100644 index 0000000000000000000000000000000000000000..f364256a0ebc5c8841f9e7d80a9c39a0d2c67d42 --- /dev/null +++ b/make/data/cacerts/verisignuniversalrootca @@ -0,0 +1,35 @@ +Owner: CN=VeriSign Universal Root Certification Authority, OU="(c) 2008 VeriSign, Inc. - For authorized use only", OU=VeriSign Trust Network, O="VeriSign, Inc.", C=US +Issuer: CN=VeriSign Universal Root Certification Authority, OU="(c) 2008 VeriSign, Inc. - For authorized use only", OU=VeriSign Trust Network, O="VeriSign, Inc.", C=US +Serial number: 401ac46421b31321030ebbe4121ac51d +Valid from: Wed Apr 02 00:00:00 GMT 2008 until: Tue Dec 01 23:59:59 GMT 2037 +Signature algorithm name: SHA256withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIEuTCCA6GgAwIBAgIQQBrEZCGzEyEDDrvkEhrFHTANBgkqhkiG9w0BAQsFADCB +vTELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL +ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwOCBWZXJp +U2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MTgwNgYDVQQDEy9W +ZXJpU2lnbiBVbml2ZXJzYWwgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAe +Fw0wODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIG9MQswCQYDVQQGEwJVUzEX +MBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0 +IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAyMDA4IFZlcmlTaWduLCBJbmMuIC0gRm9y +IGF1dGhvcml6ZWQgdXNlIG9ubHkxODA2BgNVBAMTL1ZlcmlTaWduIFVuaXZlcnNh +bCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEF +AAOCAQ8AMIIBCgKCAQEAx2E3XrEBNNti1xWb/1hajCMj1mCOkdeQmIN65lgZOIzF +9uVkhbSicfvtvbnazU0AtMgtc6XHaXGVHzk8skQHnOgO+k1KxCHfKWGPMiJhgsWH +H26MfF8WIFFE0XBPV+rjHOPMee5Y2A7Cs0WTwCznmhcrewA3ekEzeOEz4vMQGn+H +LL729fdC4uW/h2KJXwBL38Xd5HVEMkE6HnFuacsLdUYI0crSK5XQz/u5QGtkjFdN +/BMReYTtXlT2NJ8IAfMQJQYXStrxHXpma5hgZqTZ79IugvHw7wnqRMkVauIDbjPT +rJ9VAMf2CGqUuV/c4DPxhGD5WycRtPwW8rtWaoAljQIDAQABo4GyMIGvMA8GA1Ud +EwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMG0GCCsGAQUFBwEMBGEwX6FdoFsw +WTBXMFUWCWltYWdlL2dpZjAhMB8wBwYFKw4DAhoEFI/l0xqGrI2Oa8PPgGrUSBgs +exkuMCUWI2h0dHA6Ly9sb2dvLnZlcmlzaWduLmNvbS92c2xvZ28uZ2lmMB0GA1Ud +DgQWBBS2d/ppSEefUxLVwuoHMnYH0ZcHGTANBgkqhkiG9w0BAQsFAAOCAQEASvj4 +sAPmLGd75JR3Y8xuTPl9Dg3cyLk1uXBPY/ok+myDjEedO2Pzmvl2MpWRsXe8rJq+ +seQxIcaBlVZaDrHC1LGmWazxY8u4TB1ZkErvkBYoH1quEPuBUDgMbMzxPcP1Y+Oz +4yHJJDnp/RVmRvQbEdBNc6N9Rvk97ahfYtTxP/jgdFcrGJ2BtMQo2pSXpXDrrB2+ +BxHw1dvd5Yzw1TKwg+ZX4o+/vqGqvz0dtdQ46tewXDpPaj+PwGZsY6rp2aQW9IHR +lRQOfc2VNNnSj3BzgXucfr2YYdhFh5iQxeuGMMY1v/D/w1WIg0vvBZIGcfK4mJO3 +7M2CYfE45k+XmCpajQ== +-----END CERTIFICATE----- diff --git a/make/data/cacerts/xrampglobalca b/make/data/cacerts/xrampglobalca new file mode 100644 index 0000000000000000000000000000000000000000..347f1437c29851e79a9dd47914e161e8038fad22 --- /dev/null +++ b/make/data/cacerts/xrampglobalca @@ -0,0 +1,32 @@ +Owner: CN=XRamp Global Certification Authority, O=XRamp Security Services Inc, OU=www.xrampsecurity.com, C=US +Issuer: CN=XRamp Global Certification Authority, O=XRamp Security Services Inc, OU=www.xrampsecurity.com, C=US +Serial number: 50946cec18ead59c4dd597ef758fa0ad +Valid from: Mon Nov 01 17:14:04 GMT 2004 until: Mon Jan 01 05:37:19 GMT 2035 +Signature algorithm name: SHA1withRSA +Subject Public Key Algorithm: 2048-bit RSA key +Version: 3 +-----BEGIN CERTIFICATE----- +MIIEMDCCAxigAwIBAgIQUJRs7Bjq1ZxN1ZfvdY+grTANBgkqhkiG9w0BAQUFADCB +gjELMAkGA1UEBhMCVVMxHjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEk +MCIGA1UEChMbWFJhbXAgU2VjdXJpdHkgU2VydmljZXMgSW5jMS0wKwYDVQQDEyRY +UmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQxMTAxMTcx +NDA0WhcNMzUwMTAxMDUzNzE5WjCBgjELMAkGA1UEBhMCVVMxHjAcBgNVBAsTFXd3 +dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2VjdXJpdHkgU2Vy +dmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBB +dXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCYJB69FbS6 +38eMpSe2OAtp87ZOqCwuIR1cRN8hXX4jdP5efrRKt6atH67gBhbim1vZZ3RrXYCP +KZ2GG9mcDZhtdhAoWORlsH9KmHmf4MMxfoArtYzAQDsRhtDLooY2YKTVMIJt2W7Q +DxIEM5dfT2Fa8OT5kavnHTu86M/0ay00fOJIYRyO82FEzG+gSqmUsE3a56k0enI4 +qEHMPJQRfevIpoy3hsvKMzvZPTeL+3o+hiznc9cKV6xkmxnr9A8ECIqsAxcZZPRa +JSKNNCyy9mgdEm3Tih4U2sSPpuIjhdV6Db1q4Ons7Be7QhtnqiXtRYMh/MHJfNVi +PvryxS3T/dRlAgMBAAGjgZ8wgZwwEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0P +BAQDAgGGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFMZPoj0GY4QJnM5i5ASs +jVy16bYbMDYGA1UdHwQvMC0wK6ApoCeGJWh0dHA6Ly9jcmwueHJhbXBzZWN1cml0 +eS5jb20vWEdDQS5jcmwwEAYJKwYBBAGCNxUBBAMCAQEwDQYJKoZIhvcNAQEFBQAD +ggEBAJEVOQMBG2f7Shz5CmBbodpNl2L5JFMn14JkTpAuw0kbK5rc/Kh4ZzXxHfAR +vbdI4xD2Dd8/0sm2qlWkSLoC295ZLhVbO50WfUfXN+pfTXYSNrsf16GBBEYgoyxt +qZ4Bfj8pzgCT3/3JknOJiWSe5yvkHJEs0rnOfc5vMZnT5r7SHpDwCRR5XCOrTdLa +IR9NmXmd4c8nnxCbHIgNsIpkQTG4DmyQJKSbXHGPurt+HBvbaoAPIbzp26a3QPSy +i6mx5O+aGtA9aZnuqCij4Tyz8LIRnM98QObd50N9otg6tamN8jSZxNQQ4Qb9CYQQ +O+7ETPTsJ3xCwnR8gooJybQDJbw= +-----END CERTIFICATE----- diff --git a/make/data/tzdata/VERSION b/make/data/tzdata/VERSION index 1be80d5b5f69b177db4dafed3681b7bfb904aede..e96a6d784976c33049aa48643e101ef0d4cd60bb 100644 --- a/make/data/tzdata/VERSION +++ b/make/data/tzdata/VERSION @@ -21,4 +21,4 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -tzdata2019c +tzdata2020a diff --git a/make/data/tzdata/africa b/make/data/tzdata/africa index 5b344843a060f5a953adcd782fd8347456e3a7f2..8afa81a9a7812e50957bcd2e84447766d0e8b05d 100644 --- a/make/data/tzdata/africa +++ b/make/data/tzdata/africa @@ -890,19 +890,25 @@ Zone Indian/Mauritius 3:50:00 - LMT 1907 # Port Louis # 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)) + +# From Semlali Naoufal (2020-04-14): +# Following the announcement by the Moroccan government, the switch to +# GMT time will take place on Sunday, April 19, 2020 from 3 a.m. and +# the return to GMT+1 time will take place on Sunday, May 31, 2020 at 2 a.m.... +# https://maroc-diplomatique.net/maroc-le-retour-a-lheure-gmt-est-prevu-dimanche-prochain/ +# http://aujourdhui.ma/actualite/gmt1-retour-a-lheure-normale-dimanche-prochain-1 +# +# From Paul Eggert (2020-04-14): +# For now, guess that in the future Morocco will fall back at 03:00 +# the last Sunday before Ramadan, and spring forward at 02:00 the +# first Sunday after the day after Ramadan. To implement this, +# transition dates for 2021 through 2087 were determined by running +# the following program under GNU Emacs 26.3. +# (let ((islamic-year 1442)) # (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))) +# (b (1+ (calendar-islamic-to-absolute (list 10 1 islamic-year)))) # (sunday 0)) # (while (/= sunday (mod (setq a (1- a)) 7))) # (while (/= sunday (mod b 7)) @@ -962,7 +968,7 @@ Rule Morocco 2018 only - Jun 17 2:00 1:00 - Rule Morocco 2019 only - May 5 3:00 0 - Rule Morocco 2019 only - Jun 9 2:00 1:00 - Rule Morocco 2020 only - Apr 19 3:00 0 - -Rule Morocco 2020 only - May 24 2:00 1:00 - +Rule Morocco 2020 only - May 31 2:00 1:00 - Rule Morocco 2021 only - Apr 11 3:00 0 - Rule Morocco 2021 only - May 16 2:00 1:00 - Rule Morocco 2022 only - Mar 27 3:00 0 - @@ -978,7 +984,7 @@ Rule Morocco 2026 only - Mar 22 2:00 1:00 - Rule Morocco 2027 only - Feb 7 3:00 0 - Rule Morocco 2027 only - Mar 14 2:00 1:00 - Rule Morocco 2028 only - Jan 23 3:00 0 - -Rule Morocco 2028 only - Feb 27 2:00 1:00 - +Rule Morocco 2028 only - Mar 5 2:00 1:00 - Rule Morocco 2029 only - Jan 14 3:00 0 - Rule Morocco 2029 only - Feb 18 2:00 1:00 - Rule Morocco 2029 only - Dec 30 3:00 0 - @@ -994,7 +1000,7 @@ Rule Morocco 2033 only - Dec 25 2:00 1:00 - Rule Morocco 2034 only - Nov 5 3:00 0 - Rule Morocco 2034 only - Dec 17 2:00 1:00 - Rule Morocco 2035 only - Oct 28 3:00 0 - -Rule Morocco 2035 only - Dec 2 2:00 1:00 - +Rule Morocco 2035 only - Dec 9 2:00 1:00 - Rule Morocco 2036 only - Oct 19 3:00 0 - Rule Morocco 2036 only - Nov 23 2:00 1:00 - Rule Morocco 2037 only - Oct 4 3:00 0 - @@ -1010,7 +1016,7 @@ Rule Morocco 2041 only - Sep 29 2:00 1:00 - Rule Morocco 2042 only - Aug 10 3:00 0 - Rule Morocco 2042 only - Sep 21 2:00 1:00 - Rule Morocco 2043 only - Aug 2 3:00 0 - -Rule Morocco 2043 only - Sep 6 2:00 1:00 - +Rule Morocco 2043 only - Sep 13 2:00 1:00 - Rule Morocco 2044 only - Jul 24 3:00 0 - Rule Morocco 2044 only - Aug 28 2:00 1:00 - Rule Morocco 2045 only - Jul 9 3:00 0 - @@ -1026,7 +1032,7 @@ Rule Morocco 2049 only - Jul 4 2:00 1:00 - Rule Morocco 2050 only - May 15 3:00 0 - Rule Morocco 2050 only - Jun 26 2:00 1:00 - Rule Morocco 2051 only - May 7 3:00 0 - -Rule Morocco 2051 only - Jun 11 2:00 1:00 - +Rule Morocco 2051 only - Jun 18 2:00 1:00 - Rule Morocco 2052 only - Apr 28 3:00 0 - Rule Morocco 2052 only - Jun 2 2:00 1:00 - Rule Morocco 2053 only - Apr 13 3:00 0 - @@ -1042,7 +1048,7 @@ Rule Morocco 2057 only - Apr 8 2:00 1:00 - Rule Morocco 2058 only - Feb 17 3:00 0 - Rule Morocco 2058 only - Mar 31 2:00 1:00 - Rule Morocco 2059 only - Feb 9 3:00 0 - -Rule Morocco 2059 only - Mar 16 2:00 1:00 - +Rule Morocco 2059 only - Mar 23 2:00 1:00 - Rule Morocco 2060 only - Feb 1 3:00 0 - Rule Morocco 2060 only - Mar 7 2:00 1:00 - Rule Morocco 2061 only - Jan 16 3:00 0 - @@ -1052,13 +1058,13 @@ Rule Morocco 2062 only - Feb 12 2:00 1:00 - Rule Morocco 2062 only - Dec 31 3:00 0 - Rule Morocco 2063 only - Feb 4 2:00 1:00 - Rule Morocco 2063 only - Dec 16 3:00 0 - -Rule Morocco 2064 only - Jan 20 2:00 1:00 - +Rule Morocco 2064 only - Jan 27 2:00 1:00 - Rule Morocco 2064 only - Dec 7 3:00 0 - Rule Morocco 2065 only - Jan 11 2:00 1:00 - Rule Morocco 2065 only - Nov 22 3:00 0 - Rule Morocco 2066 only - Jan 3 2:00 1:00 - Rule Morocco 2066 only - Nov 14 3:00 0 - -Rule Morocco 2066 only - Dec 19 2:00 1:00 - +Rule Morocco 2066 only - Dec 26 2:00 1:00 - Rule Morocco 2067 only - Nov 6 3:00 0 - Rule Morocco 2067 only - Dec 11 2:00 1:00 - Rule Morocco 2068 only - Oct 21 3:00 0 - @@ -1068,13 +1074,13 @@ Rule Morocco 2069 only - Nov 17 2:00 1:00 - Rule Morocco 2070 only - Oct 5 3:00 0 - Rule Morocco 2070 only - Nov 9 2:00 1:00 - Rule Morocco 2071 only - Sep 20 3:00 0 - -Rule Morocco 2071 only - Oct 25 2:00 1:00 - +Rule Morocco 2071 only - Nov 1 2:00 1:00 - Rule Morocco 2072 only - Sep 11 3:00 0 - Rule Morocco 2072 only - Oct 16 2:00 1:00 - Rule Morocco 2073 only - Aug 27 3:00 0 - Rule Morocco 2073 only - Oct 8 2:00 1:00 - Rule Morocco 2074 only - Aug 19 3:00 0 - -Rule Morocco 2074 only - Sep 23 2:00 1:00 - +Rule Morocco 2074 only - Sep 30 2:00 1:00 - Rule Morocco 2075 only - Aug 11 3:00 0 - Rule Morocco 2075 only - Sep 15 2:00 1:00 - Rule Morocco 2076 only - Jul 26 3:00 0 - @@ -1084,7 +1090,7 @@ Rule Morocco 2077 only - Aug 22 2:00 1:00 - Rule Morocco 2078 only - Jul 10 3:00 0 - Rule Morocco 2078 only - Aug 14 2:00 1:00 - Rule Morocco 2079 only - Jun 25 3:00 0 - -Rule Morocco 2079 only - Jul 30 2:00 1:00 - +Rule Morocco 2079 only - Aug 6 2:00 1:00 - Rule Morocco 2080 only - Jun 16 3:00 0 - Rule Morocco 2080 only - Jul 21 2:00 1:00 - Rule Morocco 2081 only - Jun 1 3:00 0 - @@ -1100,7 +1106,7 @@ Rule Morocco 2085 only - May 27 2:00 1:00 - Rule Morocco 2086 only - Apr 14 3:00 0 - Rule Morocco 2086 only - May 19 2:00 1:00 - Rule Morocco 2087 only - Mar 30 3:00 0 - -Rule Morocco 2087 only - May 4 2:00 1:00 - +Rule Morocco 2087 only - May 11 2:00 1:00 - # 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 @@ -1202,7 +1208,7 @@ Link Africa/Maputo Africa/Lusaka # Zambia #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. +# Rearguard section, for parsers lacking negative DST; see ziguard.awk. 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 @@ -1216,7 +1222,7 @@ Zone Africa/Windhoek 1:08:24 - LMT 1892 Feb 8 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. +# Rearguard section, for parsers lacking negative DST; see ziguard.awk. 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: diff --git a/make/data/tzdata/asia b/make/data/tzdata/asia index e4487d26dd156550562e8bd0ee3d6b4d048026c8..04e47605f083c584ab88fa1cb1ca2f1962e6ad04 100644 --- a/make/data/tzdata/asia +++ b/make/data/tzdata/asia @@ -309,6 +309,27 @@ Zone Asia/Yangon 6:24:47 - LMT 1880 # or Rangoon # China +# From Phake Nick (2020-04-15): +# According to this news report: +# http://news.sina.com.cn/c/2004-09-01/19524201403.shtml +# on April 11, 1919, newspaper in Shanghai said clocks in Shanghai will spring +# forward for an hour starting from midnight of that Saturday. The report did +# not mention what happened in Shanghai thereafter, but it mentioned that a +# similar trial in Tianjin which ended at October 1st as citizens are told to +# recede the clock on September 30 from 12:00pm to 11:00pm. The trial at +# Tianjin got terminated in 1920. +# +# From Paul Eggert (2020-04-15): +# The Returns of Trade and Trade Reports, page 711, says "Daylight saving was +# given a trial during the year, and from the 12th April to the 1st October +# the clocks were all set one hour ahead of sun time. Though the scheme was +# generally esteemed a success, it was announced early in 1920 that it would +# not be repeated." +# +# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S +Rule Shang 1919 only - Apr 12 24:00 1:00 D +Rule Shang 1919 only - Sep 30 24:00 0 S + # From Paul Eggert (2018-10-02): # The following comes from Table 1 of: # Li Yu. Research on the daylight saving movement in 1940s Shanghai. @@ -317,6 +338,89 @@ Zone Asia/Yangon 6:24:47 - LMT 1880 # or Rangoon # 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. + +# From Phake Nick (2020-04-15): +# +# For the history of time in Shanghai between 1940-1942, the situation is +# actually slightly more complex than the table [below].... At the time, +# there were three different authorities in Shanghai, including Shanghai +# International Settlement, a settlement established by western countries with +# its own westernized form of government, Shanghai French Concession, similar +# to the international settlement but is controlled by French, and then the +# rest of the city of Shanghai, which have already been controlled by Japanese +# force through a puppet local government (Wang Jingwei regime). It was +# additionally complicated by the circumstances that, according to the 1940s +# Shanghai summer time essay cited in the database, some +# departments/businesses/people in the Shanghai city itself during that time +# period, refused to change their clock and instead only changed their opening +# hours. +# +# For example, as quoted in the article, in 1940, other than the authority +# itself, power, tram, bus companies, cinema, department stores, and other +# public service organizations have all decided to follow the summer time and +# spring forward the clock. On the other hand, the custom office refused to +# spring forward the clock because of worry on mechanical wear to the physical +# clock, postal office refused to spring forward because of disruption to +# business and log-keeping, although they did changed their office hour to +# match rest of the city. So is travel agents, and also weather +# observatory. It is said both time standards had their own supporters in the +# city at the time, those who prefer new time standard would have moved their +# clock while those who prefer the old time standard would keep their clock +# unchange, and there were different clocks that use different time standard +# in the city at the time for people who use different time standard to adjust +# their clock to their preferred time. +# +# a. For the 1940 May 31 spring forward, the essay claim that it was +# coordinared between the international settlement authority and the French +# concession authority and have gathered support from Hong Kong and Xiamen, +# that it would spring forward an hour from May 31 "midnight", and the essay +# claim "Hong Kong government implemented the spring forward in the same time +# on the same date as Shanghai". +# +# b. For the 1940 fall back, it was said that they initially intended to do +# so on September 30 00:59 at night, however they postponed it to October 12 +# after discussion with relevant parties. However schools restored to the +# original schedule ten days earlier. +# +# c. For the 1941 spring forward, it is said to start from March 15 +# "following the previous year's method", and in addition to that the essay +# cited an announcement in 1941 from the Wang regime which said the Special +# City of Shanghai under Wang regime control will follow the DST rule set by +# the Settlements, irrespective of the original DST plan announced by the Wang +# regime for other area under its control(April 1 to September 30). (no idea +# to situation before that announcement) +# +# d. For the 1941 fall back, it was said that the fall back would occurs at +# the end of September (A newspaper headline cited by the essay, published on +# October 1, 1941, have the headlines which said "French Concession would +# rewind to the old clock this morning), but it ultimately didn't happen due +# to disagreement between the international settlement authority and the +# French concession authority, and the fall back ultimately occurred on +# November 1. +# +# e. In 1941 December, Japan have officially started war with the United +# States and the United Kingdom, and in Shanghai they have marched into the +# international settlement, taken over its control +# +# f. For the 1942 spring forward, the essay said that the spring forward +# started on January 31. It said this time the custom office and postal +# department will also change their clocks, unlike before. +# +# g. The essay itself didn't cover any specific changes thereafter until the +# end of the war, it quoted a November 1942 command from the government of the +# Wang regime, which claim the daylight saving time applies year round during +# the war. However, the essay ambiguously said the period is "February 1 to +# September 30", which I don't really understand what is the meaning of such +# period in the context of year round implementation here.. More researches +# might be needed to show exactly what happened during that period of time. + +# From Phake Nick (2020-04-15): +# According to a Japanese tour bus pamphlet in Nanjing area believed to be +# from around year 1941: http://www.tt-museum.jp/tairiku_0280_nan1941.html , +# the schedule listed was in the format of Japanese time. Which indicate some +# use of the Japanese time (instead of syncing by DST) might have occurred in +# the Yangtze river delta area during that period of time although the scope +# of such use will need to be investigated to determine. # # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Shang 1940 only - Jun 1 0:00 1:00 D @@ -595,7 +699,7 @@ Zone Asia/Urumqi 5:50:20 - LMT 1928 6:00 - +06 -# Hong Kong (Xianggang) +# Hong Kong # Milne gives 7:36:41.7; round this. @@ -605,9 +709,7 @@ Zone Asia/Urumqi 5:50:20 - LMT 1928 # 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 +# think 3:30 is correct. # From Phake Nick (2018-10-27): # According to Singaporean newspaper @@ -718,10 +820,10 @@ Zone Asia/Urumqi 5:50:20 - LMT 1928 # 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): +# From Paul Eggert (2020-04-15): # Here are the dates given at -# https://www.hko.gov.hk/gts/time/Summertime.htm -# as of 2014-06-19: +# https://www.hko.gov.hk/en/gts/time/Summertime.htm +# as of 2020-02-10: # Year Period # 1941 15 Jun to 30 Sep # 1942 Whole year @@ -1851,6 +1953,47 @@ Zone Asia/Jerusalem 2:20:54 - LMT 1880 # '9:00' and 'JST' is from Guy Harris. +# From Paul Eggert (2020-01-19): +# Starting in the 7th century, Japan generally followed an ancient Chinese +# timekeeping system that divided night and day into six hours each, +# with hour length depending on season. In 1873 the government +# started requiring the use of a Western style 24-hour clock. See: +# Yulia Frumer, "Making Time: Astronomical Time Measurement in Tokugawa Japan" +# . As the tzdb code and +# data support only 24-hour clocks, its tables model timestamps before +# 1873 using Western-style local mean time. + +# 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/明治二十八年勅令第百六十七號標準時ニ關スル件中改正ノ件 + # 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 @@ -1899,37 +2042,6 @@ 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 STDOFF RULES FORMAT [UNTIL] Zone Asia/Tokyo 9:18:59 - LMT 1887 Dec 31 15:00u 9:00 Japan J%sT @@ -3109,22 +3221,9 @@ Zone Asia/Karachi 4:28:12 - LMT 1907 # [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. +# Palestine summer time will start on Mar 24th 2018 ... # http://www.palestinecabinet.gov.ps/Website/AR/NDecrees/ViewFile.ashx?ID=e7a42ab7-ee23-435a-b9c8-a4f7e81f3817 # From Even Scharning (2019-03-23): @@ -3134,15 +3233,20 @@ Zone Asia/Karachi 4:28:12 - LMT 1907 # 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 Even Scharning (2019-04-10): # Our source in Palestine said it happened Friday 29 at 00:00 local time.... + +# From Sharef Mustafa (2019-10-18): +# Palestine summer time will end on midnight Oct 26th 2019 ... +# http://www.palestinecabinet.gov.ps/website/ar/ViewDetails?ID=43948 # # From Paul Eggert (2019-04-10): # For now, guess spring-ahead transitions are March's last Friday at 00:00. +# +# From Tim Parenti (2016-10-19): +# Predict fall transitions on October's last Saturday at 01:00 from now on. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule EgyptAsia 1957 only - May 10 0:00 1:00 S diff --git a/make/data/tzdata/backward b/make/data/tzdata/backward index 2a41a98010ec96ada250aa18c5a351e9ed80edbc..8c12cf74d3f00eb0110077e33fa1e2097d1d4051 100644 --- a/make/data/tzdata/backward +++ b/make/data/tzdata/backward @@ -40,6 +40,7 @@ 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/Nuuk America/Godthab Link America/Indiana/Indianapolis America/Indianapolis Link America/Argentina/Jujuy America/Jujuy Link America/Indiana/Knox America/Knox_IN diff --git a/make/data/tzdata/europe b/make/data/tzdata/europe index 5c49a4a77bc6d04a7c23669ecadf9614c2586add..c6bca763a102eccc6bb969fd8f352faec24f6c7f 100644 --- a/make/data/tzdata/europe +++ b/make/data/tzdata/europe @@ -572,12 +572,13 @@ Zone Europe/Dublin -0:25:00 - LMT 1880 Aug 2 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. +# Vanguard section, for zic and other parsers that support negative DST. # 1:00 Eire IST/GMT -# These three lines are for when SAVE values are always nonnegative. +# Rearguard section, for parsers lacking negative DST; see ziguard.awk. 1:00 - IST 1971 Oct 31 2:00u 0:00 GB-Eire GMT/IST 1996 0:00 EU GMT/IST +# End of rearguard section. ############################################################################### @@ -1041,7 +1042,7 @@ Zone Europe/Prague 0:57:44 - LMT 1850 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. +# Rearguard section, for parsers lacking negative DST; see ziguard.awk. 0:00 - GMT 1947 Feb 23 2:00 # End of rearguard section. 1:00 Czech CE%sT 1979 @@ -1198,14 +1199,17 @@ 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 +# +# Use the old name Scoresbysund, as the current name Ittoqqortoormiit +# exceeds tzdb's 14-letter limit and has no common English abbreviation. 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 +Zone America/Nuuk -3:26:56 - LMT 1916 Jul 28 # Godthåb -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 +Zone America/Thule -4:35:08 - LMT 1916 Jul 28 # Pituffik -4:00 Thule A%sT # Estonia @@ -1575,7 +1579,7 @@ Zone Europe/Budapest 1:16:20 - LMT 1890 Oct # # 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 +# of Iceland, the almanak had been based on Reykjavík 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 diff --git a/make/data/tzdata/leapseconds b/make/data/tzdata/leapseconds index 753cd8e43071f94072abeb54b92c8e52b226bce4..fe8e170ed26e14611d0bdfe84321f7415db73923 100644 --- a/make/data/tzdata/leapseconds +++ b/make/data/tzdata/leapseconds @@ -87,9 +87,15 @@ Leap 2012 Jun 30 23:59:60 + S Leap 2015 Jun 30 23:59:60 + S Leap 2016 Dec 31 23:59:60 + S +# UTC timestamp when this leap second list expires. +# Any additional leap seconds will come after this. +# This Expires line is commented out for now, +# so that pre-2020a zic implementations do not reject this file. +#Expires 2020 Dec 28 00:00:00 + # POSIX timestamps for the data in this file: #updated 1467936000 (2016-07-08 00:00:00 UTC) -#expires 1593302400 (2020-06-28 00:00:00 UTC) +#expires 1609113600 (2020-12-28 00:00:00 UTC) -# Updated through IERS Bulletin C58 -# File expires on: 28 June 2020 +# Updated through IERS Bulletin C59 +# File expires on: 28 December 2020 diff --git a/make/data/tzdata/northamerica b/make/data/tzdata/northamerica index 0135ef16cd267ae941efd826ac2c0cd64ea44d58..60c7addef09f2a9ea63dc6a3bcc0eeb21b064ed6 100644 --- a/make/data/tzdata/northamerica +++ b/make/data/tzdata/northamerica @@ -109,7 +109,7 @@ # 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 +# https://web.archive.org/web/20160517155308/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 @@ -1493,7 +1493,8 @@ Zone America/Goose_Bay -4:01:40 - LMT 1884 # Happy Valley-Goose Bay -4:00 Canada A%sT -# west Labrador, Nova Scotia, Prince Edward I +# west Labrador, Nova Scotia, Prince Edward I, +# Îles-de-la-Madeleine, Listuguj reserve # From Brian Inglis (2015-07-20): # From the historical weather station records available at: @@ -1512,6 +1513,13 @@ Zone America/Goose_Bay -4:01:40 - LMT 1884 # Happy Valley-Goose Bay # in Canada to observe DST in 1971 but not 1970; for now we'll assume # this is a typo. +# From Jeffery Nichols (2020-01-09): +# America/Halifax ... also applies to Îles-de-la-Madeleine and the Listuguj +# reserve in Quebec. Officially, this came into effect on January 1, 2007 +# (Legal Time Act, CQLR c T-5.1), but the legislative debates surrounding that +# bill say that it is "accommodating the customs and practices" of those +# regions, which suggests that they have always been in-line with Halifax. + # 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 @@ -1605,19 +1613,20 @@ Zone America/Moncton -4:19:08 - LMT 1883 Dec 9 # Quebec -# From Paul Eggert (2015-03-24): +# From Paul Eggert (2020-01-10): # See America/Toronto for most of Quebec, including Montreal. +# See America/Halifax for the Îles de la Madeleine and the Listuguj reserve. # # 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 +# https://www.justice.gouv.qc.ca/en/department/ministre/functions-and-responsabilities/legal-time-in-quebec/the-situation-in-minganie-and-basse-cote-nord/ # 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. +# This common practice was codified into law as of 2007; see Legal Time Act, +# CQLR c T-5.1 . # For lack of better info, guess this practice began around 1970, contra to # Shanks & Pottenger who have this region observing AST/ADT. @@ -1636,6 +1645,15 @@ Zone America/Blanc-Sablon -3:48:28 - LMT 1884 # 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 Jeffery Nichols (2020-02-06): +# According to the [Shanks] atlas, those western Ontario zones are huge, +# covering most of Ontario northwest of Sault Ste Marie and Timmins. +# The zones seem to include towns bigger than the ones they're named after, +# like Dryden in America/Rainy_River and Wawa (and maybe Attawapiskat) in +# America/Nipigon. I assume it's too much trouble to change the name of the +# zone (like when you found out that America/Glace_Bay includes Sydney, Nova +# Scotia).... + # 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 @@ -2442,6 +2460,18 @@ Zone America/Creston -7:46:04 - LMT 1884 # obtained in November 2008 should be ignored... # I apologize for reporting incorrect information in 2008. +# From Tim Parenti (2020-03-05): +# The government of Yukon announced [yesterday] the cessation of seasonal time +# changes. "After clocks are pushed ahead one hour on March 8, the territory +# will remain on [UTC-07]. ... [The government] found 93 per cent of +# respondents wanted to end seasonal time changes and, of that group, 70 per +# cent wanted 'permanent Pacific Daylight Saving Time.'" +# https://www.cbc.ca/news/canada/north/yukon-end-daylight-saving-time-1.5486358 +# +# Although the government press release prefers PDT, we prefer MST for +# consistency with nearby Dawson Creek, Creston, and Fort Nelson. +# https://yukon.ca/en/news/yukon-end-seasonal-time-change + # 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 @@ -2496,11 +2526,13 @@ Zone America/Inuvik 0 - -00 1953 # Inuvik founded 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 + -8:00 Canada P%sT 2020 Mar 8 2:00 + -7:00 - MST 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 + -8:00 Canada P%sT 2020 Mar 8 2:00 + -7:00 - MST ############################################################################### diff --git a/make/data/tzdata/zone.tab b/make/data/tzdata/zone.tab index 8020ca04251d836c417696979881508243945585..e33057e45ce929b2542c8ed97bfbdead11271559 100644 --- a/make/data/tzdata/zone.tab +++ b/make/data/tzdata/zone.tab @@ -154,8 +154,8 @@ 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) +CA +6043-13503 America/Whitehorse Pacific - Yukon (east) +CA +6404-13925 America/Dawson Pacific - Yukon (west) 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) @@ -212,7 +212,7 @@ 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 +6411-05144 America/Nuuk 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 @@ -358,7 +358,7 @@ RU +554521+0373704 Europe/Moscow MSK+00 - Moscow area # 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 +UA +4457+03406 Europe/Simferopol 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 @@ -422,8 +422,8 @@ 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) +UA +4837+02218 Europe/Uzhgorod Transcarpathia +UA +4750+03510 Europe/Zaporozhye Zaporozhye and east Lugansk UG +0019+03225 Africa/Kampala UM +2813-17722 Pacific/Midway Midway Islands UM +1917+16637 Pacific/Wake Wake Island diff --git a/make/lib/Awt2dLibraries.gmk b/make/lib/Awt2dLibraries.gmk index a06bfd6db047a220cf70ddeb802fec100dcb7f03..9368a9d508c0b9eca42995b17324154e94b34822 100644 --- a/make/lib/Awt2dLibraries.gmk +++ b/make/lib/Awt2dLibraries.gmk @@ -658,6 +658,13 @@ endif ########################################################################################## +ifeq ($(TOOLCHAIN_TYPE), clang) + ifeq ($(TOOLCHAIN_VERSION), 10.1) + # Work around an optimizer bug seen with Xcode 10.1, but fixed by 10.3 + BUILD_LIBLCMS_cmsopt.c_CFLAGS := -O0 + endif +endif + # TODO: Update awt lib path when awt is converted $(eval $(call SetupNativeCompilation,BUILD_LIBLCMS, \ LIBRARY := lcms, \ diff --git a/make/lib/SecurityLibraries.gmk b/make/lib/SecurityLibraries.gmk index 2a1721bc1c49f038b297acdc8cb2ce16fe833842..a8eeceb3cd5d8073332debcf793aebd45fcbfd8d 100644 --- a/make/lib/SecurityLibraries.gmk +++ b/make/lib/SecurityLibraries.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -171,7 +171,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/mscapi, \ LDFLAGS := $(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ - LDFLAGS_SUFFIX := Crypt32.Lib advapi32.lib, \ + LDFLAGS_SUFFIX := Crypt32.Lib advapi32.lib ncrypt.lib, \ VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \ RC_FLAGS := $(RC_FLAGS) \ -D "JDK_FNAME=sunmscapi.dll" \ diff --git a/make/mapfiles/libjava/mapfile-vers b/make/mapfiles/libjava/mapfile-vers index 4725579998fe8efbc490e9fe39a8a46a2a717aca..85f287d3d365ae798eca149d7f73fdcd9ec0c82a 100644 --- a/make/mapfiles/libjava/mapfile-vers +++ b/make/mapfiles/libjava/mapfile-vers @@ -205,6 +205,7 @@ SUNWprivate_1.1 { Java_java_lang_SecurityManager_currentClassLoader0; Java_java_lang_SecurityManager_currentLoadedClass0; Java_java_lang_SecurityManager_getClassContext; + Java_java_lang_Shutdown_beforeHalt; Java_java_lang_Shutdown_halt0; Java_java_lang_String_intern; Java_java_lang_System_identityHashCode; diff --git a/make/mapfiles/libnio/mapfile-linux b/make/mapfiles/libnio/mapfile-linux index 30f795f6f57755513d939c4109aacef8415833d5..bdfaa45f13f9a789716cd12a21e45fda87348d08 100644 --- a/make/mapfiles/libnio/mapfile-linux +++ b/make/mapfiles/libnio/mapfile-linux @@ -153,8 +153,9 @@ SUNWprivate_1.1 { Java_sun_nio_fs_LinuxNativeDispatcher_fsetxattr0; Java_sun_nio_fs_LinuxNativeDispatcher_fremovexattr0; Java_sun_nio_fs_LinuxNativeDispatcher_setmntent0; - Java_sun_nio_fs_LinuxNativeDispatcher_getmntent; + Java_sun_nio_fs_LinuxNativeDispatcher_getmntent0; Java_sun_nio_fs_LinuxNativeDispatcher_endmntent; + Java_sun_nio_fs_LinuxNativeDispatcher_getlinelen; Java_sun_nio_fs_UnixNativeDispatcher_init; Java_sun_nio_fs_UnixNativeDispatcher_getcwd; Java_sun_nio_fs_UnixNativeDispatcher_strerror; @@ -176,6 +177,7 @@ SUNWprivate_1.1 { Java_sun_nio_fs_UnixNativeDispatcher_close; Java_sun_nio_fs_UnixNativeDispatcher_read; Java_sun_nio_fs_UnixNativeDispatcher_write; + Java_sun_nio_fs_UnixNativeDispatcher_rewind; Java_sun_nio_fs_UnixNativeDispatcher_fopen0; Java_sun_nio_fs_UnixNativeDispatcher_fclose; Java_sun_nio_fs_UnixNativeDispatcher_opendir0; diff --git a/make/src/classes/build/tools/generatecacerts/GenerateCacerts.java b/make/src/classes/build/tools/generatecacerts/GenerateCacerts.java new file mode 100644 index 0000000000000000000000000000000000000000..f3a9fcd2712dea2e0f3a00f5cb6d4d3853ceecc4 --- /dev/null +++ b/make/src/classes/build/tools/generatecacerts/GenerateCacerts.java @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * 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 build.tools.generatecacerts; + +import java.io.DataOutputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.nio.file.DirectoryStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.security.DigestOutputStream; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; +import java.util.Arrays; +import java.util.SortedSet; +import java.util.TreeSet; + +/** + * Generate cacerts + * args[0]: Full path string to the directory that contains CA certs + * args[1]: Full path string to the generated cacerts + */ +public class GenerateCacerts { + public static void main(String[] args) throws Exception { + try (FileOutputStream fos = new FileOutputStream(args[1])) { + store(args[0], fos, "changeit".toCharArray()); + } + } + + // The following code is copied from JavaKeyStore.java. + + private static final int MAGIC = 0xfeedfeed; + private static final int VERSION_2 = 0x02; + + // This method is a simplified version of JavaKeyStore::engineStore. + // A new "dir" argument is added. All cert names in "dir" is collected into + // a sorted array. Each cert is stored with a creation date set to its + // notBefore value. Thus the output is determined as long as the certs + // are the same. + public static void store(String dir, OutputStream stream, char[] password) + throws IOException, NoSuchAlgorithmException, CertificateException + { + byte[] encoded; // the certificate encoding + CertificateFactory cf = CertificateFactory.getInstance("X509"); + + MessageDigest md = getPreKeyedHash(password); + DataOutputStream dos + = new DataOutputStream(new DigestOutputStream(stream, md)); + + dos.writeInt(MAGIC); + // always write the latest version + dos.writeInt(VERSION_2); + + // All file names in dir sorted. + // README is excluded. Name starting with "." excluded. + SortedSet entries = new TreeSet(); + try (DirectoryStream ds = Files.newDirectoryStream(Paths.get(dir))) { + for (Path p : ds) { + String fName = p.getFileName().toString(); + if (!fName.equals("README") && !fName.startsWith(".")) { + entries.add(fName); + } + } + } + + dos.writeInt(entries.size()); + + for (String entry : entries) { + + String alias = entry + " [jdk]"; + X509Certificate cert; + try (InputStream fis = Files.newInputStream(Paths.get(dir, entry))) { + cert = (X509Certificate) cf.generateCertificate(fis); + } + + dos.writeInt(2); + + // Write the alias + dos.writeUTF(alias); + + // Write the (entry creation) date, which is notBefore of the cert + dos.writeLong(cert.getNotBefore().getTime()); + + // Write the trusted certificate + encoded = cert.getEncoded(); + dos.writeUTF(cert.getType()); + dos.writeInt(encoded.length); + dos.write(encoded); + } + + /* + * Write the keyed hash which is used to detect tampering with + * the keystore (such as deleting or modifying key or + * certificate entries). + */ + byte[] digest = md.digest(); + + dos.write(digest); + dos.flush(); + } + + private static MessageDigest getPreKeyedHash(char[] password) + throws NoSuchAlgorithmException, UnsupportedEncodingException + { + + MessageDigest md = MessageDigest.getInstance("SHA"); + byte[] passwdBytes = convertToBytes(password); + md.update(passwdBytes); + Arrays.fill(passwdBytes, (byte) 0x00); + md.update("Mighty Aphrodite".getBytes("UTF8")); + return md; + } + + private static byte[] convertToBytes(char[] password) { + int i, j; + byte[] passwdBytes = new byte[password.length * 2]; + for (i=0, j=0; i> 8); + passwdBytes[j++] = (byte)password[i]; + } + return passwdBytes; + } +} diff --git a/src/aix/native/java/net/aix_close.c b/src/aix/native/java/net/aix_close.c index 8c070e4b76bd8b51015413abdf6d98acb1c28eef..90d57b42f079353ad699d3f5af948c6a0138d351 100644 --- a/src/aix/native/java/net/aix_close.c +++ b/src/aix/native/java/net/aix_close.c @@ -39,6 +39,9 @@ * (see aix_close_init). * */ + +#include +#include #include #include #include @@ -76,10 +79,35 @@ typedef struct { static int sigWakeup = (SIGRTMAX - 1); /* - * The fd table and the number of file descriptors + * fdTable holds one entry per file descriptor, up to a certain + * maximum. + * Theoretically, the number of possible file descriptors can get + * large, though usually it does not. Entries for small value file + * descriptors are kept in a simple table, which covers most scenarios. + * Entries for large value file descriptors are kept in an overflow + * table, which is organized as a sparse two dimensional array whose + * slabs are allocated on demand. This covers all corner cases while + * keeping memory consumption reasonable. + */ + +/* Base table for low value file descriptors */ +static fdEntry_t* fdTable = NULL; +/* Maximum size of base table (in number of entries). */ +static const int fdTableMaxSize = 0x1000; /* 4K */ +/* Actual size of base table (in number of entries) */ +static int fdTableLen = 0; +/* Max. theoretical number of file descriptors on system. */ +static int fdLimit = 0; + +/* Overflow table, should base table not be large enough. Organized as + * an array of n slabs, each holding 64k entries. */ -static fdEntry_t *fdTable = NULL; -static int fdCount = 0; +static fdEntry_t** fdOverflowTable = NULL; +/* Number of slabs in the overflow table */ +static int fdOverflowTableLen = 0; +/* Number of entries in one slab */ +static const int fdOverflowTableSlabSize = 0x10000; /* 64k */ +pthread_mutex_t fdOverflowTableLock = PTHREAD_MUTEX_INITIALIZER; /* * Null signal handler @@ -98,42 +126,42 @@ void aix_close_init() { struct rlimit nbr_files; sigset_t sigset; struct sigaction sa; + int i = 0; - /* Check already initialized */ - if (fdCount > 0 && fdTable != NULL) { - return; - } - - /* - * Allocate table based on the maximum number of - * file descriptors. - */ + /* Determine the maximum number of possible file descriptors. */ if (-1 == getrlimit(RLIMIT_NOFILE, &nbr_files)) { fprintf(stderr, "library initialization failed - " "unable to get max # of allocated fds\n"); abort(); } - fdCount = nbr_files.rlim_max; - /* - * We have a conceptual problem here, when the number of files is - * unlimited. As a kind of workaround, we ensure the table is big - * enough for handle even a large number of files. Since SAP itself - * recommends a limit of 32000 files, we just use 64000 as 'infinity'. - */ - if (nbr_files.rlim_max == RLIM_INFINITY) { - fdCount = 64000; + if (nbr_files.rlim_max != RLIM_INFINITY) { + fdLimit = nbr_files.rlim_max; + } else { + /* We just do not know. */ + fdLimit = INT_MAX; } - fdTable = (fdEntry_t *)calloc(fdCount, sizeof(fdEntry_t)); + + /* Allocate table for low value file descriptors. */ + fdTableLen = fdLimit < fdTableMaxSize ? fdLimit : fdTableMaxSize; + fdTable = (fdEntry_t*) calloc(fdTableLen, sizeof(fdEntry_t)); if (fdTable == NULL) { fprintf(stderr, "library initialization failed - " "unable to allocate file descriptor table - out of memory"); abort(); + } else { + for (i = 0; i < fdTableLen; i ++) { + pthread_mutex_init(&fdTable[i].lock, NULL); + } } - { - int i; - for (i=0; i < fdCount; i++) { - pthread_mutex_init(&fdTable[i].lock, NULL); + /* Allocate overflow table, if needed */ + if (fdLimit > fdTableMaxSize) { + fdOverflowTableLen = ((fdLimit - fdTableMaxSize) / fdOverflowTableSlabSize) + 1; + fdOverflowTable = (fdEntry_t**) calloc(fdOverflowTableLen, sizeof(fdEntry_t*)); + if (fdOverflowTable == NULL) { + fprintf(stderr, "library initialization failed - " + "unable to allocate file descriptor overflow table - out of memory"); + abort(); } } @@ -151,17 +179,60 @@ void aix_close_init() { } /* - * Return the fd table for this fd or NULL is fd out - * of range. + * Return the fd table for this fd. */ static inline fdEntry_t *getFdEntry(int fd) { - if (fd < 0 || fd >= fdCount) { + fdEntry_t* result = NULL; + + if (fd < 0) { return NULL; } - return &fdTable[fd]; + + /* This should not happen. If it does, our assumption about + * max. fd value was wrong. */ + assert(fd < fdLimit); + + if (fd < fdTableMaxSize) { + /* fd is in base table. */ + assert(fd < fdTableLen); + result = &fdTable[fd]; + } else { + /* fd is in overflow table. */ + const int indexInOverflowTable = fd - fdTableMaxSize; + const int rootindex = indexInOverflowTable / fdOverflowTableSlabSize; + const int slabindex = indexInOverflowTable % fdOverflowTableSlabSize; + fdEntry_t* slab = NULL; + assert(rootindex < fdOverflowTableLen); + assert(slabindex < fdOverflowTableSlabSize); + pthread_mutex_lock(&fdOverflowTableLock); + /* Allocate new slab in overflow table if needed */ + if (fdOverflowTable[rootindex] == NULL) { + fdEntry_t* const newSlab = + (fdEntry_t*)calloc(fdOverflowTableSlabSize, sizeof(fdEntry_t)); + if (newSlab == NULL) { + fprintf(stderr, "Unable to allocate file descriptor overflow" + " table slab - out of memory"); + pthread_mutex_unlock(&fdOverflowTableLock); + abort(); + } else { + int i; + for (i = 0; i < fdOverflowTableSlabSize; i ++) { + pthread_mutex_init(&newSlab[i].lock, NULL); + } + fdOverflowTable[rootindex] = newSlab; + } + } + pthread_mutex_unlock(&fdOverflowTableLock); + slab = fdOverflowTable[rootindex]; + result = &slab[slabindex]; + } + + return result; + } + /* * Start a blocking operation :- * Insert thread onto thread list for the fd. diff --git a/src/macosx/bin/java_md_macosx.c b/src/macosx/bin/java_md_macosx.c index eb20be7726975e712f8f0b386babc2e64ac068e5..3fa7c2cc4f4cccd7864ebda7be5036d8aa60be26 100644 --- a/src/macosx/bin/java_md_macosx.c +++ b/src/macosx/bin/java_md_macosx.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -752,7 +752,7 @@ CounterGet() { struct timeval tv; gettimeofday(&tv, NULL); - return (tv.tv_sec * 1000) + tv.tv_usec; + return (tv.tv_sec * 1000000) + tv.tv_usec; } diff --git a/src/macosx/classes/apple/security/KeychainStore.java b/src/macosx/classes/apple/security/KeychainStore.java index c6c771a244c690d6701a174628562190929b616b..034d6d43308245d72064fdb268cfd12b134c5f8e 100644 --- a/src/macosx/classes/apple/security/KeychainStore.java +++ b/src/macosx/classes/apple/security/KeychainStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. * 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 @@ public final class KeychainStore extends KeyStoreSpi { 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() { @@ -224,6 +226,9 @@ public final class KeychainStore extends KeyStoreSpi { // Get the Algorithm ID next DerValue[] value = in.getSequence(2); + if (value.length < 1 || value.length > 2) { + throw new IOException("Invalid length for AlgorithmIdentifier"); + } AlgorithmId algId = new AlgorithmId(value[0].getOID()); String algName = algId.getName(); @@ -771,6 +776,10 @@ public final class KeychainStore extends KeyStoreSpi { entries.clear(); _scanKeychain(); + if (debug != null) { + debug.println("KeychainStore load entry count: " + + entries.size()); + } } } diff --git a/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java b/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java index 3cccfa5cdde53ff799c002e3390adb48bce4cfb6..7d102c093fbec21cb69093f7acb49f1d6329693d 100644 --- a/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java @@ -180,8 +180,11 @@ final class CPlatformResponder { // It is necessary to use testCharIgnoringModifiers instead of testChar for event // generation in such case to avoid uppercase letters in text components. LWCToolkit lwcToolkit = (LWCToolkit)Toolkit.getDefaultToolkit(); - if (lwcToolkit.getLockingKeyState(KeyEvent.VK_CAPS_LOCK) && - Locale.SIMPLIFIED_CHINESE.equals(lwcToolkit.getDefaultKeyboardLocale())) { + if ((lwcToolkit.getLockingKeyState(KeyEvent.VK_CAPS_LOCK) && + Locale.SIMPLIFIED_CHINESE.equals(lwcToolkit.getDefaultKeyboardLocale())) || + (LWCToolkit.isLocaleUSInternationalPC(lwcToolkit.getDefaultKeyboardLocale()) && + LWCToolkit.isCharModifierKeyInUSInternationalPC(testChar) && + (testChar != testCharIgnoringModifiers))) { testChar = testCharIgnoringModifiers; } diff --git a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java index 9b17d8bca2ce6a59d39c0217306cc1bcb4b1a3a1..93ceb7bb51b620f2ba5eccce1e6ebf04ed40030a 100644 --- a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java +++ b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java @@ -726,6 +726,23 @@ public final class LWCToolkit extends LWToolkit { return locale; } + public static boolean isLocaleUSInternationalPC(Locale locale) { + return (locale != null ? + locale.toString().equals("_US_UserDefined_15000") : false); + } + + public static boolean isCharModifierKeyInUSInternationalPC(char ch) { + // 5 characters: APOSTROPHE, QUOTATION MARK, ACCENT GRAVE, SMALL TILDE, + // CIRCUMFLEX ACCENT + final char[] modifierKeys = {'\'', '"', '`', '\u02DC', '\u02C6'}; + for (char modKey : modifierKeys) { + if (modKey == ch) { + return true; + } + } + return false; + } + @Override public InputMethodDescriptor getInputMethodAdapterDescriptor() { if (sInputMethodDescriptor == null) diff --git a/src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_PCM.cpp b/src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_PCM.cpp index cadbb11bc155825dc0901da6c7d59c241ed56210..608ee13d7ec90be6f42b8229e5cba7b2e6f1e47a 100644 --- a/src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_PCM.cpp +++ b/src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_PCM.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * 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,10 +202,14 @@ public: // (required only if Write() can override the buffer) bool Allocate(int requestedBufferSize, int extraBytes) { int fullBufferSize = requestedBufferSize + extraBytes; - int powerOfTwo = 1; + long powerOfTwo = 1; while (powerOfTwo < fullBufferSize) { powerOfTwo <<= 1; } + if (powerOfTwo > INT_MAX || fullBufferSize < 0) { + ERROR0("RingBuffer::Allocate: REQUESTED MEMORY SIZE IS TOO BIG\n"); + return false; + } pBuffer = (Byte*)malloc(powerOfTwo); if (pBuffer == NULL) { ERROR0("RingBuffer::Allocate: OUT OF MEMORY\n"); diff --git a/src/macosx/native/sun/awt/AWTView.m b/src/macosx/native/sun/awt/AWTView.m index 0cb28c8a3ff2dea6dbbc642a54ab4d46b862f6a6..29dd6410eafa134b60bb62146e83ecc58e3c221c 100644 --- a/src/macosx/native/sun/awt/AWTView.m +++ b/src/macosx/native/sun/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 @@ -144,6 +144,11 @@ AWT_ASSERT_APPKIT_THREAD; fInputMethodLOCKABLE = NULL; } + if (rolloverTrackingArea != nil) { + [self removeTrackingArea:rolloverTrackingArea]; + [rolloverTrackingArea release]; + rolloverTrackingArea = nil; + } [super dealloc]; } diff --git a/src/macosx/native/sun/awt/AWTWindow.m b/src/macosx/native/sun/awt/AWTWindow.m index bd19d8f7e6ea26b839a505267957f11b1d8643fc..4cc2ace5babeeea8ac5c4d2b4171572b54e3d18d 100644 --- a/src/macosx/native/sun/awt/AWTWindow.m +++ b/src/macosx/native/sun/awt/AWTWindow.m @@ -456,7 +456,7 @@ AWT_ASSERT_APPKIT_THREAD; 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/macosx/native/sun/awt/CGraphicsEnv.m b/src/macosx/native/sun/awt/CGraphicsEnv.m index cc83026b9a93d79867bb23491a92cccf06d5752b..4815b5a659d1506b605a3b5288a6c5b9ce0976a8 100644 --- a/src/macosx/native/sun/awt/CGraphicsEnv.m +++ b/src/macosx/native/sun/awt/CGraphicsEnv.m @@ -203,7 +203,7 @@ JNF_COCOA_ENTER(env); 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/macosx/native/sun/java2d/opengl/CGLGraphicsConfig.m b/src/macosx/native/sun/java2d/opengl/CGLGraphicsConfig.m index 5d5fb8f7ea2e921d7eb0a0c1ce74f8d2bf8d50c4..bbf387ef4ed84a4bc2a896514f652a9ac6627a61 100644 --- a/src/macosx/native/sun/java2d/opengl/CGLGraphicsConfig.m +++ b/src/macosx/native/sun/java2d/opengl/CGLGraphicsConfig.m @@ -220,7 +220,6 @@ Java_sun_java2d_opengl_CGLGraphicsConfig_getCGLConfigInfo AWT_ASSERT_APPKIT_THREAD; jint displayID = (jint)[(NSNumber *)[argValue objectAtIndex: 0] intValue]; - jint pixfmt = (jint)[(NSNumber *)[argValue objectAtIndex: 1] intValue]; jint swapInterval = (jint)[(NSNumber *)[argValue objectAtIndex: 2] intValue]; JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; [argValue removeAllObjects]; @@ -229,11 +228,7 @@ Java_sun_java2d_opengl_CGLGraphicsConfig_getCGLConfigInfo NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - CGOpenGLDisplayMask glMask = (CGOpenGLDisplayMask)pixfmt; if (sharedContext == NULL) { - if (glMask == 0) { - glMask = CGDisplayIDToOpenGLDisplayMask(displayID); - } NSOpenGLPixelFormatAttribute attrs[] = { NSOpenGLPFAAllowOfflineRenderers, @@ -244,16 +239,17 @@ Java_sun_java2d_opengl_CGLGraphicsConfig_getCGLConfigInfo NSOpenGLPFAColorSize, 32, NSOpenGLPFAAlphaSize, 8, NSOpenGLPFADepthSize, 16, - NSOpenGLPFAScreenMask, glMask, 0 }; sharedPixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs]; if (sharedPixelFormat == nil) { - J2dRlsTraceLn(J2D_TRACE_ERROR, "CGLGraphicsConfig_getCGLConfigInfo: shared NSOpenGLPixelFormat is NULL"); - [argValue addObject: [NSNumber numberWithLong: 0L]]; - return; + J2dRlsTraceLn(J2D_TRACE_ERROR, + "CGLGraphicsConfig_getCGLConfigInfo: shared NSOpenGLPixelFormat is NULL"); + + [argValue addObject: [NSNumber numberWithLong: 0L]]; + return; } sharedContext = diff --git a/src/share/back/classTrack.c b/src/share/back/classTrack.c index 20ad067ff9a4eee62f4846aaad1d14921349977c..e3fcb01eeb0960eac357fe0931c14bd6c1f022f5 100644 --- a/src/share/back/classTrack.c +++ b/src/share/back/classTrack.c @@ -22,273 +22,206 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + /* * This module tracks classes that have been prepared, so as to - * be able to compute which have been unloaded. On VM start-up - * all prepared classes are put in a table. As class prepare - * events come in they are added to the table. After an unload - * event or series of them, the VM can be asked for the list - * of classes; this list is compared against the table keep by - * this module, any classes no longer present are known to - * have been unloaded. - * - * For efficient access, classes are keep in a hash table. - * Each slot in the hash table has a linked list of KlassNode. - * - * Comparing current set of classes is compared with previous - * set by transferring all classes in the current set into - * a new table, any that remain in the old table have been - * unloaded. + * be able to report which have been unloaded. On VM start-up + * and whenever new classes are loaded, all prepared classes' + * signatures are attached as JVMTI tag to the class object. + * Class unloading is tracked by registering + * ObjectFree callback on class objects. When this happens, we find + * the signature of the unloaded class(es) and report them back + * to the event handler to synthesize class-unload-events. */ #include "util.h" #include "bag.h" #include "classTrack.h" -/* ClassTrack hash table slot count */ -#define CT_HASH_SLOT_COUNT 263 /* Prime which eauals 4k+3 for some k */ - -typedef struct KlassNode { - jclass klass; /* weak global reference */ - char *signature; /* class signature */ - struct KlassNode *next; /* next node in this slot */ -} KlassNode; +#define NOT_TAGGED 0 /* - * Hash table of prepared classes. Each entry is a pointer - * to a linked list of KlassNode. + * The JVMTI tracking env to keep track of klass tags for class-unloads */ -static KlassNode **table; +static jvmtiEnv* trackingEnv; /* - * Return slot in hash table to use for this class. + * A bag containing all the deleted classes' signatures. Must be accessed under + * classTrackLock. */ -static jint -hashKlass(jclass klass) -{ - jint hashCode = objectHashCode(klass); - return abs(hashCode) % CT_HASH_SLOT_COUNT; -} +struct bag* deletedSignatures; /* - * Transfer a node (which represents klass) from the current - * table to the new table. + * Lock to keep integrity of deletedSignatures. */ -static void -transferClass(JNIEnv *env, jclass klass, KlassNode **newTable) { - jint slot = hashKlass(klass); - KlassNode **head = &table[slot]; - KlassNode **newHead = &newTable[slot]; - KlassNode **nodePtr; - KlassNode *node; - - /* Search the node list of the current table for klass */ - for (nodePtr = head; node = *nodePtr, node != NULL; nodePtr = &(node->next)) { - if (isSameObject(env, klass, node->klass)) { - /* Match found transfer node */ - - /* unlink from old list */ - *nodePtr = node->next; - - /* insert in new list */ - node->next = *newHead; - *newHead = node; - - return; - } - } - - /* we haven't found the class, only unloads should have happenned, - * so the only reason a class should not have been found is - * that it is not prepared yet, in which case we don't want it. - * Asset that the above is true. - */ -/**** the HotSpot VM doesn't create prepare events for some internal classes *** - JDI_ASSERT_MSG((classStatus(klass) & - (JVMTI_CLASS_STATUS_PREPARED|JVMTI_CLASS_STATUS_ARRAY))==0, - classSignature(klass)); -***/ -} +static jrawMonitorID classTrackLock; /* - * Delete a hash table of classes. - * The signatures of classes in the table are returned. + * Invoke the callback when classes are freed, find and record the signature + * in deletedSignatures. Those are only used in addPreparedClass() by the + * same thread. */ -static struct bag * -deleteTable(JNIEnv *env, KlassNode *oldTable[]) +static void JNICALL +cbTrackingObjectFree(jvmtiEnv* jvmti_env, jlong tag) { - struct bag *signatures = bagCreateBag(sizeof(char*), 10); - jint slot; - - if (signatures == NULL) { - EXIT_ERROR(AGENT_ERROR_OUT_OF_MEMORY,"signatures"); + debugMonitorEnter(classTrackLock); + if (deletedSignatures == NULL) { + debugMonitorExit(classTrackLock); + return; } + *(char**)bagAdd(deletedSignatures) = (char*)jlong_to_ptr(tag); - for (slot = 0; slot < CT_HASH_SLOT_COUNT; slot++) { - KlassNode *node = oldTable[slot]; - - while (node != NULL) { - KlassNode *next; - char **sigSpot; - - /* Add signature to the signature bag */ - sigSpot = bagAdd(signatures); - if (sigSpot == NULL) { - EXIT_ERROR(AGENT_ERROR_OUT_OF_MEMORY,"signature bag"); - } - *sigSpot = node->signature; - - /* Free weak ref and the node itself */ - JNI_FUNC_PTR(env,DeleteWeakGlobalRef)(env, node->klass); - next = node->next; - jvmtiDeallocate(node); - - node = next; - } - } - jvmtiDeallocate(oldTable); - - return signatures; + debugMonitorExit(classTrackLock); } /* - * Called after class unloads have occurred. Creates a new hash table - * of currently loaded prepared classes. - * The signatures of classes which were unloaded (not present in the - * new table) are returned. + * Called after class unloads have occurred. + * The signatures of classes which were unloaded are returned. */ struct bag * classTrack_processUnloads(JNIEnv *env) { - KlassNode **newTable; - struct bag *unloadedSignatures; - - unloadedSignatures = NULL; - newTable = jvmtiAllocate(CT_HASH_SLOT_COUNT * sizeof(KlassNode *)); - if (newTable == NULL) { - EXIT_ERROR(AGENT_ERROR_OUT_OF_MEMORY, "classTrack table"); - } else { - - (void)memset(newTable, 0, CT_HASH_SLOT_COUNT * sizeof(KlassNode *)); - - WITH_LOCAL_REFS(env, 1) { - - jint classCount; - jclass *classes; - jvmtiError error; - int i; - - error = allLoadedClasses(&classes, &classCount); - if ( error != JVMTI_ERROR_NONE ) { - jvmtiDeallocate(newTable); - EXIT_ERROR(error,"loaded classes"); - } else { - - /* Transfer each current class into the new table */ - for (i=0; iassertOn) { - /* Check this is not a duplicate */ - for (node = *head; node != NULL; node = node->next) { - if (isSameObject(env, klass, node->klass)) { - JDI_ASSERT_FAILED("Attempting to insert duplicate class"); - break; - } + jvmtiEnv* env = trackingEnv; + char* signature; + + if (gdata && gdata->assertOn) { + // Check this is not already tagged. + jlong tag; + error = JVMTI_FUNC_PTR(trackingEnv, GetTag)(env, klass, &tag); + if (error != JVMTI_ERROR_NONE) { + EXIT_ERROR(error, "Unable to GetTag with class trackingEnv"); } + JDI_ASSERT(tag == NOT_TAGGED); } - node = jvmtiAllocate(sizeof(KlassNode)); - if (node == NULL) { - EXIT_ERROR(AGENT_ERROR_OUT_OF_MEMORY,"KlassNode"); - } - error = classSignature(klass, &(node->signature), NULL); + error = classSignature(klass, &signature, NULL); if (error != JVMTI_ERROR_NONE) { - jvmtiDeallocate(node); EXIT_ERROR(error,"signature"); } - if ((node->klass = JNI_FUNC_PTR(env,NewWeakGlobalRef)(env, klass)) == NULL) { - jvmtiDeallocate(node->signature); - jvmtiDeallocate(node); - EXIT_ERROR(AGENT_ERROR_NULL_POINTER,"NewWeakGlobalRef"); + error = JVMTI_FUNC_PTR(trackingEnv, SetTag)(env, klass, ptr_to_jlong(signature)); + if (error != JVMTI_ERROR_NONE) { + jvmtiDeallocate(signature); + EXIT_ERROR(error,"SetTag"); } +} - /* Insert the new node */ - node->next = *head; - *head = node; +static jboolean +setupEvents() +{ + jvmtiError error; + jvmtiEventCallbacks cb; + jvmtiCapabilities caps; + memset(&caps, 0, sizeof(caps)); + caps.can_generate_object_free_events = 1; + error = JVMTI_FUNC_PTR(trackingEnv, AddCapabilities)(trackingEnv, &caps); + if (error != JVMTI_ERROR_NONE) { + return JNI_FALSE; + } + memset(&cb, 0, sizeof(cb)); + cb.ObjectFree = cbTrackingObjectFree; + error = JVMTI_FUNC_PTR(trackingEnv, SetEventCallbacks)(trackingEnv, &cb, sizeof(cb)); + if (error != JVMTI_ERROR_NONE) { + return JNI_FALSE; + } + error = JVMTI_FUNC_PTR(trackingEnv, SetEventNotificationMode)(trackingEnv, JVMTI_ENABLE, JVMTI_EVENT_OBJECT_FREE, NULL); + if (error != JVMTI_ERROR_NONE) { + return JNI_FALSE; + } + return JNI_TRUE; } /* - * Called once to build the initial prepared class hash table. + * Called once to initialize class-tracking. */ void classTrack_initialize(JNIEnv *env) { - WITH_LOCAL_REFS(env, 1) { + jint classCount; + jclass *classes; + jvmtiError error; + jint i; - jint classCount; - jclass *classes; - jvmtiError error; - jint i; + deletedSignatures = NULL; + classTrackLock = debugMonitorCreate("Deleted class tag lock"); + trackingEnv = getSpecialJvmti(); + if (trackingEnv == NULL) { + EXIT_ERROR(AGENT_ERROR_INTERNAL, "Failed to allocate tag-tracking jvmtiEnv"); + } - error = allLoadedClasses(&classes, &classCount); - if ( error == JVMTI_ERROR_NONE ) { - table = jvmtiAllocate(CT_HASH_SLOT_COUNT * sizeof(KlassNode *)); - if (table != NULL) { - (void)memset(table, 0, CT_HASH_SLOT_COUNT * sizeof(KlassNode *)); - for (i=0; ihandlerID = external? ++requestIdCounter : 0; error = eventFilterRestricted_install(node); + if (node->ei == EI_GC_FINISH) { + classTrack_activate(getEnv()); + } if (error == JVMTI_ERROR_NONE) { insert(getHandlerChain(node->ei), node); } diff --git a/src/share/back/util.c b/src/share/back/util.c index 84f9b6e94bd623c6589ef43d6b9abc975dbe801d..30f3ea4f95791ad2f61de9a79eeb159c7d2ab794 100644 --- a/src/share/back/util.c +++ b/src/share/back/util.c @@ -1744,7 +1744,7 @@ isMethodObsolete(jmethodID method) } /* Get the jvmti environment to be used with tags */ -static jvmtiEnv * +jvmtiEnv * getSpecialJvmti(void) { jvmtiEnv *jvmti; diff --git a/src/share/back/util.h b/src/share/back/util.h index 0f9aa1cd8026f346c1f22e69da45c25a6f27ed07..42538d3f4ef738c54ff6f9ac7b57ae80d029646b 100644 --- a/src/share/back/util.h +++ b/src/share/back/util.h @@ -429,4 +429,6 @@ void createLocalRefSpace(JNIEnv *env, jint capacity); void saveGlobalRef(JNIEnv *env, jobject obj, jobject *pobj); void tossGlobalRef(JNIEnv *env, jobject *pobj); +jvmtiEnv* getSpecialJvmti(void); + #endif diff --git a/src/share/bin/java.c b/src/share/bin/java.c index 80c9a08ce6b85133df7b64be4edafe20496863cb..d74b185deb64356ec06a81f2d25f0e55f1d89e59 100644 --- a/src/share/bin/java.c +++ b/src/share/bin/java.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -191,7 +191,7 @@ JLI_Launch(int argc, char ** argv, /* main argc, argc */ char *main_class = NULL; int ret; InvocationFunctions ifn; - jlong start, end; + jlong start = 0, end = 0; char jvmpath[MAXPATHLEN]; char jrepath[MAXPATHLEN]; char jvmcfg[MAXPATHLEN]; @@ -367,7 +367,7 @@ JavaMain(void * _args) jmethodID mainID; jobjectArray mainArgs; int ret = 0; - jlong start, end; + jlong start = 0, end = 0; RegisterThread(); @@ -1320,7 +1320,7 @@ LoadMainClass(JNIEnv *env, int mode, char *name) jmethodID mid; jstring str; jobject result; - jlong start, end; + jlong start = 0, end = 0; jclass cls = GetLauncherHelperClass(env); NULL_CHECK0(cls); if (JLI_IsTraceLauncher()) { @@ -1336,7 +1336,7 @@ LoadMainClass(JNIEnv *env, int mode, char *name) env, cls, mid, USE_STDERR, mode, str)); if (JLI_IsTraceLauncher()) { - end = CounterGet(); + end = CounterGet(); printf("%ld micro seconds to load main class\n", (long)(jint)Counter2Micros(end-start)); printf("----%s----\n", JLDEBUG_ENV_ENTRY); @@ -1727,7 +1727,7 @@ ReadKnownVMs(const char *jvmCfgName, jboolean speculative) char line[MAXPATHLEN+20]; int cnt = 0; int lineno = 0; - jlong start, end; + jlong start = 0, end = 0; int vmType; char *tmpPtr; char *altVMName = NULL; @@ -1836,7 +1836,7 @@ ReadKnownVMs(const char *jvmCfgName, jboolean speculative) knownVMsCount = cnt; if (JLI_IsTraceLauncher()) { - end = CounterGet(); + end = CounterGet(); printf("%ld micro seconds to parse jvm.cfg\n", (long)(jint)Counter2Micros(end-start)); } diff --git a/src/share/classes/com/sun/crypto/provider/BlowfishCipher.java b/src/share/classes/com/sun/crypto/provider/BlowfishCipher.java index d0341b08a799f4e4fa42f0c10e40443964c13223..e991108e8e8935ff70160abce6b0fcb41649678d 100644 --- a/src/share/classes/com/sun/crypto/provider/BlowfishCipher.java +++ b/src/share/classes/com/sun/crypto/provider/BlowfishCipher.java @@ -82,7 +82,7 @@ public final class BlowfishCipher extends CipherSpi { /** * Sets the padding mechanism of this cipher. * - * @param padding the padding mechanism + * @param paddingScheme the padding mechanism * * @exception NoSuchPaddingException if the requested padding mechanism * does not exist diff --git a/src/share/classes/com/sun/crypto/provider/DESCipher.java b/src/share/classes/com/sun/crypto/provider/DESCipher.java index 2fff5b7d16cb343af0e0f9deaa09fea1fd0d5f9e..742ee95a3e34c2da5987710ef03bf985c052ff00 100644 --- a/src/share/classes/com/sun/crypto/provider/DESCipher.java +++ b/src/share/classes/com/sun/crypto/provider/DESCipher.java @@ -77,7 +77,7 @@ public final class DESCipher extends CipherSpi { /** * Sets the padding mechanism of this cipher. * - * @param padding the padding mechanism + * @param paddingScheme the padding mechanism * * @exception NoSuchPaddingException if the requested padding mechanism * does not exist diff --git a/src/share/classes/com/sun/crypto/provider/DESedeCipher.java b/src/share/classes/com/sun/crypto/provider/DESedeCipher.java index 135ed24d3eed5f9e497e5cf095fa09907e003c28..1ab81c41c1845380eb74f2ea03d5960e34d3dcff 100644 --- a/src/share/classes/com/sun/crypto/provider/DESedeCipher.java +++ b/src/share/classes/com/sun/crypto/provider/DESedeCipher.java @@ -74,7 +74,7 @@ public final class DESedeCipher extends CipherSpi { /** * Sets the padding mechanism of this cipher. * - * @param padding the padding mechanism + * @param paddingScheme the padding mechanism * * @exception NoSuchPaddingException if the requested padding mechanism * does not exist diff --git a/src/share/classes/com/sun/crypto/provider/DESedeWrapCipher.java b/src/share/classes/com/sun/crypto/provider/DESedeWrapCipher.java index 94685659af39c870c8008abbb40f8c89d6c39b2d..8c1a5a3b3af73c50a4f448246679aff0f85f5314 100644 --- a/src/share/classes/com/sun/crypto/provider/DESedeWrapCipher.java +++ b/src/share/classes/com/sun/crypto/provider/DESedeWrapCipher.java @@ -32,7 +32,7 @@ import javax.crypto.spec.*; /** * This class implements the CMS DESede KeyWrap algorithm as defined - * in + * in * "XML Encryption Syntax and Processing" section 5.6.2 * "CMS Triple DES Key Wrap". * Note: only CBC mode and NoPadding padding @@ -159,9 +159,8 @@ public final class DESedeWrapCipher extends CipherSpi { /** * Initializes this cipher with a key and a source of randomness. * - *

The cipher only supports the following two operation modes: - * Cipher.WRAP_MODE, and - * Cipher.UNWRAP_MODE. + *

The cipher only supports the following two operation modes: + * {@code Cipher.WRAP_MODE}, and {@code Cipher.UNWRAP_MODE}. *

For modes other than the above two, UnsupportedOperationException * will be thrown. *

If this cipher requires an initialization vector (IV), it will get @@ -192,9 +191,8 @@ public final class DESedeWrapCipher extends CipherSpi { * Initializes this cipher with a key, a set of algorithm parameters, * and a source of randomness. * - *

The cipher only supports the following two operation modes: - * Cipher.WRAP_MODE, and - * Cipher.UNWRAP_MODE. + *

The cipher only supports the following two operation modes: + * {@code Cipher.WRAP_MODE}, and {@code Cipher.UNWRAP_MODE}. *

For modes other than the above two, UnsupportedOperationException * will be thrown. *

If this cipher requires an initialization vector (IV), it will get @@ -252,9 +250,8 @@ public final class DESedeWrapCipher extends CipherSpi { * Initializes this cipher with a key, a set of algorithm parameters, * and a source of randomness. * - *

The cipher only supports the following two operation modes: - * Cipher.WRAP_MODE, and - * Cipher.UNWRAP_MODE. + *

The cipher only supports the following two operation modes: + * {@code Cipher.WRAP_MODE}, and {@code Cipher.UNWRAP_MODE}. *

For modes other than the above two, UnsupportedOperationException * will be thrown. *

If this cipher requires an initialization vector (IV), it will get @@ -360,15 +357,15 @@ public final class DESedeWrapCipher extends CipherSpi { * current Cipher.engineInit(...) implementation, * IllegalStateException will always be thrown upon invocation. * - * @param in the input buffer. - * @param inOffset the offset in in where the input + * @param input the input buffer. + * @param inputOffset the offset in {@code input} where the input * starts. - * @param inLen the input length. - * @param out the buffer for the result. - * @param outOffset the ofset in out where the result + * @param inputLen the input length. + * @param output the buffer for the result. + * @param outputOffset the ofset in {@code output} where the result * is stored. * - * @return the number of bytes stored in out. + * @return the number of bytes stored in {@code out}. * * @exception IllegalStateException upon invocation of this method. */ diff --git a/src/share/classes/com/sun/crypto/provider/DHKeyPairGenerator.java b/src/share/classes/com/sun/crypto/provider/DHKeyPairGenerator.java index 09b132e920e341ece6363d9a86f96cd187c9a0c3..f9290b38601df0dd0791be625fcb532defca334a 100644 --- a/src/share/classes/com/sun/crypto/provider/DHKeyPairGenerator.java +++ b/src/share/classes/com/sun/crypto/provider/DHKeyPairGenerator.java @@ -118,7 +118,7 @@ public final class DHKeyPairGenerator extends KeyPairGeneratorSpi { * generator, and optionally the requested size in bits of the random * exponent (private value). * - * @param params the parameter set used to generate the key pair + * @param algParams the parameter set used to generate the key pair * @param random the source of randomness * * @exception InvalidAlgorithmParameterException if the given parameters diff --git a/src/share/classes/com/sun/crypto/provider/DHParameterGenerator.java b/src/share/classes/com/sun/crypto/provider/DHParameterGenerator.java index edfa89e5c2cc781ec6ba918d009179ca40c59eb9..d921b6dc1803e348b4f362edb43fce942be521db 100644 --- a/src/share/classes/com/sun/crypto/provider/DHParameterGenerator.java +++ b/src/share/classes/com/sun/crypto/provider/DHParameterGenerator.java @@ -92,7 +92,7 @@ public final class DHParameterGenerator extends AlgorithmParameterGeneratorSpi { * generation values, which specify the size of the prime modulus and * the size of the random exponent, both in bits. * - * @param params the set of parameter generation values + * @param genParamSpec the set of parameter generation values * @param random the source of randomness * * @exception InvalidAlgorithmParameterException if the given parameter diff --git a/src/share/classes/com/sun/crypto/provider/JceKeyStore.java b/src/share/classes/com/sun/crypto/provider/JceKeyStore.java index d05dcacac1ac68d9ff371decf9b62d927b18fc17..7dd63c19731566b09104e80b925f607e5446bd1f 100644 --- a/src/share/classes/com/sun/crypto/provider/JceKeyStore.java +++ b/src/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, 2020, Oracle and/or its affiliates. All rights reserved. * 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; @@ -62,6 +64,7 @@ import sun.misc.ObjectInputFilter; 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; @@ -78,6 +81,12 @@ public final class JceKeyStore extends KeyStoreSpi { private static final class SecretKeyEntry { Date date; // the creation date of this entry SealedObject sealedKey; + + // Maximum possible length of sealedKey. Used to detect malicious + // input data. This field is set to the file length of the keystore + // at loading. It is useless when creating a new SecretKeyEntry + // to be store in a keystore. + int maxLength; } // Trusted certificate @@ -133,8 +142,8 @@ public final class JceKeyStore extends KeyStoreSpi { } key = keyProtector.recover(encrInfo); } else { - key = - keyProtector.unseal(((SecretKeyEntry)entry).sealedKey); + SecretKeyEntry ske = ((SecretKeyEntry)entry); + key = keyProtector.unseal(ske.sealedKey, ske.maxLength); } return key; @@ -279,6 +288,7 @@ public final class JceKeyStore extends KeyStoreSpi { // seal and store the key entry.sealedKey = keyProtector.seal(key); + entry.maxLength = Integer.MAX_VALUE; entries.put(alias.toLowerCase(Locale.ENGLISH), entry); } @@ -683,10 +693,15 @@ public final class JceKeyStore extends KeyStoreSpi { Hashtable cfs = null; ByteArrayInputStream bais = null; byte[] encoded = null; + int trustedKeyCount = 0, privateKeyCount = 0, secretKeyCount = 0; if (stream == null) return; + byte[] allData = IOUtils.readAllBytes(stream); + int fullLength = allData.length; + + stream = new ByteArrayInputStream(allData); if (password != null) { md = getPreKeyedHash(password); dis = new DataInputStream(new DigestInputStream(stream, md)); @@ -729,7 +744,7 @@ public final class JceKeyStore extends KeyStoreSpi { tag = dis.readInt(); if (tag == 1) { // private-key entry - + privateKeyCount++; PrivateKeyEntry entry = new PrivateKeyEntry(); // read the alias @@ -774,7 +789,7 @@ public final class JceKeyStore extends KeyStoreSpi { entries.put(alias, entry); } else if (tag == 2) { // trusted certificate entry - + trustedKeyCount++; TrustedCertEntry entry = new TrustedCertEntry(); // read the alias @@ -808,7 +823,7 @@ public final class JceKeyStore extends KeyStoreSpi { entries.put(alias, entry); } else if (tag == 3) { // secret-key entry - + secretKeyCount++; SecretKeyEntry entry = new SecretKeyEntry(); // read the alias @@ -825,10 +840,11 @@ public final class JceKeyStore extends KeyStoreSpi { AccessController.doPrivileged( (PrivilegedAction)() -> { ObjectInputFilter.Config.setObjectInputFilter( - ois2, new DeserializationChecker()); + ois2, new DeserializationChecker(fullLength)); return null; }); entry.sealedKey = (SealedObject)ois.readObject(); + entry.maxLength = fullLength; // NOTE: don't close ois here since we are still // using dis!!! } catch (ClassNotFoundException cnfe) { @@ -841,10 +857,18 @@ public final class JceKeyStore extends KeyStoreSpi { 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 @@ -897,21 +921,42 @@ public final class JceKeyStore extends KeyStoreSpi { * deserialized. */ private static class DeserializationChecker implements ObjectInputFilter { - private static final int MAX_NESTED_DEPTH = 2; + + // Full length of keystore, anything inside a SecretKeyEntry should not + // be bigger. Otherwise, must be illegal. + private final int fullLength; + + public DeserializationChecker(int fullLength) { + this.fullLength = fullLength; + } @Override public ObjectInputFilter.Status checkInput(ObjectInputFilter.FilterInfo info) { - // First run a custom filter - long nestedDepth = info.depth(); - if ((nestedDepth == 1 && - info.serialClass() != SealedObjectForKeyProtector.class) || - (nestedDepth > MAX_NESTED_DEPTH && - info.serialClass() != null && - info.serialClass() != Object.class)) { + if (info.arrayLength() > fullLength) { return Status.REJECTED; } + // First run a custom filter + Class clazz = info.serialClass(); + switch((int)info.depth()) { + case 1: + if (clazz != SealedObjectForKeyProtector.class) { + return Status.REJECTED; + } + break; + case 2: + if (clazz != null && clazz != SealedObject.class + && clazz != byte[].class) { + return Status.REJECTED; + } + break; + default: + if (clazz != null && clazz != Object.class) { + return Status.REJECTED; + } + break; + } // Next run the default filter, if available ObjectInputFilter defaultFilter = diff --git a/src/share/classes/com/sun/crypto/provider/KeyProtector.java b/src/share/classes/com/sun/crypto/provider/KeyProtector.java index c1f96efbd97a937d3d405392859c7618449dc812..63a06a3110ca4917fefbc6ad6540509f40edb5f7 100644 --- a/src/share/classes/com/sun/crypto/provider/KeyProtector.java +++ b/src/share/classes/com/sun/crypto/provider/KeyProtector.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 @@ -48,6 +48,7 @@ import javax.security.auth.DestroyFailedException; import sun.security.x509.AlgorithmId; import sun.security.util.ObjectIdentifier; +import sun.security.util.SecurityProperties; /** * This class implements a protection mechanism for private keys. In JCE, we @@ -75,14 +76,39 @@ final class KeyProtector { private static final String KEY_PROTECTOR_OID = "1.3.6.1.4.1.42.2.17.1.1"; private static final int MAX_ITERATION_COUNT = 5000000; - private static final int ITERATION_COUNT = 200000; + private static final int MIN_ITERATION_COUNT = 10000; + private static final int DEFAULT_ITERATION_COUNT = 200000; private static final int SALT_LEN = 20; // the salt length private static final int DIGEST_LEN = 20; + private static final int ITERATION_COUNT; // the password used for protecting/recovering keys passed through this // key protector private char[] password; + /** + * {@systemProperty jdk.jceks.iterationCount} property indicating the + * number of iterations for password-based encryption (PBE) in JCEKS + * keystores. Values in the range 10000 to 5000000 are considered valid. + * If the value is out of this range, or is not a number, or is + * unspecified; a default of 200000 is used. + */ + static { + int iterationCount = DEFAULT_ITERATION_COUNT; + String ic = SecurityProperties.privilegedGetOverridable( + "jdk.jceks.iterationCount"); + if (ic != null && !ic.isEmpty()) { + try { + iterationCount = Integer.parseInt(ic); + if (iterationCount < MIN_ITERATION_COUNT || + iterationCount > MAX_ITERATION_COUNT) { + iterationCount = DEFAULT_ITERATION_COUNT; + } + } catch (NumberFormatException e) {} + } + ITERATION_COUNT = iterationCount; + } + KeyProtector(char[] password) { if (password == null) { throw new IllegalArgumentException("password can't be null"); @@ -326,8 +352,11 @@ final class KeyProtector { /** * Unseals the sealed key. + * + * @param maxLength Maximum possible length of so. + * If bigger, must be illegal. */ - Key unseal(SealedObject so) + Key unseal(SealedObject so, int maxLength) throws NoSuchAlgorithmException, UnrecoverableKeyException { SecretKey sKey = null; try { @@ -362,7 +391,7 @@ final class KeyProtector { SunJCE.getInstance(), "PBEWithMD5AndTripleDES"); cipher.init(Cipher.DECRYPT_MODE, sKey, params); - return soForKeyProtector.getKey(cipher); + return soForKeyProtector.getKey(cipher, maxLength); } catch (NoSuchAlgorithmException ex) { // Note: this catch needed to be here because of the // later catch of GeneralSecurityException diff --git a/src/share/classes/com/sun/crypto/provider/OAEPParameters.java b/src/share/classes/com/sun/crypto/provider/OAEPParameters.java index 74b3cc408d9663e776f4b74c4c0a4ec26714f351..d3cbae6f595fec7221de13b5147c229b7878469a 100644 --- a/src/share/classes/com/sun/crypto/provider/OAEPParameters.java +++ b/src/share/classes/com/sun/crypto/provider/OAEPParameters.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -137,6 +137,10 @@ public final class OAEPParameters extends AlgorithmParametersSpi { mgfSpec = MGF1ParameterSpec.SHA384; } else if (mgfDigestName.equals("SHA-512")) { mgfSpec = MGF1ParameterSpec.SHA512; + } else if (mgfDigestName.equals("SHA-512/224")) { + mgfSpec = MGF1ParameterSpec.SHA512_224; + } else if (mgfDigestName.equals("SHA-512/256")) { + mgfSpec = MGF1ParameterSpec.SHA512_256; } else { throw new IOException( "Unrecognized message digest algorithm"); diff --git a/src/share/classes/com/sun/crypto/provider/PBEWithMD5AndDESCipher.java b/src/share/classes/com/sun/crypto/provider/PBEWithMD5AndDESCipher.java index b19f7b3fc50bc1aa35d784b6bb4b2332bc8736cb..e5756d4ced52c97ed1bb7e4d74da00a9f1591f84 100644 --- a/src/share/classes/com/sun/crypto/provider/PBEWithMD5AndDESCipher.java +++ b/src/share/classes/com/sun/crypto/provider/PBEWithMD5AndDESCipher.java @@ -80,7 +80,7 @@ public final class PBEWithMD5AndDESCipher extends CipherSpi { * Sets the padding mechanism of this cipher. This algorithm only uses * PKCS #5 padding. * - * @param padding the padding mechanism + * @param paddingScheme the padding mechanism * * @exception NoSuchPaddingException if the requested padding mechanism * is invalid diff --git a/src/share/classes/com/sun/crypto/provider/PBEWithMD5AndTripleDESCipher.java b/src/share/classes/com/sun/crypto/provider/PBEWithMD5AndTripleDESCipher.java index 7119233f95ef92de544382795d49fad2a1808644..f2712b6957ff98cb042f8ffdcb5623288f67d615 100644 --- a/src/share/classes/com/sun/crypto/provider/PBEWithMD5AndTripleDESCipher.java +++ b/src/share/classes/com/sun/crypto/provider/PBEWithMD5AndTripleDESCipher.java @@ -92,7 +92,7 @@ public final class PBEWithMD5AndTripleDESCipher extends CipherSpi { * Sets the padding mechanism of this cipher. This algorithm only uses * PKCS #5 padding. * - * @param padding the padding mechanism + * @param paddingScheme the padding mechanism * * @exception NoSuchPaddingException if the requested padding mechanism * is invalid diff --git a/src/share/classes/com/sun/crypto/provider/PBKDF2HmacSHA1Factory.java b/src/share/classes/com/sun/crypto/provider/PBKDF2HmacSHA1Factory.java index ae49c79cafb237420a4838ccfef1dfb7df94134a..e786d53f98aeaa598547a7d600a2d7caa1dd60e0 100644 --- a/src/share/classes/com/sun/crypto/provider/PBKDF2HmacSHA1Factory.java +++ b/src/share/classes/com/sun/crypto/provider/PBKDF2HmacSHA1Factory.java @@ -75,7 +75,7 @@ public final class PBKDF2HmacSHA1Factory extends SecretKeyFactorySpi { * * @param key the key * - * @param keySpec the requested format in which the key material shall be + * @param keySpecCl the requested format in which the key material shall be * returned * * @return the underlying key specification (key material) in the diff --git a/src/share/classes/com/sun/crypto/provider/RSACipher.java b/src/share/classes/com/sun/crypto/provider/RSACipher.java index 5faefb6bdacbbcd652a37983d6c291bbda5d78e6..1d7baca3f582742b2ec544cccde7ed550ec634db 100644 --- a/src/share/classes/com/sun/crypto/provider/RSACipher.java +++ b/src/share/classes/com/sun/crypto/provider/RSACipher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * 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,13 +44,15 @@ import sun.security.util.KeyUtil; /** * RSA cipher implementation. Supports RSA en/decryption and signing/verifying - * using PKCS#1 v1.5 padding and without padding (raw RSA). Note that raw RSA - * is supported mostly for completeness and should only be used in rare cases. + * using both PKCS#1 v1.5 and OAEP (v2.2) paddings and without padding (raw RSA). + * Note that raw RSA is supported mostly for completeness and should only be + * used in rare cases. * * Objects should be instantiated by calling Cipher.getInstance() using the * following algorithm names: - * . "RSA/ECB/PKCS1Padding" (or "RSA") for PKCS#1 padding. The mode (blocktype) - * is selected based on the en/decryption mode and public/private key used + * . "RSA/ECB/PKCS1Padding" (or "RSA") for PKCS#1 v1.5 padding. + * . "RSA/ECB/OAEPwithandMGF1Padding" (or "RSA/ECB/OAEPPadding") for + * PKCS#1 v2.2 padding. * . "RSA/ECB/NoPadding" for rsa RSA. * * We only do one RSA operation per doFinal() call. If the application passes @@ -81,7 +83,7 @@ public final class RSACipher extends CipherSpi { private final static String PAD_NONE = "NoPadding"; // constant for PKCS#1 v1.5 RSA private final static String PAD_PKCS1 = "PKCS1Padding"; - // constant for PKCS#2 v2.0 OAEP with MGF1 + // constant for PKCS#2 v2.2 OAEP with MGF1 private final static String PAD_OAEP_MGF1 = "OAEP"; // current mode, one of MODE_* above. Set when init() is called diff --git a/src/share/classes/com/sun/crypto/provider/SealedObjectForKeyProtector.java b/src/share/classes/com/sun/crypto/provider/SealedObjectForKeyProtector.java index c95770e91d22f7b7c6e407a9f0ca112adfb30c11..7a22629a9efce821048ee9bdc9c9cac6a208ecec 100644 --- a/src/share/classes/com/sun/crypto/provider/SealedObjectForKeyProtector.java +++ b/src/share/classes/com/sun/crypto/provider/SealedObjectForKeyProtector.java @@ -73,7 +73,7 @@ final class SealedObjectForKeyProtector extends SealedObject { return params; } - final Key getKey(Cipher c) + final Key getKey(Cipher c, int maxLength) throws IOException, ClassNotFoundException, IllegalBlockSizeException, BadPaddingException { @@ -82,7 +82,7 @@ final class SealedObjectForKeyProtector extends SealedObject { AccessController.doPrivileged( (PrivilegedAction) () -> { ObjectInputFilter.Config.setObjectInputFilter(ois, - DeserializationChecker.ONE_FILTER); + new DeserializationChecker(maxLength)); return null; }); try { @@ -110,7 +110,7 @@ final class SealedObjectForKeyProtector extends SealedObject { */ private static class DeserializationChecker implements ObjectInputFilter { - private static final ObjectInputFilter ONE_FILTER; + private static final ObjectInputFilter OWN_FILTER; static { String prop = AccessController.doPrivileged( @@ -122,26 +122,32 @@ final class SealedObjectForKeyProtector extends SealedObject { return Security.getProperty(KEY_SERIAL_FILTER); } }); - ONE_FILTER = new DeserializationChecker(prop == null ? null - : ObjectInputFilter.Config.createFilter(prop)); + OWN_FILTER = prop == null + ? null + : ObjectInputFilter.Config.createFilter(prop); } - private final ObjectInputFilter base; + // Maximum possible length of anything inside + private final int maxLength; - private DeserializationChecker(ObjectInputFilter base) { - this.base = base; + private DeserializationChecker(int maxLength) { + this.maxLength = maxLength; } @Override public ObjectInputFilter.Status checkInput( ObjectInputFilter.FilterInfo info) { + if (info.arrayLength() > maxLength) { + return Status.REJECTED; + } + if (info.serialClass() == Object.class) { return Status.UNDECIDED; } - if (base != null) { - Status result = base.checkInput(info); + if (OWN_FILTER != null) { + Status result = OWN_FILTER.checkInput(info); if (result != Status.UNDECIDED) { return result; } diff --git a/src/share/classes/com/sun/crypto/provider/SunJCE.java b/src/share/classes/com/sun/crypto/provider/SunJCE.java index 55c55e2de59b6f8042eed60104c0a40cd999cc79..efe8031fec479d94e6bde58a199e9ec6e5d8a785 100644 --- a/src/share/classes/com/sun/crypto/provider/SunJCE.java +++ b/src/share/classes/com/sun/crypto/provider/SunJCE.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -131,7 +131,9 @@ public final class SunJCE extends Provider { + "|OAEPWITHSHA-224ANDMGF1PADDING" + "|OAEPWITHSHA-256ANDMGF1PADDING" + "|OAEPWITHSHA-384ANDMGF1PADDING" - + "|OAEPWITHSHA-512ANDMGF1PADDING"); + + "|OAEPWITHSHA-512ANDMGF1PADDING" + + "|OAEPWITHSHA-512/224ANDMGF1PADDING" + + "|OAEPWITHSHA-512/256ANDMGF1PADDING"); put("Cipher.RSA SupportedKeyClasses", "java.security.interfaces.RSAPublicKey" + "|java.security.interfaces.RSAPrivateKey"); diff --git a/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java b/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java index 0a278e0a1f96a4d041f8b04d5c1ebf5647f172a8..3df5e4d1769a1c4c185f26df516ed1fda6d89eb6 100644 --- a/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java +++ b/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java @@ -911,6 +911,10 @@ public class GIFImageReader extends ImageReader { try { // Read and decode the image data, fill in theImage this.initCodeSize = stream.readUnsignedByte(); + // GIF allows max 8 bpp, so anything larger is bogus for the roots. + if (this.initCodeSize < 1 || this.initCodeSize > 8) { + throw new IIOException("Bad code size:" + this.initCodeSize); + } // Read first data block this.blockLength = stream.readUnsignedByte(); @@ -1009,7 +1013,6 @@ public class GIFImageReader extends ImageReader { processReadAborted(); return theImage; } catch (IOException e) { - e.printStackTrace(); throw new IIOException("I/O error reading image!", e); } } diff --git a/src/share/classes/com/sun/media/sound/DirectAudioDevice.java b/src/share/classes/com/sun/media/sound/DirectAudioDevice.java index ba862f1164596209620c096301a99ddf1f9943b7..6688afa36d374fd41032d46b356d64e29edc8821 100644 --- a/src/share/classes/com/sun/media/sound/DirectAudioDevice.java +++ b/src/share/classes/com/sun/media/sound/DirectAudioDevice.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1121,7 +1121,7 @@ final class DirectAudioDevice extends AbstractMixer { public void open(AudioInputStream stream) throws LineUnavailableException, IOException { // $$fb part of fix for 4679187: Clip.open() throws unexpected Exceptions - Toolkit.isFullySpecifiedAudioFormat(format); + Toolkit.isFullySpecifiedAudioFormat(stream.getFormat()); synchronized (mixer) { if (Printer.trace) Printer.trace("> DirectClip.open(stream)"); @@ -1135,11 +1135,18 @@ final class DirectAudioDevice extends AbstractMixer { if (Printer.debug) Printer.debug("DirectClip: open(AIS): lengthInFrames: " + lengthInFrames); int bytesRead = 0; + int frameSize = stream.getFormat().getFrameSize(); if (lengthInFrames != AudioSystem.NOT_SPECIFIED) { // read the data from the stream into an array in one fell swoop. - int arraysize = lengthInFrames * stream.getFormat().getFrameSize(); - streamData = new byte[arraysize]; - + int arraysize = lengthInFrames * frameSize; + if (arraysize < 0) { + throw new IllegalArgumentException("Audio data < 0"); + } + try { + streamData = new byte[arraysize]; + } catch (OutOfMemoryError e) { + throw new IOException("Audio data is too big"); + } int bytesRemaining = arraysize; int thisRead = 0; while (bytesRemaining > 0 && thisRead >= 0) { @@ -1157,9 +1164,14 @@ final class DirectAudioDevice extends AbstractMixer { // we use a slightly modified version of ByteArrayOutputStream // to get direct access to the byte array (we don't want a new array // to be allocated) - int MAX_READ_LIMIT = 16384; + int maxReadLimit = Math.max(16384, frameSize); DirectBAOS dbaos = new DirectBAOS(); - byte tmp[] = new byte[MAX_READ_LIMIT]; + byte[] tmp; + try { + tmp = new byte[maxReadLimit]; + } catch (OutOfMemoryError e) { + throw new IOException("Audio data is too big"); + } int thisRead = 0; while (thisRead >= 0) { thisRead = stream.read(tmp, 0, tmp.length); @@ -1173,7 +1185,7 @@ final class DirectAudioDevice extends AbstractMixer { } // while streamData = dbaos.getInternalBuffer(); } - lengthInFrames = bytesRead / stream.getFormat().getFrameSize(); + lengthInFrames = bytesRead / frameSize; if (Printer.debug) Printer.debug("Read to end of stream. lengthInFrames: " + lengthInFrames); diff --git a/src/share/classes/com/sun/media/sound/Toolkit.java b/src/share/classes/com/sun/media/sound/Toolkit.java index 5d52b8fe79108dc257af53dd4fbbe8961cb85ce8..96733cfa9e5826105eff6e1d07016ad039017a5c 100644 --- a/src/share/classes/com/sun/media/sound/Toolkit.java +++ b/src/share/classes/com/sun/media/sound/Toolkit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -154,6 +154,14 @@ public final class Toolkit { } static void isFullySpecifiedAudioFormat(AudioFormat format) { + // Our code requires a positive frame size, that's probably is not + // necessary for non-linear encodings, but for now + // IllegalArgumentException is better than ArithmeticException + if (format.getFrameSize() <= 0) { + throw new IllegalArgumentException("invalid frame size: " + +((format.getFrameSize() == -1) ? + "NOT_SPECIFIED":String.valueOf(format.getFrameSize()))); + } if (!format.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED) && !format.getEncoding().equals(AudioFormat.Encoding.PCM_UNSIGNED) && !format.getEncoding().equals(AudioFormat.Encoding.ULAW) @@ -176,11 +184,6 @@ public final class Toolkit { +((format.getSampleSizeInBits()==-1)? "NOT_SPECIFIED":String.valueOf(format.getSampleSizeInBits()))); } - if (format.getFrameSize() <= 0) { - throw new IllegalArgumentException("invalid frame size: " - +((format.getFrameSize()==-1)? - "NOT_SPECIFIED":String.valueOf(format.getFrameSize()))); - } if (format.getChannels() <= 0) { throw new IllegalArgumentException("invalid number of channels: " +((format.getChannels()==-1)? diff --git a/src/share/classes/com/sun/net/httpserver/Headers.java b/src/share/classes/com/sun/net/httpserver/Headers.java index 0ca7d39d42034fe777894f6542bbd8ea1e941c80..8d1a356e05fa5d985461acefeb097a7d1b0867cc 100644 --- a/src/share/classes/com/sun/net/httpserver/Headers.java +++ b/src/share/classes/com/sun/net/httpserver/Headers.java @@ -80,11 +80,14 @@ public class Headers implements Map> { char[] b = key.toCharArray(); if (b[0] >= 'a' && b[0] <= 'z') { b[0] = (char)(b[0] - ('a' - 'A')); - } + } else if (b[0] == '\r' || b[0] == '\n') + throw new IllegalArgumentException("illegal character in key"); + for (int i=1; i= 'A' && b[i] <= 'Z') { b[i] = (char) (b[i] + ('a' - 'A')); - } + } else if (b[i] == '\r' || b[i] == '\n') + throw new IllegalArgumentException("illegal character in key"); } return new String(b); } @@ -126,6 +129,8 @@ public class Headers implements Map> { } public List put(String key, List value) { + for (String v : value) + checkValue(v); return map.put (normalize(key), value); } @@ -137,6 +142,7 @@ public class Headers implements Map> { * @param value the header value to add to the header */ public void add (String key, String value) { + checkValue(value); String k = normalize(key); List l = map.get(k); if (l == null) { @@ -146,6 +152,30 @@ public class Headers implements Map> { l.add (value); } + private static void checkValue(String value) { + int len = value.length(); + for (int i=0; i= len - 2) { + throw new IllegalArgumentException("Illegal CR found in header"); + } + char c1 = value.charAt(i+1); + char c2 = value.charAt(i+2); + if (c1 != '\n') { + throw new IllegalArgumentException("Illegal char found after CR in header"); + } + if (c2 != ' ' && c2 != '\t') { + throw new IllegalArgumentException("No whitespace found after CRLF in header"); + } + i+=2; + } else if (c == '\n') { + throw new IllegalArgumentException("Illegal LF found in header"); + } + } + } + /** * sets the given value as the sole header value * for the given key. If the mapping does not diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignature.java b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignature.java index 6ea1443af3a4c1090437a78c6db93223f737b44f..ae8593bc600b503d197b69136b0ec98d93f2f768 100644 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignature.java +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignature.java @@ -699,15 +699,15 @@ public final class XMLSignature extends SignatureElementProxy { //create a SignatureAlgorithms from the SignatureMethod inside //SignedInfo. This is used to validate the signature. SignatureAlgorithm sa = si.getSignatureAlgorithm(); - if (log.isLoggable(java.util.logging.Level.FINE)) { - log.log(java.util.logging.Level.FINE, "signatureMethodURI = " + sa.getAlgorithmURI()); - log.log(java.util.logging.Level.FINE, "jceSigAlgorithm = " + sa.getJCEAlgorithmString()); - log.log(java.util.logging.Level.FINE, "jceSigProvider = " + sa.getJCEProviderName()); - log.log(java.util.logging.Level.FINE, "PublicKey = " + pk); - } byte sigBytes[] = null; try { sa.initVerify(pk); + if (log.isLoggable(java.util.logging.Level.FINE)) { + log.log(java.util.logging.Level.FINE, "signatureMethodURI = " + sa.getAlgorithmURI()); + log.log(java.util.logging.Level.FINE, "jceSigAlgorithm = " + sa.getJCEAlgorithmString()); + log.log(java.util.logging.Level.FINE, "jceSigProvider = " + sa.getJCEProviderName()); + log.log(java.util.logging.Level.FINE, "PublicKey = " + pk); + } // Get the canonicalized (normalized) SignedInfo SignerOutputStream so = new SignerOutputStream(sa); diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java index db1f49eaee466277250c810e81064c8af424dd90..741f3c1a83f844f32bb924cd6cdbdbcee7ebd256 100644 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java @@ -376,14 +376,14 @@ public class Base64 { return null; } - int lengthDataBits = binaryData.length * EIGHTBIT; - if (lengthDataBits == 0) { + long lengthDataBits = ((long) binaryData.length) * ((long) EIGHTBIT); + if (lengthDataBits == 0L) { return ""; } - int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP; - int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP; - int numberQuartet = fewerThan24bits != 0 ? numberTriplets + 1 : numberTriplets; + long fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP; + int numberTriplets = (int) (lengthDataBits / TWENTYFOURBITGROUP); + int numberQuartet = fewerThan24bits != 0L ? numberTriplets + 1 : numberTriplets; int quartesPerLine = length / 4; int numberLines = (numberQuartet - 1) / quartesPerLine; char encodedData[] = null; diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/IgnoreAllErrorHandler.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/IgnoreAllErrorHandler.java index d06a41ffd2011c65feb87b3bb2c59c2bd958b3c0..4d0ab5266b537fd9c46a4cc81e52347da4200288 100644 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/IgnoreAllErrorHandler.java +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/IgnoreAllErrorHandler.java @@ -35,19 +35,30 @@ import org.xml.sax.SAXParseException; public class IgnoreAllErrorHandler implements ErrorHandler { /** {@link org.apache.commons.logging} logging facility */ - private static java.util.logging.Logger log = + private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(IgnoreAllErrorHandler.class.getName()); /** Field throwExceptions */ - private static final boolean warnOnExceptions = - System.getProperty("com.sun.org.apache.xml.internal.security.test.warn.on.exceptions", "false").equals("true"); + private static final boolean warnOnExceptions = getProperty( + "com.sun.org.apache.xml.internal.security.test.warn.on.exceptions"); /** Field throwExceptions */ - private static final boolean throwExceptions = - System.getProperty("com.sun.org.apache.xml.internal.security.test.throw.exceptions", "false").equals("true"); + private static final boolean throwExceptions = getProperty( + "com.sun.org.apache.xml.internal.security.test.throw.exceptions"); + private static boolean getProperty(String name) { + return java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + + @Override + public Boolean run() { + return Boolean.getBoolean(name); + } + }); + } /** @inheritDoc */ + @Override public void warning(SAXParseException ex) throws SAXException { if (IgnoreAllErrorHandler.warnOnExceptions) { log.log(java.util.logging.Level.WARNING, "", ex); @@ -59,6 +70,7 @@ public class IgnoreAllErrorHandler implements ErrorHandler { /** @inheritDoc */ + @Override public void error(SAXParseException ex) throws SAXException { if (IgnoreAllErrorHandler.warnOnExceptions) { log.log(java.util.logging.Level.SEVERE, "", ex); @@ -70,6 +82,7 @@ public class IgnoreAllErrorHandler implements ErrorHandler { /** @inheritDoc */ + @Override public void fatalError(SAXParseException ex) throws SAXException { if (IgnoreAllErrorHandler.warnOnExceptions) { log.log(java.util.logging.Level.WARNING, "", ex); diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java index b798e33a4238841e6baec4a9d43a4f1dac3b1d66..629f435108e7549d93233b835c600f66c8a685f8 100644 --- a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java +++ b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java @@ -108,6 +108,7 @@ public class ResolverDirectHTTP extends ResourceResolverSpi { @Override public XMLSignatureInput engineResolveURI(ResourceResolverContext context) throws ResourceResolverException { + InputStream inputStream = null; try { // calculate new URI @@ -139,7 +140,7 @@ public class ResolverDirectHTTP extends ResourceResolverSpi { } String mimeType = urlConnection.getHeaderField("Content-Type"); - InputStream inputStream = urlConnection.getInputStream(); + inputStream = urlConnection.getInputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte buf[] = new byte[4096]; int read = 0; @@ -168,6 +169,16 @@ public class ResolverDirectHTTP extends ResourceResolverSpi { throw new ResourceResolverException("generic.EmptyMessage", ex, context.attr, context.baseUri); } catch (IllegalArgumentException e) { throw new ResourceResolverException("generic.EmptyMessage", e, context.attr, context.baseUri); + } finally { + if (inputStream != null) { + try { + inputStream.close(); + } catch (IOException e) { + if (log.isLoggable(java.util.logging.Level.FINE)) { + log.log(java.util.logging.Level.FINE, e.getMessage(), e); + } + } + } } } diff --git a/src/share/classes/com/sun/security/sasl/digest/FactoryImpl.java b/src/share/classes/com/sun/security/sasl/digest/FactoryImpl.java index 39ec03d75931921d58f549e3db2ee1eb907464b0..5e6a76ecea41c8d56cde2384449c28a1ce86a8da 100644 --- a/src/share/classes/com/sun/security/sasl/digest/FactoryImpl.java +++ b/src/share/classes/com/sun/security/sasl/digest/FactoryImpl.java @@ -60,7 +60,7 @@ SaslServerFactory{ * * @throws SaslException If there is an error creating the DigestMD5 * SASL client. - * @returns a new SaslClient ; otherwise null if unsuccessful. + * @return a new SaslClient; otherwise null if unsuccessful. */ public SaslClient createSaslClient(String[] mechs, String authorizationId, String protocol, String serverName, @@ -90,7 +90,7 @@ SaslServerFactory{ * * @throws SaslException If there is an error creating the DigestMD5 * SASL server. - * @returns a new SaslServer ; otherwise null if unsuccessful. + * @return a new SaslServer; otherwise null if unsuccessful. */ public SaslServer createSaslServer(String mech, String protocol, String serverName, Map props, CallbackHandler cbh) @@ -114,7 +114,7 @@ SaslServerFactory{ /** * Returns the authentication mechanisms that this factory can produce. * - * @returns String[] {"DigestMD5"} if policies in env match those of this + * @return String[] {"DigestMD5"} if policies in env match those of this * factory. */ public String[] getMechanismNames(Map env) { diff --git a/src/share/classes/com/sun/security/sasl/ntlm/FactoryImpl.java b/src/share/classes/com/sun/security/sasl/ntlm/FactoryImpl.java index e7a3097ca27a556a87340ab1a3f2cd8b18809d63..fff919aac2c484e08d8d24244b0b7b79a26ddfa6 100644 --- a/src/share/classes/com/sun/security/sasl/ntlm/FactoryImpl.java +++ b/src/share/classes/com/sun/security/sasl/ntlm/FactoryImpl.java @@ -57,7 +57,7 @@ SaslServerFactory{ /** * Returns a new instance of the NTLM SASL client mechanism. * Argument checks are performed in SaslClient's constructor. - * @returns a new SaslClient ; otherwise null if unsuccessful. + * @return a new SaslClient; otherwise null if unsuccessful. * @throws SaslException If there is an error creating the NTLM * SASL client. */ @@ -86,7 +86,7 @@ SaslServerFactory{ /** * Returns a new instance of the NTLM SASL server mechanism. * Argument checks are performed in SaslServer's constructor. - * @returns a new SaslServer ; otherwise null if unsuccessful. + * @return a new SaslServer; otherwise null if unsuccessful. * @throws SaslException If there is an error creating the NTLM * SASL server. */ @@ -116,7 +116,7 @@ SaslServerFactory{ /** * Returns the authentication mechanisms that this factory can produce. * - * @returns String[] {"NTLM"} if policies in env match those of this + * @return String[] {"NTLM"} if policies in env match those of this * factory. */ public String[] getMechanismNames(Map env) { diff --git a/src/share/classes/com/sun/tools/jdi/VMState.java b/src/share/classes/com/sun/tools/jdi/VMState.java index cd3c621d61c7ff881c1a00c88dd4014fd89a644a..7c246b70c11812944bed285e58acb3c8856cbe17 100644 --- a/src/share/classes/com/sun/tools/jdi/VMState.java +++ b/src/share/classes/com/sun/tools/jdi/VMState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -172,7 +172,14 @@ class VMState { } synchronized boolean hasListener(VMListener listener) { - return listeners.contains(listener); + Iterator> iter = listeners.iterator(); + while (iter.hasNext()) { + WeakReference ref = iter.next(); + if (listener.equals(ref.get())) { + return true; + } + } + return false; } synchronized void removeListener(VMListener listener) { diff --git a/src/share/classes/java/io/BufferedReader.java b/src/share/classes/java/io/BufferedReader.java index ee9f66a42315175ac5f7e7233641e33279644fa1..16b82e024b0e8138f54fb688bf09c6d7bcb19bea 100644 --- a/src/share/classes/java/io/BufferedReader.java +++ b/src/share/classes/java/io/BufferedReader.java @@ -310,7 +310,7 @@ public class BufferedReader extends Reader { * @exception IOException If an I/O error occurs */ String readLine(boolean ignoreLF) throws IOException { - StringBuffer s = null; + StringBuilder s = null; int startChar; synchronized (lock) { @@ -366,7 +366,7 @@ public class BufferedReader extends Reader { } if (s == null) - s = new StringBuffer(defaultExpectedLineLength); + s = new StringBuilder(defaultExpectedLineLength); s.append(cb, startChar, i - startChar); } } diff --git a/src/share/classes/java/io/File.java b/src/share/classes/java/io/File.java index 846ddc3004dd25ddb02b61433d9c86c18052d95e..ad1978a97948a0d2c4dae59bcc8b7d8ea70a01ac 100644 --- a/src/share/classes/java/io/File.java +++ b/src/share/classes/java/io/File.java @@ -183,11 +183,13 @@ public class File * @return true if the file path is invalid. */ final boolean isInvalid() { - if (status == null) { - status = (this.path.indexOf('\u0000') < 0) ? PathStatus.CHECKED - : PathStatus.INVALID; + PathStatus s = status; + if (s == null) { + s = (this.path.indexOf('\u0000') < 0) ? PathStatus.CHECKED + : PathStatus.INVALID; + status = s; } - return status == PathStatus.INVALID; + return s == PathStatus.INVALID; } /** diff --git a/src/share/classes/java/io/ObjectInputStream.java b/src/share/classes/java/io/ObjectInputStream.java index b16d53b4bc64628abb800be3ae28621b907e414a..247be774d1355073afa661e0b830a8005b62fe5f 100644 --- a/src/share/classes/java/io/ObjectInputStream.java +++ b/src/share/classes/java/io/ObjectInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. * 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,6 +50,7 @@ import sun.misc.SharedSecrets; import sun.reflect.misc.ReflectUtil; import sun.misc.JavaOISAccess; import sun.util.logging.PlatformLogger; +import sun.security.action.GetBooleanAction; /** * An ObjectInputStream deserializes primitive data and objects previously @@ -243,6 +244,23 @@ public class ObjectInputStream /** queue for WeakReferences to audited subclasses */ static final ReferenceQueue> subclassAuditsQueue = new ReferenceQueue<>(); + + /** + * Property to permit setting a filter after objects + * have been read. + * See {@link #setObjectInputFilter(ObjectInputFilter)} + */ + static final boolean SET_FILTER_AFTER_READ = + privilegedGetProperty("jdk.serialSetFilterAfterRead"); + + private static boolean privilegedGetProperty(String theProp) { + if (System.getSecurityManager() == null) { + return Boolean.getBoolean(theProp); + } else { + return AccessController.doPrivileged( + new GetBooleanAction(theProp)); + } + } } static { @@ -1250,6 +1268,10 @@ public class ObjectInputStream serialFilter != ObjectInputFilter.Config.getSerialFilter()) { throw new IllegalStateException("filter can not be set more than once"); } + if (totalObjectRefs > 0 && !Caches.SET_FILTER_AFTER_READ) { + throw new IllegalStateException( + "filter can not be set after an object has been read"); + } this.serialFilter = filter; } @@ -1798,6 +1820,8 @@ public class ObjectInputStream break; case TC_REFERENCE: descriptor = (ObjectStreamClass) readHandle(unshared); + // Should only reference initialized class descriptors + descriptor.checkInitialized(); break; case TC_PROXYCLASSDESC: descriptor = readProxyDesc(unshared); diff --git a/src/share/classes/java/io/ObjectStreamClass.java b/src/share/classes/java/io/ObjectStreamClass.java index a2181c6095323b1d8ce08ec44f9d442f7d2cdddd..64453b25a41149a3e65f838ea36a93740e2f9cda 100644 --- a/src/share/classes/java/io/ObjectStreamClass.java +++ b/src/share/classes/java/io/ObjectStreamClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -863,6 +863,17 @@ public class ObjectStreamClass implements Serializable { throw new InternalError("Unexpected call when not initialized"); } + /** + * Throws InvalidClassException if not initialized. + * To be called in cases where an uninitialized class descriptor indicates + * a problem in the serialization stream. + */ + final void checkInitialized() throws InvalidClassException { + if (!initialized) { + throw new InvalidClassException("Class descriptor should be initialized"); + } + } + /** * Throws an InvalidClassException if object instances referencing this * class descriptor should not be allowed to deserialize. This method does @@ -1119,6 +1130,9 @@ public class ObjectStreamClass implements Serializable { } catch (IllegalAccessException ex) { // should not occur, as access checks have been suppressed throw new InternalError(ex); + } catch (InstantiationError err) { + throw (InstantiationException) + new InstantiationException().initCause(err); } } else { throw new UnsupportedOperationException(); diff --git a/src/share/classes/java/lang/ClassLoader.java b/src/share/classes/java/lang/ClassLoader.java index 925fdacce3fd969eb45ac9b9b5ff82fd69487885..2e98092f63e97df487d28b768df506d957d6eb9d 100644 --- a/src/share/classes/java/lang/ClassLoader.java +++ b/src/share/classes/java/lang/ClassLoader.java @@ -1,6 +1,5 @@ /* * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2019, 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 @@ -1468,17 +1467,6 @@ public abstract class ClassLoader { } } - /* - * Initialize default paths for native libraries search. - * Must be done early as JDK may load libraries during bootstrap. - * - * @see java.lang.System#initPhase1 - */ - static void initLibraryPaths() { - usr_paths = initializePath("java.library.path"); - sys_paths = initializePath("sun.boot.library.path"); - } - // Returns true if the specified class loader can be found in this class // loader's delegation chain. boolean isAncestor(ClassLoader cl) { @@ -1821,9 +1809,10 @@ public abstract class ClassLoader { boolean isAbsolute) { ClassLoader loader = (fromClass == null) ? null : fromClass.getClassLoader(); - assert sys_paths != null : "should be initialized at this point"; - assert usr_paths != null : "should be initialized at this point"; - + if (sys_paths == null) { + usr_paths = initializePath("java.library.path"); + sys_paths = initializePath("sun.boot.library.path"); + } if (isAbsolute) { if (loadLibrary0(fromClass, new File(name))) { return; @@ -1913,14 +1902,13 @@ public abstract class ClassLoader { name + " already loaded in another classloader"); } - /* - * When a library is being loaded, JNI_OnLoad function can cause - * another loadLibrary invocation that should succeed. + /* If the library is being loaded (must be by the same thread, + * because Runtime.load and Runtime.loadLibrary are + * synchronous). The reason is can occur is that the JNI_OnLoad + * function can cause another loadLibrary invocation. * - * We use a static stack to hold the list of libraries we are - * loading because this can happen only when called by the - * same thread because Runtime.load and Runtime.loadLibrary - * are synchronous. + * Thus we can use a static stack to hold the list of libraries + * we are loading. * * If there is a pending load operation for the library, we * immediately return success; otherwise, we raise diff --git a/src/share/classes/java/lang/Runtime.java b/src/share/classes/java/lang/Runtime.java index a203eb041f5d0109f4ba1be489c519e0e9e8ac3d..4f923d74f517ce59f4b71b4f01387f9a6ee738e5 100644 --- a/src/share/classes/java/lang/Runtime.java +++ b/src/share/classes/java/lang/Runtime.java @@ -1,6 +1,5 @@ /* * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2019, 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 @@ -285,6 +284,7 @@ public class Runtime { if (sm != null) { sm.checkExit(status); } + Shutdown.beforeHalt(); Shutdown.halt(status); } @@ -810,7 +810,7 @@ public class Runtime { load0(Reflection.getCallerClass(), filename); } - void load0(Class fromClass, String filename) { + synchronized void load0(Class fromClass, String filename) { SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkLink(filename); @@ -871,14 +871,14 @@ public class Runtime { loadLibrary0(Reflection.getCallerClass(), libname); } - void loadLibrary0(Class fromClass, String libname) { + synchronized void loadLibrary0(Class fromClass, String libname) { SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkLink(libname); } if (libname.indexOf((int)File.separatorChar) != -1) { throw new UnsatisfiedLinkError( - "Directory separator should not appear in library name: " + libname); + "Directory separator should not appear in library name: " + libname); } ClassLoader.loadLibrary(fromClass, libname, false); } diff --git a/src/share/classes/java/lang/Shutdown.java b/src/share/classes/java/lang/Shutdown.java index 7ce64ffae188d0b5a05e19cbff0d4aad83b1a1d6..959493eb902b7862caff38957540ed7233a905b6 100644 --- a/src/share/classes/java/lang/Shutdown.java +++ b/src/share/classes/java/lang/Shutdown.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -130,6 +130,9 @@ class Shutdown { } } + /* Notify the VM that it's time to halt. */ + static native void beforeHalt(); + /* The halt method is synchronized on the halt lock * to avoid corruption of the delete-on-shutdown file list. * It invokes the true native halt method. @@ -209,6 +212,7 @@ class Shutdown { /* Synchronize on the class object, causing any other thread * that attempts to initiate shutdown to stall indefinitely */ + beforeHalt(); sequence(); halt(status); } diff --git a/src/share/classes/java/lang/System.java b/src/share/classes/java/lang/System.java index 898629b7b43e2669bf75292e62d69f02da5feb82..fc67d54afa8cca44a41ae33af902ad3b1deb0dd8 100644 --- a/src/share/classes/java/lang/System.java +++ b/src/share/classes/java/lang/System.java @@ -1226,8 +1226,6 @@ public final class System { setOut0(newPrintStream(fdOut, props.getProperty("sun.stdout.encoding"))); setErr0(newPrintStream(fdErr, props.getProperty("sun.stderr.encoding"))); - ClassLoader.initLibraryPaths(); - // Load the zip library now in order to keep java.util.zip.ZipFile // from trying to use itself to load this library later. loadLibrary("zip"); diff --git a/src/share/classes/java/lang/instrument/package.html b/src/share/classes/java/lang/instrument/package.html index e6839e52f9b87745272c1bd3ef82c487a8c15b24..c0d9bbbb8c9b1112d29e50e75e596b3473a9b277 100644 --- a/src/share/classes/java/lang/instrument/package.html +++ b/src/share/classes/java/lang/instrument/package.html @@ -38,6 +38,13 @@ Provides services that allow Java programming language agents to instrument programs running on the JVM. The mechanism for instrumentation is modification of the byte-codes of methods. +

+Note: developers/admininstrators are responsible for verifying the trustworthiness of +content and structure of the Java Agents they deploy, since those are able to arbitrarily +transform the bytecode from other JAR files. Since that happens after the Jars containing +the bytecode have been verified as trusted, the trustworthiness of a Java Agent can determine +the trust towards the entire program. +

Package Specification

diff --git a/src/share/classes/java/lang/invoke/MethodType.java b/src/share/classes/java/lang/invoke/MethodType.java index ec2a7f6edcbcb892be9703d9fc3ba1cf7c927a4e..58a6c433b6318fbc5e5bdbcbfefa5b20c648244b 100644 --- a/src/share/classes/java/lang/invoke/MethodType.java +++ b/src/share/classes/java/lang/invoke/MethodType.java @@ -97,7 +97,8 @@ class MethodType implements java.io.Serializable { // The remaining fields are caches of various sorts: private @Stable MethodTypeForm form; // erased form, plus cached data about primitives - private @Stable MethodType wrapAlt; // alternative wrapped/unwrapped version + private @Stable Object wrapAlt; // alternative wrapped/unwrapped version and + // private communication for readObject and readResolve private @Stable Invokers invokers; // cache of handy higher-order adapters private @Stable String methodDescriptor; // cache for toMethodDescriptorString @@ -673,7 +674,7 @@ class MethodType implements java.io.Serializable { private static MethodType wrapWithPrims(MethodType pt) { assert(pt.hasPrimitives()); - MethodType wt = pt.wrapAlt; + MethodType wt = (MethodType)pt.wrapAlt; if (wt == null) { // fill in lazily wt = MethodTypeForm.canonicalize(pt, MethodTypeForm.WRAP, MethodTypeForm.WRAP); @@ -685,7 +686,7 @@ class MethodType implements java.io.Serializable { private static MethodType unwrapWithNoPrims(MethodType wt) { assert(!wt.hasPrimitives()); - MethodType uwt = wt.wrapAlt; + MethodType uwt = (MethodType)wt.wrapAlt; if (uwt == null) { // fill in lazily uwt = MethodTypeForm.canonicalize(wt, MethodTypeForm.UNWRAP, MethodTypeForm.UNWRAP); @@ -1144,27 +1145,18 @@ s.writeObject(this.parameterArray()); * @see #writeObject */ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { - // Assign temporary defaults in case this object escapes - MethodType_init(void.class, NO_PTYPES); + // Assign defaults in case this object escapes + UNSAFE.putObject(this, rtypeOffset, void.class); + UNSAFE.putObject(this, ptypesOffset, NO_PTYPES); s.defaultReadObject(); // requires serialPersistentFields to be an empty array Class returnType = (Class) s.readObject(); Class[] parameterArray = (Class[]) s.readObject(); - parameterArray = parameterArray.clone(); // make sure it is unshared - // Assign deserialized values - MethodType_init(returnType, parameterArray); - } - - // Initialization of state for deserialization only - private void MethodType_init(Class rtype, Class[] ptypes) { - // In order to communicate these values to readResolve, we must - // store them into the implementation-specific final fields. - checkRtype(rtype); - checkPtypes(ptypes); - UNSAFE.putObject(this, rtypeOffset, rtype); - UNSAFE.putObject(this, ptypesOffset, ptypes); + // Verify all operands, and make sure ptypes is unshared + // Cache the new MethodType for readResolve + wrapAlt = new MethodType[]{MethodType.methodType(returnType, parameterArray)}; } // Support for resetting final fields while deserializing @@ -1189,12 +1181,10 @@ s.writeObject(this.parameterArray()); // Do not use a trusted path for deserialization: // return makeImpl(rtype, ptypes, true); // Verify all operands, and make sure ptypes is unshared: - try { - return methodType(rtype, ptypes); - } finally { - // Re-assign defaults in case this object escapes - MethodType_init(void.class, NO_PTYPES); - } + // Return a new validated MethodType for the rtype and ptypes passed from readObject. + MethodType mt = ((MethodType[])wrapAlt)[0]; + wrapAlt = null; + return mt; } /** diff --git a/src/share/classes/java/math/MutableBigInteger.java b/src/share/classes/java/math/MutableBigInteger.java index 73a244fd5b4a4c175a108d1c5af5c5db2f03ae43..b9cb0fb0debbe860caa1617bd64ad149134f076e 100644 --- a/src/share/classes/java/math/MutableBigInteger.java +++ b/src/share/classes/java/math/MutableBigInteger.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -2088,8 +2088,8 @@ class MutableBigInteger { } /** - * Calculate the multiplicative inverse of this mod mod, where mod is odd. - * This and mod are not changed by the calculation. + * Calculate the multiplicative inverse of this modulo mod, where the mod + * argument is odd. This and mod are not changed by the calculation. * * This method implements an algorithm due to Richard Schroeppel, that uses * the same intermediate representation as Montgomery Reduction @@ -2143,8 +2143,18 @@ class MutableBigInteger { k += trailingZeros; } - while (c.sign < 0) - c.signedAdd(p); + if (c.compare(p) >= 0) { // c has a larger magnitude than p + MutableBigInteger remainder = c.divide(p, + new MutableBigInteger()); + // The previous line ignores the sign so we copy the data back + // into c which will restore the sign as needed (and converts + // it back to a SignedMutableBigInteger) + c.copyValue(remainder); + } + + if (c.sign < 0) { + c.signedAdd(p); + } return fixup(c, p, k); } @@ -2182,8 +2192,8 @@ class MutableBigInteger { } // In theory, c may be greater than p at this point (Very rare!) - while (c.compare(p) >= 0) - c.subtract(p); + if (c.compare(p) >= 0) + c = c.divide(p, new MutableBigInteger()); return c; } diff --git a/src/share/classes/java/nio/Buffer.java b/src/share/classes/java/nio/Buffer.java index 2a90de846105c65483258639d7caaa66f5303f09..e45e05fe0eac2b282dbb1636adba5fae8f4a11aa 100644 --- a/src/share/classes/java/nio/Buffer.java +++ b/src/share/classes/java/nio/Buffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -274,8 +274,8 @@ public abstract class Buffer { if ((newLimit > capacity) || (newLimit < 0)) throw new IllegalArgumentException(); limit = newLimit; - if (position > limit) position = limit; - if (mark > limit) mark = -1; + if (position > newLimit) position = newLimit; + if (mark > newLimit) mark = -1; return this; } @@ -496,16 +496,18 @@ public abstract class Buffer { * @return The current position value, before it is incremented */ final int nextGetIndex() { // package-private - if (position >= limit) + int p = position; + if (p >= limit) throw new BufferUnderflowException(); - return position++; + position = p + 1; + return p; } final int nextGetIndex(int nb) { // package-private - if (limit - position < nb) - throw new BufferUnderflowException(); int p = position; - position += nb; + if (limit - p < nb) + throw new BufferUnderflowException(); + position = p + nb; return p; } @@ -517,16 +519,18 @@ public abstract class Buffer { * @return The current position value, before it is incremented */ final int nextPutIndex() { // package-private - if (position >= limit) + int p = position; + if (p >= limit) throw new BufferOverflowException(); - return position++; + position = p + 1; + return p; } final int nextPutIndex(int nb) { // package-private - if (limit - position < nb) - throw new BufferOverflowException(); int p = position; - position += nb; + if (limit - p < nb) + throw new BufferOverflowException(); + position = p + nb; return p; } diff --git a/src/share/classes/java/nio/ByteBufferAs-X-Buffer.java.template b/src/share/classes/java/nio/ByteBufferAs-X-Buffer.java.template index bae622550ac2fafb74ece6ae98b23c69f44641c3..810b0f4b72888e0f24b31039aa07ac8fc25419a1 100644 --- a/src/share/classes/java/nio/ByteBufferAs-X-Buffer.java.template +++ b/src/share/classes/java/nio/ByteBufferAs-X-Buffer.java.template @@ -72,7 +72,6 @@ class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private public $Type$Buffer slice() { int pos = this.position(); int lim = this.limit(); - assert (pos <= lim); int rem = (pos <= lim ? lim - pos : 0); int off = (pos << $LG_BYTES_PER_VALUE$) + offset; assert (off >= 0); diff --git a/src/share/classes/java/nio/Direct-X-Buffer.java.template b/src/share/classes/java/nio/Direct-X-Buffer.java.template index e9f6d9fd0dbac6ebcb204258312eea1b3d939a7d..fd7af812c6abbf9e34e8ef66ee2d3ea9a5045d9d 100644 --- a/src/share/classes/java/nio/Direct-X-Buffer.java.template +++ b/src/share/classes/java/nio/Direct-X-Buffer.java.template @@ -206,7 +206,6 @@ class Direct$Type$Buffer$RW$$BO$ public $Type$Buffer slice() { int pos = this.position(); int lim = this.limit(); - assert (pos <= lim); int rem = (pos <= lim ? lim - pos : 0); int off = (pos << $LG_BYTES_PER_VALUE$); assert (off >= 0); diff --git a/src/share/classes/java/nio/Heap-X-Buffer.java.template b/src/share/classes/java/nio/Heap-X-Buffer.java.template index e8639c4d21fbabc182fed26c91682f5392e1ea71..1b327277f0f5cd787c46a7a0827a736444bc87f7 100644 --- a/src/share/classes/java/nio/Heap-X-Buffer.java.template +++ b/src/share/classes/java/nio/Heap-X-Buffer.java.template @@ -95,12 +95,15 @@ class Heap$Type$Buffer$RW$ } public $Type$Buffer slice() { + int pos = this.position(); + int lim = this.limit(); + int rem = (pos <= lim ? lim - pos : 0); return new Heap$Type$Buffer$RW$(hb, -1, 0, - this.remaining(), - this.remaining(), - this.position() + offset); + rem, + rem, + pos + offset); } public $Type$Buffer duplicate() { @@ -147,10 +150,11 @@ class Heap$Type$Buffer$RW$ public $Type$Buffer get($type$[] dst, int offset, int length) { checkBounds(offset, length, dst.length); - if (length > remaining()) + int pos = position(); + if (length > limit() - pos) throw new BufferUnderflowException(); - System.arraycopy(hb, ix(position()), dst, offset, length); - position(position() + length); + System.arraycopy(hb, ix(pos), dst, offset, length); + position(pos + length); return this; } @@ -185,10 +189,11 @@ class Heap$Type$Buffer$RW$ public $Type$Buffer put($type$[] src, int offset, int length) { #if[rw] checkBounds(offset, length, src.length); - if (length > remaining()) + int pos = position(); + if (length > limit() - pos) throw new BufferOverflowException(); - System.arraycopy(src, offset, hb, ix(position()), length); - position(position() + length); + System.arraycopy(src, offset, hb, ix(pos), length); + position(pos + length); return this; #else[rw] throw new ReadOnlyBufferException(); @@ -201,19 +206,22 @@ class Heap$Type$Buffer$RW$ if (src == this) throw new IllegalArgumentException(); Heap$Type$Buffer sb = (Heap$Type$Buffer)src; - int n = sb.remaining(); - if (n > remaining()) + int pos = position(); + int sbpos = sb.position(); + int n = sb.limit() - sbpos; + if (n > limit() - pos) throw new BufferOverflowException(); - System.arraycopy(sb.hb, sb.ix(sb.position()), - hb, ix(position()), n); - sb.position(sb.position() + n); - position(position() + n); + System.arraycopy(sb.hb, sb.ix(sbpos), + hb, ix(pos), n); + sb.position(sbpos + n); + position(pos + n); } else if (src.isDirect()) { int n = src.remaining(); - if (n > remaining()) + int pos = position(); + if (n > limit() - pos) throw new BufferOverflowException(); - src.get(hb, ix(position()), n); - position(position() + n); + src.get(hb, ix(pos), n); + position(pos + n); } else { super.put(src); } @@ -225,8 +233,10 @@ class Heap$Type$Buffer$RW$ public $Type$Buffer compact() { #if[rw] - System.arraycopy(hb, ix(position()), hb, ix(0), remaining()); - position(remaining()); + int pos = position(); + int rem = limit() - pos; + System.arraycopy(hb, ix(pos), hb, ix(0), rem); + position(rem); limit(capacity()); discardMark(); return this; @@ -284,8 +294,9 @@ class Heap$Type$Buffer$RW$ } public CharBuffer asCharBuffer() { - int size = this.remaining() >> 1; - int off = offset + position(); + int pos = position(); + int size = (limit() - pos) >> 1; + int off = offset + pos; return (bigEndian ? (CharBuffer)(new ByteBufferAsCharBuffer$RW$B(this, -1, @@ -335,8 +346,9 @@ class Heap$Type$Buffer$RW$ } public ShortBuffer asShortBuffer() { - int size = this.remaining() >> 1; - int off = offset + position(); + int pos = position(); + int size = (limit() - pos) >> 1; + int off = offset + pos; return (bigEndian ? (ShortBuffer)(new ByteBufferAsShortBuffer$RW$B(this, -1, @@ -386,8 +398,9 @@ class Heap$Type$Buffer$RW$ } public IntBuffer asIntBuffer() { - int size = this.remaining() >> 2; - int off = offset + position(); + int pos = position(); + int size = (limit() - pos) >> 2; + int off = offset + pos; return (bigEndian ? (IntBuffer)(new ByteBufferAsIntBuffer$RW$B(this, -1, @@ -437,8 +450,9 @@ class Heap$Type$Buffer$RW$ } public LongBuffer asLongBuffer() { - int size = this.remaining() >> 3; - int off = offset + position(); + int pos = position(); + int size = (limit() - pos) >> 3; + int off = offset + pos; return (bigEndian ? (LongBuffer)(new ByteBufferAsLongBuffer$RW$B(this, -1, @@ -488,8 +502,9 @@ class Heap$Type$Buffer$RW$ } public FloatBuffer asFloatBuffer() { - int size = this.remaining() >> 2; - int off = offset + position(); + int pos = position(); + int size = (limit() - pos) >> 2; + int off = offset + pos; return (bigEndian ? (FloatBuffer)(new ByteBufferAsFloatBuffer$RW$B(this, -1, @@ -539,8 +554,9 @@ class Heap$Type$Buffer$RW$ } public DoubleBuffer asDoubleBuffer() { - int size = this.remaining() >> 3; - int off = offset + position(); + int pos = position(); + int size = (limit() - pos) >> 3; + int off = offset + pos; return (bigEndian ? (DoubleBuffer)(new ByteBufferAsDoubleBuffer$RW$B(this, -1, diff --git a/src/share/classes/java/nio/StringCharBuffer.java b/src/share/classes/java/nio/StringCharBuffer.java index 0c20fa669c501eac36572b54a32201bd813ca834..a8f07f1ce6cd5b5b1515b39023125ec6a08a3d18 100644 --- a/src/share/classes/java/nio/StringCharBuffer.java +++ b/src/share/classes/java/nio/StringCharBuffer.java @@ -42,12 +42,15 @@ class StringCharBuffer // package-private } public CharBuffer slice() { + int pos = this.position(); + int lim = this.limit(); + int rem = (pos <= lim ? lim - pos : 0); return new StringCharBuffer(str, -1, 0, - this.remaining(), - this.remaining(), - offset + this.position()); + rem, + rem, + offset + pos); } private StringCharBuffer(CharSequence s, diff --git a/src/share/classes/java/nio/file/Files.java b/src/share/classes/java/nio/file/Files.java index 012118c60f6d07925b99de3cfa7a40bb8c10b7c6..d6934f47b485ca77d320f6beaa45770a705951e1 100644 --- a/src/share/classes/java/nio/file/Files.java +++ b/src/share/classes/java/nio/file/Files.java @@ -3348,8 +3348,8 @@ public final class Files { // ensure lines is not null before opening file Objects.requireNonNull(lines); CharsetEncoder encoder = cs.newEncoder(); - OutputStream out = newOutputStream(path, options); - try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out, encoder))) { + try (OutputStream out = newOutputStream(path, options); + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out, encoder))) { for (CharSequence line: lines) { writer.append(line); writer.newLine(); diff --git a/src/share/classes/java/security/MessageDigest.java b/src/share/classes/java/security/MessageDigest.java index a72de0ca21a715b87595d4dad19cb55389604c96..3963b60d704f56f996c72459130e12532822d22b 100644 --- a/src/share/classes/java/security/MessageDigest.java +++ b/src/share/classes/java/security/MessageDigest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -433,6 +433,12 @@ public abstract class MessageDigest extends MessageDigestSpi { /** * Compares two digests for equality. Does a simple byte compare. * + * @implNote + * All bytes in {@code digesta} are examined to determine equality. + * The calculation time depends only on the length of {@code digesta}. + * It does not depend on the length of {@code digestb} or the contents + * of {@code digesta} and {@code digestb}. + * * @param digesta one of the digests to compare. * * @param digestb the other digest to compare. @@ -444,14 +450,22 @@ public abstract class MessageDigest extends MessageDigestSpi { if (digesta == null || digestb == null) { return false; } - if (digesta.length != digestb.length) { - return false; + + int lenA = digesta.length; + int lenB = digestb.length; + + if (lenB == 0) { + return lenA == 0; } int result = 0; + result |= lenA - lenB; + // time-constant comparison - for (int i = 0; i < digesta.length; i++) { - result |= digesta[i] ^ digestb[i]; + for (int i = 0; i < lenA; i++) { + // If i >= lenB, indexB is 0; otherwise, i. + int indexB = ((i - lenB) >>> 31) * i; + result |= digesta[i] ^ digestb[indexB]; } return result == 0; } diff --git a/src/share/classes/java/security/PKCS12Attribute.java b/src/share/classes/java/security/PKCS12Attribute.java index e3898628820fed51cd73575de5c11c4c7b4cb0b5..4693e265518a7f47eaabb3088574d7c61f9d91d6 100644 --- a/src/share/classes/java/security/PKCS12Attribute.java +++ b/src/share/classes/java/security/PKCS12Attribute.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -252,6 +252,9 @@ public final class PKCS12Attribute implements KeyStore.Entry.Attribute { private void parse(byte[] encoded) throws IOException { DerInputStream attributeValue = new DerInputStream(encoded); DerValue[] attrSeq = attributeValue.getSequence(2); + if (attrSeq.length != 2) { + throw new IOException("Invalid length for PKCS12Attribute"); + } ObjectIdentifier type = attrSeq[0].getOID(); DerInputStream attrContent = new DerInputStream(attrSeq[1].toByteArray()); diff --git a/src/share/classes/java/security/Signature.java b/src/share/classes/java/security/Signature.java index 5232b9c469869344567ae6b5c8b52c8c8c0ccfa2..8d8408c492b76deac680c3890d6bbae259b7f4a6 100644 --- a/src/share/classes/java/security/Signature.java +++ b/src/share/classes/java/security/Signature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. * 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 @@ import javax.crypto.CipherSpi; import javax.crypto.IllegalBlockSizeException; import javax.crypto.BadPaddingException; import javax.crypto.NoSuchPaddingException; +import sun.misc.JavaSecuritySignatureAccess; +import sun.misc.SharedSecrets; import sun.security.util.Debug; import sun.security.jca.*; @@ -117,6 +119,34 @@ import sun.security.jca.GetInstance.Instance; 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"); @@ -275,6 +305,7 @@ public abstract class Signature extends SignatureSpi { signatureInfo.put("sun.security.rsa.RSASignature$SHA256withRSA", TRUE); signatureInfo.put("sun.security.rsa.RSASignature$SHA384withRSA", TRUE); signatureInfo.put("sun.security.rsa.RSASignature$SHA512withRSA", TRUE); + signatureInfo.put("sun.security.rsa.RSAPSSSignature", TRUE); signatureInfo.put("com.sun.net.ssl.internal.ssl.RSASignature", TRUE); signatureInfo.put("sun.security.pkcs11.P11Signature", TRUE); } @@ -466,6 +497,53 @@ public abstract class Signature extends SignatureSpi { } } + /** + * 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. @@ -486,27 +564,40 @@ public abstract class Signature extends SignatureSpi { */ 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 8 + */ + final void initVerify(Certificate certificate, + AlgorithmParameterSpec params) + throws InvalidKeyException, InvalidAlgorithmParameterException { + engineInitVerify(getPublicKeyFromCert(certificate), params); state = VERIFY; if (!skipDebug && pdebug != null) { @@ -559,6 +650,31 @@ public abstract class Signature extends SignatureSpi { } } + /** + * 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 @@ -680,7 +796,7 @@ public abstract class Signature extends SignatureSpi { * encoded or of the wrong type, if this signature algorithm is unable to * process the input data provided, etc. * @exception IllegalArgumentException if the {@code signature} - * byte array is null, or the {@code offset} or {@code length} + * byte array is {@code null}, or the {@code offset} or {@code length} * is less than 0, or the sum of the {@code offset} and * {@code length} is greater than the length of the * {@code signature} byte array. @@ -873,14 +989,15 @@ public abstract class Signature extends SignatureSpi { /** * Returns the parameters used with this signature object. * - *

The returned parameters may be the same that were used to initialize - * this signature, or may contain a combination of default and randomly - * generated parameter values used by the underlying signature - * implementation if this signature requires algorithm parameters but - * was not initialized with any. + *

If this signature has been previously initialized with parameters + * (by calling the {@code setParameter} method), this method returns + * the same parameters. If this signature has not been initialized with + * parameters, this method may return a combination of default and + * randomly generated parameter values if the underlying + * signature implementation supports it and can successfully generate + * them. Otherwise, {@code null} is returned. * - * @return the parameters used with this signature, or null if this - * signature does not use any parameters. + * @return the parameters used with this signature, or {@code null} * * @see #setParameter(AlgorithmParameterSpec) * @since 1.4 @@ -901,7 +1018,7 @@ public abstract class Signature extends SignatureSpi { * * @param param the string name of the parameter. * - * @return the object that represents the parameter value, or null if + * @return the object that represents the parameter value, or {@code null} if * there is none. * * @exception InvalidParameterException if {@code param} is an invalid @@ -1086,11 +1203,13 @@ public abstract class Signature extends SignatureSpi { } } - 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; @@ -1103,7 +1222,7 @@ public abstract class Signature extends SignatureSpi { 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 @@ -1112,7 +1231,7 @@ public abstract class Signature extends SignatureSpi { } try { SignatureSpi spi = newInstance(s); - init(spi, type, key, random); + tryOperation(spi, type, key, params, random); provider = s.getProvider(); sigSpi = spi; firstService = null; @@ -1134,6 +1253,10 @@ public abstract class Signature extends SignatureSpi { 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: " @@ -1141,22 +1264,36 @@ public abstract class Signature extends SignatureSpi { } } - private final static int I_PUB = 1; - private final static int I_PRIV = 2; - private final static 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 tryOperation(SignatureSpi spi, int type, Key key, + AlgorithmParameterSpec params, SecureRandom random) + throws InvalidKeyException, InvalidAlgorithmParameterException { - private void init(SignatureSpi spi, int type, Key key, - SecureRandom random) throws InvalidKeyException { 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); } @@ -1167,7 +1304,22 @@ public abstract class Signature extends SignatureSpi { 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); } } @@ -1176,7 +1328,12 @@ public abstract class Signature extends SignatureSpi { 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); + } } } @@ -1185,7 +1342,22 @@ public abstract class Signature extends SignatureSpi { 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); } } @@ -1236,8 +1408,16 @@ public abstract class Signature extends SignatureSpi { 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/share/classes/java/security/SignatureSpi.java b/src/share/classes/java/security/SignatureSpi.java index d6d2bc39b5e7b9b5d415bbaa0080d10636d222bb..87df4bbaf2b8ff4448e487b33492ed2c0e78bb7e 100644 --- a/src/share/classes/java/security/SignatureSpi.java +++ b/src/share/classes/java/security/SignatureSpi.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -69,6 +69,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. @@ -97,10 +124,41 @@ public abstract class SignatureSpi { * 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); } /** @@ -126,7 +184,7 @@ public abstract class SignatureSpi { * 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 @@ -222,7 +280,7 @@ public abstract class SignatureSpi { * @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 @@ -250,7 +308,7 @@ public abstract class SignatureSpi { * 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 @@ -272,7 +330,7 @@ public abstract class SignatureSpi { * @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); @@ -304,7 +362,7 @@ public abstract class SignatureSpi { */ @Deprecated protected abstract void engineSetParameter(String param, Object value) - throws InvalidParameterException; + throws InvalidParameterException; /** *

This method is overridden by providers to initialize @@ -320,23 +378,23 @@ public abstract class SignatureSpi { * are inappropriate for this signature engine */ protected void engineSetParameter(AlgorithmParameterSpec params) - throws InvalidAlgorithmParameterException { - throw new UnsupportedOperationException(); + throws InvalidAlgorithmParameterException { + throw new UnsupportedOperationException(); } /** - *

This method is overridden by providers to return the - * parameters used with this signature engine, or null - * if this signature engine does not use any parameters. + *

This method is overridden by providers to return the parameters + * used with this signature engine. * - *

The returned parameters may be the same that were used to initialize - * this signature engine, or may contain a combination of default and - * randomly generated parameter values used by the underlying signature - * implementation if this signature engine requires algorithm parameters - * but was not initialized with any. + *

If this signature engine has been previously initialized with + * parameters (by calling the {@code engineSetParameter} method), this + * method returns the same parameters. If this signature engine has not been + * initialized with parameters, this method may return a combination of + * default and randomly generated parameter values if the underlying + * signature implementation supports it and can successfully generate + * them. Otherwise, {@code null} is returned. * - * @return the parameters used with this signature engine, or null if this - * signature engine does not use any parameters + * @return the parameters used with this signature engine, or {@code null} * * @exception UnsupportedOperationException if this method is * not overridden by a provider @@ -359,7 +417,7 @@ public abstract class SignatureSpi { * * @param param the string name of the parameter. * - * @return the object that represents the parameter value, or null if + * @return the object that represents the parameter value, or {@code null} if * there is none. * * @exception InvalidParameterException if {@code param} is an diff --git a/src/share/classes/java/security/cert/X509CRL.java b/src/share/classes/java/security/cert/X509CRL.java index 2133290735761c63bd205bd5008274e667edc493..2b48ceb7bb842e519b68ffb7d07929a1d9a29456 100644 --- a/src/share/classes/java/security/cert/X509CRL.java +++ b/src/share/classes/java/security/cert/X509CRL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * 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,13 +25,9 @@ package java.security.cert; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.InvalidKeyException; -import java.security.SignatureException; -import java.security.Principal; -import java.security.Provider; -import java.security.PublicKey; +import java.security.*; +import java.security.spec.*; + import javax.security.auth.x500.X500Principal; import java.math.BigInteger; @@ -40,6 +36,7 @@ import java.util.Set; import java.util.Arrays; import sun.security.x509.X509CRLImpl; +import sun.security.util.SignatureUtil; /** *

@@ -241,7 +238,27 @@ public abstract class X509CRL extends CRL implements X509Extension { public void verify(PublicKey key, Provider sigProvider) throws CRLException, NoSuchAlgorithmException, InvalidKeyException, SignatureException { - X509CRLImpl.verify(this, key, sigProvider); + String sigAlgName = getSigAlgName(); + Signature sig = (sigProvider == null) + ? Signature.getInstance(sigAlgName) + : Signature.getInstance(sigAlgName, sigProvider); + + try { + byte[] paramBytes = getSigAlgParams(); + SignatureUtil.initVerifyWithParam(sig, key, + SignatureUtil.getParamSpec(sigAlgName, paramBytes)); + } catch (ProviderException e) { + throw new CRLException(e.getMessage(), e.getCause()); + } catch (InvalidAlgorithmParameterException e) { + throw new CRLException(e); + } + + byte[] tbsCRL = getTBSCertList(); + sig.update(tbsCRL, 0, tbsCRL.length); + + if (sig.verify(getSignature()) == false) { + throw new SignatureException("Signature does not match."); + } } /** diff --git a/src/share/classes/java/security/cert/X509Certificate.java b/src/share/classes/java/security/cert/X509Certificate.java index 174d6a73838496771e1b77080b03505ef3c14fc4..b13866a457f4c95447a102545d7685c55fe39cfc 100644 --- a/src/share/classes/java/security/cert/X509Certificate.java +++ b/src/share/classes/java/security/cert/X509Certificate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * 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,12 +27,14 @@ package java.security.cert; import java.math.BigInteger; import java.security.*; +import java.security.spec.*; import java.util.Collection; import java.util.Date; import java.util.List; import javax.security.auth.x500.X500Principal; import sun.security.x509.X509CertImpl; +import sun.security.util.SignatureUtil; /** *

@@ -647,7 +649,7 @@ implements X509Extension { return X509CertImpl.getIssuerAlternativeNames(this); } - /** + /** * Verifies that this certificate was signed using the * private key that corresponds to the specified public key. * This method uses the signature verification engine @@ -673,6 +675,25 @@ implements X509Extension { public void verify(PublicKey key, Provider sigProvider) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, SignatureException { - X509CertImpl.verify(this, key, sigProvider); + String sigName = getSigAlgName(); + Signature sig = (sigProvider == null) + ? Signature.getInstance(sigName) + : Signature.getInstance(sigName, sigProvider); + + try { + SignatureUtil.initVerifyWithParam(sig, key, + SignatureUtil.getParamSpec(sigName, getSigAlgParams())); + } catch (ProviderException e) { + throw new CertificateException(e.getMessage(), e.getCause()); + } catch (InvalidAlgorithmParameterException e) { + throw new CertificateException(e); + } + + byte[] tbsCert = getTBSCertificate(); + sig.update(tbsCert, 0, tbsCert.length); + + if (sig.verify(getSignature()) == false) { + throw new SignatureException("Signature does not match."); + } } } diff --git a/src/share/classes/java/security/interfaces/RSAKey.java b/src/share/classes/java/security/interfaces/RSAKey.java index 67fbe2bf811cdca294bf39a3c8dc1633dbb39b33..5703d669d65a0d5dc5a9f6e79c4bcae60ab952e0 100644 --- a/src/share/classes/java/security/interfaces/RSAKey.java +++ b/src/share/classes/java/security/interfaces/RSAKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. * 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 java.security.interfaces; import java.math.BigInteger; +import java.security.spec.AlgorithmParameterSpec; /** - * The interface to an RSA public or private key. + * The interface to a public or private key in + * PKCS#1 v2.2 standard, + * such as those for RSA, or RSASSA-PSS algorithms. * * @author Jan Luehe * @@ -46,4 +49,20 @@ public interface RSAKey { * @return the modulus */ public BigInteger getModulus(); + + /** + * Returns the parameters associated with this key. + * The parameters are optional and may be either + * explicitly specified or implicitly created during + * key pair generation. + * + * @implSpec + * The default implementation returns {@code null}. + * + * @return the associated parameters, may be null + * @since 8 + */ + default AlgorithmParameterSpec getParams() { + return null; + } } diff --git a/src/share/classes/java/security/interfaces/RSAMultiPrimePrivateCrtKey.java b/src/share/classes/java/security/interfaces/RSAMultiPrimePrivateCrtKey.java index f85d96a768230b83910d0c820e774219c9e6ff6a..e9afe9cc9f2fe62f4742d7bf9b327898f30be3b1 100644 --- a/src/share/classes/java/security/interfaces/RSAMultiPrimePrivateCrtKey.java +++ b/src/share/classes/java/security/interfaces/RSAMultiPrimePrivateCrtKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * 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,8 +30,8 @@ import java.security.spec.RSAOtherPrimeInfo; /** * The interface to an RSA multi-prime private key, as defined in the - * PKCS#1 v2.1, using the Chinese Remainder Theorem - * (CRT) information values. + * PKCS#1 v2.2 standard, + * using the Chinese Remainder Theorem (CRT) information values. * * @author Valerie Peng * diff --git a/src/share/classes/java/security/interfaces/RSAPrivateCrtKey.java b/src/share/classes/java/security/interfaces/RSAPrivateCrtKey.java index 0408feabbbcde4a467575a12f8fbb529b1290e36..4b391c0888698124fed6a4e0a8e78ce263a800ff 100644 --- a/src/share/classes/java/security/interfaces/RSAPrivateCrtKey.java +++ b/src/share/classes/java/security/interfaces/RSAPrivateCrtKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved. * 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,7 +28,8 @@ package java.security.interfaces; import java.math.BigInteger; /** - * The interface to an RSA private key, as defined in the PKCS#1 standard, + * The interface to an RSA private key, as defined in the + * PKCS#1 v2.2 standard, * using the Chinese Remainder Theorem (CRT) information values. * * @author Jan Luehe diff --git a/src/share/classes/java/security/interfaces/package-info.java b/src/share/classes/java/security/interfaces/package-info.java index 54c9397e6914efe2caa711190762d67e5cc9a2d9..808224395d9c0af6de513feae35342787b4bf773 100644 --- a/src/share/classes/java/security/interfaces/package-info.java +++ b/src/share/classes/java/security/interfaces/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved. * 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,7 +52,7 @@ *

Package Specification

* *
    - *
  • PKCS #1: RSA Encryption Standard, Version 1.5, November 1993
  • + *
  • PKCS #1: RSA Cryptography Specifications, Version 2.2 (RFC 8017)
  • *
  • Federal Information Processing Standards Publication (FIPS PUB) 186: * Digital Signature Standard (DSS)
  • *
diff --git a/src/share/classes/java/security/spec/MGF1ParameterSpec.java b/src/share/classes/java/security/spec/MGF1ParameterSpec.java index 1be267f0ced658ad4f1f1d134345e37e6629df2b..3821b84b5c02c23e007f39385eaca1f1bebfcf53 100644 --- a/src/share/classes/java/security/spec/MGF1ParameterSpec.java +++ b/src/share/classes/java/security/spec/MGF1ParameterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * 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,23 +29,31 @@ import java.security.spec.AlgorithmParameterSpec; /** * This class specifies the set of parameters used with mask generation - * function MGF1 in OAEP Padding and RSA-PSS signature scheme, as + * function MGF1 in OAEP Padding and RSASSA-PSS signature scheme, as * defined in the - * PKCS #1 v2.1 - * standard. + * PKCS#1 v2.2 standard. * *

Its ASN.1 definition in PKCS#1 standard is described below: *

- * MGF1Parameters ::= OAEP-PSSDigestAlgorthms
+ * PKCS1MGFAlgorithms    ALGORITHM-IDENTIFIER ::= {
+ *   { OID id-mgf1 PARAMETERS HashAlgorithm },
+ *   ...  -- Allows for future expansion --
+ * }
  * 
* where *
+ * HashAlgorithm ::= AlgorithmIdentifier {
+ *   {OAEP-PSSDigestAlgorithms}
+ * }
+ *
  * OAEP-PSSDigestAlgorithms    ALGORITHM-IDENTIFIER ::= {
- *   { OID id-sha1 PARAMETERS NULL   }|
- *   { OID id-sha224 PARAMETERS NULL   }|
- *   { OID id-sha256 PARAMETERS NULL }|
- *   { OID id-sha384 PARAMETERS NULL }|
- *   { OID id-sha512 PARAMETERS NULL },
+ *   { OID id-sha1       PARAMETERS NULL }|
+ *   { OID id-sha224     PARAMETERS NULL }|
+ *   { OID id-sha256     PARAMETERS NULL }|
+ *   { OID id-sha384     PARAMETERS NULL }|
+ *   { OID id-sha512     PARAMETERS NULL }|
+ *   { OID id-sha512-224 PARAMETERS NULL }|
+ *   { OID id-sha512-256 PARAMETERS NULL },
  *   ...  -- Allows for future expansion --
  * }
  * 
@@ -59,31 +67,47 @@ import java.security.spec.AlgorithmParameterSpec; public class MGF1ParameterSpec implements AlgorithmParameterSpec { /** - * The MGF1ParameterSpec which uses "SHA-1" message digest. + * The MGF1ParameterSpec which uses "SHA-1" message digest */ public static final MGF1ParameterSpec SHA1 = new MGF1ParameterSpec("SHA-1"); + /** - * The MGF1ParameterSpec which uses "SHA-224" message digest. + * The MGF1ParameterSpec which uses "SHA-224" message digest */ public static final MGF1ParameterSpec SHA224 = new MGF1ParameterSpec("SHA-224"); + /** - * The MGF1ParameterSpec which uses "SHA-256" message digest. + * The MGF1ParameterSpec which uses "SHA-256" message digest */ public static final MGF1ParameterSpec SHA256 = new MGF1ParameterSpec("SHA-256"); + /** - * The MGF1ParameterSpec which uses "SHA-384" message digest. + * The MGF1ParameterSpec which uses "SHA-384" message digest */ public static final MGF1ParameterSpec SHA384 = new MGF1ParameterSpec("SHA-384"); + /** - * The MGF1ParameterSpec which uses SHA-512 message digest. + * The MGF1ParameterSpec which uses SHA-512 message digest */ public static final MGF1ParameterSpec SHA512 = new MGF1ParameterSpec("SHA-512"); + /** + * The MGF1ParameterSpec which uses SHA-512/224 message digest + */ + public static final MGF1ParameterSpec SHA512_224 = + new MGF1ParameterSpec("SHA-512/224"); + + /** + * The MGF1ParameterSpec which uses SHA-512/256 message digest + */ + public static final MGF1ParameterSpec SHA512_256 = + new MGF1ParameterSpec("SHA-512/256"); + private String mdName; /** diff --git a/src/share/classes/java/security/spec/PSSParameterSpec.java b/src/share/classes/java/security/spec/PSSParameterSpec.java index a9b82d8e42b5cb2c129817749bb236804cc5cc59..7e725d75905ca04d76ac22bbc2dfe7815cdcb86d 100644 --- a/src/share/classes/java/security/spec/PSSParameterSpec.java +++ b/src/share/classes/java/security/spec/PSSParameterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * 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,37 +25,42 @@ package java.security.spec; -import java.math.BigInteger; -import java.security.spec.MGF1ParameterSpec; +import java.util.Objects; /** - * This class specifies a parameter spec for RSA-PSS signature scheme, + * This class specifies a parameter spec for RSASSA-PSS signature scheme, * as defined in the - * PKCS#1 v2.1 - * standard. + * PKCS#1 v2.2 standard. * *

Its ASN.1 definition in PKCS#1 standard is described below: *

  * RSASSA-PSS-params ::= SEQUENCE {
- *   hashAlgorithm      [0] OAEP-PSSDigestAlgorithms  DEFAULT sha1,
- *   maskGenAlgorithm   [1] PKCS1MGFAlgorithms  DEFAULT mgf1SHA1,
- *   saltLength         [2] INTEGER  DEFAULT 20,
- *   trailerField       [3] INTEGER  DEFAULT 1
+ *   hashAlgorithm      [0] HashAlgorithm      DEFAULT sha1,
+ *   maskGenAlgorithm   [1] MaskGenAlgorithm   DEFAULT mgf1SHA1,
+ *   saltLength         [2] INTEGER            DEFAULT 20,
+ *   trailerField       [3] TrailerField       DEFAULT trailerFieldBC(1)
  * }
  * 
* where *
+ * HashAlgorithm ::= AlgorithmIdentifier {
+ *   {OAEP-PSSDigestAlgorithms}
+ * }
+ * MaskGenAlgorithm ::= AlgorithmIdentifier { {PKCS1MGFAlgorithms} }
+ * TrailerField ::= INTEGER { trailerFieldBC(1) }
+ *
  * OAEP-PSSDigestAlgorithms    ALGORITHM-IDENTIFIER ::= {
- *   { OID id-sha1 PARAMETERS NULL   }|
- *   { OID id-sha224 PARAMETERS NULL   }|
- *   { OID id-sha256 PARAMETERS NULL }|
- *   { OID id-sha384 PARAMETERS NULL }|
- *   { OID id-sha512 PARAMETERS NULL },
+ *   { OID id-sha1       PARAMETERS NULL }|
+ *   { OID id-sha224     PARAMETERS NULL }|
+ *   { OID id-sha256     PARAMETERS NULL }|
+ *   { OID id-sha384     PARAMETERS NULL }|
+ *   { OID id-sha512     PARAMETERS NULL }|
+ *   { OID id-sha512-224 PARAMETERS NULL }|
+ *   { OID id-sha512-256 PARAMETERS NULL },
  *   ...  -- Allows for future expansion --
  * }
- *
  * PKCS1MGFAlgorithms    ALGORITHM-IDENTIFIER ::= {
- *   { OID id-mgf1 PARAMETERS OAEP-PSSDigestAlgorithms },
+ *   { OID id-mgf1 PARAMETERS HashAlgorithm },
  *   ...  -- Allows for future expansion --
  * }
  * 
@@ -78,55 +83,62 @@ import java.security.spec.MGF1ParameterSpec; public class PSSParameterSpec implements AlgorithmParameterSpec { - private String mdName = "SHA-1"; - private String mgfName = "MGF1"; - private AlgorithmParameterSpec mgfSpec = MGF1ParameterSpec.SHA1; - private int saltLen = 20; - private int trailerField = 1; + private final String mdName; + + private final String mgfName; + + private final AlgorithmParameterSpec mgfSpec; + + private final int saltLen; + + private final int trailerField; /** - * The PSS parameter set with all default values. - * @since 1.5 + * The {@code TrailerFieldBC} constant as defined in PKCS#1 + * + * @since 8 */ - public static final PSSParameterSpec DEFAULT = new PSSParameterSpec(); + public static final int TRAILER_FIELD_BC = 1; /** - * Constructs a new {@code PSSParameterSpec} as defined in - * the PKCS #1 standard using the default values. + * The PSS parameter set with all default values + * + * @since 1.5 */ + public static final PSSParameterSpec DEFAULT = new PSSParameterSpec + ("SHA-1", "MGF1", MGF1ParameterSpec.SHA1, 20, TRAILER_FIELD_BC); + + + // disallowed private PSSParameterSpec() { + throw new RuntimeException("default constructor not allowed"); } + /** * Creates a new {@code PSSParameterSpec} as defined in * the PKCS #1 standard using the specified message digest, * mask generation function, parameters for mask generation * function, salt length, and trailer field values. * - * @param mdName the algorithm name of the hash function. - * @param mgfName the algorithm name of the mask generation - * function. - * @param mgfSpec the parameters for the mask generation - * function. If null is specified, null will be returned by - * getMGFParameters(). - * @param saltLen the length of salt. - * @param trailerField the value of the trailer field. - * @exception NullPointerException if {@code mdName}, - * or {@code mgfName} is null. - * @exception IllegalArgumentException if {@code saltLen} - * or {@code trailerField} is less than 0. + * @param mdName the algorithm name of the hash function + * @param mgfName the algorithm name of the mask generation function + * @param mgfSpec the parameters for the mask generation function. + * If null is specified, null will be returned by + * getMGFParameters(). + * @param saltLen the length of salt + * @param trailerField the value of the trailer field + * @exception NullPointerException if {@code mdName}, or {@code mgfName} + * is null + * @exception IllegalArgumentException if {@code saltLen} or + * {@code trailerField} is less than 0 * @since 1.5 */ public PSSParameterSpec(String mdName, String mgfName, - AlgorithmParameterSpec mgfSpec, - int saltLen, int trailerField) { - if (mdName == null) { - throw new NullPointerException("digest algorithm is null"); - } - if (mgfName == null) { - throw new NullPointerException("mask generation function " + - "algorithm is null"); - } + AlgorithmParameterSpec mgfSpec, int saltLen, int trailerField) { + Objects.requireNonNull(mdName, "digest algorithm is null"); + Objects.requireNonNull(mgfName, + "mask generation function algorithm is null"); if (saltLen < 0) { throw new IllegalArgumentException("negative saltLen value: " + saltLen); @@ -147,23 +159,19 @@ public class PSSParameterSpec implements AlgorithmParameterSpec { * using the specified salt length and other default values as * defined in PKCS#1. * - * @param saltLen the length of salt in bits to be used in PKCS#1 - * PSS encoding. + * @param saltLen the length of salt in bytes to be used in PKCS#1 + * PSS encoding * @exception IllegalArgumentException if {@code saltLen} is - * less than 0. + * less than 0 */ public PSSParameterSpec(int saltLen) { - if (saltLen < 0) { - throw new IllegalArgumentException("negative saltLen value: " + - saltLen); - } - this.saltLen = saltLen; + this("SHA-1", "MGF1", MGF1ParameterSpec.SHA1, saltLen, TRAILER_FIELD_BC); } /** * Returns the message digest algorithm name. * - * @return the message digest algorithm name. + * @return the message digest algorithm name * @since 1.5 */ public String getDigestAlgorithm() { @@ -173,7 +181,7 @@ public class PSSParameterSpec implements AlgorithmParameterSpec { /** * Returns the mask generation function algorithm name. * - * @return the mask generation function algorithm name. + * @return the mask generation function algorithm name * * @since 1.5 */ @@ -184,7 +192,7 @@ public class PSSParameterSpec implements AlgorithmParameterSpec { /** * Returns the parameters for the mask generation function. * - * @return the parameters for the mask generation function. + * @return the parameters for the mask generation function * @since 1.5 */ public AlgorithmParameterSpec getMGFParameters() { @@ -192,21 +200,31 @@ public class PSSParameterSpec implements AlgorithmParameterSpec { } /** - * Returns the salt length in bits. + * Returns the salt length in bytes. * - * @return the salt length. + * @return the salt length */ public int getSaltLength() { return saltLen; } /** - * Returns the value for the trailer field, i.e. bc in PKCS#1 v2.1. + * Returns the value for the trailer field. * - * @return the value for the trailer field, i.e. bc in PKCS#1 v2.1. + * @return the value for the trailer field * @since 1.5 */ 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/share/classes/java/security/spec/RSAKeyGenParameterSpec.java b/src/share/classes/java/security/spec/RSAKeyGenParameterSpec.java index a73c6cd46b71b75a62d1494f7c13277d78432020..014af6fe35c9b7f3b752b1c0ebd242af8e6d92b1 100644 --- a/src/share/classes/java/security/spec/RSAKeyGenParameterSpec.java +++ b/src/share/classes/java/security/spec/RSAKeyGenParameterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. * 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 @@ public class RSAKeyGenParameterSpec implements AlgorithmParameterSpec { private int keysize; private BigInteger publicExponent; + private AlgorithmParameterSpec keyParams; /** * The public-exponent value F0 = 3. @@ -55,15 +56,30 @@ public class RSAKeyGenParameterSpec implements AlgorithmParameterSpec { public static final BigInteger F4 = BigInteger.valueOf(65537); /** - * Constructs a new {@code RSAParameterSpec} object from the - * given keysize and public-exponent value. + * Constructs a new {@code RSAKeyGenParameterSpec} object from the + * given keysize, public-exponent value, and null key parameters. * * @param keysize the modulus size (specified in number of bits) * @param publicExponent the public exponent */ public RSAKeyGenParameterSpec(int keysize, BigInteger publicExponent) { + this(keysize, publicExponent, null); + } + + /** + * Constructs a new {@code RSAKeyGenParameterSpec} object from the + * given keysize, public-exponent value, and key parameters. + * + * @param keysize the modulus size (specified in number of bits) + * @param publicExponent the public exponent + * @param keyParams the key parameters, may be null + * @since 8 + */ + public RSAKeyGenParameterSpec(int keysize, BigInteger publicExponent, + AlgorithmParameterSpec keyParams) { this.keysize = keysize; this.publicExponent = publicExponent; + this.keyParams = keyParams; } /** @@ -83,4 +99,15 @@ public class RSAKeyGenParameterSpec implements AlgorithmParameterSpec { public BigInteger getPublicExponent() { return publicExponent; } + + /** + * Returns the parameters to be associated with key. + * + * @return the associated parameters, may be null if + * not present + * @since 8 + */ + public AlgorithmParameterSpec getKeyParams() { + return keyParams; + } } diff --git a/src/share/classes/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java b/src/share/classes/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java index a198e43a2e1947733a3019c9b3c1b3d533c54df9..f7bd8832a98da9bf6a41721ba5e9b9606f7b3d52 100644 --- a/src/share/classes/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java +++ b/src/share/classes/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * 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,11 +26,13 @@ package java.security.spec; import java.math.BigInteger; +import java.util.Objects; /** * This class specifies an RSA multi-prime private key, as defined in the - * PKCS#1 v2.1, using the Chinese Remainder Theorem (CRT) information - * values for efficiency. + * PKCS#1 v2.2 standard + * using the Chinese Remainder Theorem (CRT) information values + * for efficiency. * * @author Valerie Peng * @@ -57,34 +59,28 @@ public class RSAMultiPrimePrivateCrtKeySpec extends RSAPrivateKeySpec { private final RSAOtherPrimeInfo otherPrimeInfo[]; /** - * Creates a new {@code RSAMultiPrimePrivateCrtKeySpec} - * given the modulus, publicExponent, privateExponent, - * primeP, primeQ, primeExponentP, primeExponentQ, - * crtCoefficient, and otherPrimeInfo as defined in PKCS#1 v2.1. + * Creates a new {@code RSAMultiPrimePrivateCrtKeySpec}. * *

Note that the contents of {@code otherPrimeInfo} * are copied to protect against subsequent modification when * constructing this object. * - * @param modulus the modulus n. - * @param publicExponent the public exponent e. - * @param privateExponent the private exponent d. - * @param primeP the prime factor p of n. - * @param primeQ the prime factor q of n. - * @param primeExponentP this is d mod (p-1). - * @param primeExponentQ this is d mod (q-1). - * @param crtCoefficient the Chinese Remainder Theorem - * coefficient q-1 mod p. - * @param otherPrimeInfo triplets of the rest of primes, null can be - * specified if there are only two prime factors (p and q). - * @exception NullPointerException if any of the parameters, i.e. - * {@code modulus}, - * {@code publicExponent}, {@code privateExponent}, - * {@code primeP}, {@code primeQ}, - * {@code primeExponentP}, {@code primeExponentQ}, - * {@code crtCoefficient}, is null. - * @exception IllegalArgumentException if an empty, i.e. 0-length, - * {@code otherPrimeInfo} is specified. + * @param modulus the modulus n + * @param publicExponent the public exponent e + * @param privateExponent the private exponent d + * @param primeP the prime factor p of n + * @param primeQ the prime factor q of n + * @param primeExponentP this is d mod (p-1) + * @param primeExponentQ this is d mod (q-1) + * @param crtCoefficient the Chinese Remainder Theorem + * coefficient q-1 mod p + * @param otherPrimeInfo triplets of the rest of primes, null can be + * specified if there are only two prime factors + * (p and q) + * @throws NullPointerException if any of the specified parameters + * with the exception of {@code otherPrimeInfo} is null + * @throws IllegalArgumentException if an empty, i.e. 0-length, + * {@code otherPrimeInfo} is specified */ public RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus, BigInteger publicExponent, @@ -95,45 +91,67 @@ public class RSAMultiPrimePrivateCrtKeySpec extends RSAPrivateKeySpec { BigInteger primeExponentQ, BigInteger crtCoefficient, RSAOtherPrimeInfo[] otherPrimeInfo) { - super(modulus, privateExponent); - if (modulus == null) { - throw new NullPointerException("the modulus parameter must be " + - "non-null"); - } - if (publicExponent == null) { - throw new NullPointerException("the publicExponent parameter " + - "must be non-null"); - } - if (privateExponent == null) { - throw new NullPointerException("the privateExponent parameter " + - "must be non-null"); - } - if (primeP == null) { - throw new NullPointerException("the primeP parameter " + - "must be non-null"); - } - if (primeQ == null) { - throw new NullPointerException("the primeQ parameter " + - "must be non-null"); - } - if (primeExponentP == null) { - throw new NullPointerException("the primeExponentP parameter " + - "must be non-null"); - } - if (primeExponentQ == null) { - throw new NullPointerException("the primeExponentQ parameter " + - "must be non-null"); - } - if (crtCoefficient == null) { - throw new NullPointerException("the crtCoefficient parameter " + - "must be non-null"); - } - this.publicExponent = publicExponent; - this.primeP = primeP; - this.primeQ = primeQ; - this.primeExponentP = primeExponentP; - this.primeExponentQ = primeExponentQ; - this.crtCoefficient = crtCoefficient; + this(modulus, publicExponent, privateExponent, primeP, primeQ, + primeExponentP, primeExponentQ, crtCoefficient, otherPrimeInfo, + null); + } + + /** + * Creates a new {@code RSAMultiPrimePrivateCrtKeySpec} with additional + * key parameters. + * + *

Note that the contents of {@code otherPrimeInfo} + * are copied to protect against subsequent modification when + * constructing this object. + * + * @param modulus the modulus n + * @param publicExponent the public exponent e + * @param privateExponent the private exponent d + * @param primeP the prime factor p of n + * @param primeQ the prime factor q of n + * @param primeExponentP this is d mod (p-1) + * @param primeExponentQ this is d mod (q-1) + * @param crtCoefficient the Chinese Remainder Theorem coefficient + * q-1 mod p + * @param otherPrimeInfo triplets of the rest of primes, null can be + * specified if there are only two prime factors + * (p and q) + * @param keyParams the parameters associated with key + * @throws NullPointerException if any of the specified parameters + * with the exception of {@code otherPrimeInfo} and {@code keyParams} + * is null + * @throws IllegalArgumentException if an empty, i.e. 0-length, + * {@code otherPrimeInfo} is specified + * @since 8 + */ + public RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus, + BigInteger publicExponent, + BigInteger privateExponent, + BigInteger primeP, + BigInteger primeQ, + BigInteger primeExponentP, + BigInteger primeExponentQ, + BigInteger crtCoefficient, + RSAOtherPrimeInfo[] otherPrimeInfo, + AlgorithmParameterSpec keyParams) { + super(modulus, privateExponent, keyParams); + Objects.requireNonNull(modulus, + "the modulus parameter must be non-null"); + Objects.requireNonNull(privateExponent, + "the privateExponent parameter must be non-null"); + this.publicExponent = Objects.requireNonNull(publicExponent, + "the publicExponent parameter must be non-null"); + this.primeP = Objects.requireNonNull(primeP, + "the primeP parameter must be non-null"); + this.primeQ = Objects.requireNonNull(primeQ, + "the primeQ parameter must be non-null"); + this.primeExponentP = Objects.requireNonNull(primeExponentP, + "the primeExponentP parameter must be non-null"); + this.primeExponentQ = Objects.requireNonNull(primeExponentQ, + "the primeExponentQ parameter must be non-null"); + this.crtCoefficient = Objects.requireNonNull(crtCoefficient, + "the crtCoefficient parameter must be non-null"); + if (otherPrimeInfo == null) { this.otherPrimeInfo = null; } else if (otherPrimeInfo.length == 0) { @@ -202,8 +220,8 @@ public class RSAMultiPrimePrivateCrtKeySpec extends RSAPrivateKeySpec { * Returns a copy of the otherPrimeInfo or null if there are * only two prime factors (p and q). * - * @return the otherPrimeInfo. Returns a new array each - * time this method is called. + * @return the otherPrimeInfo. Returns a new array each time this method + * is called. */ public RSAOtherPrimeInfo[] getOtherPrimeInfo() { if (otherPrimeInfo == null) return null; diff --git a/src/share/classes/java/security/spec/RSAOtherPrimeInfo.java b/src/share/classes/java/security/spec/RSAOtherPrimeInfo.java index 10d8471765dc331b13e349bf6ddd6561ae45ee94..99b83a8859bde8592607eda269372ff94ef95307 100644 --- a/src/share/classes/java/security/spec/RSAOtherPrimeInfo.java +++ b/src/share/classes/java/security/spec/RSAOtherPrimeInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved. * 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,15 +29,16 @@ import java.math.BigInteger; /** * This class represents the triplet (prime, exponent, and coefficient) - * inside RSA's OtherPrimeInfo structure, as defined in the PKCS#1 v2.1. + * inside RSA's OtherPrimeInfo structure, as defined in the + * PKCS#1 v2.2 standard. * The ASN.1 syntax of RSA's OtherPrimeInfo is as follows: * *

  * OtherPrimeInfo ::= SEQUENCE {
- *   prime INTEGER,
- *   exponent INTEGER,
- *   coefficient INTEGER
- *   }
+ *   prime        INTEGER,
+ *   exponent     INTEGER,
+ *   coefficient  INTEGER
+ * }
  *
  * 
* diff --git a/src/share/classes/java/security/spec/RSAPrivateCrtKeySpec.java b/src/share/classes/java/security/spec/RSAPrivateCrtKeySpec.java index d0ba70be44308d6bb67631990f5527aba36cb247..f4d618b3842bfac3440b83532657b82b85b5760c 100644 --- a/src/share/classes/java/security/spec/RSAPrivateCrtKeySpec.java +++ b/src/share/classes/java/security/spec/RSAPrivateCrtKeySpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved. * 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,9 @@ package java.security.spec; import java.math.BigInteger; /** - * This class specifies an RSA private key, as defined in the PKCS#1 - * standard, using the Chinese Remainder Theorem (CRT) information values for - * efficiency. + * This class specifies an RSA private key, as defined in the + * PKCS#1 v2.2 standard, + * using the Chinese Remainder Theorem (CRT) information values for efficiency. * * @author Jan Luehe * @@ -52,13 +52,8 @@ public class RSAPrivateCrtKeySpec extends RSAPrivateKeySpec { private final BigInteger primeExponentQ; private final BigInteger crtCoefficient; - - /** - * Creates a new {@code RSAPrivateCrtKeySpec} - * given the modulus, publicExponent, privateExponent, - * primeP, primeQ, primeExponentP, primeExponentQ, and - * crtCoefficient as defined in PKCS#1. + * Creates a new {@code RSAPrivateCrtKeySpec}. * * @param modulus the modulus n * @param publicExponent the public exponent e @@ -78,7 +73,36 @@ public class RSAPrivateCrtKeySpec extends RSAPrivateKeySpec { BigInteger primeExponentP, BigInteger primeExponentQ, BigInteger crtCoefficient) { - super(modulus, privateExponent); + this(modulus, publicExponent, privateExponent, primeP, primeQ, + primeExponentP, primeExponentQ, crtCoefficient, null); + } + + /** + * Creates a new {@code RSAPrivateCrtKeySpec} with additional + * key parameters. + * + * @param modulus the modulus n + * @param publicExponent the public exponent e + * @param privateExponent the private exponent d + * @param primeP the prime factor p of n + * @param primeQ the prime factor q of n + * @param primeExponentP this is d mod (p-1) + * @param primeExponentQ this is d mod (q-1) + * @param crtCoefficient the Chinese Remainder Theorem + * coefficient q-1 mod p + * @param keyParams the parameters associated with key + * @since 8 + */ + public RSAPrivateCrtKeySpec(BigInteger modulus, + BigInteger publicExponent, + BigInteger privateExponent, + BigInteger primeP, + BigInteger primeQ, + BigInteger primeExponentP, + BigInteger primeExponentQ, + BigInteger crtCoefficient, + AlgorithmParameterSpec keyParams) { + super(modulus, privateExponent, keyParams); this.publicExponent = publicExponent; this.primeP = primeP; this.primeQ = primeQ; diff --git a/src/share/classes/java/security/spec/RSAPrivateKeySpec.java b/src/share/classes/java/security/spec/RSAPrivateKeySpec.java index e749146168420d467a554c6f25830f3debe46e53..2bb06c5868896b5388c70820713c6ef2370a698e 100644 --- a/src/share/classes/java/security/spec/RSAPrivateKeySpec.java +++ b/src/share/classes/java/security/spec/RSAPrivateKeySpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved. * 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,8 +43,9 @@ import java.math.BigInteger; public class RSAPrivateKeySpec implements KeySpec { - private BigInteger modulus; - private BigInteger privateExponent; + private final BigInteger modulus; + private final BigInteger privateExponent; + private final AlgorithmParameterSpec params; /** * Creates a new RSAPrivateKeySpec. @@ -53,8 +54,22 @@ public class RSAPrivateKeySpec implements KeySpec { * @param privateExponent the private exponent */ public RSAPrivateKeySpec(BigInteger modulus, BigInteger privateExponent) { + this(modulus, privateExponent, null); + } + + /** + * Creates a new RSAPrivateKeySpec with additional key parameters. + * + * @param modulus the modulus + * @param privateExponent the private exponent + * @param params the parameters associated with this key, may be null + * @since 8 + */ + public RSAPrivateKeySpec(BigInteger modulus, BigInteger privateExponent, + AlgorithmParameterSpec params) { this.modulus = modulus; this.privateExponent = privateExponent; + this.params = params; } /** @@ -74,4 +89,15 @@ public class RSAPrivateKeySpec implements KeySpec { public BigInteger getPrivateExponent() { return this.privateExponent; } + + /** + * Returns the parameters associated with this key, may be null if not + * present. + * + * @return the parameters associated with this key + * @since 8 + */ + public AlgorithmParameterSpec getParams() { + return this.params; + } } diff --git a/src/share/classes/java/security/spec/RSAPublicKeySpec.java b/src/share/classes/java/security/spec/RSAPublicKeySpec.java index 9a944f962b1841688d2b085c84becc27ae419379..b9ab224622774ad8168c076e2119cfd2ad54e6ec 100644 --- a/src/share/classes/java/security/spec/RSAPublicKeySpec.java +++ b/src/share/classes/java/security/spec/RSAPublicKeySpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved. * 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,8 +43,9 @@ import java.math.BigInteger; public class RSAPublicKeySpec implements KeySpec { - private BigInteger modulus; - private BigInteger publicExponent; + private final BigInteger modulus; + private final BigInteger publicExponent; + private final AlgorithmParameterSpec params; /** * Creates a new RSAPublicKeySpec. @@ -53,10 +54,25 @@ public class RSAPublicKeySpec implements KeySpec { * @param publicExponent the public exponent */ public RSAPublicKeySpec(BigInteger modulus, BigInteger publicExponent) { + this(modulus, publicExponent, null); + } + + /** + * Creates a new RSAPublicKeySpec with additional key parameters. + * + * @param modulus the modulus + * @param publicExponent the public exponent + * @param params the parameters associated with this key, may be null + * @since 8 + */ + public RSAPublicKeySpec(BigInteger modulus, BigInteger publicExponent, + AlgorithmParameterSpec params) { this.modulus = modulus; this.publicExponent = publicExponent; + this.params = params; } + /** * Returns the modulus. * @@ -74,4 +90,16 @@ public class RSAPublicKeySpec implements KeySpec { public BigInteger getPublicExponent() { return this.publicExponent; } + + /** + * Returns the parameters associated with this key, may be null if not + * present. + * + * @return the parameters associated with this key + * @since 8 + */ + public AlgorithmParameterSpec getParams() { + return this.params; + } + } diff --git a/src/share/classes/java/security/spec/package-info.java b/src/share/classes/java/security/spec/package-info.java index cb393088e5b5727eb4dcfa7244b3cc9c5506d6f7..ed99a20d4924bc5b02121ce3a21adf79da8d539b 100644 --- a/src/share/classes/java/security/spec/package-info.java +++ b/src/share/classes/java/security/spec/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved. * 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 @@ *

Package Specification

* *
    - *
  • PKCS #1: RSA Encryption Standard, Version 1.5, November 1993
  • + *
  • PKCS #1: RSA Cryptography Specifications, Version 2.2 (RFC 8017)
  • *
  • PKCS #8: Private-Key Information Syntax Standard, * Version 1.2, November 1993
  • *
  • Federal Information Processing Standards Publication (FIPS PUB) 186: diff --git a/src/share/classes/java/util/ArrayList.java b/src/share/classes/java/util/ArrayList.java index 133a39ac785b417ce95a720cde77db851143e6a2..48628a43050fd7555806c42724138595540a63c7 100644 --- a/src/share/classes/java/util/ArrayList.java +++ b/src/share/classes/java/util/ArrayList.java @@ -175,14 +175,16 @@ public class ArrayList extends AbstractList * @throws NullPointerException if the specified collection is null */ public ArrayList(Collection c) { - elementData = c.toArray(); - if ((size = elementData.length) != 0) { - // c.toArray might (incorrectly) not return Object[] (see 6260652) - if (elementData.getClass() != Object[].class) - elementData = Arrays.copyOf(elementData, size, Object[].class); + Object[] a = c.toArray(); + if ((size = a.length) != 0) { + if (c.getClass() == ArrayList.class) { + elementData = a; + } else { + elementData = Arrays.copyOf(a, size, Object[].class); + } } else { // replace with empty array. - this.elementData = EMPTY_ELEMENTDATA; + elementData = EMPTY_ELEMENTDATA; } } diff --git a/src/share/classes/java/util/PriorityQueue.java b/src/share/classes/java/util/PriorityQueue.java index e1e3dfb3f380be8adb8985bc2018f7f1833c1d5a..595dc18bb4c56c98749b22d36bf60dd8dc605609 100644 --- a/src/share/classes/java/util/PriorityQueue.java +++ b/src/share/classes/java/util/PriorityQueue.java @@ -254,8 +254,7 @@ public class PriorityQueue extends AbstractQueue private void initElementsFromCollection(Collection c) { Object[] a = c.toArray(); - // If c.toArray incorrectly doesn't return Object[], copy it. - if (a.getClass() != Object[].class) + if (c.getClass() != ArrayList.class) a = Arrays.copyOf(a, a.length, Object[].class); int len = a.length; if (len == 1 || this.comparator != null) diff --git a/src/share/classes/java/util/Scanner.java b/src/share/classes/java/util/Scanner.java index 68396488f1cf60c3ce4ff4b8863cc5c40ed8d860..76692c0490d9a65b3cb6a41d6e63f8dada1fee2d 100644 --- a/src/share/classes/java/util/Scanner.java +++ b/src/share/classes/java/util/Scanner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -425,7 +425,7 @@ public final class Scanner implements Iterator, Closeable { // here but what can we do? The final authority will be // whatever parse method is invoked, so ultimately the // Scanner will do the right thing - String digit = "((?i)["+radixDigits+"]|\\p{javaDigit})"; + String digit = "((?i)["+radixDigits+"\\p{javaDigit}])"; String groupedNumeral = "("+non0Digit+digit+"?"+digit+"?("+ groupSeparator+digit+digit+digit+")+)"; // digit++ is the possessive form which is necessary for reducing @@ -475,7 +475,7 @@ public final class Scanner implements Iterator, Closeable { private Pattern decimalPattern; private void buildFloatAndDecimalPattern() { // \\p{javaDigit} may not be perfect, see above - String digit = "([0-9]|(\\p{javaDigit}))"; + String digit = "(([0-9\\p{javaDigit}]))"; String exponent = "([eE][+-]?"+digit+"+)?"; String groupedNumeral = "("+non0Digit+digit+"?"+digit+"?("+ groupSeparator+digit+digit+digit+")+)"; @@ -1188,25 +1188,25 @@ public final class Scanner implements Iterator, Closeable { // These must be literalized to avoid collision with regex // metacharacters such as dot or parenthesis - groupSeparator = "\\" + dfs.getGroupingSeparator(); - decimalSeparator = "\\" + dfs.getDecimalSeparator(); + groupSeparator = "\\x{" + Integer.toHexString(dfs.getGroupingSeparator()) + "}"; + decimalSeparator = "\\x{" + Integer.toHexString(dfs.getDecimalSeparator()) + "}"; // Quoting the nonzero length locale-specific things // to avoid potential conflict with metacharacters - nanString = "\\Q" + dfs.getNaN() + "\\E"; - infinityString = "\\Q" + dfs.getInfinity() + "\\E"; + nanString = Pattern.quote(dfs.getNaN()); + infinityString = Pattern.quote(dfs.getInfinity()); positivePrefix = df.getPositivePrefix(); if (positivePrefix.length() > 0) - positivePrefix = "\\Q" + positivePrefix + "\\E"; + positivePrefix = Pattern.quote(positivePrefix); negativePrefix = df.getNegativePrefix(); if (negativePrefix.length() > 0) - negativePrefix = "\\Q" + negativePrefix + "\\E"; + negativePrefix = Pattern.quote(negativePrefix); positiveSuffix = df.getPositiveSuffix(); if (positiveSuffix.length() > 0) - positiveSuffix = "\\Q" + positiveSuffix + "\\E"; + positiveSuffix = Pattern.quote(positiveSuffix); negativeSuffix = df.getNegativeSuffix(); if (negativeSuffix.length() > 0) - negativeSuffix = "\\Q" + negativeSuffix + "\\E"; + negativeSuffix = Pattern.quote(negativeSuffix); // Force rebuilding and recompilation of locale dependent // primitive patterns diff --git a/src/share/classes/java/util/Vector.java b/src/share/classes/java/util/Vector.java index 733226f9e9128501dce2b673414ba59fb774c347..3837a338e143dcb4cf5cff194728a9dff33ce01a 100644 --- a/src/share/classes/java/util/Vector.java +++ b/src/share/classes/java/util/Vector.java @@ -171,11 +171,13 @@ public class Vector * @since 1.2 */ public Vector(Collection c) { - elementData = c.toArray(); - elementCount = elementData.length; - // c.toArray might (incorrectly) not return Object[] (see 6260652) - if (elementData.getClass() != Object[].class) - elementData = Arrays.copyOf(elementData, elementCount, Object[].class); + Object[] a = c.toArray(); + elementCount = a.length; + if (c.getClass() == ArrayList.class) { + elementData = a; + } else { + elementData = Arrays.copyOf(a, elementCount, Object[].class); + } } /** diff --git a/src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java b/src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java index 1f310ef48850e996f66582ec49915e222fee866f..f068640a3fd32ede407fd814ef33f9a5aa587b6d 100644 --- a/src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java +++ b/src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java @@ -34,6 +34,7 @@ package java.util.concurrent; import java.util.AbstractList; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Comparator; @@ -135,8 +136,7 @@ public class CopyOnWriteArrayList elements = ((CopyOnWriteArrayList)c).getArray(); else { elements = c.toArray(); - // c.toArray might (incorrectly) not return Object[] (see 6260652) - if (elements.getClass() != Object[].class) + if (c.getClass() != java.util.ArrayList.class) elements = Arrays.copyOf(elements, elements.length, Object[].class); } setArray(elements); @@ -762,6 +762,9 @@ public class CopyOnWriteArrayList */ public int addAllAbsent(Collection c) { Object[] cs = c.toArray(); + if (c.getClass() != ArrayList.class) { + cs = cs.clone(); + } if (cs.length == 0) return 0; final ReentrantLock lock = this.lock; @@ -822,9 +825,10 @@ public class CopyOnWriteArrayList try { Object[] elements = getArray(); int len = elements.length; - if (len == 0 && cs.getClass() == Object[].class) + if (len == 0 && (c.getClass() == CopyOnWriteArrayList.class || + c.getClass() == ArrayList.class)) { setArray(cs); - else { + } else { Object[] newElements = Arrays.copyOf(elements, len + cs.length); System.arraycopy(cs, 0, newElements, len, cs.length); setArray(newElements); diff --git a/src/share/classes/java/util/concurrent/ForkJoinWorkerThread.java b/src/share/classes/java/util/concurrent/ForkJoinWorkerThread.java index 8723f0aac6913afcb5b792505ed8098b1b7afd19..2444d09ec23b1c3af4bfa127aa40a4479c3733c7 100644 --- a/src/share/classes/java/util/concurrent/ForkJoinWorkerThread.java +++ b/src/share/classes/java/util/concurrent/ForkJoinWorkerThread.java @@ -73,6 +73,11 @@ public class ForkJoinWorkerThread extends Thread { final ForkJoinPool pool; // the pool this thread works in final ForkJoinPool.WorkQueue workQueue; // work-stealing mechanics + /** An AccessControlContext supporting no privileges */ + private static final AccessControlContext INNOCUOUS_ACC = + new AccessControlContext( + new ProtectionDomain[] { new ProtectionDomain(null, null) }); + /** * Creates a ForkJoinWorkerThread operating in the given pool. * @@ -82,6 +87,7 @@ public class ForkJoinWorkerThread extends Thread { protected ForkJoinWorkerThread(ForkJoinPool pool) { // Use a placeholder until a useful name can be set in registerWorker super("aForkJoinWorkerThread"); + U.putOrderedObject(this, INHERITEDACCESSCONTROLCONTEXT, INNOCUOUS_ACC); this.pool = pool; this.workQueue = pool.registerWorker(this); } @@ -215,13 +221,6 @@ public class ForkJoinWorkerThread extends Thread { private static final ThreadGroup innocuousThreadGroup = createThreadGroup(); - /** An AccessControlContext supporting no privileges */ - private static final AccessControlContext INNOCUOUS_ACC = - new AccessControlContext( - new ProtectionDomain[] { - new ProtectionDomain(null, null) - }); - InnocuousForkJoinWorkerThread(ForkJoinPool pool) { super(pool, innocuousThreadGroup, INNOCUOUS_ACC); } diff --git a/src/share/classes/java/util/concurrent/PriorityBlockingQueue.java b/src/share/classes/java/util/concurrent/PriorityBlockingQueue.java index d124a3ea9e5934508a11135e724244481feb0e83..268b21cae048dfabd2cf0fd7272c446ce28401f6 100644 --- a/src/share/classes/java/util/concurrent/PriorityBlockingQueue.java +++ b/src/share/classes/java/util/concurrent/PriorityBlockingQueue.java @@ -263,8 +263,7 @@ public class PriorityBlockingQueue extends AbstractQueue } Object[] a = c.toArray(); int n = a.length; - // If c.toArray incorrectly doesn't return Object[], copy it. - if (a.getClass() != Object[].class) + if (c.getClass() != java.util.ArrayList.class) a = Arrays.copyOf(a, n, Object[].class); if (screen && (n == 1 || this.comparator != null)) { for (int i = 0; i < n; ++i) diff --git a/src/share/classes/javax/crypto/Cipher.java b/src/share/classes/javax/crypto/Cipher.java index b18ce92c4dbbb8e6d528be65fbe6d654cc81206f..d3d09d7e2c6d5478c2b33f82ae90ab631d700987 100644 --- a/src/share/classes/javax/crypto/Cipher.java +++ b/src/share/classes/javax/crypto/Cipher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -317,11 +317,15 @@ public class Cipher { while (parser.hasMoreTokens() && count < 3) { parts[count++] = parser.nextToken().trim(); } - if (count == 0 || count == 2 || parser.hasMoreTokens()) { + if (count == 0 || count == 2) { throw new NoSuchAlgorithmException("Invalid transformation" + " format:" + transformation); } + // treats all subsequent tokens as part of padding + if (count == 3 && parser.hasMoreTokens()) { + parts[2] = parts[2] + parser.nextToken("\r\n"); + } } catch (NoSuchElementException e) { throw new NoSuchAlgorithmException("Invalid transformation " + "format:" + transformation); diff --git a/src/share/classes/javax/crypto/CipherSpi.java b/src/share/classes/javax/crypto/CipherSpi.java index 72bfa803bd53011705e5b76d81bbaf6714621886..a7335f01b26254b2da1842e58e90ac93e2c91c34 100644 --- a/src/share/classes/javax/crypto/CipherSpi.java +++ b/src/share/classes/javax/crypto/CipherSpi.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, 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 @@ -755,6 +755,7 @@ public abstract class CipherSpi { return 0; } int outLenNeeded = engineGetOutputSize(inLen); + if (output.remaining() < outLenNeeded) { throw new ShortBufferException("Need at least " + outLenNeeded + " bytes of space in output buffer"); @@ -762,98 +763,77 @@ public abstract class CipherSpi { boolean a1 = input.hasArray(); boolean a2 = output.hasArray(); - - if (a1 && a2) { - byte[] inArray = input.array(); - int inOfs = input.arrayOffset() + inPos; - byte[] outArray = output.array(); + int total = 0; + byte[] inArray, outArray; + if (a2) { // output has an accessible byte[] + outArray = output.array(); int outPos = output.position(); int outOfs = output.arrayOffset() + outPos; - int n; - if (isUpdate) { - n = engineUpdate(inArray, inOfs, inLen, outArray, outOfs); - } else { - n = engineDoFinal(inArray, inOfs, inLen, outArray, outOfs); - } - input.position(inLimit); - output.position(outPos + n); - return n; - } else if (!a1 && a2) { - int outPos = output.position(); - byte[] outArray = output.array(); - int outOfs = output.arrayOffset() + outPos; - byte[] inArray = new byte[getTempArraySize(inLen)]; - int total = 0; - do { - int chunk = Math.min(inLen, inArray.length); - if (chunk > 0) { - input.get(inArray, 0, chunk); - } - int n; - if (isUpdate || (inLen != chunk)) { - n = engineUpdate(inArray, 0, chunk, outArray, outOfs); + + if (a1) { // input also has an accessible byte[] + inArray = input.array(); + int inOfs = input.arrayOffset() + inPos; + if (isUpdate) { + total = engineUpdate(inArray, inOfs, inLen, outArray, outOfs); } else { - n = engineDoFinal(inArray, 0, chunk, outArray, outOfs); + total = engineDoFinal(inArray, inOfs, inLen, outArray, outOfs); } - total += n; - outOfs += n; - inLen -= chunk; - } while (inLen > 0); - output.position(outPos + total); - return total; - } else { // output is not backed by an accessible byte[] - byte[] inArray; - int inOfs; - if (a1) { - inArray = input.array(); - inOfs = input.arrayOffset() + inPos; - } else { + input.position(inLimit); + } else { // input does not have accessible byte[] inArray = new byte[getTempArraySize(inLen)]; - inOfs = 0; - } - byte[] outArray = new byte[getTempArraySize(outLenNeeded)]; - int outSize = outArray.length; - int total = 0; - boolean resized = false; - do { - int chunk = - Math.min(inLen, (outSize == 0? inArray.length : outSize)); - if (!a1 && !resized && chunk > 0) { - input.get(inArray, 0, chunk); - inOfs = 0; - } - try { + do { + int chunk = Math.min(inLen, inArray.length); + if (chunk > 0) { + input.get(inArray, 0, chunk); + } int n; - if (isUpdate || (inLen != chunk)) { - n = engineUpdate(inArray, inOfs, chunk, outArray, 0); + if (isUpdate || (inLen > chunk)) { + n = engineUpdate(inArray, 0, chunk, outArray, outOfs); } else { - n = engineDoFinal(inArray, inOfs, chunk, outArray, 0); + n = engineDoFinal(inArray, 0, chunk, outArray, outOfs); } - resized = false; - inOfs += chunk; + total += n; + outOfs += n; inLen -= chunk; - if (n > 0) { - output.put(outArray, 0, n); - total += n; - } - } catch (ShortBufferException e) { - if (resized) { - // we just resized the output buffer, but it still - // did not work. Bug in the provider, abort - throw (ProviderException)new ProviderException - ("Could not determine buffer size").initCause(e); - } - // output buffer is too small, realloc and try again - resized = true; - outSize = engineGetOutputSize(chunk); - outArray = new byte[outSize]; + } while (inLen > 0); + } + output.position(outPos + total); + } else { // output does not have an accessible byte[] + if (a1) { // but input has an accessible byte[] + inArray = input.array(); + int inOfs = input.arrayOffset() + inPos; + if (isUpdate) { + outArray = engineUpdate(inArray, inOfs, inLen); + } else { + outArray = engineDoFinal(inArray, inOfs, inLen); } - } while (inLen > 0); - if (a1) { input.position(inLimit); + if (outArray != null && outArray.length != 0) { + output.put(outArray); + total = outArray.length; + } + } else { // input also does not have an accessible byte[] + inArray = new byte[getTempArraySize(inLen)]; + do { + int chunk = Math.min(inLen, inArray.length); + if (chunk > 0) { + input.get(inArray, 0, chunk); + } + int n; + if (isUpdate || (inLen > chunk)) { + outArray = engineUpdate(inArray, 0, chunk); + } else { + outArray = engineDoFinal(inArray, 0, chunk); + } + if (outArray != null && outArray.length != 0) { + output.put(outArray); + total += outArray.length; + } + inLen -= chunk; + } while (inLen > 0); } - return total; } + return total; } /** diff --git a/src/share/classes/javax/crypto/spec/OAEPParameterSpec.java b/src/share/classes/javax/crypto/spec/OAEPParameterSpec.java index fcdc018cb6daa58948c4fed845684a7a31056b55..0b90452e6ef548fdc71c44e0f14e1218ed1f0d95 100644 --- a/src/share/classes/javax/crypto/spec/OAEPParameterSpec.java +++ b/src/share/classes/javax/crypto/spec/OAEPParameterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * 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,40 +32,53 @@ import java.security.spec.MGF1ParameterSpec; /** * This class specifies the set of parameters used with OAEP Padding, * as defined in the - * PKCS #1 - * standard. + * PKCS#1 v2.2 standard. * * Its ASN.1 definition in PKCS#1 standard is described below: *
      * RSAES-OAEP-params ::= SEQUENCE {
    - *   hashAlgorithm      [0] OAEP-PSSDigestAlgorithms     DEFAULT sha1,
    - *   maskGenAlgorithm   [1] PKCS1MGFAlgorithms  DEFAULT mgf1SHA1,
    - *   pSourceAlgorithm   [2] PKCS1PSourceAlgorithms  DEFAULT pSpecifiedEmpty
    + *   hashAlgorithm      [0] HashAlgorithm     DEFAULT sha1,
    + *   maskGenAlgorithm   [1] MaskGenAlgorithm  DEFAULT mgf1SHA1,
    + *   pSourceAlgorithm   [2] PSourceAlgorithm  DEFAULT pSpecifiedEmpty
      * }
      * 
    * where *
    + * HashAlgorithm ::= AlgorithmIdentifier {
    + *   {OAEP-PSSDigestAlgorithms}
    + * }
    + * MaskGenAlgorithm ::= AlgorithmIdentifier { {PKCS1MGFAlgorithms} }
    + * PSourceAlgorithm ::= AlgorithmIdentifier {
    + *   {PKCS1PSourceAlgorithms}
    + * }
    + *
      * OAEP-PSSDigestAlgorithms    ALGORITHM-IDENTIFIER ::= {
    - *   { OID id-sha1 PARAMETERS NULL   }|
    - *   { OID id-sha256 PARAMETERS NULL }|
    - *   { OID id-sha384 PARAMETERS NULL }|
    - *   { OID id-sha512 PARAMETERS NULL },
    + *   { OID id-sha1       PARAMETERS NULL }|
    + *   { OID id-sha224     PARAMETERS NULL }|
    + *   { OID id-sha256     PARAMETERS NULL }|
    + *   { OID id-sha384     PARAMETERS NULL }|
    + *   { OID id-sha512     PARAMETERS NULL }|
    + *   { OID id-sha512-224 PARAMETERS NULL }|
    + *   { OID id-sha512-256 PARAMETERS NULL },
      *   ...  -- Allows for future expansion --
      * }
      * PKCS1MGFAlgorithms    ALGORITHM-IDENTIFIER ::= {
    - *   { OID id-mgf1 PARAMETERS OAEP-PSSDigestAlgorithms },
    + *   { OID id-mgf1 PARAMETERS HashAlgorithm },
      *   ...  -- Allows for future expansion --
      * }
      * PKCS1PSourceAlgorithms    ALGORITHM-IDENTIFIER ::= {
    - *   { OID id-pSpecified PARAMETERS OCTET STRING },
    + *   { OID id-pSpecified PARAMETERS EncodingParameters },
      *   ...  -- Allows for future expansion --
      * }
    + * EncodingParameters ::= OCTET STRING(SIZE(0..MAX))
      * 
    *

    Note: the OAEPParameterSpec.DEFAULT uses the following: + *

      *     message digest  -- "SHA-1"
      *     mask generation function (mgf) -- "MGF1"
      *     parameters for mgf -- MGF1ParameterSpec.SHA1
      *     source of encoding input -- PSource.PSpecified.DEFAULT
    + * 
    * * @see java.security.spec.MGF1ParameterSpec * @see PSource diff --git a/src/share/classes/javax/crypto/spec/PSource.java b/src/share/classes/javax/crypto/spec/PSource.java index a3d2efe893098c45e76ca4af049c8ecafd38f9ce..0e5a6c88a9615a0b69f99b1cd081ba6d8738c4a9 100644 --- a/src/share/classes/javax/crypto/spec/PSource.java +++ b/src/share/classes/javax/crypto/spec/PSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * 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,13 +28,19 @@ package javax.crypto.spec; /** * This class specifies the source for encoding input P in OAEP Padding, * as defined in the - * PKCS #1 - * standard. + * PKCS#1 v2.2 standard. + *
    + * PSourceAlgorithm ::= AlgorithmIdentifier {
    + *   {PKCS1PSourceAlgorithms}
    + * }
    + * 
    + * where *
      * PKCS1PSourceAlgorithms    ALGORITHM-IDENTIFIER ::= {
    - *   { OID id-pSpecified PARAMETERS OCTET STRING },
    + *   { OID id-pSpecified PARAMETERS EncodingParameters },
      *   ...  -- Allows for future expansion --
      * }
    + * EncodingParameters ::= OCTET STRING(SIZE(0..MAX))
      * 
    * @author Valerie Peng * diff --git a/src/share/classes/javax/crypto/spec/package.html b/src/share/classes/javax/crypto/spec/package.html index b8fd80724dea3bddeb98356becc97fed69fd8ee6..fd4bac4b16b71cc5ea99d17faeef18b1ad7ebe73 100644 --- a/src/share/classes/javax/crypto/spec/package.html +++ b/src/share/classes/javax/crypto/spec/package.html @@ -1,5 +1,5 @@ + + + + + true + everyChunk + + + + true + 1000 ms + + + + true + everyChunk + + + + true + 1000 ms + + + + true + + + + true + + + + true + true + 20 ms + + + + true + true + 20 ms + + + + true + true + 20 ms + + + + true + true + 20 ms + + + + false + true + 20 ms + + + + true + true + 0 ms + + + + true + true + 0 ms + + + + true + true + 0 ms + + + + true + true + + + + false + true + 0 ms + + + + false + true + + + + false + + + + true + beginChunk + + + + true + beginChunk + + + + true + 20 ms + + + + true + 20 ms + + + + true + 10 ms + + + + false + 10 ms + + + + false + 10 ms + + + + false + 10 ms + + + + false + 10 ms + + + + false + 10 ms + + + + true + 10 ms + + + + true + true + + + + true + everyChunk + + + + true + beginChunk + + + + true + beginChunk + + + + true + beginChunk + + + + true + beginChunk + + + + true + beginChunk + + + + true + beginChunk + + + + true + beginChunk + + + + true + + + + true + + + + true + + + + true + + + + true + + + + true + + + + true + + + + false + everyChunk + + + + true + everyChunk + + + + true + beginChunk + + + + true + beginChunk + + + + true + beginChunk + + + + true + beginChunk + + + + false + + + + true + + + + true + + + + true + + + + true + + + + true + + + + true + true + + + + true + true + + + + true + + + + true + 0 ms + + + + true + 0 ms + + + + true + 0 ms + + + + true + 0 ms + + + + true + 0 ms + + + + true + 0 ms + + + + true + 0 ms + + + + true + 0 ms + + + + false + 0 ms + + + + false + 0 ms + + + + true + 0 ms + + + + true + + + + true + + + + true + + + + true + + + + true + + + + true + + + + true + + + + true + + + + true + + + + false + + + + false + + + + true + + + + false + true + + + + true + + + + false + everyChunk + + + + false + + + + true + false + 0 ns + + + + true + beginChunk + + + + true + 1000 ms + + + + true + 1000 ms + + + + true + 60 s + + + + false + + + + false + + + + true + beginChunk + + + + true + everyChunk + + + + true + 100 ms + + + + true + beginChunk + + + + true + everyChunk + + + + true + + + + true + beginChunk + + + + true + beginChunk + + + + true + 10 s + + + + true + 1000 ms + + + + true + 10 s + + + + true + beginChunk + + + + true + endChunk + + + + true + 5 s + + + + true + beginChunk + + + + true + everyChunk + + + + false + true + + + + false + true + + + + true + everyChunk + + + + true + true + 20 ms + + + + true + true + 20 ms + + + + true + true + 20 ms + + + + true + true + 20 ms + + + + true + true + 20 ms + + + + false + true + + + + true + true + + + + true + 1000 ms + + + + true + + + + true + + + + true + + + + true + + + + true + 10 ms + + + + true + 0 ms + + + + true + 10 ms + + + + true + 10 ms + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 20 ms + + 20 ms + + 20 ms + + false + + + + diff --git a/src/share/classes/jdk/jfr/conf/profile.jfc b/src/share/classes/jdk/jfr/conf/profile.jfc new file mode 100644 index 0000000000000000000000000000000000000000..a8e168bbeb2790ddeb7baa3e7d3b5c7c8ee61e69 --- /dev/null +++ b/src/share/classes/jdk/jfr/conf/profile.jfc @@ -0,0 +1,817 @@ + + + + + + + + true + everyChunk + + + + true + 1000 ms + + + + true + everyChunk + + + + true + 1000 ms + + + + true + + + + true + + + + true + true + 10 ms + + + + true + true + 10 ms + + + + true + true + 10 ms + + + + true + true + 10 ms + + + + true + true + 10 ms + + + + true + true + 0 ms + + + + true + true + 0 ms + + + + true + true + 0 ms + + + + true + true + + + + false + true + 0 ms + + + + false + true + + + + false + + + + true + beginChunk + + + + true + beginChunk + + + + true + 10 ms + + + + true + 10 ms + + + + true + 0 ms + + + + false + 0 ms + + + + false + 0 ms + + + + false + 0 ms + + + + false + 0 ms + + + + false + 0 ms + + + + true + 0 ms + + + + true + true + + + + true + 60 s + + + + true + beginChunk + + + + true + beginChunk + + + + true + beginChunk + + + + true + beginChunk + + + + true + beginChunk + + + + true + beginChunk + + + + true + beginChunk + + + + true + + + + true + + + + true + + + + true + + + + true + + + + true + + + + true + + + + false + everyChunk + + + + true + everyChunk + + + + true + beginChunk + + + + true + beginChunk + + + + true + beginChunk + + + + true + beginChunk + + + + false + + + + true + + + + true + + + + true + + + + true + + + + true + + + + true + true + + + + true + true + + + + true + + + + true + 0 ms + + + + true + 0 ms + + + + true + 0 ms + + + + true + 0 ms + + + + true + 0 ms + + + + true + 0 ms + + + + true + 0 ms + + + + true + 0 ms + + + + false + 0 ms + + + + false + 0 ms + + + + true + 0 ms + + + + true + + + + true + + + + true + + + + true + + + + true + + + + true + + + + true + + + + true + + + + true + + + + true + + + + true + + + + true + + + + false + true + + + + true + + + + false + everyChunk + + + + false + + + + true + true + 0 ns + + + + true + beginChunk + + + + true + 1000 ms + + + + true + 100 ms + + + + true + 10 s + + + + true + + + + false + + + + true + beginChunk + + + + true + everyChunk + + + + true + 100 ms + + + + true + beginChunk + + + + true + everyChunk + + + + true + + + + true + beginChunk + + + + true + beginChunk + + + + true + 10 s + + + + true + 1000 ms + + + + true + 10 s + + + + true + beginChunk + + + + true + endChunk + + + + true + 5 s + + + + true + beginChunk + + + + true + everyChunk + + + + true + true + + + + true + true + + + + true + everyChunk + + + + true + true + 10 ms + + + + true + true + 10 ms + + + + true + true + 10 ms + + + + true + true + 10 ms + + + + true + true + 10 ms + + + + false + true + + + + true + true + + + + true + 1000 ms + + + + true + + + + true + + + + true + + + + true + + + + true + 10 ms + + + + true + 0 ms + + + + 10 ms + true + + + + true + 10 ms + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 ms + + 10 ms + + 10 ms + + false + + + + diff --git a/src/share/classes/jdk/jfr/consumer/ChunkParser.java b/src/share/classes/jdk/jfr/consumer/ChunkParser.java new file mode 100644 index 0000000000000000000000000000000000000000..ee6e00d6ecda5ad35987879b5e35eb129a1d3b4c --- /dev/null +++ b/src/share/classes/jdk/jfr/consumer/ChunkParser.java @@ -0,0 +1,174 @@ +/* + * 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. 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.consumer; + +import java.io.IOException; +import java.util.Collection; +import java.util.List; + +import jdk.jfr.EventType; +import jdk.jfr.internal.LogLevel; +import jdk.jfr.internal.LogTag; +import jdk.jfr.internal.Logger; +import jdk.jfr.internal.MetadataDescriptor; +import jdk.jfr.internal.Type; +import jdk.jfr.internal.consumer.ChunkHeader; +import jdk.jfr.internal.consumer.RecordingInput; + +/** + * Parses a chunk. + * + */ +final class ChunkParser { + private static final long CONSTANT_POOL_TYPE_ID = 1; + private final RecordingInput input; + private final LongMap parsers; + private final ChunkHeader chunkHeader; + private final long absoluteChunkEnd; + private final MetadataDescriptor metadata; + private final LongMap typeMap; + private final TimeConverter timeConverter; + + public ChunkParser(RecordingInput input) throws IOException { + this(new ChunkHeader(input)); + } + + private ChunkParser(ChunkHeader header) throws IOException { + this.input = header.getInput(); + this.chunkHeader = header; + this.metadata = header.readMetadata(); + this.absoluteChunkEnd = header.getEnd(); + this.timeConverter = new TimeConverter(chunkHeader, metadata.getGMTOffset()); + + ParserFactory factory = new ParserFactory(metadata, timeConverter); + LongMap constantPools = factory.getConstantPools(); + parsers = factory.getParsers(); + typeMap = factory.getTypeMap(); + + fillConstantPools(parsers, constantPools); + constantPools.forEach(ConstantMap::setIsResolving); + constantPools.forEach(ConstantMap::resolve); + constantPools.forEach(ConstantMap::setResolved); + + input.position(chunkHeader.getEventStart()); + } + + public RecordedEvent readEvent() throws IOException { + while (input.position() < absoluteChunkEnd) { + long pos = input.position(); + int size = input.readInt(); + if (size == 0) { + throw new IOException("Event can't have zero size"); + } + long typeId = input.readLong(); + if (typeId > CONSTANT_POOL_TYPE_ID) { // also skips metadata (id=0) + Parser ep = parsers.get(typeId); + if (ep instanceof EventParser) { + return (RecordedEvent) ep.parse(input); + } + } + input.position(pos + size); + } + return null; + } + + private void fillConstantPools(LongMap typeParser, LongMap constantPools) throws IOException { + long nextCP = chunkHeader.getAbsoluteChunkStart(); + long deltaToNext = chunkHeader.getConstantPoolPosition(); + while (deltaToNext != 0) { + nextCP += deltaToNext; + input.position(nextCP); + final long position = nextCP; + int size = input.readInt(); // size + long typeId = input.readLong(); + if (typeId != CONSTANT_POOL_TYPE_ID) { + throw new IOException("Expected check point event (id = 1) at position " + nextCP + ", but found type id = " + typeId); + } + input.readLong(); // timestamp + input.readLong(); // duration + deltaToNext = input.readLong(); + final long delta = deltaToNext; + boolean flush = input.readBoolean(); + int poolCount = input.readInt(); + Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.TRACE, () -> { + return "New constant pool: startPosition=" + position + ", size=" + size + ", deltaToNext=" + delta + ", flush=" + flush + ", poolCount=" + poolCount; + }); + + for (int i = 0; i < poolCount; i++) { + long id = input.readLong(); // type id + ConstantMap pool = constantPools.get(id); + Type type = typeMap.get(id); + if (pool == null) { + Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Found constant pool(" + id + ") that is never used"); + if (type == null) { + throw new IOException("Error parsing constant pool type " + getName(id) + " at position " + input.position() + " at check point between [" + nextCP + ", " + nextCP + size + "]"); + } + pool = new ConstantMap(ObjectFactory.create(type, timeConverter), type.getName()); + constantPools.put(type.getId(), pool); + } + Parser parser = typeParser.get(id); + if (parser == null) { + throw new IOException("Could not find constant pool type with id = " + id); + } + try { + int count = input.readInt(); + Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.TRACE, () -> "Constant: " + getName(id) + "[" + count + "]"); + for (int j = 0; j < count; j++) { + long key = input.readLong(); + Object value = parser.parse(input); + pool.put(key, value); + } + } catch (Exception e) { + throw new IOException("Error parsing constant pool type " + getName(id) + " at position " + input.position() + " at check point between [" + nextCP + ", " + nextCP + size + "]", e); + } + } + if (input.position() != nextCP + size) { + throw new IOException("Size of check point event doesn't match content"); + } + } + } + + private String getName(long id) { + Type type = typeMap.get(id); + return type == null ? ("unknown(" + id + ")") : type.getName(); + } + + public Collection getTypes() { + return metadata.getTypes(); + } + + public List getEventTypes() { + return metadata.getEventTypes(); + } + + public boolean isLastChunk() { + return chunkHeader.isLastChunk(); + } + + public ChunkParser nextChunkParser() throws IOException { + return new ChunkParser(chunkHeader.nextHeader()); + } +} diff --git a/src/share/classes/jdk/jfr/consumer/ConstantMap.java b/src/share/classes/jdk/jfr/consumer/ConstantMap.java new file mode 100644 index 0000000000000000000000000000000000000000..4779e03d6f89702463029f739148ad327f54770b --- /dev/null +++ b/src/share/classes/jdk/jfr/consumer/ConstantMap.java @@ -0,0 +1,139 @@ +/* + * 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. 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.consumer; + +import java.util.ArrayList; +import java.util.List; + +/** + * Holds mapping between a set of keys and their corresponding object. + * + * If the type is a known type, i.e. {@link RecordedThread}, an + * {@link ObjectFactory} can be supplied which will instantiate a typed object. + */ +final class ConstantMap { + private final static class Reference { + private final long key; + private final ConstantMap pool; + + Reference(ConstantMap pool, long key) { + this.pool = pool; + this.key = key; + } + + Object resolve() { + return pool.get(key); + } + } + + private final ObjectFactory factory; + private final LongMap objects; + + private LongMap isResolving; + private boolean allResolved; + private String name; + + ConstantMap(ObjectFactory factory, String name) { + this.name = name; + this.objects = new LongMap<>(); + this.factory = factory; + } + + Object get(long id) { + // fast path, all objects in pool resolved + if (allResolved) { + return objects.get(id); + } + // referenced from a pool, deal with this later + if (isResolving == null) { + return new Reference(this, id); + } + + Boolean beingResolved = isResolving.get(id); + + // we are resolved (but not the whole pool) + if (Boolean.FALSE.equals(beingResolved)) { + return objects.get(id); + } + + // resolving ourself, abort to avoid infinite recursion + if (Boolean.TRUE.equals(beingResolved)) { + return null; + } + + // resolve me! + isResolving.put(id, Boolean.TRUE); + Object resolved = resolve(objects.get(id)); + isResolving.put(id, Boolean.FALSE); + if (factory != null) { + Object factorized = factory.createObject(id, resolved); + objects.put(id, factorized); + return factorized; + } else { + objects.put(id, resolved); + return resolved; + } + } + + private static Object resolve(Object o) { + if (o instanceof Reference) { + return resolve(((Reference) o).resolve()); + } + if (o != null && o.getClass().isArray()) { + final Object[] array = (Object[]) o; + for (int i = 0; i < array.length; i++) { + array[i] = resolve(array[i]); + } + return array; + } + return o; + } + + public void resolve() { + List keyList = new ArrayList<>(); + objects.keys().forEachRemaining(keyList::add); + for (Long l : keyList) { + get(l); + } + } + + public void put(long key, Object value) { + objects.put(key, value); + } + + public void setIsResolving() { + isResolving = new LongMap<>(); + } + + public void setResolved() { + allResolved = true; + isResolving = null; // pool finished, release memory + } + + public String getName() { + return name; + } +} diff --git a/src/share/classes/jdk/jfr/consumer/EventParser.java b/src/share/classes/jdk/jfr/consumer/EventParser.java new file mode 100644 index 0000000000000000000000000000000000000000..e1e679c898349b4dbfc12ae26619e5c609077239 --- /dev/null +++ b/src/share/classes/jdk/jfr/consumer/EventParser.java @@ -0,0 +1,72 @@ +/* + * 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. 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.consumer; + +import static jdk.jfr.internal.EventInstrumentation.FIELD_DURATION; + +import java.io.IOException; +import java.util.List; + +import jdk.jfr.EventType; +import jdk.jfr.ValueDescriptor; +import jdk.jfr.internal.consumer.RecordingInput; + +/** + * Parses an event and returns a {@link RecordedEvent}. + * + */ +final class EventParser extends Parser { + private final Parser[] parsers; + private final EventType eventType; + private final TimeConverter timeConverter; + private final boolean hasDuration; + private final List valueDescriptors; + + EventParser(TimeConverter timeConverter, EventType type, Parser[] parsers) { + this.timeConverter = timeConverter; + this.parsers = parsers; + this.eventType = type; + this.hasDuration = type.getField(FIELD_DURATION) != null; + this.valueDescriptors = type.getFields(); + } + + @Override + public Object parse(RecordingInput input) throws IOException { + Object[] values = new Object[parsers.length]; + for (int i = 0; i < parsers.length; i++) { + values[i] = parsers[i].parse(input); + } + Long startTicks = (Long) values[0]; + long startTime = timeConverter.convertTimestamp(startTicks); + if (hasDuration) { + long durationTicks = (Long) values[1]; + long endTime = timeConverter.convertTimestamp(startTicks + durationTicks); + return new RecordedEvent(eventType, valueDescriptors, values, startTime, endTime, timeConverter); + } else { + return new RecordedEvent(eventType, valueDescriptors, values, startTime, startTime, timeConverter); + } + } +} diff --git a/src/share/classes/jdk/jfr/consumer/LongMap.java b/src/share/classes/jdk/jfr/consumer/LongMap.java new file mode 100644 index 0000000000000000000000000000000000000000..65706e7bb75b6e418705b22a43f3a9032fe76834 --- /dev/null +++ b/src/share/classes/jdk/jfr/consumer/LongMap.java @@ -0,0 +1,61 @@ +/* + * 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. 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.consumer; + +import java.util.HashMap; +import java.util.Iterator; + +/** + * Commonly used data structure for looking up objects given an id (long value) + * + * TODO: Implement without using Map and Long objects, to minimize allocation + * + * @param + */ +final class LongMap implements Iterable { + private final HashMap map; + + LongMap() { + map = new HashMap<>(101); + } + + void put(long id, T object) { + map.put(id, object); + } + + T get(long id) { + return map.get(id); + } + + @Override + public Iterator iterator() { + return map.values().iterator(); + } + + Iterator keys() { + return map.keySet().iterator(); + } +} diff --git a/src/share/classes/jdk/jfr/consumer/ObjectFactory.java b/src/share/classes/jdk/jfr/consumer/ObjectFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..72fee3ed6973246590d1696a2f7a5f18c69051d3 --- /dev/null +++ b/src/share/classes/jdk/jfr/consumer/ObjectFactory.java @@ -0,0 +1,85 @@ +/* + * 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. 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.consumer; + +import java.util.List; + +import jdk.jfr.ValueDescriptor; +import jdk.jfr.internal.Type; + +/** + * Abstract factory for creating specialized types + */ +abstract class ObjectFactory { + + final static String TYPE_PREFIX_VERSION_1 = "com.oracle.jfr.types."; + final static String TYPE_PREFIX_VERSION_2 = Type.TYPES_PREFIX; + final static String STACK_FRAME_VERSION_1 = TYPE_PREFIX_VERSION_1 + "StackFrame"; + final static String STACK_FRAME_VERSION_2 = TYPE_PREFIX_VERSION_2 + "StackFrame"; + + public static ObjectFactory create(Type type, TimeConverter timeConverter) { + switch (type.getName()) { + case "java.lang.Thread": + return RecordedThread.createFactory(type, timeConverter); + case TYPE_PREFIX_VERSION_1 + "StackFrame": + case TYPE_PREFIX_VERSION_2 + "StackFrame": + return RecordedFrame.createFactory(type, timeConverter); + case TYPE_PREFIX_VERSION_1 + "Method": + case TYPE_PREFIX_VERSION_2 + "Method": + return RecordedMethod.createFactory(type, timeConverter); + case TYPE_PREFIX_VERSION_1 + "ThreadGroup": + case TYPE_PREFIX_VERSION_2 + "ThreadGroup": + return RecordedThreadGroup.createFactory(type, timeConverter); + case TYPE_PREFIX_VERSION_1 + "StackTrace": + case TYPE_PREFIX_VERSION_2 + "StackTrace": + return RecordedStackTrace.createFactory(type, timeConverter); + case TYPE_PREFIX_VERSION_1 + "ClassLoader": + case TYPE_PREFIX_VERSION_2 + "ClassLoader": + return RecordedClassLoader.createFactory(type, timeConverter); + case "java.lang.Class": + return RecordedClass.createFactory(type, timeConverter); + } + return null; + } + + private final List valueDescriptors; + + ObjectFactory(Type type) { + this.valueDescriptors = type.getFields(); + } + + T createObject(long id, Object value) { + if (value == null) { + return null; + } + if (value instanceof Object[]) { + return createTyped(valueDescriptors, id, (Object[]) value); + } + throw new InternalError("Object factory must have struct type"); + } + + abstract T createTyped(List valueDescriptors, long id, Object[] values); +} diff --git a/src/share/classes/jdk/jfr/consumer/Parser.java b/src/share/classes/jdk/jfr/consumer/Parser.java new file mode 100644 index 0000000000000000000000000000000000000000..572e37d3ac427e1241876e41455b7fa2dd25e98a --- /dev/null +++ b/src/share/classes/jdk/jfr/consumer/Parser.java @@ -0,0 +1,45 @@ +/* + * 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. 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.consumer; + +import java.io.IOException; + +import jdk.jfr.internal.consumer.RecordingInput; + +/** + * Base class for parsing data from a {@link RecordingInput}. + */ +abstract class Parser { + /** + * Parses data from a {@link RecordingInput} and return an object. + * + * @param input input to read from + * @return an object + * @throws IOException if operation couldn't be completed due to I/O + * problems + */ + abstract Object parse(RecordingInput input) throws IOException; +} diff --git a/src/share/classes/jdk/jfr/consumer/ParserFactory.java b/src/share/classes/jdk/jfr/consumer/ParserFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..4064e889d7ffcf7c4734056759d2cf08001ec9a0 --- /dev/null +++ b/src/share/classes/jdk/jfr/consumer/ParserFactory.java @@ -0,0 +1,303 @@ +/* + * 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. 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.consumer; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import jdk.jfr.EventType; +import jdk.jfr.ValueDescriptor; +import jdk.jfr.internal.MetadataDescriptor; +import jdk.jfr.internal.PrivateAccess; +import jdk.jfr.internal.Type; +import jdk.jfr.internal.consumer.RecordingInput; + +/** + * Class that create parsers suitable for reading events and constant pools + */ +final class ParserFactory { + private final LongMap parsers = new LongMap<>(); + private final TimeConverter timeConverter; + private final LongMap types = new LongMap<>(); + private final LongMap constantPools; + + public ParserFactory(MetadataDescriptor metadata, TimeConverter timeConverter) throws IOException { + this.constantPools = new LongMap<>(); + this.timeConverter = timeConverter; + for (Type t : metadata.getTypes()) { + types.put(t.getId(), t); + } + for (Type t : types) { + if (!t.getFields().isEmpty()) { // Avoid primitives + CompositeParser cp = createCompositeParser(t); + if (t.isSimpleType()) { // Reduce to nested parser + parsers.put(t.getId(), cp.parsers[0]); + } + + } + } + // Override event types with event parsers + for (EventType t : metadata.getEventTypes()) { + parsers.put(t.getId(), createEventParser(t)); + } + } + + public LongMap getParsers() { + return parsers; + } + + public LongMap getConstantPools() { + return constantPools; + } + + public LongMap getTypeMap() { + return types; + } + + private EventParser createEventParser(EventType eventType) throws IOException { + List parsers = new ArrayList(); + for (ValueDescriptor f : eventType.getFields()) { + parsers.add(createParser(f)); + } + return new EventParser(timeConverter, eventType, parsers.toArray(new Parser[0])); + } + + private Parser createParser(ValueDescriptor v) throws IOException { + boolean constantPool = PrivateAccess.getInstance().isConstantPool(v); + if (v.isArray()) { + Type valueType = PrivateAccess.getInstance().getType(v); + ValueDescriptor element = PrivateAccess.getInstance().newValueDescriptor(v.getName(), valueType, v.getAnnotationElements(), 0, constantPool, null); + return new ArrayParser(createParser(element)); + } + long id = v.getTypeId(); + Type type = types.get(id); + if (type == null) { + throw new IOException("Type '" + v.getTypeName() + "' is not defined"); + } + if (constantPool) { + ConstantMap pool = constantPools.get(id); + if (pool == null) { + pool = new ConstantMap(ObjectFactory.create(type, timeConverter), type.getName()); + constantPools.put(id, pool); + } + return new ConstantMapValueParser(pool); + } + Parser parser = parsers.get(id); + if (parser == null) { + if (!v.getFields().isEmpty()) { + return createCompositeParser(type); + } else { + return registerParserType(type, createPrimitiveParser(type)); + } + } + return parser; + } + + private Parser createPrimitiveParser(Type type) throws IOException { + switch (type.getName()) { + case "int": + return new IntegerParser(); + case "long": + return new LongParser(); + case "float": + return new FloatParser(); + case "double": + return new DoubleParser(); + case "char": + return new CharacterParser(); + case "boolean": + return new BooleanParser(); + case "short": + return new ShortParser(); + case "byte": + return new ByteParser(); + case "java.lang.String": + ConstantMap pool = new ConstantMap(ObjectFactory.create(type, timeConverter), type.getName()); + constantPools.put(type.getId(), pool); + return new StringParser(pool); + default: + throw new IOException("Unknown primitive type " + type.getName()); + } + } + + private Parser registerParserType(Type t, Parser parser) { + Parser p = parsers.get(t.getId()); + // check if parser exists (known type) + if (p != null) { + return p; + } + parsers.put(t.getId(), parser); + return parser; + } + + private CompositeParser createCompositeParser(Type type) throws IOException { + List vds = type.getFields(); + Parser[] parsers = new Parser[vds.size()]; + CompositeParser composite = new CompositeParser(parsers); + // need to pre-register so recursive types can be handled + registerParserType(type, composite); + + int index = 0; + for (ValueDescriptor vd : vds) { + parsers[index++] = createParser(vd); + } + return composite; + } + + private static final class BooleanParser extends Parser { + @Override + public Object parse(RecordingInput input) throws IOException { + return input.readBoolean() ? Boolean.TRUE : Boolean.FALSE; + } + } + + private static final class ByteParser extends Parser { + @Override + public Object parse(RecordingInput input) throws IOException { + return Byte.valueOf(input.readByte()); + } + } + + private static final class LongParser extends Parser { + @Override + public Object parse(RecordingInput input) throws IOException { + return Long.valueOf(input.readLong()); + } + } + + private static final class IntegerParser extends Parser { + @Override + public Object parse(RecordingInput input) throws IOException { + return Integer.valueOf(input.readInt()); + } + } + + private static final class ShortParser extends Parser { + @Override + public Object parse(RecordingInput input) throws IOException { + return Short.valueOf(input.readShort()); + } + } + + private static final class CharacterParser extends Parser { + @Override + public Object parse(RecordingInput input) throws IOException { + return Character.valueOf(input.readChar()); + } + } + + private static final class FloatParser extends Parser { + @Override + public Object parse(RecordingInput input) throws IOException { + return Float.valueOf(input.readFloat()); + } + } + + private static final class DoubleParser extends Parser { + @Override + public Object parse(RecordingInput input) throws IOException { + return Double.valueOf(input.readDouble()); + } + } + + private static final class StringParser extends Parser { + private final ConstantMap stringConstantMap; + private String last; + + StringParser(ConstantMap stringConstantMap) { + this.stringConstantMap = stringConstantMap; + } + + @Override + public Object parse(RecordingInput input) throws IOException { + String s = parseEncodedString(input); + if (!Objects.equals(s, last)) { + last = s; + } + return last; + } + + private String parseEncodedString(RecordingInput input) throws IOException { + byte encoding = input.readByte(); + if (encoding == RecordingInput.STRING_ENCODING_CONSTANT_POOL) { + long id = input.readLong(); + return (String) stringConstantMap.get(id); + } else { + return input.readEncodedString(encoding); + } + } + } + + private final static class ArrayParser extends Parser { + private final Parser elementParser; + + public ArrayParser(Parser elementParser) { + this.elementParser = elementParser; + } + + @Override + public Object parse(RecordingInput input) throws IOException { + final int size = input.readInt(); + final Object[] array = new Object[size]; + for (int i = 0; i < size; i++) { + array[i] = elementParser.parse(input); + } + return array; + } + } + + private final static class CompositeParser extends Parser { + private final Parser[] parsers; + + public CompositeParser(Parser[] valueParsers) { + this.parsers = valueParsers; + } + + @Override + public Object parse(RecordingInput input) throws IOException { + final Object[] values = new Object[parsers.length]; + for (int i = 0; i < values.length; i++) { + values[i] = parsers[i].parse(input); + } + return values; + } + } + + private static final class ConstantMapValueParser extends Parser { + private final ConstantMap pool; + + ConstantMapValueParser(ConstantMap pool) { + this.pool = pool; + } + + @Override + public Object parse(RecordingInput input) throws IOException { + return pool.get(input.readLong()); + } + } +} diff --git a/src/share/classes/jdk/jfr/consumer/RecordedClass.java b/src/share/classes/jdk/jfr/consumer/RecordedClass.java new file mode 100644 index 0000000000000000000000000000000000000000..66bca255411d1ffbf8034b94f52b3b021d23ec9f --- /dev/null +++ b/src/share/classes/jdk/jfr/consumer/RecordedClass.java @@ -0,0 +1,103 @@ +/* + * 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 + * 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.consumer; + +import java.lang.reflect.Modifier; +import java.util.List; + +import jdk.jfr.ValueDescriptor; +import jdk.jfr.internal.Type; + +/** + * A recorded Java type, such as a class or an interface. + * + * @since 8 + */ +public final class RecordedClass extends RecordedObject { + + static ObjectFactory createFactory(Type type, TimeConverter timeConverter) { + return new ObjectFactory(type) { + @Override + RecordedClass createTyped(List desc, long id, Object[] object) { + return new RecordedClass(desc, id, object, timeConverter); + } + }; + } + + private final long uniqueId; + + // package private + private RecordedClass(List descriptors, long id, Object[] values, TimeConverter timeConverter) { + super(descriptors, values, timeConverter); + this.uniqueId = id; + } + + /** + * Returns the modifiers of the class. + *

    + * See {@link java.lang.reflect.Modifier} + * + * @return the modifiers + * + * @see Modifier + */ + public int getModifiers() { + return getTyped("modifiers", Integer.class, -1); + } + + /** + * Returns the class loader that defined the class. + *

    + * If the bootstrap class loader is represented as {@code null} in the Java + * Virtual Machine (JVM), then {@code null} is also the return value of this method. + * + * @return the class loader defining this class, can be {@code null} + */ + public RecordedClassLoader getClassLoader() { + return getTyped("classLoader", RecordedClassLoader.class, null); + } + + /** + * Returns the fully qualified name of the class (for example, + * {@code "java.lang.String"}). + * + * @return the class name, not {@code null} + */ + public String getName() { + return getTyped("name", String.class, null).replace("/", "."); + } + + /** + * Returns a unique ID for the class. + *

    + * The ID might not be the same between Java Virtual Machine (JVM) instances. + * + * @return a unique ID + */ + public long getId() { + return uniqueId; + } +} diff --git a/src/share/classes/jdk/jfr/consumer/RecordedClassLoader.java b/src/share/classes/jdk/jfr/consumer/RecordedClassLoader.java new file mode 100644 index 0000000000000000000000000000000000000000..5103eece8f02b81c5e6de552d3c3746936a640b3 --- /dev/null +++ b/src/share/classes/jdk/jfr/consumer/RecordedClassLoader.java @@ -0,0 +1,90 @@ +/* + * 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 + * 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.consumer; + +import java.util.List; + +import jdk.jfr.ValueDescriptor; +import jdk.jfr.internal.Type; + +/** + * A recorded Java class loader. + * + * @since 8 + */ +public final class RecordedClassLoader extends RecordedObject { + + static ObjectFactory createFactory(Type type, TimeConverter timeConverter) { + return new ObjectFactory(type) { + @Override + RecordedClassLoader createTyped(List desc, long id, Object[] object) { + return new RecordedClassLoader(desc, id, object, timeConverter); + } + }; + } + + private final long uniqueId; + + // package private + private RecordedClassLoader(List descriptors, long id, Object[] values, TimeConverter timeConverter) { + super(descriptors, values, timeConverter); + this.uniqueId = id; + } + + /** + * Returns the class of the class loader. + *

    + * If the bootstrap class loader is represented as {@code null} in the Java + * Virtual Machine (JVM), then {@code null} is also the return value of this + * method. + * + * @return class of the class loader, can be {@code null} + */ + public RecordedClass getType() { + return getTyped("type", RecordedClass.class, null); + } + + /** + * Returns the name of the class loader (for example, "boot", "platform", and + * "app"). + * + * @return the class loader name, can be {@code null} + */ + public String getName() { + return getTyped("name", String.class, null); + } + + /** + * Returns a unique ID for the class loader. + *

    + * The ID might not be the same between Java Virtual Machine (JVM) instances. + * + * @return a unique ID + */ + public long getId() { + return uniqueId; + } +} diff --git a/src/share/classes/jdk/jfr/consumer/RecordedEvent.java b/src/share/classes/jdk/jfr/consumer/RecordedEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..1fe0edeb03baeb0f1923e8f1aa1daafec277069c --- /dev/null +++ b/src/share/classes/jdk/jfr/consumer/RecordedEvent.java @@ -0,0 +1,124 @@ +/* + * 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 + * 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.consumer; + +import java.time.Duration; +import java.time.Instant; +import java.util.List; + +import jdk.jfr.EventType; +import jdk.jfr.ValueDescriptor; +import jdk.jfr.internal.EventInstrumentation; + +/** + * A recorded event. + * + * @since 8 + */ +public final class RecordedEvent extends RecordedObject { + private final EventType eventType; + private final long startTime; + // package private needed for efficient sorting + final long endTime; + + // package private + RecordedEvent(EventType type, List vds, Object[] values, long startTime, long endTime, TimeConverter timeConverter) { + super(vds, values, timeConverter); + this.eventType = type; + this.startTime = startTime; + this.endTime = endTime; + } + + /** + * Returns the stack trace that was created when the event was committed, or + * {@code null} if the event lacks a stack trace. + * + * @return stack trace, or {@code null} if doesn't exist for the event + */ + public RecordedStackTrace getStackTrace() { + return getTyped(EventInstrumentation.FIELD_STACK_TRACE, RecordedStackTrace.class, null); + } + + /** + * Returns the thread from which the event was committed, or {@code null} if + * the thread was not recorded. + * + * @return thread, or {@code null} if doesn't exist for the event + */ + public RecordedThread getThread() { + return getTyped(EventInstrumentation.FIELD_EVENT_THREAD, RecordedThread.class, null); + } + + /** + * Returns the event type that describes the event. + * + * @return the event type, not {@code null} + */ + public EventType getEventType() { + return eventType; + } + + /** + * Returns the start time of the event. + *

    + * If the event is an instant event, then the start time and end time are the same. + * + * @return the start time, not {@code null} + */ + public Instant getStartTime() { + return Instant.ofEpochSecond(0, startTime); + } + + /** + * Returns the end time of the event. + *

    + * If the event is an instant event, then the start time and end time are the same. + * + * @return the end time, not {@code null} + */ + public Instant getEndTime() { + return Instant.ofEpochSecond(0, endTime); + } + + /** + * Returns the duration of the event, measured in nanoseconds. + * + * @return the duration in nanoseconds, not {@code null} + */ + public Duration getDuration() { + return Duration.ofNanos(endTime - startTime); + } + + /** + * Returns the list of descriptors that describes the fields of the event. + * + * @return descriptors, not {@code null} + */ + @Override + public List getFields() { + return getEventType().getFields(); + } +} diff --git a/src/share/classes/jdk/jfr/consumer/RecordedFrame.java b/src/share/classes/jdk/jfr/consumer/RecordedFrame.java new file mode 100644 index 0000000000000000000000000000000000000000..c541d01cf92446baa5b1442a314493551dd64a00 --- /dev/null +++ b/src/share/classes/jdk/jfr/consumer/RecordedFrame.java @@ -0,0 +1,113 @@ +/* + * 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 + * 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.consumer; + +import java.lang.reflect.Modifier; +import java.util.List; + +import jdk.jfr.ValueDescriptor; +import jdk.jfr.internal.Type; + +/** + * A recorded frame in a stack trace. + * + * @since 8 + */ +public final class RecordedFrame extends RecordedObject { + + static ObjectFactory createFactory(Type type, TimeConverter timeConverter) { + return new ObjectFactory(type) { + @Override + RecordedFrame createTyped(List desc, long id, Object[] object) { + return new RecordedFrame(desc, object, timeConverter); + } + }; + } + + // package private + RecordedFrame(List desc, Object[] objects, TimeConverter timeConverter) { + super(desc, objects, timeConverter); + } + + /** + * Returns {@code true} if this is a Java frame, {@code false} otherwise. + *

    + * A Java method that has a native modifier is considered a Java frame. + * + * @return {@code true} if this is a Java frame, {@code false} otherwise + * + * @see Modifier#isNative(int) + */ + public boolean isJavaFrame() { + // Only Java frames exist today, but this allows + // API to be extended for native frame in the future. + if (hasField("javaFrame")) { + return getTyped("javaFrame", Boolean.class, Boolean.TRUE); + } + return true; + } + + /** + * Returns the bytecode index for the execution point that is represented by + * this recorded frame. + * + * @return byte code index, or {@code -1} if doesn't exist + */ + public int getBytecodeIndex() { + return getTyped("bytecodeIndex", Integer.class, Integer.valueOf(-1)); + } + + /** + * Returns the line number for the execution point that is represented by this + * recorded frame, or {@code -1} if doesn't exist + * + * @return the line number, or {@code -1} if doesn't exist + */ + public int getLineNumber() { + return getTyped("lineNumber", Integer.class, Integer.valueOf(-1)); + } + + /** + * Returns the frame type for the execution point that is represented by this + * recorded frame (for example, {@code "Interpreted"}, {@code "JIT compiled"} or + * {@code "Inlined"}). + * + * @return the frame type, or {@code null} if doesn't exist + */ + public String getType() { + return getTyped("type", String.class, null); + } + + /** + * Returns the method for the execution point that is represented by this + * recorded frame. + * + * @return the method, not {@code null} + */ + public RecordedMethod getMethod() { + return getTyped("method", RecordedMethod.class, null); + } +} diff --git a/src/share/classes/jdk/jfr/consumer/RecordedMethod.java b/src/share/classes/jdk/jfr/consumer/RecordedMethod.java new file mode 100644 index 0000000000000000000000000000000000000000..3f20d3d1b3e5059acba499699c19db48dade6843 --- /dev/null +++ b/src/share/classes/jdk/jfr/consumer/RecordedMethod.java @@ -0,0 +1,120 @@ +/* + * 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 + * 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.consumer; + +import java.lang.reflect.Modifier; +import java.util.List; + +import jdk.jfr.ValueDescriptor; +import jdk.jfr.internal.Type; + +/** + * A recorded method. + * + * @since 8 + */ +public final class RecordedMethod extends RecordedObject { + + static ObjectFactory createFactory(Type type, TimeConverter timeConverter) { + return new ObjectFactory(type) { + @Override + RecordedMethod createTyped(List desc, long id, Object[] object) { + return new RecordedMethod(desc, object, timeConverter); + } + }; + } + + private RecordedMethod(List descriptors, Object[] objects, TimeConverter timeConverter) { + super(descriptors, objects, timeConverter); + } + + /** + * Returns the class this method belongs to, if it belong to a Java frame. + *

    + * To ensure this is a Java frame, use the {@link RecordedFrame#isJavaFrame()} + * method. + * + * @return the class, may be {@code null} if not a Java frame + * + * @see RecordedFrame#isJavaFrame() + */ + public RecordedClass getType() { + return getTyped("type", RecordedClass.class, null); + } + + /** + * Returns the name of this method, for example {@code "toString"}. + *

    + * If this method doesn't belong to a Java frame the result is undefined. + * + * @return method name, or {@code null} if doesn't exist + * + * @see RecordedFrame#isJavaFrame() + */ + public String getName() { + return getTyped("name", String.class, null); + } + + /** + * Returns the method descriptor for this method (for example, + * {@code "(Ljava/lang/String;)V"}). + *

    + * See Java Virtual Machine Specification, 4.3 + *

    + * If this method doesn't belong to a Java frame then the the result is undefined. + * + * @return method descriptor. + * + * @see RecordedFrame#isJavaFrame() + */ + public String getDescriptor() { + return getTyped("descriptor", String.class, null); + } + + /** + * Returns the modifiers for this method. + *

    + * If this method doesn't belong to a Java frame, then the result is undefined. + * + * @return the modifiers + * + * @see Modifier + * @see RecordedFrame#isJavaFrame + */ + public int getModifiers() { + return getTyped("modifiers", Integer.class, Integer.valueOf(0)); + } + + /** + * Returns whether this method is hidden (for example, wrapper code in a lambda + * expressions). + * + * @return {@code true} if method is hidden, {@code false} otherwise + */ + public boolean isHidden() { + return getTyped("hidden", Boolean.class, Boolean.FALSE); + } +} diff --git a/src/share/classes/jdk/jfr/consumer/RecordedObject.java b/src/share/classes/jdk/jfr/consumer/RecordedObject.java new file mode 100644 index 0000000000000000000000000000000000000000..d2f896e6acc93bdd64156958754394f2f51ca258 --- /dev/null +++ b/src/share/classes/jdk/jfr/consumer/RecordedObject.java @@ -0,0 +1,903 @@ +/* + * 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 + * 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.consumer; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.time.Duration; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.util.List; +import java.util.Objects; + +import jdk.jfr.Timespan; +import jdk.jfr.Timestamp; +import jdk.jfr.ValueDescriptor; +import jdk.jfr.internal.PrivateAccess; +import jdk.jfr.internal.tool.PrettyWriter; + +/** + * A complex data type that consists of one or more fields. + *

    + * This class provides methods to select and query nested objects by passing a + * dot {@code "."} delimited {@code String} object (for instance, + * {@code "aaa.bbb"}). A method evaluates a nested object from left to right, + * and if a part is {@code null}, it throws {@code NullPointerException}. + * + * @since 8 + */ +public class RecordedObject { + + private final static class UnsignedValue { + private final Object o; + + UnsignedValue(Object o) { + this.o = o; + } + + Object value() { + return o; + } + } + + private final Object[] objects; + private final List descriptors; + private final TimeConverter timeConverter; + + // package private, not to be subclassed outside this package + RecordedObject(List descriptors, Object[] objects, TimeConverter timeConverter) { + this.descriptors = descriptors; + this.objects = objects; + this.timeConverter = timeConverter; + } + + // package private + final T getTyped(String name, Class clazz, T defaultValue) { + // Unnecessary to check field presence twice, but this + // will do for now. + if (!hasField(name)) { + return defaultValue; + } + T object = getValue(name); + if (object == null || object.getClass().isAssignableFrom(clazz)) { + return object; + } else { + return defaultValue; + } + } + + /** + * Returns {@code true} if a field with the given name exists, {@code false} + * otherwise. + * + * @param name name of the field to get, not {@code null} + * + * @return {@code true} if the field exists, {@code false} otherwise. + * + * @see #getFields() + */ + public boolean hasField(String name) { + Objects.requireNonNull(name); + for (ValueDescriptor v : descriptors) { + if (v.getName().equals(name)) { + return true; + } + } + int dotIndex = name.indexOf("."); + if (dotIndex > 0) { + String structName = name.substring(0, dotIndex); + for (ValueDescriptor v : descriptors) { + if (!v.getFields().isEmpty() && v.getName().equals(structName)) { + RecordedObject child = getValue(structName); + if (child != null) { + return child.hasField(name.substring(dotIndex + 1)); + } + } + } + } + return false; + } + + /** + * Returns the value of the field with the given name. + *

    + * The return type may be a primitive type or a subclass of + * {@link RecordedObject}. + *

    + * It's possible to index into a nested object by using {@code "."} (for + * instance {@code "thread.group.parent.name}"). + *

    + * A field might change or be removed in a future JDK release. A best practice + * for callers of this method is to validate the field before attempting access. + *

    + * Example + * + *

    +     * 
    +     * if (event.hasField("intValue")) {
    +     *   int intValue = event.getValue("intValue");
    +     *   System.out.println("Int value: " + intValue);
    +     * }
    +     *
    +     * if (event.hasField("objectClass")) {
    +     *   RecordedClass clazz = event.getValue("objectClass");
    +     *   System.out.println("Class name: " + clazz.getName());
    +     * }
    +     *
    +     * if (event.hasField("sampledThread")) {
    +     *   RecordedThread sampledThread = event.getValue("sampledThread");
    +     *   System.out.println("Sampled thread: " + sampledThread.getName());
    +     * }
    +     * 
    +     * 
    + * + * @param the return type + * @param name of the field to get, not {@code null} + * @throws IllegalArgumentException if no field called {@code name} exists + * + * @return the value, can be {@code null} + * + * @see #hasField(String) + * + */ + final public T getValue(String name) { + @SuppressWarnings("unchecked") + T t = (T) getValue(name, false); + return t; + } + + private Object getValue(String name, boolean allowUnsigned) { + Objects.requireNonNull(name); + int index = 0; + for (ValueDescriptor v : descriptors) { + if (name.equals(v.getName())) { + Object object = objects[index]; + if (object == null) { + // error or missing + return null; + } + if (v.getFields().isEmpty()) { + if (allowUnsigned && PrivateAccess.getInstance().isUnsigned(v)) { + // Types that are meaningless to widen + if (object instanceof Character || object instanceof Long) { + return object; + } + return new UnsignedValue(object); + } + return object; // primitives and primitive arrays + } else { + if (object instanceof RecordedObject) { + // known types from factory + return object; + } + // must be array type + Object[] array = (Object[]) object; + if (v.isArray()) { + // struct array + return structifyArray(v, array, 0); + } + // struct + return new RecordedObject(v.getFields(), (Object[]) object, timeConverter); + } + } + index++; + } + + int dotIndex = name.indexOf("."); + if (dotIndex > 0) { + String structName = name.substring(0, dotIndex); + for (ValueDescriptor v : descriptors) { + if (!v.getFields().isEmpty() && v.getName().equals(structName)) { + RecordedObject child = getValue(structName); + String subName = name.substring(dotIndex + 1); + if (child != null) { + return child.getValue(subName, allowUnsigned); + } else { + // Call getValueDescriptor to trigger IllegalArgumentException if the name is + // incorrect. Type can't be validate due to type erasure + getValueDescriptor(v.getFields(), subName, null); + throw new NullPointerException("Field value for \"" + structName + "\" was null. Can't access nested field \"" + subName + "\""); + } + } + } + } + throw new IllegalArgumentException("Could not find field with name " + name); + } + + // Returns the leaf value descriptor matches both name or value, or throws an + // IllegalArgumentException + private ValueDescriptor getValueDescriptor(List descriptors, String name, String leafType) { + int dotIndex = name.indexOf("."); + if (dotIndex > 0) { + String first = name.substring(0, dotIndex); + String second = name.substring(dotIndex + 1); + for (ValueDescriptor v : descriptors) { + if (v.getName().equals(first)) { + List fields = v.getFields(); + if (!fields.isEmpty()) { + return getValueDescriptor(v.getFields(), second, leafType); + } + } + } + throw new IllegalArgumentException("Attempt to get unknown field \"" + first + "\""); + } + for (ValueDescriptor v : descriptors) { + if (v.getName().equals(name)) { + if (leafType != null && !v.getTypeName().equals(leafType)) { + throw new IllegalArgumentException("Attempt to get " + v.getTypeName() + " field \"" + name + "\" with illegal data type conversion " + leafType); + } + return v; + } + } + throw new IllegalArgumentException("\"Attempt to get unknown field \"" + name + "\""); + } + + // Gets a value, but checks that type and name is correct first + // This is to prevent a call to getString on a thread field, that is + // null to succeed. + private T getTypedValue(String name, String typeName) { + Objects.requireNonNull(name); + // Validate name and type first + getValueDescriptor(descriptors, name, typeName); + return getValue(name); + } + + private Object[] structifyArray(ValueDescriptor v, Object[] array, int dimension) { + if (array == null) { + return null; + } + Object[] structArray = new Object[array.length]; + for (int i = 0; i < structArray.length; i++) { + Object arrayElement = array[i]; + if (dimension == 0) { + // No general way to handle structarrays + // without invoking ObjectFactory for every instance (which may require id) + if (isStackFrameType(v.getTypeName())) { + structArray[i] = new RecordedFrame(v.getFields(), (Object[]) arrayElement, timeConverter); + } else { + structArray[i] = new RecordedObject(v.getFields(), (Object[]) arrayElement, timeConverter); + } + } else { + structArray[i] = structifyArray(v, (Object[]) arrayElement, dimension - 1); + } + } + return structArray; + } + + private boolean isStackFrameType(String typeName) { + if (ObjectFactory.STACK_FRAME_VERSION_1.equals(typeName)) { + return true; + } + if (ObjectFactory.STACK_FRAME_VERSION_2.equals(typeName)) { + return true; + } + return false; + } + + /** + * Returns an immutable list of the fields for this object. + * + * @return the fields, not {@code null} + */ + public List getFields() { + return descriptors; + } + + /** + * Returns the value of a field of type {@code boolean}. + *

    + * It's possible to index into a nested object using {@code "."} (for example, + * {@code "aaa.bbb"}). + *

    + * A field might change or be removed in a future JDK release. A best practice + * for callers of this method is to validate the field before attempting access. + * + * @param name name of the field to get, not {@code null} + * + * @return the value of the field, {@code true} or {@code false} + * + * @throws IllegalArgumentException if the field doesn't exist, or the field is + * not of type {@code boolean} + * + * @see #hasField(String) + * @see #getValue(String) + */ + public final boolean getBoolean(String name) { + Object o = getValue(name); + if (o instanceof Boolean) { + return ((Boolean) o).booleanValue(); + } + throw newIllegalArgumentException(name, "boolean"); + } + + /** + * Returns the value of a field of type {@code byte}. + *

    + * It's possible to index into a nested object using {@code "."} (for example, + * {@code "foo.bar"}). + *

    + * A field might change or be removed in a future JDK release. A best practice + * for callers of this method is to validate the field before attempting access. + * + * @param name of the field to get, not {@code null} + * + * @return the value of the field + * + * @throws IllegalArgumentException if the field doesn't exist, or the field is + * not of type {@code byte} + * + * @see #hasField(String) + * @see #getValue(String) + */ + public final byte getByte(String name) { + Object o = getValue(name); + if (o instanceof Byte) { + return ((Byte) o).byteValue(); + } + throw newIllegalArgumentException(name, "byte"); + } + + /** + * Returns the value of a field of type {@code char}. + *

    + * It's possible to index into a nested object using {@code "."} (for example, + * {@code "aaa.bbb"}). + *

    + * A field might change or be removed in a future JDK release. A best practice + * for callers of this method is to validate the field before attempting access. + * + * @param name of the field to get, not {@code null} + * + * @return the value of the field as a {@code char} + * + * @throws IllegalArgumentException if the field doesn't exist, or the field is + * not of type {@code char} + * + * @see #hasField(String) + * @see #getValue(String) + */ + public final char getChar(String name) { + Object o = getValue(name); + if (o instanceof Character) { + return ((Character) o).charValue(); + } + + throw newIllegalArgumentException(name, "char"); + } + + /** + * Returns the value of a field of type {@code short} or of another primitive + * type convertible to type {@code short} by a widening conversion. + *

    + * This method can be used on the following types: {@code short} and {@code byte}. + *

    + * If the field has the {@code @Unsigned} annotation and is of a narrower type + * than {@code short}, then the value is returned as an unsigned. + *

    + * It's possible to index into a nested object using {@code "."} (for example, + * {@code "aaa.bbb"}). + *

    + * A field might change or be removed in a future JDK release. A best practice + * for callers of this method is to validate the field before attempting access. + * + * @param name of the field to get, not {@code null} + * + * @return the value of the field converted to type {@code short} + * + * @throws IllegalArgumentException if the field doesn't exist, or the field + * value can't be converted to the type {@code short} by a widening + * conversion + * + * @see #hasField(String) + * @set #getValue(String) + */ + public final short getShort(String name) { + Object o = getValue(name, true); + if (o instanceof Short) { + return ((Short) o).shortValue(); + } + if (o instanceof Byte) { + return ((Byte) o).byteValue(); + } + if (o instanceof UnsignedValue) { + Object u = ((UnsignedValue) o).value(); + if (u instanceof Short) { + return ((Short) u).shortValue(); + } + if (u instanceof Byte) { + return (short) Byte.toUnsignedInt(((Byte) u)); + } + } + throw newIllegalArgumentException(name, "short"); + } + + /** + * Returns the value of a field of type {@code int} or of another primitive type + * that is convertible to type {@code int} by a widening conversion. + *

    + * This method can be used on fields of the following types: {@code int}, + * {@code short}, {@code char}, and {@code byte}. + *

    + * If the field has the {@code @Unsigned} annotation and is of a narrower type + * than {@code int}, then the value will be returned as an unsigned. + *

    + * It's possible to index into a nested object using {@code "."} (for example, + * {@code "aaa.bbb"}). + *

    + * A field might change or be removed in a future JDK release. A best practice + * for callers of this method is to validate the field before attempting access. + * + * @param name of the field to get, not {@code null} + * + * @return the value of the field converted to type {@code int} + * + * @throws IllegalArgumentException if the field doesn't exist, or the field + * value can't be converted to the type {@code int} by a widening + * conversion + * + * @see #hasField(String) + * @set #getValue(String) + */ + public final int getInt(String name) { + Object o = getValue(name, true); + if (o instanceof Integer) { + return ((Integer) o).intValue(); + } + if (o instanceof Short) { + return ((Short) o).intValue(); + } + if (o instanceof Character) { + return ((Character) o).charValue(); + } + if (o instanceof Byte) { + return ((Byte) o).intValue(); + } + if (o instanceof UnsignedValue) { + Object u = ((UnsignedValue) o).value(); + if (u instanceof Integer) { + return ((Integer) u).intValue(); + } + if (u instanceof Short) { + return Short.toUnsignedInt(((Short) u)); + } + if (u instanceof Byte) { + return Byte.toUnsignedInt(((Byte) u)); + } + } + throw newIllegalArgumentException(name, "int"); + } + + /** + * Returns the value of a field of type {@code float} or of another primitive + * type convertible to type {@code float} by a widening conversion. + *

    + * This method can be used on fields of the following types: {@code float}, + * {@code long}, {@code int}, {@code short}, {@code char}, and {@code byte}. + *

    + * It's possible to index into a nested object using {@code "."} (for example, + * {@code "aaa.bbb"}). + *

    + * A field might change or be removed in a future JDK release. A best practice + * for callers of this method is to validate the field before attempting access. + * + * @param name of the field to get, not {@code null} + * + * @return the value of the field converted to type {@code float} + * + * @throws IllegalArgumentException if the field doesn't exist, or the field + * value can't be converted to the type {@code float} by a widening + * conversion + * + * @see #hasField(String) + * @set #getValue(String) + */ + public final float getFloat(String name) { + Object o = getValue(name); + if (o instanceof Float) { + return ((Float) o).floatValue(); + } + if (o instanceof Long) { + return ((Long) o).floatValue(); + } + if (o instanceof Integer) { + return ((Integer) o).floatValue(); + } + if (o instanceof Short) { + return ((Short) o).floatValue(); + } + if (o instanceof Byte) { + return ((Byte) o).byteValue(); + } + if (o instanceof Character) { + return ((Character) o).charValue(); + } + throw newIllegalArgumentException(name, "float"); + } + + /** + * Returns the value of a field of type {@code long} or of another primitive + * type that is convertible to type {@code long} by a widening conversion. + *

    + * This method can be used on fields of the following types: {@code long}, + * {@code int}, {@code short}, {@code char}, and {@code byte}. + *

    + * If the field has the {@code @Unsigned} annotation and is of a narrower type + * than {@code long}, then the value will be returned as an unsigned. + *

    + * It's possible to index into a nested object using {@code "."} (for example, + * {@code "aaa.bbb"}). + *

    + * A field might change or be removed in a future JDK release. A best practice + * for callers of this method is to validate the field before attempting access. + * + * @param name of the field to get, not {@code null} + * + * @return the value of the field converted to type {@code long} + * + * @throws IllegalArgumentException if the field doesn't exist, or the field + * value can't be converted to the type {@code long} via a widening + * conversion + * + * @see #hasField(String) + * @set #getValue(String) + */ + public final long getLong(String name) { + Object o = getValue(name, true); + if (o instanceof Long) { + return ((Long) o).longValue(); + } + if (o instanceof Integer) { + return ((Integer) o).longValue(); + } + if (o instanceof Short) { + return ((Short) o).longValue(); + } + if (o instanceof Character) { + return ((Character) o).charValue(); + } + if (o instanceof Byte) { + return ((Byte) o).longValue(); + } + if (o instanceof UnsignedValue) { + Object u = ((UnsignedValue) o).value(); + if (u instanceof Integer) { + return Integer.toUnsignedLong(((Integer) u)); + } + if (u instanceof Short) { + return Short.toUnsignedLong(((Short) u)); + } + if (u instanceof Byte) { + return Byte.toUnsignedLong(((Byte) u)); + } + } + throw newIllegalArgumentException(name, "long"); + } + + /** + * Returns the value of a field of type {@code double} or of another primitive + * type that is convertible to type {@code double} by a widening conversion. + *

    + * This method can be used on fields of the following types: {@code double}, {@code float}, + * {@code long}, {@code int}, {@code short}, {@code char}, and {@code byte}. + *

    + * It's possible to index into a nested object using {@code "."} (for example, + * {@code "aaa.bbb"}). + *

    + * A field might change or be removed in a future JDK release. A best practice + * for callers of this method is to validate the field before attempting access. + * + * @param name of the field to get, not {@code null} + * + * @return the value of the field converted to type {@code double} + * + * @throws IllegalArgumentException if the field doesn't exist, or the field + * value can't be converted to the type {@code double} by a widening + * conversion + * + * @see #hasField(String) + * @set #getValue(String) + */ + public final double getDouble(String name) { + Object o = getValue(name); + if (o instanceof Double) { + return ((Double) o).doubleValue(); + } + if (o instanceof Float) { + return ((Float) o).doubleValue(); + } + if (o instanceof Long) { + return ((Long) o).doubleValue(); + } + if (o instanceof Integer) { + return ((Integer) o).doubleValue(); + } + if (o instanceof Short) { + return ((Short) o).doubleValue(); + } + if (o instanceof Byte) { + return ((Byte) o).byteValue(); + } + if (o instanceof Character) { + return ((Character) o).charValue(); + } + throw newIllegalArgumentException(name, "double"); + } + + /** + * Returns the value of a field of type {@code String}. + *

    + * It's possible to index into a nested object using {@code "."} (for example, + * {@code "foo.bar"}). + *

    + * A field might change or be removed in a future JDK release. A best practice + * for callers of this method is to validate the field before attempting access. + * + * @param name of the field to get, not {@code null} + * + * @return the value of the field as a {@code String}, can be {@code null} + * + * @throws IllegalArgumentException if the field doesn't exist, or the field + * isn't of type {@code String} + * + * @see #hasField(String) + * @set #getValue(String) + */ + public final String getString(String name) { + return getTypedValue(name, "java.lang.String"); + } + + /** + * Returns the value of a timespan field. + *

    + * This method can be used on fields annotated with {@code @Timespan}, and of + * the following types: {@code long}, {@code int}, {@code short}, {@code char}, + * and {@code byte}. + *

    + * It's possible to index into a nested object using {@code "."} (for example, + * {@code "aaa.bbb"}). + *

    + * A field might change or be removed in a future JDK release. A best practice + * for callers of this method is to validate the field before attempting access. + * + * @param name of the field to get, not {@code null} + * + * @return a time span represented as a {@code Duration}, not {@code null} + * + * @throws IllegalArgumentException if the field doesn't exist, or the field + * value can't be converted to a {@code Duration} object + * + * @see #hasField(String) + * @set #getValue(String) + */ + public final Duration getDuration(String name) { + Object o = getValue(name); + if (o instanceof Long) { + return getDuration(((Long) o).longValue(), name); + } + if (o instanceof Integer) { + return getDuration(((Integer) o).longValue(), name); + } + if (o instanceof Short) { + return getDuration(((Short) o).longValue(), name); + } + if (o instanceof Character) { + return getDuration(((Character) o).charValue(), name); + } + if (o instanceof Byte) { + return getDuration(((Byte) o).longValue(), name); + } + if (o instanceof UnsignedValue) { + Object u = ((UnsignedValue) o).value(); + if (u instanceof Integer) { + return getDuration(Integer.toUnsignedLong((Integer) u), name); + } + if (u instanceof Short) { + return getDuration(Short.toUnsignedLong((Short) u), name); + } + if (u instanceof Byte) { + return getDuration(Short.toUnsignedLong((Byte) u), name); + } + } + throw newIllegalArgumentException(name, "java,time.Duration"); + } + + private Duration getDuration(long timespan, String name) throws InternalError { + ValueDescriptor v = getValueDescriptor(descriptors, name, null); + if (timespan == Long.MIN_VALUE) { + return Duration.ofSeconds(Long.MIN_VALUE, 0); + } + Timespan ts = v.getAnnotation(Timespan.class); + if (ts != null) { + switch (ts.value()) { + case Timespan.MICROSECONDS: + return Duration.ofNanos(1000 * timespan); + case Timespan.SECONDS: + return Duration.ofSeconds(timespan); + case Timespan.MILLISECONDS: + return Duration.ofMillis(timespan); + case Timespan.NANOSECONDS: + return Duration.ofNanos(timespan); + case Timespan.TICKS: + return Duration.ofNanos(timeConverter.convertTimespan(timespan)); + } + throw new IllegalArgumentException("Attempt to get " + v.getTypeName() + " field \"" + name + "\" with illegal timespan unit " + ts.value()); + } + throw new IllegalArgumentException("Attempt to get " + v.getTypeName() + " field \"" + name + "\" with missing @Timespan"); + } + + /** + * Returns the value of a timestamp field. + *

    + * This method can be used on fields annotated with {@code @Timestamp}, and of + * the following types: {@code long}, {@code int}, {@code short}, {@code char} + * and {@code byte}. + *

    + * It's possible to index into a nested object using {@code "."} (for example, + * {@code "aaa.bbb"}). + *

    + * A field might change or be removed in a future JDK release. A best practice + * for callers of this method is to validate the field before attempting access. + * + * @param name of the field to get, not {@code null} + * + * @return a timstamp represented as an {@code Instant}, not {@code null} + * + * @throws IllegalArgumentException if the field doesn't exist, or the field + * value can't be converted to an {@code Instant} object + * + * @see #hasField(String) + * @set #getValue(String) + */ + public final Instant getInstant(String name) { + Object o = getValue(name, true); + if (o instanceof Long) { + return getInstant(((Long) o).longValue(), name); + } + if (o instanceof Integer) { + return getInstant(((Integer) o).longValue(), name); + } + if (o instanceof Short) { + return getInstant(((Short) o).longValue(), name); + } + if (o instanceof Character) { + return getInstant(((Character) o).charValue(), name); + } + if (o instanceof Byte) { + return getInstant(((Byte) o).longValue(), name); + } + if (o instanceof UnsignedValue) { + Object u = ((UnsignedValue) o).value(); + if (u instanceof Integer) { + return getInstant(Integer.toUnsignedLong((Integer) u), name); + } + if (u instanceof Short) { + return getInstant(Short.toUnsignedLong((Short) u), name); + } + if (u instanceof Byte) { + return getInstant(Short.toUnsignedLong((Byte) u), name); + } + } + throw newIllegalArgumentException(name, "java.time.Instant"); + } + + private Instant getInstant(long timestamp, String name) { + ValueDescriptor v = getValueDescriptor(descriptors, name, null); + Timestamp ts = v.getAnnotation(Timestamp.class); + if (ts != null) { + if (timestamp == Long.MIN_VALUE) { + return Instant.MIN; + } + switch (ts.value()) { + case Timestamp.MILLISECONDS_SINCE_EPOCH: + return Instant.ofEpochMilli(timestamp); + case Timestamp.TICKS: + return Instant.ofEpochSecond(0, timeConverter.convertTimestamp(timestamp)); + } + throw new IllegalArgumentException("Attempt to get " + v.getTypeName() + " field \"" + name + "\" with illegal timestamp unit " + ts.value()); + } + throw new IllegalArgumentException("Attempt to get " + v.getTypeName() + " field \"" + name + "\" with missing @Timestamp"); + } + + /** + * Returns the value of a field of type {@code Class}. + *

    + * It's possible to index into a nested object using {@code "."} (for example, + * {@code "aaa.bbb"}). + *

    + * A field might change or be removed in a future JDK release. A best practice + * for callers of this method is to validate the field before attempting access. + * + * @param name of the field to get, not {@code null} + * + * @return the value of the field as a {@code RecordedClass}, can be + * {@code null} + * + * @throws IllegalArgumentException if the field doesn't exist, or the field + * isn't of type {@code Class} + * + * @see #hasField(String) + * @set #getValue(String) + */ + public final RecordedClass getClass(String name) { + return getTypedValue(name, "java.lang.Class"); + } + + /** + * Returns the value of a field of type {@code Thread}. + *

    + * It's possible to index into a nested object using {@code "."} (for example, + * {@code "foo.bar"}). + *

    + * A field might change or be removed in a future JDK release. A best practice + * for callers of this method is to validate the field before attempting access. + * + * @param name of the field to get, not {@code null} + * + * @return the value of the field as a {@code RecordedThread} object, can be + * {@code null} + * + * @throws IllegalArgumentException if the field doesn't exist, or the field + * isn't of type {@code Thread} + * + * @see #hasField(String) + * @set #getValue(String) + */ + public final RecordedThread getThread(String name) { + return getTypedValue(name, "java.lang.Thread"); + } + + /** + * Returns a textual representation of this object. + * + * @return textual description of this object + */ + @Override + final public String toString() { + StringWriter s = new StringWriter(); + PrettyWriter p = new PrettyWriter(new PrintWriter(s)); + p.setStackDepth(5); + if (this instanceof RecordedEvent) { + p.print((RecordedEvent) this); + } else { + p.print(this, ""); + } + p.flush(true); + return s.toString(); + } + + // package private for now. Used by EventWriter + OffsetDateTime getOffsetDateTime(String name) { + Instant instant = getInstant(name); + if (instant.equals(Instant.MIN)) { + return OffsetDateTime.MIN; + } + return OffsetDateTime.ofInstant(getInstant(name), timeConverter.getZoneOffset()); + } + + private static IllegalArgumentException newIllegalArgumentException(String name, String typeName) { + return new IllegalArgumentException("Attempt to get field \"" + name + "\" with illegal data type conversion " + typeName); + } +} diff --git a/src/share/classes/jdk/jfr/consumer/RecordedStackTrace.java b/src/share/classes/jdk/jfr/consumer/RecordedStackTrace.java new file mode 100644 index 0000000000000000000000000000000000000000..1d2f7ea6c57033f42c56b15ad838856b1d10395f --- /dev/null +++ b/src/share/classes/jdk/jfr/consumer/RecordedStackTrace.java @@ -0,0 +1,80 @@ +/* + * 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 + * 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.consumer; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import jdk.jfr.ValueDescriptor; +import jdk.jfr.internal.Type; + +/** + * A recorded stack trace. + * + * @since 8 + */ +public final class RecordedStackTrace extends RecordedObject { + + static ObjectFactory createFactory(Type type, TimeConverter timeConverter) { + return new ObjectFactory(type) { + @Override + RecordedStackTrace createTyped(List desc, long id, Object[] object) { + return new RecordedStackTrace(desc, object, timeConverter); + } + }; + } + + private RecordedStackTrace(List desc, Object[] values, TimeConverter timeConverter) { + super(desc, values, timeConverter); + } + + /** + * Returns the frames in the stack trace. + * + * @return a list of Java stack frames, not {@code null} + */ + @SuppressWarnings("unchecked") + public List getFrames() { + Object[] array = getTyped("frames", Object[].class, null); + if (array == null) { + return Collections.EMPTY_LIST; + } + List list = Arrays.asList(array); + return (List) list; + } + + /** + * Returns {@code true} if the stack trace is truncated due to its size, + * {@code false} otherwise. + * + * @return {@code true} if the stack trace is truncated, {@code false} + * otherwise + */ + public boolean isTruncated() { + return getTyped("truncated", Boolean.class, true); + } +} diff --git a/src/share/classes/jdk/jfr/consumer/RecordedThread.java b/src/share/classes/jdk/jfr/consumer/RecordedThread.java new file mode 100644 index 0000000000000000000000000000000000000000..ec16654c2e855fe227997c572396438213e9b012 --- /dev/null +++ b/src/share/classes/jdk/jfr/consumer/RecordedThread.java @@ -0,0 +1,118 @@ +/* + * 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 + * 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.consumer; + +import java.util.List; + +import jdk.jfr.ValueDescriptor; +import jdk.jfr.internal.Type; + +/** + * A recorded thread. + * + * @since 8 + */ +public final class RecordedThread extends RecordedObject { + + static ObjectFactory createFactory(Type type, TimeConverter timeConverter) { + return new ObjectFactory(type) { + @Override + RecordedThread createTyped(List desc, long id, Object[] object) { + return new RecordedThread(desc, id, object, timeConverter); + } + }; + } + + private final long uniqueId; + + private RecordedThread(List descriptors, long id, Object[] values, TimeConverter timeConverter) { + super(descriptors, values, timeConverter); + this.uniqueId = id; + } + + /** + * Returns the thread name used by the operating system. + * + * @return the OS thread name, or {@code null} if doesn't exist + */ + public String getOSName() { + return getTyped("osName", String.class, null); + } + + /** + * Returns the thread ID used by the operating system. + * + * @return The Java thread ID, or {@code -1} if doesn't exist + */ + public long getOSThreadId() { + Long l = getTyped("osThreadId", Long.class, -1L); + return l.longValue(); + } + + /** + * Returns the Java thread group, if available. + * + * @return the thread group, or {@code null} if doesn't exist + */ + public RecordedThreadGroup getThreadGroup() { + return getTyped("group", RecordedThreadGroup.class, null); + } + + /** + * Returns the Java thread name, or {@code null} if if doesn't exist. + *

    + * Returns {@code java.lang.Thread.getName()} if the thread has a Java + * representation. {@code null} otherwise. + * + * @return the Java thread name, or {@code null} if doesn't exist + */ + public String getJavaName() { + return getTyped("javaName", String.class, null); + } + + /** + * Returns the Java thread ID, or {@code -1} if it's not a Java thread. + * + * @return the Java thread ID, or {@code -1} if it's not a Java thread + */ + public long getJavaThreadId() { + Long l = getTyped("javaThreadId", Long.class, -1L); + return l.longValue(); + } + + /** + * Returns a unique ID for both native threads and Java threads that can't be + * reused within the lifespan of the JVM. + *

    + * See {@link #getJavaThreadId()} for the ID that is returned by + * {@code java.lang.Thread.getId()} + * + * @return a unique ID for the thread + */ + public long getId() { + return uniqueId; + } +} diff --git a/src/share/classes/jdk/jfr/consumer/RecordedThreadGroup.java b/src/share/classes/jdk/jfr/consumer/RecordedThreadGroup.java new file mode 100644 index 0000000000000000000000000000000000000000..2eec6f8b0dc7d0013b76eee67a68777b494003a4 --- /dev/null +++ b/src/share/classes/jdk/jfr/consumer/RecordedThreadGroup.java @@ -0,0 +1,70 @@ +/* + * 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 + * 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.consumer; + +import java.util.List; + +import jdk.jfr.ValueDescriptor; +import jdk.jfr.internal.Type; + +/** + * A recorded Java thread group. + * + * @since 8 + */ +public final class RecordedThreadGroup extends RecordedObject { + + static ObjectFactory createFactory(Type type, TimeConverter timeConverter) { + return new ObjectFactory(type) { + @Override + RecordedThreadGroup createTyped(List desc, long id, Object[] object) { + return new RecordedThreadGroup(desc, object, timeConverter); + } + }; + } + + private RecordedThreadGroup(List descriptors, Object[] objects, TimeConverter timeConverter) { + super(descriptors, objects, timeConverter); + } + + /** + * Returns the name of the thread group, or {@code null} if doesn't exist. + * + * @return the thread group name, or {@code null} if doesn't exist + */ + public String getName() { + return getTyped("name", String.class, null); + } + + /** + * Returns the parent thread group, or {@code null} if it doesn't exist. + * + * @return parent thread group, or {@code null} if it doesn't exist. + */ + public RecordedThreadGroup getParent() { + return getTyped("parent", RecordedThreadGroup.class, null); + } +} diff --git a/src/share/classes/jdk/jfr/consumer/RecordingFile.java b/src/share/classes/jdk/jfr/consumer/RecordingFile.java new file mode 100644 index 0000000000000000000000000000000000000000..290c09c117ad08f3cd275930d45ee4721ff18a48 --- /dev/null +++ b/src/share/classes/jdk/jfr/consumer/RecordingFile.java @@ -0,0 +1,269 @@ +/* + * 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 + * 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.consumer; + +import java.io.Closeable; +import java.io.EOFException; +import java.io.File; +import java.io.IOException; +import java.nio.file.NoSuchFileException; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; + +import jdk.jfr.EventType; +import jdk.jfr.internal.MetadataDescriptor; +import jdk.jfr.internal.Type; +import jdk.jfr.internal.consumer.ChunkHeader; +import jdk.jfr.internal.consumer.RecordingInput; +import jdk.jfr.internal.consumer.RecordingInternals; + +/** + * A recording file. + *

    + * The following example shows how read and print all events in a recording file. + * + *

    + * 
    + * try (RecordingFile recordingFile = new RecordingFile(Paths.get("recording.jfr"))) {
    + *   while (recordingFile.hasMoreEvents()) {
    + *     RecordedEvent event = recordingFile.readEvent();
    + *     System.out.println(event);
    + *   }
    + * }
    + * 
    + * 
    + * + * @since 8 + */ +public final class RecordingFile implements Closeable { + static{ + RecordingInternals.INSTANCE = new RecordingInternals() { + public List readTypes(RecordingFile file) throws IOException { + return file.readTypes(); + } + + public boolean isLastEventInChunk(RecordingFile file) { + return file.isLastEventInChunk; + } + + @Override + public Object getOffsetDataTime(RecordedObject event, String name) { + return event.getOffsetDateTime(name); + } + + @Override + public void sort(List events) { + Collections.sort(events, (e1, e2) -> Long.compare(e1.endTime, e2.endTime)); + } + }; + } + + private boolean isLastEventInChunk; + private final File file; + private RecordingInput input; + private ChunkParser chunkParser; + private RecordedEvent nextEvent; + private boolean eof; + + /** + * Creates a recording file. + * + * @param file the path of the file to open, not {@code null} + * @throws IOException if it's not a valid recording file, or an I/O error + * occurred + * @throws NoSuchFileException if the {@code file} can't be located + * + * @throws SecurityException if a security manager exists and its + * {@code checkRead} method denies read access to the file. + */ + public RecordingFile(Path file) throws IOException { + this.file = file.toFile(); + this.input = new RecordingInput(this.file); + findNext(); + } + + /** + * Reads the next event in the recording. + * + * @return the next event, not {@code null} + * + * @throws EOFException if no more events exist in the recording file + * @throws IOException if an I/O error occurs. + * + * @see #hasMoreEvents() + */ + public RecordedEvent readEvent() throws IOException { + if (eof) { + ensureOpen(); + throw new EOFException(); + } + isLastEventInChunk = false; + RecordedEvent event = nextEvent; + nextEvent = chunkParser.readEvent(); + if (nextEvent == null) { + isLastEventInChunk = true; + findNext(); + } + return event; + } + + /** + * Returns {@code true} if unread events exist in the recording file, + * {@code false} otherwise. + * + * @return {@code true} if unread events exist in the recording, {@code false} + * otherwise. + */ + public boolean hasMoreEvents() { + return !eof; + } + + /** + * Returns a list of all event types in this recording. + * + * @return a list of event types, not {@code null} + * @throws IOException if an I/O error occurred while reading from the file + * + * @see #hasMoreEvents() + */ + public List readEventTypes() throws IOException { + ensureOpen(); + List types = new ArrayList<>(); + HashSet foundIds = new HashSet<>(); + try (RecordingInput ri = new RecordingInput(file)) { + ChunkHeader ch = new ChunkHeader(ri); + aggregateEventTypeForChunk(ch, types, foundIds); + while (!ch.isLastChunk()) { + ch = ch.nextHeader(); + aggregateEventTypeForChunk(ch, types, foundIds); + } + } + return types; + } + + List readTypes() throws IOException { + ensureOpen(); + List types = new ArrayList<>(); + HashSet foundIds = new HashSet<>(); + try (RecordingInput ri = new RecordingInput(file)) { + ChunkHeader ch = new ChunkHeader(ri); + aggregateTypeForChunk(ch, types, foundIds); + while (!ch.isLastChunk()) { + ch = ch.nextHeader(); + aggregateTypeForChunk(ch, types, foundIds); + } + } + return types; + } + + private void aggregateTypeForChunk(ChunkHeader ch, List types, HashSet foundIds) throws IOException { + MetadataDescriptor m = ch.readMetadata(); + for (Type t : m.getTypes()) { + if (!foundIds.contains(t.getId())) { + types.add(t); + foundIds.add(t.getId()); + } + } + } + + private static void aggregateEventTypeForChunk(ChunkHeader ch, List types, HashSet foundIds) throws IOException { + MetadataDescriptor m = ch.readMetadata(); + for (EventType t : m.getEventTypes()) { + if (!foundIds.contains(t.getId())) { + types.add(t); + foundIds.add(t.getId()); + } + } + } + + /** + * Closes this recording file and releases any system resources that are + * associated with it. + * + * @throws IOException if an I/O error occurred + */ + public void close() throws IOException { + if (input != null) { + eof = true; + input.close(); + chunkParser = null; + input = null; + nextEvent = null; + } + } + + /** + * Returns a list of all events in a file. + *

    + * This method is intended for simple cases where it's convenient to read all + * events in a single operation. It isn't intended for reading large files. + * + * @param path the path to the file, not {@code null} + * + * @return the events from the file as a {@code List} object; whether the + * {@code List} is modifiable or not is implementation dependent and + * therefore not specified, not {@code null} + * + * @throws IOException if an I/O error occurred, it's not a Flight Recorder + * file or a version of a JFR file that can't be parsed + * + * @throws SecurityException if a security manager exists and its + * {@code checkRead} method denies read access to the file. + */ + public static List readAllEvents(Path path) throws IOException { + try (RecordingFile r = new RecordingFile(path)) { + List list = new ArrayList<>(); + while (r.hasMoreEvents()) { + list.add(r.readEvent()); + } + return list; + } + } + + // either sets next to an event or sets eof to true + private void findNext() throws IOException { + while (nextEvent == null) { + if (chunkParser == null) { + chunkParser = new ChunkParser(input); + } else if (!chunkParser.isLastChunk()) { + chunkParser = chunkParser.nextChunkParser(); + } else { + eof = true; + return; + } + nextEvent = chunkParser.readEvent(); + } + } + + private void ensureOpen() throws IOException { + if (input == null) { + throw new IOException("Stream Closed"); + } + } +} diff --git a/src/share/classes/jdk/jfr/consumer/TimeConverter.java b/src/share/classes/jdk/jfr/consumer/TimeConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..0397f8a6858d4a8f7e86d8424fc0797e4aa651b2 --- /dev/null +++ b/src/share/classes/jdk/jfr/consumer/TimeConverter.java @@ -0,0 +1,72 @@ +/* + * 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. 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.consumer; + +import java.time.DateTimeException; +import java.time.ZoneOffset; + +import jdk.jfr.internal.LogLevel; +import jdk.jfr.internal.LogTag; +import jdk.jfr.internal.Logger; +import jdk.jfr.internal.consumer.ChunkHeader; + +/** + * Converts ticks to nanoseconds + */ +final class TimeConverter { + private final long startTicks; + private final long startNanos; + private final double divisor; + private final ZoneOffset zoneOffet; + + TimeConverter(ChunkHeader chunkHeader, int rawOffset) { + this.startTicks = chunkHeader.getStartTicks(); + this.startNanos = chunkHeader.getStartNanos(); + this.divisor = chunkHeader.getTicksPerSecond() / 1000_000_000L; + this.zoneOffet = zoneOfSet(rawOffset); + } + + private ZoneOffset zoneOfSet(int rawOffset) { + try { + return ZoneOffset.ofTotalSeconds(rawOffset / 1000); + } catch (DateTimeException dte) { + Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Could not create ZoneOffset from raw offset " + rawOffset); + } + return ZoneOffset.UTC; + } + + public long convertTimestamp(long ticks) { + return startNanos + (long) ((ticks - startTicks) / divisor); + } + + public long convertTimespan(long ticks) { + return (long) (ticks / divisor); + } + + public ZoneOffset getZoneOffset() { + return zoneOffet; + } +} diff --git a/src/share/classes/jdk/jfr/consumer/package-info.java b/src/share/classes/jdk/jfr/consumer/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..f920f012e4ee8eec23f4f9c2c99f600cda709a5f --- /dev/null +++ b/src/share/classes/jdk/jfr/consumer/package-info.java @@ -0,0 +1,82 @@ +/* + * 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 + * 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 package contains classes for consuming Flight Recorder data. + *

    + * In the following example, the program prints a histogram of all method samples in a recording. + *

    + * 
    + *   public static void main(String[] args) {
    + *     if (args.length != 0) {
    + *       System.out.println("Must specify recording file.");
    + *       return;
    + *     }
    + *     try (RecordingFile f = new RecordingFile(Paths.get(args[0]))) {
    + *       Map{@literal <}String, SimpleEntry{@literal <}String, Integer{@literal >}{@literal >} histogram = new HashMap{@literal <}{@literal >}();
    + *       int total = 0;
    + *       while (f.hasMoreEvents()) {
    + *         RecordedEvent event = f.readEvent();
    + *         if (event.getEventType().getName().equals("jdk.ExecutionSample")) {
    + *           RecordedStackTrace s = event.getStackTrace();
    + *           if (s != null) {
    + *             RecordedFrame topFrame= s.getFrames().get(0);
    + *             if (topFrame.isJavaFrame())  {
    + *               RecordedMethod method = topFrame.getMethod();
    + *               String methodName = method.getType().getName() + "#" + method.getName() + " " + method.getDescriptor();
    + *               Entry entry = histogram.computeIfAbsent(methodName, u -{@literal >} new SimpleEntry{@literal <}String, Integer{@literal >}(methodName, 0));
    + *               entry.setValue(entry.getValue() + 1);
    + *               total++;
    + *             }
    + *           }
    + *         }
    + *       }
    + *       List{@literal <}SimpleEntry{@literal <}String, Integer{@literal >}{@literal >} entries = new ArrayList{@literal <}{@literal >}(histogram.values());
    + *       entries.sort((u, v) -{@literal >} v.getValue().compareTo(u.getValue()));
    + *       for (SimpleEntry{@literal <}String, Integer{@literal >} c : entries) {
    + *         System.out.printf("%2.0f%% %s\n", 100 * (float) c.getValue() / total, c.getKey());
    + *       }
    + *       System.out.println("\nSample count: " + total);
    + *     } catch (IOException ioe) {
    + *       System.out.println("Error reading file " + args[0] + ". " + ioe.getMessage());
    + *     }
    + *   }
    + * 
    + * 
    + *

    + * Null-handling + *

    + * All methods define whether they accept or return {@code null} in the Javadoc. + * Typically this is expressed as {@code "not null"}. If a {@code null} + * parameter is used where it is not allowed, a + * {@code java.lang.NullPointerException} is thrown. If a {@code null} + * parameters is passed to a method that throws other exceptions, such as + * {@code java.io.IOException}, the {@code java.lang.NullPointerException} takes + * precedence, unless the Javadoc for the method explicitly states how + * {@code null} is handled, i.e. by throwing {@code java.lang.IllegalArgumentException}. + * + * @since 8 + */ +package jdk.jfr.consumer; diff --git a/src/share/classes/jdk/jfr/events/AbstractJDKEvent.java b/src/share/classes/jdk/jfr/events/AbstractJDKEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..f1043480c79da9db6047185febd0c9d9e8f08caf --- /dev/null +++ b/src/share/classes/jdk/jfr/events/AbstractJDKEvent.java @@ -0,0 +1,37 @@ +/* + * 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. 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.Enabled; +import jdk.jfr.Event; +import jdk.jfr.Registered; +import jdk.jfr.StackTrace; + +@Registered(false) +@Enabled(false) +@StackTrace(false) +abstract class AbstractJDKEvent extends Event { +} diff --git a/src/share/classes/jdk/jfr/events/ActiveRecordingEvent.java b/src/share/classes/jdk/jfr/events/ActiveRecordingEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..631315e43c8e0b495607e0d52460840d8d74c098 --- /dev/null +++ b/src/share/classes/jdk/jfr/events/ActiveRecordingEvent.java @@ -0,0 +1,67 @@ +/* + * 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. 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.Label; +import jdk.jfr.DataAmount; +import jdk.jfr.Name; +import jdk.jfr.StackTrace; +import jdk.jfr.Timespan; +import jdk.jfr.Timestamp; +import jdk.jfr.internal.Type; + +@Name(Type.EVENT_NAME_PREFIX + "ActiveRecording") +@Label("Flight Recording") +@Category("Flight Recorder") +@StackTrace(false) +public final class ActiveRecordingEvent extends AbstractJDKEvent { + + @Label("Id") + public long id; + + @Label("Name") + public String name; + + @Label("Destination") + public String destination; + + @Label("Max Age") + @Timespan(Timespan.MILLISECONDS) + public long maxAge; + + @Label("Max Size") + @DataAmount + public long maxSize; + + @Label("Start Time") + @Timestamp(Timestamp.MILLISECONDS_SINCE_EPOCH) + public long recordingStart; + + @Label("Recording Duration") + @Timespan(Timespan.MILLISECONDS) + public long recordingDuration; +} diff --git a/src/share/classes/jdk/jfr/events/ActiveSettingEvent.java b/src/share/classes/jdk/jfr/events/ActiveSettingEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..0c51db6bae818e644c387136581ae30ce3b18ee0 --- /dev/null +++ b/src/share/classes/jdk/jfr/events/ActiveSettingEvent.java @@ -0,0 +1,48 @@ +/* + * 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. 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.Label; +import jdk.jfr.Name; +import jdk.jfr.StackTrace; +import jdk.jfr.internal.Type; + +@Name(Type.EVENT_NAME_PREFIX + "ActiveSetting") +@Label("Recording Setting") +@Category("Flight Recorder") +@StackTrace(false) +public final class ActiveSettingEvent extends AbstractJDKEvent { + + @Label("Event Id") + public long id; + + @Label("Setting Name") + public String name; + + @Label("Setting Value") + public String value; +} diff --git a/src/share/classes/jdk/jfr/events/ErrorThrownEvent.java b/src/share/classes/jdk/jfr/events/ErrorThrownEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..64efc7049df8f23e4cc68118ce79b58cc659c9c4 --- /dev/null +++ b/src/share/classes/jdk/jfr/events/ErrorThrownEvent.java @@ -0,0 +1,44 @@ +/* + * 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 + * 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.Type; + +@Name(Type.EVENT_NAME_PREFIX + "JavaErrorThrow") +@Label("Java Error") +@Category("Java Application") +@Description("An object derived from java.lang.Error has been created. OutOfMemoryErrors are ignored") +public final class ErrorThrownEvent extends AbstractJDKEvent { + + @Label("Message") + public String message; + + @Label("Class") + public Class thrownClass; +} diff --git a/src/share/classes/jdk/jfr/events/ExceptionStatisticsEvent.java b/src/share/classes/jdk/jfr/events/ExceptionStatisticsEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..1a63019a469b6cc70c843542be0eac893c9bddca --- /dev/null +++ b/src/share/classes/jdk/jfr/events/ExceptionStatisticsEvent.java @@ -0,0 +1,44 @@ +/* + * 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 + * 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.StackTrace; +import jdk.jfr.internal.Type; + +@Name(Type.EVENT_NAME_PREFIX + "ExceptionStatistics") +@Label("Exception Statistics") +@Category({ "Java Application", "Statistics" }) +@Description("Number of objects derived from java.lang.Throwable that have been created") +@StackTrace(false) +public final class ExceptionStatisticsEvent extends AbstractJDKEvent { + + @Label("Exceptions Created") + public long throwables; +} diff --git a/src/share/classes/jdk/jfr/events/ExceptionThrownEvent.java b/src/share/classes/jdk/jfr/events/ExceptionThrownEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..1489803ee89fd7302fe6c32b1e9148e90c053e36 --- /dev/null +++ b/src/share/classes/jdk/jfr/events/ExceptionThrownEvent.java @@ -0,0 +1,45 @@ +/* + * 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 + * 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.Type; + +@Name(Type.EVENT_NAME_PREFIX + "JavaExceptionThrow") +@Label("Java Exception") +@Category("Java Application") +@Description("An object derived from java.lang.Exception has been created") +public final class ExceptionThrownEvent extends AbstractJDKEvent { + + @Label("Message") + public String message; + + @Label("Class") + public Class thrownClass; +} diff --git a/src/share/classes/jdk/jfr/events/FileForceEvent.java b/src/share/classes/jdk/jfr/events/FileForceEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..d5b62a91a12fd695085170a561aa455df3810397 --- /dev/null +++ b/src/share/classes/jdk/jfr/events/FileForceEvent.java @@ -0,0 +1,59 @@ +/* + * 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. 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.Type; + +@Name(Type.EVENT_NAME_PREFIX + "FileForce") +@Label("File Force") +@Category("Java Application") +@Description("Force updates to be written to file") +public final class FileForceEvent extends AbstractJDKEvent { + + public static final ThreadLocal EVENT = + new ThreadLocal() { + @Override protected FileForceEvent initialValue() { + return new FileForceEvent(); + } + }; + + @Label("Path") + @Description("Full path of the file") + public String path; + + @Label("Update Metadata") + @Description("Whether the file metadata is updated") + public boolean metaData; + + public void reset() { + path = null; + metaData = false; + } +} diff --git a/src/share/classes/jdk/jfr/events/FileReadEvent.java b/src/share/classes/jdk/jfr/events/FileReadEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..f868f05bc5ce562cb6366d4ae83a62efec1b9640 --- /dev/null +++ b/src/share/classes/jdk/jfr/events/FileReadEvent.java @@ -0,0 +1,66 @@ +/* + * 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 + * 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.DataAmount; +import jdk.jfr.Name; +import jdk.jfr.internal.Type; + +@Name(Type.EVENT_NAME_PREFIX + "FileRead") +@Label("File Read") +@Category("Java Application") +@Description("Reading data from a file") +public final class FileReadEvent extends AbstractJDKEvent { + + public static final ThreadLocal EVENT = + new ThreadLocal() { + @Override protected FileReadEvent initialValue() { + return new FileReadEvent(); + } + }; + + @Label("Path") + @Description("Full path of the file") + public String path; + + @Label("Bytes Read") + @Description("Number of bytes read from the file (possibly 0)") + @DataAmount + public long bytesRead; + + @Label("End of File") + @Description("If end of file was reached") + public boolean endOfFile; + + public void reset() { + path = null; + endOfFile = false; + bytesRead = 0; + } +} diff --git a/src/share/classes/jdk/jfr/events/FileWriteEvent.java b/src/share/classes/jdk/jfr/events/FileWriteEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..c0a9fbfd95265a7fddd50776d600d330fb4ad553 --- /dev/null +++ b/src/share/classes/jdk/jfr/events/FileWriteEvent.java @@ -0,0 +1,61 @@ +/* + * 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 + * 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.DataAmount; +import jdk.jfr.Name; +import jdk.jfr.internal.Type; + +@Name(Type.EVENT_NAME_PREFIX + "FileWrite") +@Label("File Write") +@Category("Java Application") +@Description("Writing data to a file") +public final class FileWriteEvent extends AbstractJDKEvent { + + public static final ThreadLocal EVENT = + new ThreadLocal() { + @Override protected FileWriteEvent initialValue() { + return new FileWriteEvent(); + } + }; + + @Label("Path") + @Description("Full path of the file") + public String path; + + @Label("Bytes Written") + @Description("Number of bytes written to the file") + @DataAmount + public long bytesWritten; + + public void reset() { + path = null; + bytesWritten = 0; + } +} diff --git a/src/share/classes/jdk/jfr/events/SocketReadEvent.java b/src/share/classes/jdk/jfr/events/SocketReadEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..91db94c6f4988481436ee5eb636fadb1ed61d861 --- /dev/null +++ b/src/share/classes/jdk/jfr/events/SocketReadEvent.java @@ -0,0 +1,79 @@ +/* + * 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 + * 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.DataAmount; +import jdk.jfr.Name; +import jdk.jfr.Timespan; +import jdk.jfr.internal.Type; + +@Name(Type.EVENT_NAME_PREFIX + "SocketRead") +@Label("Socket Read") +@Category("Java Application") +@Description("Reading data from a socket") +public final class SocketReadEvent extends AbstractJDKEvent { + + public static final ThreadLocal EVENT = + new ThreadLocal() { + @Override protected SocketReadEvent initialValue() { + return new SocketReadEvent(); + } + }; + + @Label("Remote Host") + public String host; + + @Label("Remote Address") + public String address; + + @Label("Remote Port") + public int port; + + @Label("Timeout Value") + @Timespan(Timespan.MILLISECONDS) + public long timeout; + + @Label("Bytes Read") + @Description("Number of bytes read from the socket") + @DataAmount + public long bytesRead; + + @Label("End of Stream") + @Description("If end of stream was reached") + public boolean endOfStream; + + public void reset() { + host = null; + address = null; + port = 0; + timeout = 0; + bytesRead = 0L; + endOfStream = false; + } +} diff --git a/src/share/classes/jdk/jfr/events/SocketWriteEvent.java b/src/share/classes/jdk/jfr/events/SocketWriteEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..2a0caa36aa52d67a4e17da8c86212fa56207630e --- /dev/null +++ b/src/share/classes/jdk/jfr/events/SocketWriteEvent.java @@ -0,0 +1,68 @@ +/* + * 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 + * 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.DataAmount; +import jdk.jfr.Name; +import jdk.jfr.internal.Type; + +@Name(Type.EVENT_NAME_PREFIX + "SocketWrite") +@Label("Socket Write") +@Category("Java Application") +@Description("Writing data to a socket") +public final class SocketWriteEvent extends AbstractJDKEvent { + + public static final ThreadLocal EVENT = + new ThreadLocal() { + @Override protected SocketWriteEvent initialValue() { + return new SocketWriteEvent(); + } + }; + + @Label("Remote Host") + public String host; + + @Label("Remote Address") + public String address; + + @Label("Remote Port") + public int port; + + @Label("Bytes Written") + @Description("Number of bytes written to the socket") + @DataAmount + public long bytesWritten; + + public void reset() { + host = null; + address = null; + port = 0; + bytesWritten = 0; + } +} diff --git a/src/share/classes/jdk/jfr/internal/ASMToolkit.java b/src/share/classes/jdk/jfr/internal/ASMToolkit.java new file mode 100644 index 0000000000000000000000000000000000000000..732507ba861a0f505b3db29f2aa6787adfad5541 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/ASMToolkit.java @@ -0,0 +1,162 @@ +/* + * 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. 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.internal; + +import java.io.ByteArrayOutputStream; +import java.io.PrintWriter; +import java.util.List; + +import jdk.internal.org.objectweb.asm.ClassReader; +import jdk.internal.org.objectweb.asm.MethodVisitor; +import jdk.internal.org.objectweb.asm.Opcodes; +import jdk.internal.org.objectweb.asm.Type; +import jdk.internal.org.objectweb.asm.commons.Method; +import jdk.internal.org.objectweb.asm.util.TraceClassVisitor; +import jdk.jfr.ValueDescriptor; +import jdk.jfr.internal.EventInstrumentation.FieldInfo; + +final class ASMToolkit { + private static Type TYPE_STRING = Type.getType(String.class); + private static Type Type_THREAD = Type.getType(Thread.class); + private static Type TYPE_CLASS = Type.getType(Class.class); + + public static void invokeSpecial(MethodVisitor methodVisitor, String className, Method m) { + methodVisitor.visitMethodInsn(Opcodes.INVOKESPECIAL, className, m.getName(), m.getDescriptor(), false); + } + + public static void invokeStatic(MethodVisitor methodVisitor, String className, Method m) { + methodVisitor.visitMethodInsn(Opcodes.INVOKESTATIC, className, m.getName(), m.getDescriptor(), false); + } + + public static void invokeVirtual(MethodVisitor methodVisitor, String className, Method m) { + methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, className, m.getName(), m.getDescriptor(), false); + } + + + public static Type toType(ValueDescriptor v) { + String typeName = v.getTypeName(); + + switch (typeName) { + case "byte": + return Type.BYTE_TYPE; + case "short": + return Type.SHORT_TYPE; + case "int": + return Type.INT_TYPE; + case "long": + return Type.LONG_TYPE; + case "double": + return Type.DOUBLE_TYPE; + case "float": + return Type.FLOAT_TYPE; + case "char": + return Type.CHAR_TYPE; + case "boolean": + return Type.BOOLEAN_TYPE; + case "java.lang.String": + return TYPE_STRING; + case "java.lang.Thread": + return Type_THREAD; + case "java.lang.Class": + return TYPE_CLASS; + } + // Add support for SettingControl? + throw new Error("Not a valid type " + v.getTypeName()); + } + + /** + * Converts "int" into "I" and "java.lang.String" into "Ljava/lang/String;" + * + * @param typeName + * type + * + * @return descriptor + */ + public static String getDescriptor(String typeName) { + if ("int".equals(typeName)) { + return "I"; + } + if ("long".equals(typeName)) { + return "J"; + } + if ("boolean".equals(typeName)) { + return "Z"; + } + if ("float".equals(typeName)) { + return "F"; + } + if ("double".equals(typeName)) { + return "D"; + } + if ("short".equals(typeName)) { + return "S"; + } + if ("char".equals(typeName)) { + return "C"; + } + if ("byte".equals(typeName)) { + return "B"; + } + String internal = getInternalName(typeName); + return Type.getObjectType(internal).getDescriptor(); + } + + /** + * Converts java.lang.String into java/lang/String + * + * @param className + * + * @return internal name + */ + public static String getInternalName(String className) { + return className.replace(".", "/"); + } + + public static Method makeWriteMethod(List fields) { + StringBuilder sb = new StringBuilder(); + sb.append("("); + for (FieldInfo v : fields) { + if (!v.fieldName.equals(EventInstrumentation.FIELD_EVENT_THREAD) && !v.fieldName.equals(EventInstrumentation.FIELD_STACK_TRACE)) { + sb.append(v.fieldDescriptor); + } + } + sb.append(")V"); + return new Method("write", sb.toString()); + } + + public static void logASM(String className, byte[] bytes) { + Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.INFO, "Generated bytecode for class " + className); + Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.TRACE, () -> { + ClassReader cr = new ClassReader(bytes); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + PrintWriter w = new PrintWriter(baos); + w.println("Bytecode:"); + cr.accept(new TraceClassVisitor(w), 0); + return baos.toString(); + }); + } + +} diff --git a/src/share/classes/jdk/jfr/internal/AnnotationConstruct.java b/src/share/classes/jdk/jfr/internal/AnnotationConstruct.java new file mode 100644 index 0000000000000000000000000000000000000000..b3c594f68feb809ccbe6070ce91350505cf598cb --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/AnnotationConstruct.java @@ -0,0 +1,136 @@ +/* + * 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. 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.internal; + +import java.lang.annotation.Annotation; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.Collections; +import java.util.List; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.Description; +import jdk.jfr.Label; +import jdk.jfr.Unsigned; + +public final class AnnotationConstruct { + + private static final class AnnotationInvokationHandler implements InvocationHandler { + + private final AnnotationElement annotationElement; + + AnnotationInvokationHandler(AnnotationElement a) { + this.annotationElement = a; + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + String methodName = method.getName(); + int parameters = method.getTypeParameters().length; + if (parameters == 0 && annotationElement.hasValue(methodName)) { + return annotationElement.getValue(methodName); + } + throw new UnsupportedOperationException("Flight Recorder proxy only supports members declared in annotation interfaces, i.e. not toString, equals etc."); + } + } + + private List annotationElements = Collections.emptyList(); + private byte unsignedFlag = -1; + public AnnotationConstruct(List ann) { + this.annotationElements = ann; + } + + public AnnotationConstruct() { + } + + public void setAnnotationElements(List elements) { + annotationElements = Utils.smallUnmodifiable(elements); + } + + public String getLabel() { + Label label = getAnnotation(Label.class); + if (label == null) { + return null; + } + return label.value(); + } + + public String getDescription() { + Description description = getAnnotation(Description.class); + if (description == null) { + return null; + } + return description.value(); + } + + @SuppressWarnings("unchecked") + public final T getAnnotation(Class clazz) { + AnnotationElement ae = getAnnotationElement(clazz); + if (ae != null) { + return (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class[] { clazz }, new AnnotationInvokationHandler(ae)); + } + return null; + } + + public List getUnmodifiableAnnotationElements() { + return annotationElements; + } + + // package private + boolean remove(AnnotationElement annotation) { + return annotationElements.remove(annotation); + } + + private AnnotationElement getAnnotationElement(Class clazz) { + // if multiple annotation elements with the same name exists, prioritize + // the one with the same id. Note, id alone is not a guarantee, since it + // may differ between JVM instances. + long id = Type.getTypeId(clazz); + String className = clazz.getName(); + for (AnnotationElement a : getUnmodifiableAnnotationElements()) { + if (a.getTypeId() == id && a.getTypeName().equals(className)) { + return a; + } + } + for (AnnotationElement a : getUnmodifiableAnnotationElements()) { + if (a.getTypeName().equals(className)) { + return a; + } + } + return null; + } + + public boolean hasUnsigned() { + // Must be initialized lazily since some annotation elements + // are added after construction + if (unsignedFlag < 0) { + Unsigned unsigned = getAnnotation(Unsigned.class); + unsignedFlag = (byte) (unsigned == null ? 0 :1); + } + return unsignedFlag == (byte)1 ? true : false; + } +} diff --git a/src/share/classes/jdk/jfr/internal/Bits.java b/src/share/classes/jdk/jfr/internal/Bits.java new file mode 100644 index 0000000000000000000000000000000000000000..a6b02505bc19f98ecb33850a9721d20d00dd9be0 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/Bits.java @@ -0,0 +1,227 @@ +/* + * 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. 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.internal; + +import java.nio.ByteOrder; + +import sun.misc.Unsafe; + +final class Bits { // package-private + + private static final Unsafe unsafe = Unsafe.getUnsafe(); + // XXX TODO proper value (e.g. copy from java.nio.Bits) + private static final boolean unalignedAccess = false/*unsafe.unalignedAccess()*/; + private static final boolean bigEndian = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN; + + private Bits() { } + + // -- Swapping -- + + private static short swap(short x) { + return Short.reverseBytes(x); + } + + private static char swap(char x) { + return Character.reverseBytes(x); + } + + private static int swap(int x) { + return Integer.reverseBytes(x); + } + + private static long swap(long x) { + return Long.reverseBytes(x); + } + + private static float swap(float x) { + return Float.intBitsToFloat(swap(Float.floatToIntBits(x))); + } + + private static double swap(double x) { + return Double.longBitsToDouble(swap(Double.doubleToLongBits(x))); + } + + // -- Alignment -- + + private static boolean isAddressAligned(long a, int datumSize) { + return (a & datumSize - 1) == 0; + } + + // -- Primitives stored per byte + + private static byte char1(char x) { return (byte)(x >> 8); } + private static byte char0(char x) { return (byte)(x ); } + + private static byte short1(short x) { return (byte)(x >> 8); } + private static byte short0(short x) { return (byte)(x ); } + + private static byte int3(int x) { return (byte)(x >> 24); } + private static byte int2(int x) { return (byte)(x >> 16); } + private static byte int1(int x) { return (byte)(x >> 8); } + private static byte int0(int x) { return (byte)(x ); } + + private static byte long7(long x) { return (byte)(x >> 56); } + private static byte long6(long x) { return (byte)(x >> 48); } + private static byte long5(long x) { return (byte)(x >> 40); } + private static byte long4(long x) { return (byte)(x >> 32); } + private static byte long3(long x) { return (byte)(x >> 24); } + private static byte long2(long x) { return (byte)(x >> 16); } + private static byte long1(long x) { return (byte)(x >> 8); } + private static byte long0(long x) { return (byte)(x ); } + + private static void putCharBigEndianUnaligned(long a, char x) { + putByte_(a , char1(x)); + putByte_(a + 1, char0(x)); + } + + private static void putShortBigEndianUnaligned(long a, short x) { + putByte_(a , short1(x)); + putByte_(a + 1, short0(x)); + } + + private static void putIntBigEndianUnaligned(long a, int x) { + putByte_(a , int3(x)); + putByte_(a + 1, int2(x)); + putByte_(a + 2, int1(x)); + putByte_(a + 3, int0(x)); + } + + private static void putLongBigEndianUnaligned(long a, long x) { + putByte_(a , long7(x)); + putByte_(a + 1, long6(x)); + putByte_(a + 2, long5(x)); + putByte_(a + 3, long4(x)); + putByte_(a + 4, long3(x)); + putByte_(a + 5, long2(x)); + putByte_(a + 6, long1(x)); + putByte_(a + 7, long0(x)); + } + + private static void putFloatBigEndianUnaligned(long a, float x) { + putIntBigEndianUnaligned(a, Float.floatToRawIntBits(x)); + } + + private static void putDoubleBigEndianUnaligned(long a, double x) { + putLongBigEndianUnaligned(a, Double.doubleToRawLongBits(x)); + } + + private static void putByte_(long a, byte b) { + unsafe.putByte(a, b); + } + + private static void putBoolean_(long a, boolean x) { + unsafe.putBoolean(null, a, x); + } + + private static void putChar_(long a, char x) { + unsafe.putChar(a, bigEndian ? x : swap(x)); + } + + private static void putShort_(long a, short x) { + unsafe.putShort(a, bigEndian ? x : swap(x)); + } + + private static void putInt_(long a, int x) { + unsafe.putInt(a, bigEndian ? x : swap(x)); + } + + private static void putLong_(long a, long x) { + unsafe.putLong(a, bigEndian ? x : swap(x)); + } + + private static void putFloat_(long a, float x) { + unsafe.putFloat(a, bigEndian ? x : swap(x)); + } + + private static void putDouble_(long a, double x) { + unsafe.putDouble(a, bigEndian ? x : swap(x)); + } + + // external api + static int putByte(long a, byte x) { + putByte_(a, x); + return Byte.BYTES; + } + + static int putBoolean(long a, boolean x) { + putBoolean_(a, x); + return Byte.BYTES; + } + + static int putChar(long a, char x) { + if (unalignedAccess || isAddressAligned(a, Character.BYTES)) { + putChar_(a, x); + return Character.BYTES; + } + putCharBigEndianUnaligned(a, x); + return Character.BYTES; + } + + static int putShort(long a, short x) { + if (unalignedAccess || isAddressAligned(a, Short.BYTES)) { + putShort_(a, x); + return Short.BYTES; + } + putShortBigEndianUnaligned(a, x); + return Short.BYTES; + } + + static int putInt(long a, int x) { + if (unalignedAccess || isAddressAligned(a, Integer.BYTES)) { + putInt_(a, x); + return Integer.BYTES; + } + putIntBigEndianUnaligned(a, x); + return Integer.BYTES; + } + + static int putLong(long a, long x) { + if (unalignedAccess || isAddressAligned(a, Long.BYTES)) { + putLong_(a, x); + return Long.BYTES; + } + putLongBigEndianUnaligned(a, x); + return Long.BYTES; + } + + static int putFloat(long a, float x) { + if (unalignedAccess || isAddressAligned(a, Float.BYTES)) { + putFloat_(a, x); + return Float.BYTES; + } + putFloatBigEndianUnaligned(a, x); + return Float.BYTES; + } + + static int putDouble(long a, double x) { + if (unalignedAccess || isAddressAligned(a, Double.BYTES)) { + putDouble_(a, x); + return Double.BYTES; + } + putDoubleBigEndianUnaligned(a, x); + return Double.BYTES; + } +} diff --git a/src/share/classes/jdk/jfr/internal/ChunkInputStream.java b/src/share/classes/jdk/jfr/internal/ChunkInputStream.java new file mode 100644 index 0000000000000000000000000000000000000000..1a27170c6b91ef445e3e675d17191981931c1008 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/ChunkInputStream.java @@ -0,0 +1,116 @@ +/* + * 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. 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.internal; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +final class ChunkInputStream extends InputStream { + private final Iterator chunks; + private RepositoryChunk currentChunk; + private InputStream stream; + + ChunkInputStream(List chunks) throws IOException { + List l = new ArrayList<>(chunks.size()); + for (RepositoryChunk c : chunks) { + c.use(); // keep alive while we're reading. + l.add(c); + } + + this.chunks = l.iterator(); + nextStream(); + } + + @Override + public int available() throws IOException { + if (stream != null) { + return stream.available(); + } + return 0; + } + + private boolean nextStream() throws IOException { + if (!nextChunk()) { + return false; + } + + stream = new BufferedInputStream(SecuritySupport.newFileInputStream(currentChunk.getFile())); + return true; + } + + private boolean nextChunk() { + if (!chunks.hasNext()) { + return false; + } + currentChunk = chunks.next(); + return true; + } + + @Override + public int read() throws IOException { + while (true) { + if (stream != null) { + int r = stream.read(); + if (r != -1) { + return r; + } + stream.close(); + currentChunk.release(); + stream = null; + currentChunk = null; + } + if (!nextStream()) { + return -1; + } + } + } + + @Override + public void close() throws IOException { + if (stream != null) { + stream.close(); + stream = null; + } + while (currentChunk != null) { + currentChunk.release(); + currentChunk = null; + if (!nextChunk()) { + return; + } + } + } + + @Override + @SuppressWarnings("deprecation") + protected void finalize() throws Throwable { + super.finalize(); + close(); + } +} diff --git a/src/share/classes/jdk/jfr/internal/ChunksChannel.java b/src/share/classes/jdk/jfr/internal/ChunksChannel.java new file mode 100644 index 0000000000000000000000000000000000000000..1139536c93876f8fa49ed46a625e2b07d057b49a --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/ChunksChannel.java @@ -0,0 +1,145 @@ +/* + * 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 + * 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.internal; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; +import java.nio.channels.ReadableByteChannel; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +final class ChunksChannel implements ReadableByteChannel { + private final Iterator chunks; + private RepositoryChunk current; + private ReadableByteChannel channel; + + public ChunksChannel(List chunks) throws IOException { + if (chunks.isEmpty()) { + throw new FileNotFoundException("No chunks"); + } + List l = new ArrayList<>(chunks.size()); + for (RepositoryChunk c : chunks) { + c.use(); // keep alive while we're reading. + l.add(c); + } + this.chunks = l.iterator(); + nextChannel(); + } + + private boolean nextChunk() { + if (!chunks.hasNext()) { + return false; + } + current = chunks.next(); + return true; + } + + private boolean nextChannel() throws IOException { + if (!nextChunk()) { + return false; + } + + channel = current.newChannel(); + return true; + } + + @Override + public int read(ByteBuffer dst) throws IOException { + for (;;) { + if (channel != null) { + assert current != null; + int r = channel.read(dst); + if (r != -1) { + return r; + } + channel.close(); + current.release(); + channel = null; + current = null; + } + if (!nextChannel()) { + return -1; + } + } + } + + public long transferTo(FileChannel out) throws IOException { + long pos = 0; + for (;;) { + if (channel != null) { + assert current != null; + + long rem = current.getSize(); + + while (rem > 0) { + long n = Math.min(rem, 1024 * 1024); + long w = out.transferFrom(channel, pos, n); + pos += w; + rem -= w; + } + + channel.close(); + current.release(); + + channel = null; + current = null; + } + if (!nextChannel()) { + return pos; + } + } + } + + @Override + public void close() throws IOException { + if (channel != null) { + channel.close(); + channel = null; + } + while (current != null) { + current.release(); + current = null; + if (!nextChunk()) { + return; + } + } + } + + @Override + public boolean isOpen() { + return channel != null; + } + + @Override + @SuppressWarnings("deprecation") + protected void finalize() throws Throwable { + super.finalize(); + close(); + } +} diff --git a/src/share/classes/jdk/jfr/internal/Control.java b/src/share/classes/jdk/jfr/internal/Control.java new file mode 100644 index 0000000000000000000000000000000000000000..3b24aec0bbf2ed277ff0d9028e7250a30e322b0c --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/Control.java @@ -0,0 +1,209 @@ +/* + * 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. 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.internal; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.security.AccessControlContext; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.Collections; +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + +// User must never be able to subclass directly. +// +// Never put Control or Setting Control in a collections +// so overridable versions of hashCode or equals are +// executed in the wrong context. TODO: wrap this class +// in SsecureControl directly when it is instantiated and +// forward calls using AccessControlContext +abstract public class Control { + private final AccessControlContext context; + private final static int CACHE_SIZE = 5; + private final Set[] cachedUnions = new HashSet[CACHE_SIZE]; + private final String[] cachedValues = new String[CACHE_SIZE]; + private String defaultValue; + private String lastValue; + + // called by exposed subclass in external API + public Control(AccessControlContext acc) { + Objects.requireNonNull(acc); + this.context = acc; + + } + + // only to be called by trusted VM code + public Control(String defaultValue) { + this.defaultValue = defaultValue; + this.context = null; + } + + // For user code to override, must never be called from jdk.jfr.internal + // for user defined settings + public abstract String combine(Set values); + + // For user code to override, must never be called from jdk.jfr.internal + // for user defined settings + public abstract void setValue(String value); + + // For user code to override, must never be called from jdk.jfr.internal + // for user defined settings + public abstract String getValue(); + + // Package private, user code should not have access to this method + final void apply(Set values) { + setValueSafe(findCombineSafe(values)); + } + + // Package private, user code should not have access to this method. + // Only called during event registration + final void setDefault() { + if (defaultValue == null) { + defaultValue = getValueSafe(); + } + apply(defaultValue); + } + + final String getValueSafe() { + if (context == null) { + // VM events requires no access control context + return getValue(); + } else { + return AccessController.doPrivileged(new PrivilegedAction() { + @Override + public String run() { + try { + return getValue(); + } catch (Throwable t) { + // Prevent malicious user to propagate exception callback in the wrong context + Logger.log(LogTag.JFR_SETTING, LogLevel.WARN, "Exception occured when trying to get value for " + getClass()); + } + return defaultValue != null ? defaultValue : ""; // Need to return something + } + }, context); + } + } + + private void apply(String value) { + if (lastValue != null && Objects.equals(value, lastValue)) { + return; + } + setValueSafe(value); + } + + final void setValueSafe(String value) { + if (context == null) { + // VM events requires no access control context + try { + setValue(value); + } catch (Throwable t) { + Logger.log(LogTag.JFR_SETTING, LogLevel.WARN, "Exception occured when setting value \"" + value + "\" for " + getClass()); + } + } else { + AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Void run() { + try { + setValue(value); + } catch (Throwable t) { + // Prevent malicious user to propagate exception callback in the wrong context + Logger.log(LogTag.JFR_SETTING, LogLevel.WARN, "Exception occured when setting value \"" + value + "\" for " + getClass()); + } + return null; + } + }, context); + } + lastValue = value; + } + + + private String combineSafe(Set values) { + if (context == null) { + // VM events requires no access control context + return combine(values); + } + return AccessController.doPrivileged(new PrivilegedAction() { + @Override + public String run() { + try { + combine(Collections.unmodifiableSet(values)); + } catch (Throwable t) { + // Prevent malicious user to propagate exception callback in the wrong context + Logger.log(LogTag.JFR_SETTING, LogLevel.WARN, "Exception occured when combining " + values + " for " + getClass()); + } + return null; + } + }, context); + } + + private final String findCombineSafe(Set values) { + if (values.size() == 1) { + return values.iterator().next(); + } + for (int i = 0; i < CACHE_SIZE; i++) { + if (Objects.equals(cachedUnions[i], values)) { + return cachedValues[i]; + } + } + String result = combineSafe(values); + for (int i = 0; i < CACHE_SIZE - 1; i++) { + cachedUnions[i + 1] = cachedUnions[i]; + cachedValues[i + 1] = cachedValues[i]; + } + cachedValues[0] = result; + cachedUnions[0] = values; + return result; + } + + + // package private, user code should not have access to this method + final String getDefaultValue() { + return defaultValue; + } + + // package private, user code should not have access to this method + final String getLastValue() { + return lastValue; + } + + // Precaution to prevent a malicious user from instantiating instances + // of a control where the context has not been set up. + @Override + public final Object clone() throws java.lang.CloneNotSupportedException { + throw new CloneNotSupportedException(); + } + + private final void writeObject(ObjectOutputStream out) throws IOException { + throw new IOException("Object cannot be serialized"); + } + + private final void readObject(ObjectInputStream in) throws IOException { + throw new IOException("Class cannot be deserialized"); + } +} diff --git a/src/share/classes/jdk/jfr/internal/Cutoff.java b/src/share/classes/jdk/jfr/internal/Cutoff.java new file mode 100644 index 0000000000000000000000000000000000000000..9bf9cceabb172058c680e26c6fac3c7f49e1a228 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/Cutoff.java @@ -0,0 +1,75 @@ +/* + * 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 + * 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.internal; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import jdk.jfr.MetadataDefinition; + +/** + * Event annotation, determines the cutoff above which an event should not be + * recorded, i.e. {@code "20 ms"}. + * + * This settings is only supported for JVM events, + * + * @Since 8 + */ +@MetadataDefinition +@Target({ ElementType.TYPE }) +@Inherited +@Retention(RetentionPolicy.RUNTIME) +public @interface Cutoff { + /** + * Settings name {@code "cutoff"} for configuring event cutoffs. + */ + public final static String NAME = "cutoff"; + public final static String INIFITY = "infinity"; + + /** + * Cutoff, for example {@code "20 ms"}. + *

    + * String representation of a positive {@code Long} value followed by an empty + * space and one of the following units
    + *
    + * {@code "ns"} (nanoseconds)
    + * {@code "us"} (microseconds)
    + * {@code "ms"} (milliseconds)
    + * {@code "s"} (seconds)
    + * {@code "m"} (minutes)
    + * {@code "h"} (hours)
    + * {@code "d"} (days)
    + *

    + * Example values, {@code "0 ns"}, {@code "10 ms"} and {@code "1 s"}. If the + * events has an infinite timespan, the text {@code"infinity"} should be used. + * + * @return the threshold, default {@code "0 ns"} not {@code null} + */ + String value() default "inifity"; +} diff --git a/src/share/classes/jdk/jfr/internal/EventClassBuilder.java b/src/share/classes/jdk/jfr/internal/EventClassBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..d20b773465a3bf461cb1eec0e5d973d72c6773b4 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/EventClassBuilder.java @@ -0,0 +1,142 @@ +/* + * 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. 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.internal; + +import java.util.List; +import java.util.concurrent.atomic.AtomicLong; + +import jdk.internal.org.objectweb.asm.AnnotationVisitor; +import jdk.internal.org.objectweb.asm.ClassWriter; +import jdk.internal.org.objectweb.asm.Label; +import jdk.internal.org.objectweb.asm.MethodVisitor; +import jdk.internal.org.objectweb.asm.Opcodes; +import jdk.internal.org.objectweb.asm.Type; +import jdk.internal.org.objectweb.asm.commons.GeneratorAdapter; +import jdk.internal.org.objectweb.asm.commons.Method; +import jdk.jfr.AnnotationElement; +import jdk.jfr.Event; +import jdk.jfr.ValueDescriptor; + + +// Helper class for building dynamic events +public final class EventClassBuilder { + + private static final Type TYPE_EVENT = Type.getType(Event.class); + private static final Type TYPE_IOBE = Type.getType(IndexOutOfBoundsException.class); + private static final Method DEFAULT_CONSTRUCTOR = Method.getMethod("void ()"); + private static final Method SET_METHOD = Method.getMethod("void set (int, java.lang.Object)"); + private static final AtomicLong idCounter = new AtomicLong(); + private final ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); + private final String fullClassName; + private final Type type; + private final List fields; + private final List annotationElements; + + public EventClassBuilder(List annotationElements, List fields) { + this.fullClassName = "jdk.jfr.DynamicEvent" + idCounter.incrementAndGet(); + this.type = Type.getType(fullClassName.replace(".", "/")); + this.fields = fields; + this.annotationElements = annotationElements; + } + + public Class build() { + buildClassInfo(); + buildConstructor(); + buildFields(); + buildSetMethod(); + endClass(); + byte[] bytes = classWriter.toByteArray(); + ASMToolkit.logASM(fullClassName, bytes); + return SecuritySupport.defineClass(type.getInternalName(), bytes, Event.class.getClassLoader()).asSubclass(Event.class); + } + + private void endClass() { + classWriter.visitEnd(); + } + + private void buildSetMethod() { + GeneratorAdapter ga = new GeneratorAdapter(Opcodes.ACC_PUBLIC, SET_METHOD, null, null, classWriter); + int index = 0; + for (ValueDescriptor v : fields) { + ga.loadArg(0); + ga.visitLdcInsn(index); + Label notEqual = new Label(); + ga.ifICmp(GeneratorAdapter.NE, notEqual); + ga.loadThis(); + ga.loadArg(1); + Type fieldType = ASMToolkit.toType(v); + ga.unbox(ASMToolkit.toType(v)); + ga.putField(type, v.getName(), fieldType); + ga.visitInsn(Opcodes.RETURN); + ga.visitLabel(notEqual); + index++; + } + ga.throwException(TYPE_IOBE, "Index must between 0 and " + fields.size()); + ga.endMethod(); + } + + private void buildConstructor() { + MethodVisitor mv = classWriter.visitMethod(Opcodes.ACC_PUBLIC, DEFAULT_CONSTRUCTOR.getName(), DEFAULT_CONSTRUCTOR.getDescriptor(), null, null); + mv.visitIntInsn(Opcodes.ALOAD, 0); + ASMToolkit.invokeSpecial(mv, TYPE_EVENT.getInternalName(), DEFAULT_CONSTRUCTOR); + mv.visitInsn(Opcodes.RETURN); + mv.visitMaxs(0, 0); + } + + private void buildClassInfo() { + String internalSuperName = ASMToolkit.getInternalName(Event.class.getName()); + String internalClassName = type.getInternalName(); + classWriter.visit(52, Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER, internalClassName, null, internalSuperName, null); + + for (AnnotationElement a : annotationElements) { + String descriptor = ASMToolkit.getDescriptor(a.getTypeName()); + AnnotationVisitor av = classWriter.visitAnnotation(descriptor, true); + for (ValueDescriptor v : a.getValueDescriptors()) { + Object value = a.getValue(v.getName()); + String name = v.getName(); + if (v.isArray()) { + AnnotationVisitor arrayVisitor = av.visitArray(name); + Object[] array = (Object[]) value; + for (int i = 0; i < array.length; i++) { + arrayVisitor.visit(null, array[i]); + } + arrayVisitor.visitEnd(); + } else { + av.visit(name, value); + } + } + av.visitEnd(); + } + } + + private void buildFields() { + for (ValueDescriptor v : fields) { + String internal = ASMToolkit.getDescriptor(v.getTypeName()); + classWriter.visitField(Opcodes.ACC_PRIVATE, v.getName(), internal, null, null); + // No need to store annotations on field since they will be replaced anyway. + } + } +} diff --git a/src/share/classes/jdk/jfr/internal/EventControl.java b/src/share/classes/jdk/jfr/internal/EventControl.java new file mode 100644 index 0000000000000000000000000000000000000000..33a46c3eaf23bd0ec18d5fb47f270c3d025a86ca --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/EventControl.java @@ -0,0 +1,291 @@ +/* + * 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. 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.internal; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.Enabled; +import jdk.jfr.Event; +import jdk.jfr.Name; +import jdk.jfr.Period; +import jdk.jfr.SettingControl; +import jdk.jfr.SettingDefinition; +import jdk.jfr.StackTrace; +import jdk.jfr.Threshold; +import jdk.jfr.events.ActiveSettingEvent; +import jdk.jfr.internal.EventInstrumentation.SettingInfo; +import jdk.jfr.internal.settings.CutoffSetting; +import jdk.jfr.internal.settings.EnabledSetting; +import jdk.jfr.internal.settings.PeriodSetting; +import jdk.jfr.internal.settings.StackTraceSetting; +import jdk.jfr.internal.settings.ThresholdSetting; + +// This class can't have a hard reference from PlatformEventType, since it +// holds SettingControl instances that need to be released +// when a class is unloaded (to avoid memory leaks). +public final class EventControl { + + static final String FIELD_SETTING_PREFIX = "setting"; + private static final Type TYPE_ENABLED = TypeLibrary.createType(EnabledSetting.class); + private static final Type TYPE_THRESHOLD = TypeLibrary.createType(ThresholdSetting.class); + private static final Type TYPE_STACK_TRACE = TypeLibrary.createType(StackTraceSetting.class); + private static final Type TYPE_PERIOD = TypeLibrary.createType(PeriodSetting.class); + private static final Type TYPE_CUTOFF = TypeLibrary.createType(CutoffSetting.class); + + private final List settingInfos = new ArrayList<>(); + private final Map eventControls = new HashMap<>(5); + private final PlatformEventType type; + private final String idName; + + EventControl(PlatformEventType eventType) { + eventControls.put(Enabled.NAME, defineEnabled(eventType)); + if (eventType.hasDuration()) { + eventControls.put(Threshold.NAME, defineThreshold(eventType)); + } + if (eventType.hasStackTrace()) { + eventControls.put(StackTrace.NAME, defineStackTrace(eventType)); + } + if (eventType.hasPeriod()) { + eventControls.put(Period.NAME, definePeriod(eventType)); + } + if (eventType.hasCutoff()) { + eventControls.put(Cutoff.NAME, defineCutoff(eventType)); + } + + ArrayList aes = new ArrayList<>(eventType.getAnnotationElements()); + remove(eventType, aes, Threshold.class); + remove(eventType, aes, Period.class); + remove(eventType, aes, Enabled.class); + remove(eventType, aes, StackTrace.class); + remove(eventType, aes, Cutoff.class); + aes.trimToSize(); + eventType.setAnnotations(aes); + this.type = eventType; + this.idName = String.valueOf(eventType.getId()); + } + + static void remove(PlatformEventType type, List aes, Class clazz) { + long id = Type.getTypeId(clazz); + for (AnnotationElement a : type.getAnnotationElements()) { + if (a.getTypeId() == id && a.getTypeName().equals(clazz.getName())) { + aes.remove(a); + } + } + } + + EventControl(PlatformEventType es, Class eventClass) { + this(es); + defineSettings(eventClass); + } + + @SuppressWarnings("unchecked") + private void defineSettings(Class eventClass) { + // Iterate up the class hierarchy and let + // subclasses shadow base classes. + boolean allowPrivateMethod = true; + while (eventClass != null) { + for (Method m : eventClass.getDeclaredMethods()) { + boolean isPrivate = Modifier.isPrivate(m.getModifiers()); + if (m.getReturnType() == Boolean.TYPE && m.getParameterCount() == 1 && (!isPrivate || allowPrivateMethod)) { + SettingDefinition se = m.getDeclaredAnnotation(SettingDefinition.class); + if (se != null) { + Class settingClass = m.getParameters()[0].getType(); + if (!Modifier.isAbstract(settingClass.getModifiers()) && SettingControl.class.isAssignableFrom(settingClass)) { + String name = m.getName(); + Name n = m.getAnnotation(Name.class); + if (n != null) { + name = n.value(); + } + if (!eventControls.containsKey(name)) { + defineSetting((Class) settingClass, m, type, name); + } + } + } + } + } + eventClass = eventClass.getSuperclass(); + allowPrivateMethod = false; + } + } + + private void defineSetting(Class settingsClass, Method method, PlatformEventType eventType, String settingName) { + try { + int index = settingInfos.size(); + SettingInfo si = new SettingInfo(FIELD_SETTING_PREFIX + index, index); + si.settingControl = instantiateSettingControl(settingsClass); + Control c = si.settingControl; + c.setDefault(); + String defaultValue = c.getValueSafe(); + if (defaultValue != null) { + Type settingType = TypeLibrary.createType(settingsClass); + ArrayList aes = new ArrayList<>(); + for (Annotation a : method.getDeclaredAnnotations()) { + AnnotationElement ae = TypeLibrary.createAnnotation(a); + if (ae != null) { + aes.add(ae); + } + } + aes.trimToSize(); + eventControls.put(settingName, si.settingControl); + eventType.add(PrivateAccess.getInstance().newSettingDescriptor(settingType, settingName, defaultValue, aes)); + settingInfos.add(si); + } + } catch (InstantiationException e) { + // Programming error by user, fail fast + throw new InstantiationError("Could not instantiate setting " + settingsClass.getName() + " for event " + eventType.getLogName() + ". " + e.getMessage()); + } catch (IllegalAccessException e) { + // Programming error by user, fail fast + throw new IllegalAccessError("Could not access setting " + settingsClass.getName() + " for event " + eventType.getLogName() + ". " + e.getMessage()); + } + } + + private SettingControl instantiateSettingControl(Class settingControlClass) throws IllegalAccessException, InstantiationException { + SecuritySupport.makeVisibleToJFR(settingControlClass); + final Constructor cc; + try { + cc = settingControlClass.getDeclaredConstructors()[0]; + } catch (Exception e) { + throw (Error) new InternalError("Could not get constructor for " + settingControlClass.getName()).initCause(e); + } + SecuritySupport.setAccessible(cc); + try { + return (SettingControl) cc.newInstance(); + } catch (IllegalArgumentException | InvocationTargetException e) { + throw (Error) new InternalError("Could not instantiate setting for class " + settingControlClass.getName()); + } + } + + private static Control defineEnabled(PlatformEventType type) { + Enabled enabled = type.getAnnotation(Enabled.class); + // Java events are enabled by default, + // JVM events are not, maybe they should be? Would lower learning curve + // there too. + String def = type.isJVM() ? "false" : "true"; + if (enabled != null) { + def = Boolean.toString(enabled.value()); + } + type.add(PrivateAccess.getInstance().newSettingDescriptor(TYPE_ENABLED, Enabled.NAME, def, Collections.emptyList())); + return new EnabledSetting(type, def); + } + + private static Control defineThreshold(PlatformEventType type) { + Threshold threshold = type.getAnnotation(Threshold.class); + String def = "0 ns"; + if (threshold != null) { + def = threshold.value(); + } + type.add(PrivateAccess.getInstance().newSettingDescriptor(TYPE_THRESHOLD, Threshold.NAME, def, Collections.emptyList())); + return new ThresholdSetting(type, def); + } + + private static Control defineStackTrace(PlatformEventType type) { + StackTrace stackTrace = type.getAnnotation(StackTrace.class); + String def = "true"; + if (stackTrace != null) { + def = Boolean.toString(stackTrace.value()); + } + type.add(PrivateAccess.getInstance().newSettingDescriptor(TYPE_STACK_TRACE, StackTrace.NAME, def, Collections.emptyList())); + return new StackTraceSetting(type, def); + } + + private static Control defineCutoff(PlatformEventType type) { + Cutoff cutoff = type.getAnnotation(Cutoff.class); + String def = Cutoff.INIFITY; + if (cutoff != null) { + def = cutoff.value(); + } + type.add(PrivateAccess.getInstance().newSettingDescriptor(TYPE_CUTOFF, Cutoff.NAME, def, Collections.emptyList())); + return new CutoffSetting(type, def); + } + + + private static Control definePeriod(PlatformEventType type) { + Period period = type.getAnnotation(Period.class); + String def = "everyChunk"; + if (period != null) { + def = period.value(); + } + type.add(PrivateAccess.getInstance().newSettingDescriptor(TYPE_PERIOD, PeriodSetting.NAME, def, Collections.emptyList())); + return new PeriodSetting(type, def); + } + + void disable() { + for (Control c : eventControls.values()) { + if (c instanceof EnabledSetting) { + c.setValueSafe("false"); + return; + } + } + } + + void writeActiveSettingEvent() { + if (!type.isRegistered()) { + return; + } + for (Map.Entry entry : eventControls.entrySet()) { + Control c = entry.getValue(); + if (Utils.isSettingVisible(c, type.hasEventHook())) { + String value = c.getLastValue(); + if (value == null) { + value = c.getDefaultValue(); + } + ActiveSettingEvent ase = new ActiveSettingEvent(); + ase.id = type.getId(); + ase.name = entry.getKey(); + ase.value = value; + ase.commit(); + } + } + } + + public Set> getEntries() { + return eventControls.entrySet(); + } + + public PlatformEventType getEventType() { + return type; + } + + public String getSettingsId() { + return idName; + } + + public List getSettingInfos() { + return settingInfos; + } +} diff --git a/src/share/classes/jdk/jfr/internal/EventHandlerCreator.java b/src/share/classes/jdk/jfr/internal/EventHandlerCreator.java new file mode 100644 index 0000000000000000000000000000000000000000..c26dced5c470208168c568c10d5e7fc2c4564207 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/EventHandlerCreator.java @@ -0,0 +1,338 @@ +/* + * 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. 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.internal; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.List; +import java.util.StringJoiner; + +import jdk.internal.org.objectweb.asm.ClassWriter; +import jdk.internal.org.objectweb.asm.Label; +import jdk.internal.org.objectweb.asm.MethodVisitor; +import jdk.internal.org.objectweb.asm.Opcodes; +import jdk.internal.org.objectweb.asm.Type; +import jdk.internal.org.objectweb.asm.commons.Method; +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.SettingControl; +import jdk.jfr.ValueDescriptor; +import jdk.jfr.internal.EventInstrumentation.FieldInfo; +import jdk.jfr.internal.EventInstrumentation.SettingInfo; +import jdk.jfr.internal.handlers.EventHandler; + +final class EventHandlerCreator { + // TODO: + // How can we find out class version without loading a + // class as resource in a privileged block and use ASM to inspect + // the contents. Using '52' even though we know later versions + // are available. The reason for this is compatibility aspects + // with for example WLS. + private static final int CLASS_VERSION = 52; + + // This is needed so a new EventHandler is automatically generated in MetadataRespoistory + // if a user Event class is loaded using APPCDS/CDS. + private static final String SUFFIX = "_" + System.currentTimeMillis() + "-" + JVM.getJVM().getPid(); + + private static final String FIELD_EVENT_TYPE = "platformEventType"; + private static final String FIELD_PREFIX_STRING_POOL = "stringPool"; + + private final static Class eventHandlerProxy = EventHandlerProxyCreator.proxyClass; + private final static Type TYPE_STRING_POOL = Type.getType(StringPool.class); + private final static Type TYPE_EVENT_WRITER = Type.getType(EventWriter.class); + private final static Type TYPE_PLATFORM_EVENT_TYPE = Type.getType(PlatformEventType.class); + private final static Type TYPE_EVENT_HANDLER = Type.getType(eventHandlerProxy); + private final static Type TYPE_SETTING_CONTROL = Type.getType(SettingControl.class); + private final static Type TYPE_EVENT_TYPE = Type.getType(EventType.class); + private final static Type TYPE_EVENT_CONTROL = Type.getType(EventControl.class); + private final static String DESCRIPTOR_EVENT_HANDLER = "(" + Type.BOOLEAN_TYPE.getDescriptor() + TYPE_EVENT_TYPE.getDescriptor() + TYPE_EVENT_CONTROL.getDescriptor() + ")V"; + private final static Method METHOD_GET_EVENT_WRITER = new Method("getEventWriter", "()" + TYPE_EVENT_WRITER.getDescriptor()); + private final static Method METHOD_EVENT_HANDLER_CONSTRUCTOR = new Method("", DESCRIPTOR_EVENT_HANDLER); + private final static Method METHOD_RESET = new Method("reset", "()V"); + + private final ClassWriter classWriter; + private final String className; + private final String internalClassName; + private final List settingInfos; + private final List fields; + + public EventHandlerCreator(long id, List settingInfos, List fields) { + this.classWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); + this.className = makeEventHandlerName(id); + this.internalClassName = ASMToolkit.getInternalName(className); + this.settingInfos = settingInfos; + this.fields = fields; + } + + public static String makeEventHandlerName(long id) { + return eventHandlerProxy.getName() + id + SUFFIX; + } + + public EventHandlerCreator(long id, List settingInfos, EventType type, Class eventClass) { + this(id, settingInfos, createFieldInfos(eventClass, type)); + } + + private static List createFieldInfos(Class eventClass, EventType type) throws Error { + List fieldInfos = new ArrayList<>(); + for (ValueDescriptor v : type.getFields()) { + // Only value descriptors that are not fields on the event class. + if (v != TypeLibrary.STACK_TRACE_FIELD && v != TypeLibrary.THREAD_FIELD) { + String fieldName = PrivateAccess.getInstance().getFieldName(v); + String fieldDescriptor = ASMToolkit.getDescriptor(v.getTypeName()); + Class c = eventClass; + String internalName = null; + while (c != Event.class) { + try { + Field field = c.getDeclaredField(fieldName); + if (c == eventClass || !Modifier.isPrivate(field.getModifiers())) { + internalName = ASMToolkit.getInternalName(c.getName()); + break; + } + } catch (NoSuchFieldException | SecurityException e) { + // ignore + } + c = c.getSuperclass(); + } + if (internalName != null) { + fieldInfos.add(new FieldInfo(fieldName, fieldDescriptor, internalName)); + } else { + throw new InternalError("Could not locate field " + fieldName + " for event type" + type.getName()); + } + } + } + return fieldInfos; + } + + public Class makeEventHandlerClass() { + buildClassInfo(); + buildConstructor(); + buildWriteMethod(); + byte[] bytes = classWriter.toByteArray(); + ASMToolkit.logASM(className, bytes); + return SecuritySupport.defineClass(className, bytes, Event.class.getClassLoader()).asSubclass(EventHandler.class); + } + + public static EventHandler instantiateEventHandler(Class handlerClass, boolean registered, EventType eventType, EventControl eventControl) throws Error { + final Constructor cc; + try { + cc = handlerClass.getDeclaredConstructors()[0]; + } catch (Exception e) { + throw (Error) new InternalError("Could not get handler constructor for " + eventType.getName()).initCause(e); + } + // Users should not be allowed to create instances of the event handler + // so we need to unlock it here. + SecuritySupport.setAccessible(cc); + try { + List settingInfos = eventControl.getSettingInfos(); + Object[] arguments = new Object[3 + settingInfos.size()]; + arguments[0] = registered; + arguments[1] = eventType; + arguments[2] = eventControl; + for (SettingInfo si : settingInfos) { + arguments[si.index + 3] = si.settingControl; + } + return (EventHandler) cc.newInstance(arguments); + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + throw (Error) new InternalError("Could not instantiate event handler for " + eventType.getName() + ". " + e.getMessage()).initCause(e); + } + } + + private void buildConstructor() { + MethodVisitor mv = classWriter.visitMethod(Opcodes.ACC_PRIVATE, METHOD_EVENT_HANDLER_CONSTRUCTOR.getName(), makeConstructorDescriptor(settingInfos), null, null); + mv.visitVarInsn(Opcodes.ALOAD, 0); // this + mv.visitVarInsn(Opcodes.ILOAD, 1); // registered + mv.visitVarInsn(Opcodes.ALOAD, 2); // event type + mv.visitVarInsn(Opcodes.ALOAD, 3); // event control + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, Type.getInternalName(eventHandlerProxy), METHOD_EVENT_HANDLER_CONSTRUCTOR.getName(), METHOD_EVENT_HANDLER_CONSTRUCTOR.getDescriptor(), false); + for (SettingInfo si : settingInfos) { + mv.visitVarInsn(Opcodes.ALOAD, 0); // this + mv.visitVarInsn(Opcodes.ALOAD, si.index + 4); // Setting Control + mv.visitFieldInsn(Opcodes.PUTFIELD, internalClassName, si.fieldName, TYPE_SETTING_CONTROL.getDescriptor()); + } + // initialized string field writers + int fieldIndex = 0; + for (FieldInfo field : fields) { + if (field.isString()) { + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, Type.getInternalName(eventHandlerProxy), "createStringFieldWriter", "()" + TYPE_STRING_POOL.getDescriptor(), false); + mv.visitFieldInsn(Opcodes.PUTFIELD, internalClassName, FIELD_PREFIX_STRING_POOL + fieldIndex, TYPE_STRING_POOL.getDescriptor()); + } + fieldIndex++; + } + mv.visitInsn(Opcodes.RETURN); + mv.visitMaxs(0, 0); + mv.visitEnd(); + } + + private void buildClassInfo() { + String internalSuperName = ASMToolkit.getInternalName(eventHandlerProxy.getName()); + classWriter.visit(CLASS_VERSION, Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER, internalClassName, null, internalSuperName, null); + for (SettingInfo si : settingInfos) { + classWriter.visitField(Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL, si.fieldName, TYPE_SETTING_CONTROL.getDescriptor(), null, null); + } + int fieldIndex = 0; + for (FieldInfo field : fields) { + if (field.isString()) { + classWriter.visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_FINAL, FIELD_PREFIX_STRING_POOL+ fieldIndex, TYPE_STRING_POOL.getDescriptor(), null, null); + } + fieldIndex++; + } + } + + private void visitMethod(final MethodVisitor mv, final int opcode, final Type type, final Method method) { + mv.visitMethodInsn(opcode, type.getInternalName(), method.getName(), method.getDescriptor(), false); + } + + private void buildWriteMethod() { + int argIndex = 0; // // indexes the argument type array, the argument type array does not include 'this' + int slotIndex = 1; // indexes the proper slot in the local variable table, takes type size into account, therefore sometimes argIndex != slotIndex + int fieldIndex = 0; + Method desc = ASMToolkit.makeWriteMethod(fields); + Type[] argumentTypes = Type.getArgumentTypes(desc.getDescriptor()); + MethodVisitor mv = classWriter.visitMethod(Opcodes.ACC_PUBLIC, desc.getName(), desc.getDescriptor(), null, null); + mv.visitCode(); + Label start = new Label(); + Label endTryBlock = new Label(); + Label exceptionHandler = new Label(); + mv.visitTryCatchBlock(start, endTryBlock, exceptionHandler, "java/lang/Throwable"); + mv.visitLabel(start); + visitMethod(mv, Opcodes.INVOKESTATIC, TYPE_EVENT_WRITER, METHOD_GET_EVENT_WRITER); + // stack: [BW] + mv.visitInsn(Opcodes.DUP); + // stack: [BW], [BW] + // write begin event + mv.visitVarInsn(Opcodes.ALOAD, 0); + // stack: [BW], [BW], [this] + mv.visitFieldInsn(Opcodes.GETFIELD, TYPE_EVENT_HANDLER.getInternalName(), FIELD_EVENT_TYPE, TYPE_PLATFORM_EVENT_TYPE.getDescriptor()); + // stack: [BW], [BW], [BS] + visitMethod(mv, Opcodes.INVOKEVIRTUAL, TYPE_EVENT_WRITER, EventWriterMethod.BEGIN_EVENT.asASM()); + // stack: [BW], [integer] + Label recursive = new Label(); + mv.visitJumpInsn(Opcodes.IFEQ, recursive); + // stack: [BW] + // write startTime + mv.visitInsn(Opcodes.DUP); + // stack: [BW], [BW] + mv.visitVarInsn(argumentTypes[argIndex].getOpcode(Opcodes.ILOAD), slotIndex); + // stack: [BW], [BW], [long] + slotIndex += argumentTypes[argIndex++].getSize(); + visitMethod(mv, Opcodes.INVOKEVIRTUAL, TYPE_EVENT_WRITER, EventWriterMethod.PUT_LONG.asASM()); + // stack: [BW] + fieldIndex++; + // write duration + mv.visitInsn(Opcodes.DUP); + // stack: [BW], [BW] + mv.visitVarInsn(argumentTypes[argIndex].getOpcode(Opcodes.ILOAD), slotIndex); + // stack: [BW], [BW], [long] + slotIndex += argumentTypes[argIndex++].getSize(); + visitMethod(mv, Opcodes.INVOKEVIRTUAL, TYPE_EVENT_WRITER, EventWriterMethod.PUT_LONG.asASM()); + // stack: [BW] + fieldIndex++; + // write eventThread + mv.visitInsn(Opcodes.DUP); + // stack: [BW], [BW] + visitMethod(mv, Opcodes.INVOKEVIRTUAL, TYPE_EVENT_WRITER, EventWriterMethod.PUT_EVENT_THREAD.asASM()); + // stack: [BW] + // write stackTrace + mv.visitInsn(Opcodes.DUP); + // stack: [BW], [BW] + visitMethod(mv, Opcodes.INVOKEVIRTUAL, TYPE_EVENT_WRITER, EventWriterMethod.PUT_STACK_TRACE.asASM()); + // stack: [BW] + // write custom fields + while (fieldIndex < fields.size()) { + mv.visitInsn(Opcodes.DUP); + // stack: [BW], [BW] + mv.visitVarInsn(argumentTypes[argIndex].getOpcode(Opcodes.ILOAD), slotIndex); + // stack:[BW], [BW], [field] + slotIndex += argumentTypes[argIndex++].getSize(); + FieldInfo field = fields.get(fieldIndex); + if (field.isString()) { + mv.visitVarInsn(Opcodes.ALOAD, 0); + // stack:[BW], [BW], [field], [this] + mv.visitFieldInsn(Opcodes.GETFIELD, this.internalClassName, FIELD_PREFIX_STRING_POOL + fieldIndex, TYPE_STRING_POOL.getDescriptor()); + // stack:[BW], [BW], [field], [string] + } + EventWriterMethod eventMethod = EventWriterMethod.lookupMethod(field); + visitMethod(mv, Opcodes.INVOKEVIRTUAL, TYPE_EVENT_WRITER, eventMethod.asASM()); + // stack: [BW] + fieldIndex++; + } + // stack: [BW] + // write end event (writer already on stack) + visitMethod(mv, Opcodes.INVOKEVIRTUAL, TYPE_EVENT_WRITER, EventWriterMethod.END_EVENT.asASM()); + // stack [integer] + // notified -> restart event write attempt + mv.visitJumpInsn(Opcodes.IFEQ, start); + // stack: + mv.visitLabel(endTryBlock); + Label end = new Label(); + mv.visitJumpInsn(Opcodes.GOTO, end); + mv.visitLabel(exceptionHandler); + // stack: [ex] + mv.visitFrame(Opcodes.F_SAME1, 0, null, 1, new Object[] {"java/lang/Throwable"}); + visitMethod(mv, Opcodes.INVOKESTATIC, TYPE_EVENT_WRITER, METHOD_GET_EVENT_WRITER); + // stack: [ex] [BW] + mv.visitInsn(Opcodes.DUP); + // stack: [ex] [BW] [BW] + Label rethrow = new Label(); + mv.visitJumpInsn(Opcodes.IFNULL, rethrow); + // stack: [ex] [BW] + mv.visitInsn(Opcodes.DUP); + // stack: [ex] [BW] [BW] + visitMethod(mv, Opcodes.INVOKEVIRTUAL, TYPE_EVENT_WRITER, METHOD_RESET); + mv.visitLabel(rethrow); + // stack:[ex] [BW] + mv.visitFrame(Opcodes.F_SAME, 0, null, 2, new Object[] {"java/lang/Throwable", TYPE_EVENT_WRITER.getInternalName()}); + mv.visitInsn(Opcodes.POP); + // stack:[ex] + mv.visitInsn(Opcodes.ATHROW); + mv.visitLabel(recursive); + // stack: [BW] + mv.visitFrame(Opcodes.F_SAME, 0, null, 1, new Object[] { TYPE_EVENT_WRITER.getInternalName()} ); + mv.visitInsn(Opcodes.POP); + mv.visitLabel(end); + // stack: + mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); + mv.visitInsn(Opcodes.RETURN); + mv.visitMaxs(0, 0); + mv.visitEnd(); + } + + private static String makeConstructorDescriptor(List settingsInfos) { + StringJoiner constructordescriptor = new StringJoiner("", "(", ")V"); + constructordescriptor.add(Type.BOOLEAN_TYPE.getDescriptor()); + constructordescriptor.add(Type.getType(EventType.class).getDescriptor()); + constructordescriptor.add(Type.getType(EventControl.class).getDescriptor()); + for (int i = 0; i < settingsInfos.size(); i++) { + constructordescriptor.add(TYPE_SETTING_CONTROL.getDescriptor()); + } + return constructordescriptor.toString(); + } +} diff --git a/src/share/classes/jdk/jfr/internal/EventHandlerProxyCreator.java b/src/share/classes/jdk/jfr/internal/EventHandlerProxyCreator.java new file mode 100644 index 0000000000000000000000000000000000000000..2c4d06326be140f4e69e1f10a63af12b1c1b888d --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/EventHandlerProxyCreator.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 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 + * 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.internal; + +import java.util.StringJoiner; + +import jdk.internal.org.objectweb.asm.ClassWriter; +import jdk.internal.org.objectweb.asm.MethodVisitor; +import jdk.internal.org.objectweb.asm.Opcodes; +import jdk.internal.org.objectweb.asm.Type; +import jdk.internal.org.objectweb.asm.commons.Method; +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.internal.handlers.EventHandler; + +/* + * Generates an EventHandler subclass dynamically, named EventHandlerProxy. + * EventHandlerProxy is located in a publicly accessible package (jdk.jfr) + * and is used as a superclass for classes generated by EventHandlerCreator. + * The rationale behind this scheme is to block access to jdk.jfr.internal + * package and sub-packages when there is a SecurityManager installed, while + * allowing application-defined event classes to invoke the required internal + * APIs. + */ +final class EventHandlerProxyCreator { + private static final int CLASS_VERSION = 52; + + private final static Type TYPE_EVENT_TYPE = Type.getType(EventType.class); + private final static Type TYPE_EVENT_CONTROL = Type.getType(EventControl.class); + private final static String DESCRIPTOR_EVENT_HANDLER = "(" + Type.BOOLEAN_TYPE.getDescriptor() + TYPE_EVENT_TYPE.getDescriptor() + TYPE_EVENT_CONTROL.getDescriptor() + ")V"; + private final static Method METHOD_EVENT_HANDLER_CONSTRUCTOR = new Method("", DESCRIPTOR_EVENT_HANDLER); + private final static String DESCRIPTOR_TIME_STAMP = "()" + Type.LONG_TYPE.getDescriptor(); + private final static Method METHOD_TIME_STAMP = new Method("timestamp", DESCRIPTOR_TIME_STAMP); + private final static String DESCRIPTOR_DURATION = "(" + Type.LONG_TYPE.getDescriptor() + ")" + Type.LONG_TYPE.getDescriptor(); + private final static Method METHOD_DURATION = new Method("duration", DESCRIPTOR_DURATION); + + private final static ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); + private final static String className = "jdk.jfr.proxy.internal.EventHandlerProxy"; + private final static String internalClassName = ASMToolkit.getInternalName(className); + + // Create the Proxy class instance after all the previous static fields were initialized (textual order) + static final Class proxyClass = EventHandlerProxyCreator.makeEventHandlerProxyClass(); + + static void ensureInitialized() { + // trigger clinit which will setup the EventHandlerProxy class. + } + + public static Class makeEventHandlerProxyClass() { + buildClassInfo(); + buildConstructor(); + buildTimestampMethod(); + buildDurationMethod(); + byte[] bytes = classWriter.toByteArray(); + ASMToolkit.logASM(className, bytes); + return SecuritySupport.defineClass(className, bytes, Event.class.getClassLoader()).asSubclass(EventHandler.class); + } + + private static void buildConstructor() { + MethodVisitor mv = classWriter.visitMethod(0x0, METHOD_EVENT_HANDLER_CONSTRUCTOR.getName(), makeConstructorDescriptor(), null, null); + mv.visitVarInsn(Opcodes.ALOAD, 0); // this + mv.visitVarInsn(Opcodes.ILOAD, 1); // registered + mv.visitVarInsn(Opcodes.ALOAD, 2); // event type + mv.visitVarInsn(Opcodes.ALOAD, 3); // event control + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, Type.getInternalName(EventHandler.class), METHOD_EVENT_HANDLER_CONSTRUCTOR.getName(), METHOD_EVENT_HANDLER_CONSTRUCTOR.getDescriptor(), false); + mv.visitInsn(Opcodes.RETURN); + mv.visitMaxs(0, 0); + mv.visitEnd(); + } + + private static void buildClassInfo() { + String internalSuperName = ASMToolkit.getInternalName(EventHandler.class.getName()); + classWriter.visit(CLASS_VERSION, Opcodes.ACC_PUBLIC + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SUPER, internalClassName, null, internalSuperName, null); + } + + private static void buildTimestampMethod() { + MethodVisitor mv = classWriter.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, METHOD_TIME_STAMP.getName(), METHOD_TIME_STAMP.getDescriptor(), null, null); + mv.visitCode(); + mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(EventHandler.class), METHOD_TIME_STAMP.getName(), METHOD_TIME_STAMP.getDescriptor(), false); + mv.visitInsn(Opcodes.LRETURN); + mv.visitMaxs(0, 0); + mv.visitEnd(); + } + + private static void buildDurationMethod() { + MethodVisitor mv = classWriter.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, METHOD_DURATION.getName(), METHOD_DURATION.getDescriptor(), null, null); + mv.visitCode(); + mv.visitVarInsn(Opcodes.LLOAD, 0); + mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(EventHandler.class), METHOD_DURATION.getName(), METHOD_DURATION.getDescriptor(), false); + mv.visitInsn(Opcodes.LRETURN); + mv.visitMaxs(0, 0); + mv.visitEnd(); + } + + private static String makeConstructorDescriptor() { + StringJoiner constructordescriptor = new StringJoiner("", "(", ")V"); + constructordescriptor.add(Type.BOOLEAN_TYPE.getDescriptor()); + constructordescriptor.add(Type.getType(EventType.class).getDescriptor()); + constructordescriptor.add(Type.getType(EventControl.class).getDescriptor()); + return constructordescriptor.toString(); + } +} diff --git a/src/share/classes/jdk/jfr/internal/EventInstrumentation.java b/src/share/classes/jdk/jfr/internal/EventInstrumentation.java new file mode 100644 index 0000000000000000000000000000000000000000..70c48065623a099c24abe8191eadb27fc14537aa --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/EventInstrumentation.java @@ -0,0 +1,528 @@ +/* + * 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. 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.internal; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.lang.reflect.Parameter; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.function.Consumer; + +import jdk.internal.org.objectweb.asm.ClassReader; +import jdk.internal.org.objectweb.asm.ClassWriter; +import jdk.internal.org.objectweb.asm.Label; +import jdk.internal.org.objectweb.asm.MethodVisitor; +import jdk.internal.org.objectweb.asm.Opcodes; +import jdk.internal.org.objectweb.asm.Type; +import jdk.internal.org.objectweb.asm.commons.Method; +import jdk.internal.org.objectweb.asm.tree.AnnotationNode; +import jdk.internal.org.objectweb.asm.tree.ClassNode; +import jdk.internal.org.objectweb.asm.tree.FieldNode; +import jdk.internal.org.objectweb.asm.tree.MethodNode; +import jdk.jfr.Enabled; +import jdk.jfr.Event; +import jdk.jfr.Name; +import jdk.jfr.Registered; +import jdk.jfr.SettingControl; +import jdk.jfr.SettingDefinition; +import jdk.jfr.internal.handlers.EventHandler; + +/** + * Class responsible for adding instrumentation to a subclass of {@link Event}. + * + */ +public final class EventInstrumentation { + static final class SettingInfo { + private String methodName; + private String internalSettingName; + private String settingDescriptor; + final String fieldName; + final int index; + // Used when instantiating Setting + SettingControl settingControl; + + public SettingInfo(String fieldName, int index) { + this.fieldName = fieldName; + this.index = index; + } + } + + static final class FieldInfo { + private final static Type STRING = Type.getType(String.class); + final String fieldName; + final String fieldDescriptor; + final String internalClassName; + + public FieldInfo(String fieldName, String fieldDescriptor, String internalClassName) { + this.fieldName = fieldName; + this.fieldDescriptor = fieldDescriptor; + this.internalClassName = internalClassName; + } + + public boolean isString() { + return STRING.getDescriptor().equals(fieldDescriptor); + } + } + + public static final String FIELD_EVENT_THREAD = "eventThread"; + public static final String FIELD_STACK_TRACE = "stackTrace"; + public static final String FIELD_DURATION = "duration"; + + static final String FIELD_EVENT_HANDLER = "eventHandler"; + static final String FIELD_START_TIME = "startTime"; + + private static final Class eventHandlerProxy = EventHandlerProxyCreator.proxyClass; + private static final Type ANNOTATION_TYPE_NAME = Type.getType(Name.class); + private static final Type ANNOTATION_TYPE_REGISTERED = Type.getType(Registered.class); + private static final Type ANNOTATION_TYPE_ENABLED = Type.getType(Enabled.class); + private static final Type TYPE_EVENT_HANDLER = Type.getType(eventHandlerProxy); + private static final Type TYPE_SETTING_CONTROL = Type.getType(SettingControl.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]); + private static final Method METHOD_IS_ENABLED = new Method("isEnabled", Type.BOOLEAN_TYPE, new Type[0]); + private static final Method METHOD_TIME_STAMP = new Method("timestamp", Type.LONG_TYPE, new Type[0]); + private static final Method METHOD_EVENT_SHOULD_COMMIT = new Method("shouldCommit", Type.BOOLEAN_TYPE, new Type[0]); + private static final Method METHOD_EVENT_HANDLER_SHOULD_COMMIT = new Method("shouldCommit", Type.BOOLEAN_TYPE, new Type[] { Type.LONG_TYPE }); + private static final Method METHOD_DURATION = new Method("duration", Type.LONG_TYPE, new Type[] { Type.LONG_TYPE }); + + private final ClassNode classNode; + private final List settingInfos; + private final List fieldInfos;; + private final Method writeMethod; + private final String eventHandlerXInternalName; + private final String eventName; + private boolean guardHandlerReference; + private Class superClass; + + EventInstrumentation(Class superClass, byte[] bytes, long id) { + this.superClass = superClass; + this.classNode = createClassNode(bytes); + this.settingInfos = buildSettingInfos(superClass, classNode); + this.fieldInfos = buildFieldInfos(superClass, classNode); + 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; + + } + + public String getClassName() { + return classNode.name.replace("/","."); + } + + private ClassNode createClassNode(byte[] bytes) { + ClassNode classNode = new ClassNode(); + ClassReader classReader = new ClassReader(bytes); + classReader.accept(classNode, 0); + return classNode; + } + + boolean isRegistered() { + Boolean result = annotationValue(classNode, ANNOTATION_TYPE_REGISTERED.getDescriptor(), Boolean.class); + if (result != null) { + return result.booleanValue(); + } + if (superClass != null) { + Registered r = superClass.getAnnotation(Registered.class); + if (r != null) { + return r.value(); + } + } + return true; + } + + boolean isEnabled() { + Boolean result = annotationValue(classNode, ANNOTATION_TYPE_ENABLED.getDescriptor(), Boolean.class); + if (result != null) { + return result.booleanValue(); + } + if (superClass != null) { + Enabled e = superClass.getAnnotation(Enabled.class); + if (e != null) { + return e.value(); + } + } + return true; + } + + @SuppressWarnings("unchecked") + private static T annotationValue(ClassNode classNode, String typeDescriptor, Class type) { + if (classNode.visibleAnnotations != null) { + for (AnnotationNode a : classNode.visibleAnnotations) { + if (typeDescriptor.equals(a.desc)) { + List values = a.values; + if (values != null && values.size() == 2) { + Object key = values.get(0); + Object value = values.get(1); + if (key instanceof String && value != null) { + if (type == value.getClass()) { + String keyName = (String) key; + if ("value".equals(keyName)) { + return (T) value; + } + } + } + } + } + } + } + return null; + } + + private static List buildSettingInfos(Class superClass, ClassNode classNode) { + Set methodSet = new HashSet<>(); + List settingInfos = new ArrayList<>(); + String settingDescriptor = Type.getType(SettingDefinition.class).getDescriptor(); + for (MethodNode m : classNode.methods) { + if (m.visibleAnnotations != null) { + for (AnnotationNode an : m.visibleAnnotations) { + // We can't really validate the method at this + // stage. We would need to check that the parameter + // is an instance of SettingControl. + if (settingDescriptor.equals(an.desc)) { + Type returnType = Type.getReturnType(m.desc); + if (returnType.equals(Type.getType(Boolean.TYPE))) { + Type[] args = Type.getArgumentTypes(m.desc); + if (args.length == 1) { + Type paramType = args[0]; + String fieldName = EventControl.FIELD_SETTING_PREFIX + settingInfos.size(); + int index = settingInfos.size(); + SettingInfo si = new SettingInfo(fieldName, index); + si.methodName = m.name; + si.settingDescriptor = paramType.getDescriptor(); + si.internalSettingName = paramType.getInternalName(); + methodSet.add(m.name); + settingInfos.add(si); + } + } + } + } + } + } + for (Class c = superClass; c != Event.class; c = c.getSuperclass()) { + for (java.lang.reflect.Method method : c.getDeclaredMethods()) { + if (!methodSet.contains(method.getName())) { + // skip private method in base classes + if (!Modifier.isPrivate(method.getModifiers())) { + if (method.getReturnType().equals(Boolean.TYPE)) { + if (method.getParameterCount() == 1) { + Parameter param = method.getParameters()[0]; + Type paramType = Type.getType(param.getType()); + String fieldName = EventControl.FIELD_SETTING_PREFIX + settingInfos.size(); + int index = settingInfos.size(); + SettingInfo si = new SettingInfo(fieldName, index); + si.methodName = method.getName(); + si.settingDescriptor = paramType.getDescriptor(); + si.internalSettingName = paramType.getInternalName(); + methodSet.add(method.getName()); + settingInfos.add(si); + } + } + } + } + } + } + return settingInfos; + + } + + private static List buildFieldInfos(Class superClass, ClassNode classNode) { + Set fieldSet = new HashSet<>(); + List fieldInfos = new ArrayList<>(classNode.fields.size()); + // These two field are added by native as transient so they will be + // ignored by the loop below. + // The benefit of adding them manually is that we can + // control in which order they occur and we can add @Name, @Description + // in Java, instead of in native. It also means code for adding implicit + // fields for native can be reused by Java. + 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)) { + 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 (Field field : c.getDeclaredFields()) { + // skip private field in base classes + if (!Modifier.isPrivate(field.getModifiers())) { + if (isValidField(field.getModifiers(), field.getType().getName())) { + String fieldName = field.getName(); + if (!fieldSet.contains(fieldName)) { + Type fieldType = Type.getType(field.getType()); + String internalClassName = ASMToolkit.getInternalName(c.getName()); + fieldInfos.add(new FieldInfo(fieldName, fieldType.getDescriptor(), internalClassName)); + fieldSet.add(fieldName); + } + } + } + } + } + return fieldInfos; + } + + public static boolean isValidField(int access, String className) { + if (Modifier.isTransient(access) || Modifier.isStatic(access)) { + return false; + } + return jdk.jfr.internal.Type.isValidJavaFieldType(className); + } + + public byte[] buildInstrumented() { + makeInstrumented(); + return toByteArray(); + } + + private byte[] toByteArray() { + ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); + classNode.accept(cw); + cw.visitEnd(); + byte[] result = cw.toByteArray(); + Utils.writeGeneratedASM(classNode.name, result); + return result; + } + + public byte[] builUninstrumented() { + makeUninstrumented(); + return toByteArray(); + } + + private void makeInstrumented() { + // MyEvent#isEnabled() + updateMethod(METHOD_IS_ENABLED, methodVisitor -> { + Label nullLabel = new Label(); + if (guardHandlerReference) { + methodVisitor.visitFieldInsn(Opcodes.GETSTATIC, getInternalClassName(), FIELD_EVENT_HANDLER, TYPE_EVENT_HANDLER.getDescriptor()); + methodVisitor.visitJumpInsn(Opcodes.IFNULL, nullLabel); + } + methodVisitor.visitFieldInsn(Opcodes.GETSTATIC, getInternalClassName(), FIELD_EVENT_HANDLER, TYPE_EVENT_HANDLER.getDescriptor()); + ASMToolkit.invokeVirtual(methodVisitor, TYPE_EVENT_HANDLER.getInternalName(), METHOD_IS_ENABLED); + methodVisitor.visitInsn(Opcodes.IRETURN); + if (guardHandlerReference) { + methodVisitor.visitLabel(nullLabel); + methodVisitor.visitFrame(Opcodes.F_SAME, 0, null, 0, null); + methodVisitor.visitInsn(Opcodes.ICONST_0); + methodVisitor.visitInsn(Opcodes.IRETURN); + } + }); + + // MyEvent#begin() + updateMethod(METHOD_BEGIN, methodVisitor -> { + methodVisitor.visitIntInsn(Opcodes.ALOAD, 0); + ASMToolkit.invokeStatic(methodVisitor, TYPE_EVENT_HANDLER.getInternalName(), METHOD_TIME_STAMP); + methodVisitor.visitFieldInsn(Opcodes.PUTFIELD, getInternalClassName(), FIELD_START_TIME, "J"); + methodVisitor.visitInsn(Opcodes.RETURN); + }); + + // MyEvent#end() + updateMethod(METHOD_END, methodVisitor -> { + methodVisitor.visitIntInsn(Opcodes.ALOAD, 0); + methodVisitor.visitIntInsn(Opcodes.ALOAD, 0); + methodVisitor.visitFieldInsn(Opcodes.GETFIELD, getInternalClassName(), FIELD_START_TIME, "J"); + ASMToolkit.invokeStatic(methodVisitor, TYPE_EVENT_HANDLER.getInternalName(), METHOD_DURATION); + methodVisitor.visitFieldInsn(Opcodes.PUTFIELD, getInternalClassName(), FIELD_DURATION, "J"); + methodVisitor.visitInsn(Opcodes.RETURN); + methodVisitor.visitMaxs(0, 0); + }); + + // MyEvent#commit() - Java event writer + updateMethod(METHOD_COMMIT, methodVisitor -> { + // if (!isEnable()) { + // return; + // } + methodVisitor.visitCode(); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); + methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, getInternalClassName(), METHOD_IS_ENABLED.getName(), METHOD_IS_ENABLED.getDescriptor(), false); + Label l0 = new Label(); + methodVisitor.visitJumpInsn(Opcodes.IFNE, l0); + methodVisitor.visitInsn(Opcodes.RETURN); + methodVisitor.visitLabel(l0); + methodVisitor.visitFrame(Opcodes.F_SAME, 0, null, 0, null); + // if (startTime == 0) { + // startTime = EventWriter.timestamp(); + // } else { + methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); + methodVisitor.visitFieldInsn(Opcodes.GETFIELD, getInternalClassName(), FIELD_START_TIME, "J"); + methodVisitor.visitInsn(Opcodes.LCONST_0); + methodVisitor.visitInsn(Opcodes.LCMP); + Label durationalEvent = new Label(); + methodVisitor.visitJumpInsn(Opcodes.IFNE, durationalEvent); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); + methodVisitor.visitMethodInsn(Opcodes.INVOKESTATIC, TYPE_EVENT_HANDLER.getInternalName(), METHOD_TIME_STAMP.getName(), + METHOD_TIME_STAMP.getDescriptor(), false); + methodVisitor.visitFieldInsn(Opcodes.PUTFIELD, getInternalClassName(), FIELD_START_TIME, "J"); + Label commit = new Label(); + methodVisitor.visitJumpInsn(Opcodes.GOTO, commit); + // if (duration == 0) { + // duration = EventWriter.timestamp() - startTime; + // } + // } + methodVisitor.visitLabel(durationalEvent); + methodVisitor.visitFrame(Opcodes.F_SAME, 0, null, 0, null); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); + methodVisitor.visitFieldInsn(Opcodes.GETFIELD, getInternalClassName(), FIELD_DURATION, "J"); + methodVisitor.visitInsn(Opcodes.LCONST_0); + methodVisitor.visitInsn(Opcodes.LCMP); + methodVisitor.visitJumpInsn(Opcodes.IFNE, commit); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); + methodVisitor.visitMethodInsn(Opcodes.INVOKESTATIC, TYPE_EVENT_HANDLER.getInternalName(), METHOD_TIME_STAMP.getName(), METHOD_TIME_STAMP.getDescriptor(), false); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); + methodVisitor.visitFieldInsn(Opcodes.GETFIELD, getInternalClassName(), FIELD_START_TIME, "J"); + methodVisitor.visitInsn(Opcodes.LSUB); + methodVisitor.visitFieldInsn(Opcodes.PUTFIELD, getInternalClassName(), FIELD_DURATION, "J"); + methodVisitor.visitLabel(commit); + // if (shouldCommit()) { + methodVisitor.visitFrame(Opcodes.F_SAME, 0, null, 0, null); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); + methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, getInternalClassName(), METHOD_EVENT_SHOULD_COMMIT.getName(), METHOD_EVENT_SHOULD_COMMIT.getDescriptor(), false); + Label end = new Label(); + // eventHandler.write(...); + // } + methodVisitor.visitJumpInsn(Opcodes.IFEQ, end); + methodVisitor.visitFieldInsn(Opcodes.GETSTATIC, getInternalClassName(), FIELD_EVENT_HANDLER, Type.getDescriptor(eventHandlerProxy)); + + methodVisitor.visitTypeInsn(Opcodes.CHECKCAST, eventHandlerXInternalName); + for (FieldInfo fi : fieldInfos) { + methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); + methodVisitor.visitFieldInsn(Opcodes.GETFIELD, fi.internalClassName, fi.fieldName, fi.fieldDescriptor); + } + + methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, eventHandlerXInternalName, writeMethod.getName(), writeMethod.getDescriptor(), false); + methodVisitor.visitLabel(end); + methodVisitor.visitFrame(Opcodes.F_SAME, 0, null, 0, null); + methodVisitor.visitInsn(Opcodes.RETURN); + methodVisitor.visitEnd(); + }); + + // 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(eventHandlerProxy)); + 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); + methodVisitor.visitJumpInsn(Opcodes.IFEQ, fail); + 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(eventHandlerProxy)); + methodVisitor.visitTypeInsn(Opcodes.CHECKCAST, eventHandlerXInternalName); + methodVisitor.visitFieldInsn(Opcodes.GETFIELD, eventHandlerXInternalName, si.fieldName, TYPE_SETTING_CONTROL.getDescriptor()); + methodVisitor.visitTypeInsn(Opcodes.CHECKCAST, si.internalSettingName); + methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, getInternalClassName(), si.methodName, "(" + si.settingDescriptor + ")Z", false); + methodVisitor.visitJumpInsn(Opcodes.IFEQ, fail); + } + // return true + methodVisitor.visitInsn(Opcodes.ICONST_1); + methodVisitor.visitInsn(Opcodes.IRETURN); + // return false + methodVisitor.visitLabel(fail); + methodVisitor.visitInsn(Opcodes.ICONST_0); + methodVisitor.visitInsn(Opcodes.IRETURN); + }); + } + + private void makeUninstrumented() { + updateExistingWithReturnFalse(METHOD_EVENT_SHOULD_COMMIT); + updateExistingWithReturnFalse(METHOD_IS_ENABLED); + updateExistingWithEmptyVoidMethod(METHOD_COMMIT); + updateExistingWithEmptyVoidMethod(METHOD_BEGIN); + updateExistingWithEmptyVoidMethod(METHOD_END); + } + + private final void updateExistingWithEmptyVoidMethod(Method voidMethod) { + updateMethod(voidMethod, methodVisitor -> { + methodVisitor.visitInsn(Opcodes.RETURN); + }); + } + + private final void updateExistingWithReturnFalse(Method voidMethod) { + updateMethod(voidMethod, methodVisitor -> { + methodVisitor.visitInsn(Opcodes.ICONST_0); + methodVisitor.visitInsn(Opcodes.IRETURN); + }); + } + + private MethodNode getMethodNode(Method method) { + for (MethodNode m : classNode.methods) { + if (m.name.equals(method.getName()) && m.desc.equals(method.getDescriptor())) { + return m; + } + } + return null; + } + + private final void updateMethod(Method method, Consumer code) { + MethodNode old = getMethodNode(method); + int index = classNode.methods.indexOf(old); + classNode.methods.remove(old); + MethodVisitor mv = classNode.visitMethod(old.access, old.name, old.desc, null, null); + mv.visitCode(); + code.accept(mv); + mv.visitMaxs(0, 0); + MethodNode newMethod = getMethodNode(method); + classNode.methods.remove(newMethod); + classNode.methods.add(index, newMethod); + } + + public static Method makeWriteMethod(List fields) { + StringBuilder sb = new StringBuilder(); + sb.append("("); + for (FieldInfo v : fields) { + sb.append(v.fieldDescriptor); + } + sb.append(")V"); + return new Method("write", sb.toString()); + } + + private String getInternalClassName() { + return classNode.name; + } + + public List getSettingInfos() { + return settingInfos; + } + + public List getFieldInfos() { + return fieldInfos; + } + + public String getEventName() { + return eventName; + } + + public void setGuardHandler(boolean guardHandlerReference) { + this.guardHandlerReference = guardHandlerReference; + } +} diff --git a/src/share/classes/jdk/jfr/internal/EventWriter.java b/src/share/classes/jdk/jfr/internal/EventWriter.java new file mode 100644 index 0000000000000000000000000000000000000000..ef30e9411ed2c76614918986acdfa1968fcc6e35 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/EventWriter.java @@ -0,0 +1,355 @@ +/* + * 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. 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.internal; + +import sun.misc.Unsafe; +import jdk.jfr.internal.consumer.RecordingInput; + +/** + * Class must reside in a package with package restriction. + * + * Users should not have direct access to underlying memory. + * + */ +public final class EventWriter { + private static final Unsafe unsafe = Unsafe.getUnsafe(); + private final static JVM jvm = JVM.getJVM(); + + private long startPosition; + private long startPositionAddress; + private long currentPosition; + private long maxPosition; + private final long threadID; + private PlatformEventType eventType; + private int maxEventSize; + private boolean started; + private boolean valid; + private boolean flushOnEnd; + // set by the JVM, not private to avoid being optimized out + boolean notified; + + public static EventWriter getEventWriter() { + EventWriter ew = (EventWriter)JVM.getEventWriter(); + return ew != null ? ew : JVM.newEventWriter(); + } + + public void putBoolean(boolean i) { + if (isValidForSize(Byte.BYTES)) { + currentPosition += Bits.putBoolean(currentPosition, i); + } + } + + public void putByte(byte i) { + if (isValidForSize(Byte.BYTES)) { + unsafe.putByte(currentPosition, i); + ++currentPosition; + } + } + + public void putChar(char v) { + if (isValidForSize(Character.BYTES + 1)) { + putUncheckedLong(v); + } + } + + private void putUncheckedChar(char v) { + putUncheckedLong(v); + } + + public void putShort(short v) { + if (isValidForSize(Short.BYTES + 1)) { + putUncheckedLong(v & 0xFFFF); + } + } + + public void putInt(int v) { + if (isValidForSize(Integer.BYTES + 1)) { + putUncheckedLong(v & 0x00000000ffffffffL); + } + } + + private void putUncheckedInt(int v) { + putUncheckedLong(v & 0x00000000ffffffffL); + } + + public void putFloat(float i) { + if (isValidForSize(Float.BYTES)) { + currentPosition += Bits.putFloat(currentPosition, i); + } + } + + public void putLong(long v) { + if (isValidForSize(Long.BYTES + 1)) { + putUncheckedLong(v); + } + } + + public void putDouble(double i) { + if (isValidForSize(Double.BYTES)) { + currentPosition += Bits.putDouble(currentPosition, i); + } + } + + public void putString(String s, StringPool pool) { + if (s == null) { + putByte(RecordingInput.STRING_ENCODING_NULL); + return; + } + int length = s.length(); + if (length == 0) { + putByte(RecordingInput.STRING_ENCODING_EMPTY_STRING); + return; + } + if (length > StringPool.MIN_LIMIT && length < StringPool.MAX_LIMIT) { + long l = StringPool.addString(s); + if (l > 0) { + putByte(RecordingInput.STRING_ENCODING_CONSTANT_POOL); + putLong(l); + return; + } + } + putStringValue(s); + return; + } + + private void putStringValue(String s) { + int length = s.length(); + if (isValidForSize(1 + 5 + 3 * length)) { + putUncheckedByte(RecordingInput.STRING_ENCODING_CHAR_ARRAY); // 1 byte + putUncheckedInt(length); // max 5 bytes + for (int i = 0; i < length; i++) { + putUncheckedChar(s.charAt(i)); // max 3 bytes + } + } + } + + public void putEventThread() { + putLong(threadID); + } + + public void putThread(Thread athread) { + if (athread == null) { + putLong(0L); + } else { + putLong(jvm.getThreadId(athread)); + } + } + + public void putClass(Class aClass) { + if (aClass == null) { + putLong(0L); + } else { + putLong(JVM.getClassIdNonIntrinsic(aClass)); + } + } + + public void putStackTrace() { + if (eventType.getStackTraceEnabled()) { + putLong(jvm.getStackTraceId(eventType.getStackTraceOffset())); + } else { + putLong(0L); + } + } + + private void reserveEventSizeField() { + // move currentPosition Integer.Bytes offset from start position + if (isValidForSize(Integer.BYTES)) { + currentPosition += Integer.BYTES; + } + } + + private void reset() { + currentPosition = startPosition; + if (flushOnEnd) { + flushOnEnd = flush(); + } + valid = true; + started = false; + } + + private boolean isValidForSize(int requestedSize) { + if (!valid) { + return false; + } + if (currentPosition + requestedSize > maxPosition) { + flushOnEnd = flush(usedSize(), requestedSize); + // retry + if (currentPosition + requestedSize > maxPosition) { + Logger.log(LogTag.JFR_SYSTEM, + LogLevel.WARN, () -> + "Unable to commit. Requested size " + requestedSize + " too large"); + valid = false; + return false; + } + } + return true; + } + + private boolean isNotified() { + return notified; + } + + private void resetNotified() { + notified = false; + } + + private int usedSize() { + return (int) (currentPosition - startPosition); + } + + private boolean flush() { + return flush(usedSize(), 0); + } + + private boolean flush(int usedSize, int requestedSize) { + return JVM.flush(this, usedSize, requestedSize); + } + + public boolean beginEvent(PlatformEventType eventType) { + if (started) { + // recursive write attempt + return false; + } + started = true; + this.eventType = eventType; + reserveEventSizeField(); + putLong(eventType.getId()); + return true; + } + + public boolean endEvent() { + if (!valid) { + reset(); + return true; + } + final int eventSize = usedSize(); + if (eventSize > maxEventSize) { + reset(); + return true; + } + Bits.putInt(startPosition, makePaddedInt(eventSize)); + if (isNotified()) { + resetNotified(); + reset(); + // returning false will trigger restart of the event write attempt + return false; + } + startPosition = currentPosition; + unsafe.putAddress(startPositionAddress, startPosition); + // the event is now committed + if (flushOnEnd) { + flushOnEnd = flush(); + } + started = false; + return true; + } + + private EventWriter(long startPos, long maxPos, long startPosAddress, long threadID, boolean valid) { + startPosition = currentPosition = startPos; + maxPosition = maxPos; + startPositionAddress = startPosAddress; + this.threadID = threadID; + started = false; + flushOnEnd = false; + this.valid = valid; + notified = false; + // event may not exceed size for a padded integer + maxEventSize = (1 << 28) -1; + } + + private static int makePaddedInt(int v) { + // bit 0-6 + pad => bit 24 - 31 + long b1 = (((v >>> 0) & 0x7F) | 0x80) << 24; + + // bit 7-13 + pad => bit 16 - 23 + long b2 = (((v >>> 7) & 0x7F) | 0x80) << 16; + + // bit 14-20 + pad => bit 8 - 15 + long b3 = (((v >>> 14) & 0x7F) | 0x80) << 8; + + // bit 21-28 => bit 0 - 7 + long b4 = (((v >>> 21) & 0x7F)) << 0; + + return (int) (b1 + b2 + b3 + b4); + } + + private void putUncheckedLong(long v) { + if ((v & ~0x7FL) == 0L) { + putUncheckedByte((byte) v); // 0-6 + return; + } + putUncheckedByte((byte) (v | 0x80L)); // 0-6 + v >>>= 7; + if ((v & ~0x7FL) == 0L) { + putUncheckedByte((byte) v); // 7-13 + return; + } + putUncheckedByte((byte) (v | 0x80L)); // 7-13 + v >>>= 7; + if ((v & ~0x7FL) == 0L) { + putUncheckedByte((byte) v); // 14-20 + return; + } + putUncheckedByte((byte) (v | 0x80L)); // 14-20 + v >>>= 7; + if ((v & ~0x7FL) == 0L) { + putUncheckedByte((byte) v); // 21-27 + return; + } + putUncheckedByte((byte) (v | 0x80L)); // 21-27 + v >>>= 7; + if ((v & ~0x7FL) == 0L) { + putUncheckedByte((byte) v); // 28-34 + return; + } + putUncheckedByte((byte) (v | 0x80L)); // 28-34 + v >>>= 7; + if ((v & ~0x7FL) == 0L) { + putUncheckedByte((byte) v); // 35-41 + return; + } + putUncheckedByte((byte) (v | 0x80L)); // 35-41 + v >>>= 7; + if ((v & ~0x7FL) == 0L) { + putUncheckedByte((byte) v); // 42-48 + return; + } + putUncheckedByte((byte) (v | 0x80L)); // 42-48 + v >>>= 7; + + if ((v & ~0x7FL) == 0L) { + putUncheckedByte((byte) v); // 49-55 + return; + } + putUncheckedByte((byte) (v | 0x80L)); // 49-55 + putUncheckedByte((byte) (v >>> 7)); // 56-63, last byte as is. + } + + private void putUncheckedByte(byte i) { + unsafe.putByte(currentPosition, i); + ++currentPosition; + } +} diff --git a/src/share/classes/jdk/jfr/internal/EventWriterMethod.java b/src/share/classes/jdk/jfr/internal/EventWriterMethod.java new file mode 100644 index 0000000000000000000000000000000000000000..f453b571793fbdb208e8349609a10570fe669aeb --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/EventWriterMethod.java @@ -0,0 +1,81 @@ +/* + * 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. 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.internal; + +import jdk.internal.org.objectweb.asm.commons.Method; +import jdk.jfr.internal.EventInstrumentation.FieldInfo; + +public enum EventWriterMethod { + + BEGIN_EVENT("(" + jdk.internal.org.objectweb.asm.Type.getType(PlatformEventType.class).getDescriptor() + ")Z", "???", "beginEvent"), + END_EVENT("()Z", "???", "endEvent"), + PUT_BYTE("(B)V", "byte", "putByte"), + PUT_SHORT("(S)V", "short", "putShort"), + PUT_INT("(I)V", "int", "putInt"), + PUT_LONG("(J)V", "long", "putLong"), + PUT_FLOAT("(F)V", "float", "putFloat"), + PUT_DOUBLE("(D)V", "double", "putDouble"), + PUT_CHAR("(C)V", "char", "putChar"), + PUT_BOOLEAN("(Z)V", "boolean", "putBoolean"), + PUT_THREAD("(Ljava/lang/Thread;)V", Type.THREAD.getName(), "putThread"), + PUT_CLASS("(Ljava/lang/Class;)V", Type.CLASS.getName(), "putClass"), + PUT_STRING("(Ljava/lang/String;Ljdk/jfr/internal/StringPool;)V", Type.STRING.getName(), "putString"), + PUT_EVENT_THREAD("()V", Type.THREAD.getName(), "putEventThread"), + PUT_STACK_TRACE("()V", Type.TYPES_PREFIX + "StackTrace", "putStackTrace"); + + private final Method asmMethod; + private final String typeDescriptor; + + EventWriterMethod(String paramSignature, String typeName, String methodName) { + this.typeDescriptor = ASMToolkit.getDescriptor(typeName); + this.asmMethod = new Method(methodName, paramSignature); + } + + public Method asASM() { + return asmMethod; + } + + /** + * Return method in {@link EventWriter} class to use when writing event of + * a certain type. + * + * @param v field info + * + * @return the method + */ + public static EventWriterMethod lookupMethod(FieldInfo v) { + // event thread + if (v.fieldName.equals(EventInstrumentation.FIELD_EVENT_THREAD)) { + return EventWriterMethod.PUT_EVENT_THREAD; + } + for (EventWriterMethod m : EventWriterMethod.values()) { + if (v.fieldDescriptor.equals(m.typeDescriptor)) { + return m; + } + } + throw new Error("Unknown type " + v.fieldDescriptor); + } +} diff --git a/src/share/classes/jdk/jfr/internal/JVM.java b/src/share/classes/jdk/jfr/internal/JVM.java new file mode 100644 index 0000000000000000000000000000000000000000..bd7d086c47d0b1d805c30307638a165cd545fe5e --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/JVM.java @@ -0,0 +1,527 @@ +/* + * 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. 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.internal; + +import java.io.IOException; +import java.util.List; + +import jdk.jfr.Event; + +/** + * Interface against the JVM. + * + */ +public final class JVM { + private static final JVM jvm = new JVM(); + + // JVM signals file changes by doing Object#notifu on this object + static final Object FILE_DELTA_CHANGE = new Object(); + + static final long RESERVED_CLASS_ID_LIMIT = 400; + + private volatile boolean recording; + private volatile boolean nativeOK; + + private static native void registerNatives(); + + static { + registerNatives(); + // XXX + // for (LogTag tag : LogTag.values()) { + // subscribeLogLevel(tag, tag.id); + // } + Options.ensureInitialized(); + EventHandlerProxyCreator.ensureInitialized(); + } + + /** + * Get the one and only JVM. + * + * @return the JVM + */ + public static JVM getJVM() { + return jvm; + } + + private JVM() { + } + + /** + * Begin recording events + * + * Requires that JFR has been started with {@link #createNativeJFR()} + */ + public native void beginRecording(); + + /** + * Return ticks + * + * @return the time, in ticks + * + */ +// @HotSpotIntrinsicCandidate + public static native long counterTime(); + + + /** + * Emits native periodic event. + * + * @param eventTypeId type id + * + * @param timestamp commit time for event + * @param when when it is being done {@link Periodic.When} + * + * @return true if the event was committed + */ + public native boolean emitEvent(long eventTypeId, long timestamp, long when); + + /** + * End recording events, which includes flushing data in thread buffers + * + * Requires that JFR has been started with {@link #createNativeJFR()} + * + */ + public native void endRecording(); + + /** + * Return a list of all classes deriving from {@link Event} + * + * @return list of event classes. + */ + public native List> getAllEventClasses(); + + /** + * Return a count of the number of unloaded classes deriving from {@link Event} + * + * @return number of unloaded event classes. + */ + public native long getUnloadedEventClassCount(); + + /** + * Return a unique identifier for a class. The class is marked as being + * "in use" in JFR. + * + * @param clazz clazz + * + * @return a unique class identifier + */ +// @HotSpotIntrinsicCandidate + public static native long getClassId(Class clazz); + + // temporary workaround until we solve intrinsics supporting epoch shift tagging + public static native long getClassIdNonIntrinsic(Class clazz); + + /** + * Return process identifier. + * + * @return process identifier + */ + public native String getPid(); + + /** + * Return unique identifier for stack trace. + * + * Requires that JFR has been started with {@link #createNativeJFR()} + * + * @param skipCount number of frames to skip + * @return a unique stack trace identifier + */ + public native long getStackTraceId(int skipCount); + + /** + * Return identifier for thread + * + * @param t thread + * @return a unique thread identifier + */ + public native long getThreadId(Thread t); + + /** + * Frequency, ticks per second + * + * @return frequency + */ + public native long getTicksFrequency(); + + /** + * Write message to log. Should swallow null or empty message, and be able + * to handle any Java character and not crash with very large message + * + * @param tagSetId the tagset id + * @param level on level + * @param message log message + * + */ + public static native void log(int tagSetId, int level, String message); + + /** + * Subscribe to LogLevel updates for LogTag + * + * @param lt the log tag to subscribe + * @param tagSetId the tagset id + */ + public static native void subscribeLogLevel(LogTag lt, int tagSetId); + + /** + * Call to invoke event tagging and retransformation of the passed classes + * + * @param classes + */ + public native synchronized void retransformClasses(Class[] classes); + + /** + * Enable event + * + * @param eventTypeId event type id + * + * @param enabled enable event + */ + public native void setEnabled(long eventTypeId, boolean enabled); + + /** + * Interval at which the JVM should notify on {@link #FILE_DELTA_CHANGE} + * + * @param delta number of bytes, reset after file rotation + */ + public native void setFileNotification(long delta); + + /** + * Set the number of global buffers to use + * + * @param count + * + * @throws IllegalArgumentException if count is not within a valid range + * @throws IllegalStateException if value can't be changed + */ + public native void setGlobalBufferCount(long count) throws IllegalArgumentException, IllegalStateException; + + /** + * Set size of a global buffer + * + * @param size + * + * @throws IllegalArgumentException if buffer size is not within a valid + * range + */ + public native void setGlobalBufferSize(long size) throws IllegalArgumentException; + + /** + * Set overall memory size + * + * @param size + * + * @throws IllegalArgumentException if memory size is not within a valid + * range + */ + public native void setMemorySize(long size) throws IllegalArgumentException; + + /** + + /** + * Set interval for method samples, in milliseconds. + * + * Setting interval to 0 turns off the method sampler. + * + * @param intervalMillis the sampling interval + */ + public native void setMethodSamplingInterval(long type, long intervalMillis); + + /** + * Sets the file where data should be written. + * + * Requires that JFR has been started with {@link #createNativeJFR()} + * + *
    +     * Recording  Previous  Current  Action
    +     * ==============================================
    +     *    true     null      null     Ignore, keep recording in-memory
    +     *    true     null      file1    Start disk recording
    +     *    true     file      null     Copy out metadata to disk and continue in-memory recording
    +     *    true     file1     file2    Copy out metadata and start with new File (file2)
    +     *    false     *        null     Ignore, but start recording to memory with {@link #beginRecording()}
    +     *    false     *        file     Ignore, but start recording to disk with {@link #beginRecording()}
    +     *
    +     * 
    + * + * recording can be set to true/false with {@link #beginRecording()} + * {@link #endRecording()} + * + * @param file the file where data should be written, or null if it should + * not be copied out (in memory). + * + * @throws IOException + */ + public native void setOutput(String file); + + /** + * Controls if a class deriving from jdk.jfr.Event should + * always be instrumented on class load. + * + * @param force, true to force initialization, false otherwise + */ + public native void setForceInstrumentation(boolean force); + + /** + * Turn on/off thread sampling. + * + * @param sampleThreads true if threads should be sampled, false otherwise. + * + * @throws IllegalStateException if state can't be changed. + */ + public native void setSampleThreads(boolean sampleThreads) throws IllegalStateException; + + /** + * Turn on/off compressed integers. + * + * @param compressed true if compressed integers should be used, false + * otherwise. + * + * @throws IllegalStateException if state can't be changed. + */ + public native void setCompressedIntegers(boolean compressed) throws IllegalStateException; + + /** + * Set stack depth. + * + * @param depth + * + * @throws IllegalArgumentException if not within a valid range + * @throws IllegalStateException if depth can't be changed + */ + public native void setStackDepth(int depth) throws IllegalArgumentException, IllegalStateException; + + /** + * Turn on stack trace for an event + * + * @param eventTypeId the event id + * + * @param enabled if stack traces should be enabled + */ + public native void setStackTraceEnabled(long eventTypeId, boolean enabled); + + /** + * Set thread buffer size. + * + * @param size + * + * @throws IllegalArgumentException if size is not within a valid range + * @throws IllegalStateException if size can't be changed + */ + public native void setThreadBufferSize(long size) throws IllegalArgumentException, IllegalStateException; + + /** + * Set threshold for event, + * + * Long.MAXIMUM_VALUE = no limit + * + * @param eventTypeId the id of the event type + * @param ticks threshold in ticks, + * @return true, if it could be set + */ + public native boolean setThreshold(long eventTypeId, long ticks); + + /** + * Store the metadata descriptor that is to be written at the end of a + * chunk, data should be written after GMT offset and size of metadata event + * should be adjusted + * + * Requires that JFR has been started with {@link #createNativeJFR()} + * + * @param bytes binary representation of metadata descriptor + * + * @param binary representation of descriptor + */ + public native void storeMetadataDescriptor(byte[] bytes); + + public void endRecording_() { + endRecording(); + recording = false; + } + + public void beginRecording_() { + beginRecording(); + recording = true; + } + + public boolean isRecording() { + return recording; + } + + /** + * If the JVM supports JVM TI and retransformation has not been disabled this + * method will return true. This flag can not change during the lifetime of + * the JVM. + * + * @return if transform is allowed + */ + public native boolean getAllowedToDoEventRetransforms(); + + /** + * Set up native resources, data structures, threads etc. for JFR + * + * @param simulateFailure simulate a initialization failure and rollback in + * native, used for testing purposes + * + * @throws IllegalStateException if native part of JFR could not be created. + * + */ + private native boolean createJFR(boolean simulateFailure) throws IllegalStateException; + + /** + * Destroys native part of JFR. If already destroy, call is ignored. + * + * Requires that JFR has been started with {@link #createNativeJFR()} + * + * @return if an instance was actually destroyed. + * + */ + private native boolean destroyJFR(); + + public boolean createFailedNativeJFR() throws IllegalStateException { + return createJFR(true); + } + + public void createNativeJFR() { + nativeOK = createJFR(false); + } + + public boolean destroyNativeJFR() { + boolean result = destroyJFR(); + nativeOK = !result; + return result; + } + + public boolean hasNativeJFR() { + return nativeOK; + } + + /** + * Cheap test to check if JFR functionality is available. + * + * @return + */ + public native boolean isAvailable(); + + /** + * To convert ticks to wall clock time. + */ + public native double getTimeConversionFactor(); + + /** + * Return a unique identifier for a class. Compared to {@link #getClassId()} + * , this method does not tag the class as being "in-use". + * + * @param clazz class + * + * @return a unique class identifier + */ + public native long getTypeId(Class clazz); + + /** + * Fast path fetching the EventWriter using VM intrinsics + * + * @return thread local EventWriter + */ +// @HotSpotIntrinsicCandidate + public static native Object getEventWriter(); + + /** + * Create a new EventWriter + * + * @return thread local EventWriter + */ + public static native EventWriter newEventWriter(); + + /** + * Flushes the EventWriter for this thread. + */ + public static native boolean flush(EventWriter writer, int uncommittedSize, int requestedSize); + + /** + * Sets the location of the disk repository, to be used at an emergency + * dump. + * + * @param dirText + */ + public native void setRepositoryLocation(String dirText); + + /** + * Access to VM termination support. + * + *@param errorMsg descriptive message to be include in VM termination sequence + */ + public native void abort(String errorMsg); + + /** + * Adds a string to the string constant pool. + * + * If the same string is added twice, two entries will be created. + * + * @param id identifier associated with the string, not negative + * + * @param s string constant to be added, not null + * + * @return the current epoch of this insertion attempt + */ + public static native boolean addStringConstant(boolean epoch, long id, String s); + /** + * Gets the address of the jboolean epoch. + * + * The epoch alternates every checkpoint. + * + * @return The address of the jboolean. + */ + public native long getEpochAddress(); + + public native void uncaughtException(Thread thread, Throwable t); + /** + * Sets cutoff for event. + * + * Determines how long the event should be allowed to run. + * + * Long.MAXIMUM_VALUE = no limit + * + * @param eventTypeId the id of the event type + * @param cutoffTicks cutoff in ticks, + * @return true, if it could be set + */ + public native boolean setCutoff(long eventTypeId, long cutoffTicks); + + /** + * Emit old object sample events. + * + * @param cutoff the cutoff in ticks + * @param emitAll emit all samples in old object queue + */ + public native void emitOldObjectSamples(long cutoff, boolean emitAll); + + /** + * Test if a chunk rotation is warranted. + * + * @return if it is time to perform a chunk rotation + */ + public native boolean shouldRotateDisk(); +} diff --git a/src/share/classes/jdk/jfr/internal/JVMSupport.java b/src/share/classes/jdk/jfr/internal/JVMSupport.java new file mode 100644 index 0000000000000000000000000000000000000000..f509690050394f65f95c20bc562ffdc7e23a2ef1 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/JVMSupport.java @@ -0,0 +1,86 @@ +/* + * 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. 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.internal; + +import java.io.IOException; + +/** + * Checks if the running VM supports Flight Recorder. + * + * Purpose of this helper class is to detect early and cleanly if the VM has + * support for Flight Recorder, i.e. not throw {@link UnsatisfiedLinkError} in + * unexpected places. + *

    + * This is needed so a disabled-jfr.jar can be built for non Oracle JDKs. + */ +public final class JVMSupport { + + private static final String UNSUPPORTED_VM_MESSAGE = "Flight Recorder is not supported on this VM"; + private static final boolean notAvailable = !checkAvailability(); + + private static boolean checkAvailability() { + // set jfr.unsupported.vm to true to test API on an unsupported VM + try { + if (SecuritySupport.getBooleanProperty("jfr.unsupported.vm")) { + return false; + } + } catch (NoClassDefFoundError cnfe) { + return false; + } + try { + // Will typically throw UnsatisfiedLinkError if + // there is no native implementation + JVM.getJVM().isAvailable(); + return true; + } catch (Throwable t) { + return false; + } + } + + public static void ensureWithInternalError() { + if (notAvailable) { + throw new InternalError(UNSUPPORTED_VM_MESSAGE); + } + } + + public static void ensureWithIOException() throws IOException { + if (notAvailable) { + throw new IOException(UNSUPPORTED_VM_MESSAGE); + } + } + + public static void ensureWithIllegalStateException() { + if (notAvailable) { + throw new IllegalStateException(UNSUPPORTED_VM_MESSAGE); + } + } + + public static boolean isNotAvailable() { + return notAvailable; + } + + public static void tryToInitializeJVM() { + } +} diff --git a/src/share/classes/jdk/jfr/internal/JVMUpcalls.java b/src/share/classes/jdk/jfr/internal/JVMUpcalls.java new file mode 100644 index 0000000000000000000000000000000000000000..7e2d6fd81162ed907bff0673223854b255c663e5 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/JVMUpcalls.java @@ -0,0 +1,152 @@ +/* + * 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. 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.internal; + +import java.lang.reflect.Modifier; + +import jdk.jfr.Event; +import jdk.jfr.internal.handlers.EventHandler; +import jdk.jfr.internal.instrument.JDKEvents; + +/** + * All upcalls from the JVM should go through this class. + * + */ +// Called by native +final class JVMUpcalls { + /** + * Called by the JVM when a retransform happens on a tagged class + * + * @param traceId + * Id of the class + * @param dummy + * (not used but needed since invoke infrastructure in native + * uses same signature bytesForEagerInstrumentation) + * @param clazz + * class being retransformed + * @param oldBytes + * byte code + * @return byte code to use + * @throws Throwable + */ + 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 (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 + return oldBytes; + } + Logger.log(LogTag.JFR_SYSTEM, LogLevel.INFO, "Adding instrumentation to event class " + clazz.getName() + " using retransform"); + EventInstrumentation ei = new EventInstrumentation(clazz.getSuperclass(), oldBytes, traceId); + byte[] bytes = ei.buildInstrumented(); + ASMToolkit.logASM(clazz.getName(), bytes); + return bytes; + } + return JDKEvents.retransformCallback(clazz, oldBytes); + } catch (Throwable t) { + Logger.log(LogTag.JFR_SYSTEM, LogLevel.WARN, "Unexpected error when adding instrumentation to event class " + clazz.getName()); + } + return oldBytes; + + } + + /** + * Called by the JVM when requested to do an "eager" instrumentation. Would + * normally happen when JVMTI retransform capabilities are not available. + * + * @param traceId + * Id of the class + * @param forceInstrumentation + * add instrumentation regardless if event is enabled or not. + * @param superClazz + * the super class of the class being processed + * @param oldBytes + * byte code + * @return byte code to use + * @throws Throwable + */ + static byte[] bytesForEagerInstrumentation(long traceId, boolean forceInstrumentation, Class superClass, byte[] oldBytes) throws Throwable { + if (JVMSupport.isNotAvailable()) { + return oldBytes; + } + String eventName = ""; + try { + EventInstrumentation ei = new EventInstrumentation(superClass, oldBytes, traceId); + eventName = ei.getEventName(); + if (!forceInstrumentation) { + // Assume we are recording + MetadataRepository mr = MetadataRepository.getInstance(); + // No need to generate bytecode if: + // 1) Event class is disabled, and there is not an external configuration that overrides. + // 2) Event class has @Registered(false) + if (!mr.isEnabled(ei.getEventName()) && !ei.isEnabled() || !ei.isRegistered()) { + Logger.log(LogTag.JFR_SYSTEM, LogLevel.INFO, "Skipping instrumentation for event type " + eventName + " since event was disabled on class load"); + return oldBytes; + } + } + // Corner case when we are forced to generate bytecode. We can't reference the event + // handler in #isEnabled() before event class has been registered, so we add a + // guard against a null reference. + ei.setGuardHandler(true); + Logger.log(LogTag.JFR_SYSTEM, LogLevel.INFO, "Adding " + (forceInstrumentation ? "forced " : "") + "instrumentation for event type " + eventName + " during initial class load"); + EventHandlerCreator eh = new EventHandlerCreator(traceId, ei.getSettingInfos(), ei.getFieldInfos()); + // Handler class must be loaded before instrumented event class can + // be used + eh.makeEventHandlerClass(); + byte[] bytes = ei.buildInstrumented(); + ASMToolkit.logASM(ei.getClassName() + "(" + traceId + ")", bytes); + return bytes; + } catch (Throwable t) { + Logger.log(LogTag.JFR_SYSTEM, LogLevel.WARN, "Unexpected error when adding instrumentation for event type " + eventName); + return oldBytes; + } + } + + /** + * Called by the JVM to create the recorder thread. + * + * @param systemThreadGroup + * the system thread group + * + * @param contextClassLoader + * the context class loader. + * + * @return a new thread + */ + static Thread createRecorderThread(ThreadGroup systemThreadGroup, ClassLoader contextClassLoader) { + return SecuritySupport.createRecorderThread(systemThreadGroup, contextClassLoader); + } + + /** + * Called by the JVM to initialize the EventHandlerProxy class. + * + * @return the EventHandlerProxy class + */ + static Class getEventHandlerProxyClass() { + return EventHandlerProxyCreator.proxyClass; + } +} diff --git a/src/solaris/native/sun/awt/robot_common.h b/src/share/classes/jdk/jfr/internal/LogLevel.java similarity index 73% rename from src/solaris/native/sun/awt/robot_common.h rename to src/share/classes/jdk/jfr/internal/LogLevel.java index 8d231568b7459a3e9523786d25003d947b95bb4d..bb5af57a8576ae70e1e9f3d2825de18a39398f7d 100644 --- a/src/solaris/native/sun/awt/robot_common.h +++ b/src/share/classes/jdk/jfr/internal/LogLevel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2006, 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 @@ -22,18 +22,20 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -#ifndef _ROBOT_COMMON_H -#define _ROBOT_COMMON_H -#include "java_awt_event_InputEvent.h" +package jdk.jfr.internal; -#include -#include "gdefs.h" +public enum LogLevel { + TRACE(1), + DEBUG(2), + INFO(3), + WARN(4), + ERROR(5); + // must be in sync with JVM levels. -int QueryColorMap(Display *disp, - Colormap src_cmap, - Visual *src_vis, - XColor **src_colors, - int *rShift, int *gShift, int *bShift); + final int level; -#endif /* _ROBOT_COMMON_H */ + LogLevel(int level) { + this.level = level; + } +} diff --git a/src/share/classes/jdk/jfr/internal/LogTag.java b/src/share/classes/jdk/jfr/internal/LogTag.java new file mode 100644 index 0000000000000000000000000000000000000000..195d6b06adc83abc4ec0ec4630c12df55a6a8871 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/LogTag.java @@ -0,0 +1,90 @@ +/* + * 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. 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.internal; + +/* Mapped against c++ enum in jfrLogTagSet.hpp */ +public enum LogTag { + /** + * Covers + *

      + *
    • Initialization of Flight Recorder + *
    • recording life cycle (start, stop and dump) + *
    • repository life cycle + *
    • loading of configuration files. + *
    + * Target audience: operations + */ + JFR(0), + /** + * Covers general implementation aspects of JFR (for Hotspot developers) + */ + JFR_SYSTEM(1), + /** + * Covers JVM/JDK events (for Hotspot developers) + */ + JFR_SYSTEM_EVENT(2), + /** + * Covers setting for the JVM/JDK (for Hotspot developers) + */ + JFR_SYSTEM_SETTING(3), + /** + * Covers generated bytecode (for Hotspot developers) + */ + JFR_SYSTEM_BYTECODE(4), + /** + * Covers XML parsing (for Hotspot developers) + */ + JFR_SYSTEM_PARSER(5), + /** + * Covers metadata for JVM/JDK (for Hotspot developers) + */ + JFR_SYSTEM_METADATA(6), + /** + * Covers metadata for Java user (for Hotspot developers) + */ + JFR_METADATA(7), + /** + * Covers events (for users of the JDK) + */ + JFR_EVENT(8), + /** + * Covers setting (for users of the JDK) + */ + JFR_SETTING(9), + /** + * Covers usage of jcmd with JFR + */ + JFR_DCMD(10); + + /* set from native side */ + volatile int tagSetLevel = 100; // prevent logging if JVM log system has not been initialized + + final int id; + + LogTag(int tagId) { + id = tagId; + } +} diff --git a/src/share/classes/jdk/jfr/internal/Logger.java b/src/share/classes/jdk/jfr/internal/Logger.java new file mode 100644 index 0000000000000000000000000000000000000000..7ac595dc31b26b0514b8d58c32a9d05979c6e2b4 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/Logger.java @@ -0,0 +1,69 @@ +/* + * 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. 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.internal; + +import java.util.function.Supplier; + +/** + * JFR logger + * + */ + +public final class Logger { + + private final static int MAX_SIZE = 10000; + static { + // This will try to initialize the JVM logging system + JVMSupport.tryToInitializeJVM(); + } + + + public static void log(LogTag logTag, LogLevel logLevel, String message) { + if (shouldLog(logTag, logLevel)) { + logInternal(logTag, logLevel, message); + } + } + + public static void log(LogTag logTag, LogLevel logLevel, Supplier messageSupplier) { + if (shouldLog(logTag, logLevel)) { + logInternal(logTag, logLevel, messageSupplier.get()); + } + } + + private static void logInternal(LogTag logTag, LogLevel logLevel, String message) { + if (message == null || message.length() < MAX_SIZE) { + JVM.log(logTag.id, logLevel.level, message); + } else { + JVM.log(logTag.id, logLevel.level, message.substring(0, MAX_SIZE)); + } + } + + public static boolean shouldLog(LogTag tag, LogLevel level) { + // Logging level is not initialized because of lack of Xlog support in jdk8, + // so this method returns true directly now. + return true; // TODO: level.level >= tag.tagSetLevel; + } +} diff --git a/src/share/classes/jdk/jfr/internal/MetadataDescriptor.java b/src/share/classes/jdk/jfr/internal/MetadataDescriptor.java new file mode 100644 index 0000000000000000000000000000000000000000..40da229b7eabbbd30e7f2b6aa51500ba2462add7 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/MetadataDescriptor.java @@ -0,0 +1,273 @@ +/* + * 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. 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.internal; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Locale; +import java.util.TimeZone; + +import jdk.jfr.EventType; + +/** + * Metadata about a chunk + */ +public final class MetadataDescriptor { + + static final class Attribute { + final String name; + final String value; + + private Attribute(String name, String value) { + this.name = name; + this.value = value; + } + } + + static final class Element { + final String name; + final List elements = new ArrayList<>(); + final List attributes = new ArrayList<>(); + + Element(String name) { + this.name = name; + } + + long longValue(String name) { + String v = attribute(name); + if (v != null) + return Long.parseLong(v); + else + throw new IllegalArgumentException(name); + } + + String attribute(String name) { + for (Attribute a : attributes) { + if (a.name.equals(name)) { + return a.value; + } + } + return null; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + try { + prettyPrintXML(sb, "", this); + } catch (IOException e) { + // should not happen + } + return sb.toString(); + } + + long attribute(String name, long defaultValue) { + String text = attribute(name); + if (text == null) { + return defaultValue; + } + return Long.parseLong(text); + } + + String attribute(String name, String defaultValue) { + String text = attribute(name); + if (text == null) { + return defaultValue; + } + return text; + } + + List elements(String... names) { + List filteredElements = new ArrayList<>(); + for (String name : names) { + for (Element e : elements) { + if (e.name.equals(name)) { + filteredElements.add(e); + } + } + } + return filteredElements; + } + + void add(Element element) { + elements.add(element); + } + + void addAttribute(String name, Object value) { + attributes.add(new Attribute(name, String.valueOf(value))); + } + + Element newChild(String name) { + Element e = new Element(name); + elements.add(e); + return e; + } + + public void addArrayAttribute(Element element, String name, Object value) { + String typeName = value.getClass().getComponentType().getName(); + switch (typeName) { + case "int": + int[] ints = (int[]) value; + for (int i = 0; i < ints.length; i++) { + addAttribute(name + "-" + i , ints[i]); + } + break; + case "long": + long[] longs = (long[]) value; + for (int i = 0; i < longs.length; i++) { + addAttribute(name + "-" + i , longs[i]); + } + break; + case "float": + float[] floats = (float[]) value; + for (int i = 0; i < floats.length; i++) { + addAttribute(name + "-" + i , floats[i]); + } + break; + + case "double": + double[] doubles = (double[]) value; + for (int i = 0; i < doubles.length; i++) { + addAttribute(name + "-" + i , doubles[i]); + } + break; + case "short": + short[] shorts = (short[]) value; + for (int i = 0; i < shorts.length; i++) { + addAttribute(name + "-" + i , shorts[i]); + } + break; + case "char": + char[] chars = (char[]) value; + for (int i = 0; i < chars.length; i++) { + addAttribute(name + "-" + i , chars[i]); + } + break; + case "byte": + byte[] bytes = (byte[]) value; + for (int i = 0; i < bytes.length; i++) { + addAttribute(name + "-" + i , bytes[i]); + } + break; + case "boolean": + boolean[] booleans = (boolean[]) value; + for (int i = 0; i < booleans.length; i++) { + addAttribute(name + "-" + i , booleans[i]); + } + break; + case "java.lang.String": + String[] strings = (String[]) value; + for (int i = 0; i < strings.length; i++) { + addAttribute(name + "-" + i , strings[i]); + } + break; + default: + throw new InternalError("Array type of " + typeName + " is not supported"); + } + } + } + + static final String ATTRIBUTE_ID = "id"; + static final String ATTRIBUTE_SIMPLE_TYPE = "simpleType"; + static final String ATTRIBUTE_GMT_OFFSET = "gmtOffset"; + static final String ATTRIBUTE_LOCALE = "locale"; + static final String ELEMENT_TYPE = "class"; + static final String ELEMENT_SETTING = "setting"; + static final String ELEMENT_ANNOTATION = "annotation"; + static final String ELEMENT_FIELD = "field"; + static final String ATTRIBUTE_SUPER_TYPE = "superType"; + static final String ATTRIBUTE_TYPE_ID = "class"; + static final String ATTRIBUTE_DIMENSION = "dimension"; + static final String ATTRIBUTE_NAME = "name"; + static final String ATTRIBUTE_CONSTANT_POOL = "constantPool"; + static final String ATTRIBUTE_DEFAULT_VALUE = "defaultValue"; + + final List eventTypes = new ArrayList<>(); + final Collection types = new ArrayList<>(); + long gmtOffset; + String locale; + Element root; + + // package private + MetadataDescriptor() { + } + + private static void prettyPrintXML(Appendable sb, String indent, Element e) throws IOException { + sb.append(indent + "<" + e.name); + for (Attribute a : e.attributes) { + sb.append(" ").append(a.name).append("=\"").append(a.value).append("\""); + } + if (e.elements.size() == 0) { + sb.append("/"); + } + sb.append(">\n"); + for (Element child : e.elements) { + prettyPrintXML(sb, indent + " ", child); + } + if (e.elements.size() != 0) { + sb.append(indent).append("\n"); + } + } + + public Collection getTypes() { + return types; + } + + public List getEventTypes() { + return eventTypes; + } + + public int getGMTOffset() { + return (int) gmtOffset; + } + + public String getLocale() { + return locale; + } + + public static MetadataDescriptor read(DataInput input) throws IOException { + MetadataReader r = new MetadataReader(input); + return r.getDescriptor(); + } + + static void write(List types, DataOutput output) throws IOException { + MetadataDescriptor m = new MetadataDescriptor(); + m.locale = Locale.getDefault().toString(); + m.gmtOffset = TimeZone.getDefault().getRawOffset(); + m.types.addAll(types); + MetadataWriter w = new MetadataWriter(m); + w.writeBinary(output); + } + + @Override + public String toString() { + return root.toString(); + } +} diff --git a/src/share/classes/jdk/jfr/internal/MetadataHandler.java b/src/share/classes/jdk/jfr/internal/MetadataHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..831b4444c6d23dfd9b0cb5903afca22796db444f --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/MetadataHandler.java @@ -0,0 +1,421 @@ +/* + * 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. 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.internal; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.lang.annotation.Annotation; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import jdk.internal.org.xml.sax.Attributes; +import jdk.internal.org.xml.sax.EntityResolver; +import jdk.internal.org.xml.sax.SAXException; +import jdk.internal.org.xml.sax.helpers.DefaultHandler; +import jdk.internal.util.xml.SAXParser; +import jdk.internal.util.xml.impl.SAXParserImpl; +import jdk.jfr.AnnotationElement; +import jdk.jfr.Category; +import jdk.jfr.Description; +import jdk.jfr.Enabled; +import jdk.jfr.Experimental; +import jdk.jfr.Label; +import jdk.jfr.Period; +import jdk.jfr.Relational; +import jdk.jfr.StackTrace; +import jdk.jfr.Threshold; +import jdk.jfr.TransitionFrom; +import jdk.jfr.TransitionTo; +import jdk.jfr.Unsigned; + +final class MetadataHandler extends DefaultHandler implements EntityResolver { + + static class TypeElement { + List fields = new ArrayList<>(); + String name; + String label; + String description; + String category; + String superType; + String period; + boolean thread; + boolean startTime; + boolean stackTrace; + boolean cutoff; + boolean isEvent; + boolean experimental; + boolean valueType; + } + + static class FieldElement { + TypeElement referenceType; + String name; + String label; + String description; + String contentType; + String typeName; + String transition; + String relation; + boolean struct; + boolean array; + boolean experimental; + boolean unsigned; + } + + static class XmlType { + String name; + String javaType; + String contentType; + boolean unsigned; + } + + final Map types = new LinkedHashMap<>(200); + final Map xmlTypes = new HashMap<>(20); + final Map> xmlContentTypes = new HashMap<>(20); + final List relations = new ArrayList<>(); + long eventTypeId = 255; + long structTypeId = 33; + FieldElement currentField; + TypeElement currentType; + + @Override + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { + switch (qName) { + case "XmlType": + XmlType xmlType = new XmlType(); + xmlType.name = attributes.getValue("name"); + xmlType.javaType = attributes.getValue("javaType"); + xmlType.contentType = attributes.getValue("contentType"); + xmlType.unsigned = Boolean.valueOf(attributes.getValue("unsigned")); + xmlTypes.put(xmlType.name, xmlType); + break; + case "Type": + case "Event": + currentType = new TypeElement(); + currentType.name = attributes.getValue("name"); + currentType.label = attributes.getValue("label"); + currentType.description = attributes.getValue("description"); + currentType.category = attributes.getValue("category"); + currentType.thread = getBoolean(attributes, "thread", false); + currentType.stackTrace = getBoolean(attributes, "stackTrace", false); + currentType.startTime = getBoolean(attributes, "startTime", true); + currentType.period = attributes.getValue("period"); + currentType.cutoff = getBoolean(attributes, "cutoff", false); + currentType.experimental = getBoolean(attributes, "experimental", false); + currentType.isEvent = qName.equals("Event"); + break; + case "Field": + currentField = new FieldElement(); + currentField.struct = getBoolean(attributes, "struct", false); + currentField.array = getBoolean(attributes, "array", false); + currentField.name = attributes.getValue("name"); + currentField.label = attributes.getValue("label"); + currentField.typeName = attributes.getValue("type"); + currentField.description = attributes.getValue("description"); + currentField.experimental = getBoolean(attributes, "experimental", false); + currentField.contentType = attributes.getValue("contentType"); + currentField.relation = attributes.getValue("relation"); + currentField.transition = attributes.getValue("transition"); + break; + case "XmlContentType": + String name = attributes.getValue("name"); + String annotation = attributes.getValue("annotation"); + xmlContentTypes.put(name, createAnnotationElements(annotation)); + break; + case "Relation": + String n = attributes.getValue("name"); + relations.add(n); + break; + } + } + + private List createAnnotationElements(String annotation) throws InternalError { + String[] annotations = annotation.split(","); + List annotationElements = new ArrayList<>(); + for (String a : annotations) { + a = a.trim(); + int leftParenthesis = a.indexOf("("); + if (leftParenthesis == -1) { + annotationElements.add(new AnnotationElement(createAnnotationClass(a))); + } else { + int rightParenthesis = a.lastIndexOf(")"); + if (rightParenthesis == -1) { + throw new InternalError("Expected closing parenthesis for 'XMLContentType'"); + } + String value = a.substring(leftParenthesis + 1, rightParenthesis); + String type = a.substring(0, leftParenthesis); + annotationElements.add(new AnnotationElement(createAnnotationClass(type), value)); + } + } + return annotationElements; + } + + @SuppressWarnings("unchecked") + private Class createAnnotationClass(String type) { + try { + if (!type.startsWith("jdk.jfr.")) { + throw new IllegalStateException("Incorrect type " + type + ". Annotation class must be located in jdk.jfr package."); + } + Class c = Class.forName(type, true, null); + return (Class) c; + } catch (ClassNotFoundException cne) { + throw new IllegalStateException(cne); + } + } + + private boolean getBoolean(Attributes attributes, String name, boolean defaultValue) { + String value = attributes.getValue(name); + return value == null ? defaultValue : Boolean.valueOf(value); + } + + @Override + public void endElement(String uri, String localName, String qName) { + switch (qName) { + case "Type": + case "Event": + types.put(currentType.name, currentType); + currentType = null; + break; + case "Field": + currentType.fields.add(currentField); + currentField = null; + break; + } + } + + public static List createTypes() throws IOException { + SAXParser parser = new SAXParserImpl(); + MetadataHandler t = new MetadataHandler(); + try (InputStream is = new BufferedInputStream(SecuritySupport.getResourceAsStream("/jdk/jfr/internal/types/metadata.xml"))) { + Logger.log(LogTag.JFR_SYSTEM, LogLevel.DEBUG, () -> "Parsing metadata.xml"); + try { + parser.parse(is, t); + return t.buildTypes(); + } catch (Exception e) { + e.printStackTrace(); + throw new IOException(e); + } + } + } + + private List buildTypes() { + removeXMLConvenience(); + Map typeMap = buildTypeMap(); + Map relationMap = buildRelationMap(typeMap); + addFields(typeMap, relationMap); + return trimTypes(typeMap); + } + + private Map buildRelationMap(Map typeMap) { + Map relationMap = new HashMap<>(); + for (String relation : relations) { + Type relationType = new Type(Type.TYPES_PREFIX + relation, Type.SUPER_TYPE_ANNOTATION, eventTypeId++); + relationType.setAnnotations(Collections.singletonList(new AnnotationElement(Relational.class))); + AnnotationElement ae = PrivateAccess.getInstance().newAnnotation(relationType, Collections.emptyList(), true); + relationMap.put(relation, ae); + typeMap.put(relationType.getName(), relationType); + } + return relationMap; + } + + private List trimTypes(Map lookup) { + List trimmedTypes = new ArrayList<>(lookup.size()); + for (Type t : lookup.values()) { + t.trimFields(); + trimmedTypes.add(t); + } + return trimmedTypes; + } + + private void addFields(Map lookup, Map relationMap) { + for (TypeElement te : types.values()) { + Type type = lookup.get(te.name); + if (te.isEvent) { + boolean periodic = te.period!= null; + TypeLibrary.addImplicitFields(type, periodic, te.startTime && !periodic, te.thread, te.stackTrace && !periodic, te.cutoff); + } + for (FieldElement f : te.fields) { + Type fieldType = Type.getKnownType(f.typeName); + if (fieldType == null) { + fieldType = Objects.requireNonNull(lookup.get(f.referenceType.name)); + } + List aes = new ArrayList<>(); + if (f.unsigned) { + aes.add(new AnnotationElement(Unsigned.class)); + } + if (f.contentType != null) { + aes.addAll(Objects.requireNonNull(xmlContentTypes.get(f.contentType))); + } + if (f.relation != null) { + aes.add(Objects.requireNonNull(relationMap.get(f.relation))); + } + if (f.label != null) { + aes.add(new AnnotationElement(Label.class, f.label)); + } + if (f.experimental) { + aes.add(new AnnotationElement(Experimental.class)); + } + if (f.description != null) { + aes.add(new AnnotationElement(Description.class, f.description)); + } + if ("from".equals(f.transition)) { + aes.add(new AnnotationElement(TransitionFrom.class)); + } + if ("to".equals(f.transition)) { + aes.add(new AnnotationElement(TransitionTo.class)); + } + boolean constantPool = !f.struct && f.referenceType != null; + type.add(PrivateAccess.getInstance().newValueDescriptor(f.name, fieldType, aes, f.array ? 1 : 0, constantPool, null)); + } + } + } + + private Map buildTypeMap() { + Map typeMap = new HashMap<>(); + for (Type type : Type.getKnownTypes()) { + typeMap.put(type.getName(), type); + } + + for (TypeElement t : types.values()) { + List aes = new ArrayList<>(); + if (t.category != null) { + aes.add(new AnnotationElement(Category.class, buildCategoryArray(t.category))); + } + if (t.label != null) { + aes.add(new AnnotationElement(Label.class, t.label)); + } + if (t.description != null) { + aes.add(new AnnotationElement(Description.class, t.description)); + } + if (t.isEvent) { + if (t.period != null) { + aes.add(new AnnotationElement(Period.class, t.period)); + } else { + if (t.startTime) { + aes.add(new AnnotationElement(Threshold.class, "0 ns")); + } + if (t.stackTrace) { + aes.add(new AnnotationElement(StackTrace.class, true)); + } + } + if (t.cutoff) { + aes.add(new AnnotationElement(Cutoff.class, Cutoff.INIFITY)); + } + } + if (t.experimental) { + aes.add(new AnnotationElement(Experimental.class)); + } + Type type; + if (t.isEvent) { + aes.add(new AnnotationElement(Enabled.class, false)); + type = new PlatformEventType(t.name, eventTypeId++, false, true); + } else { + // Struct types had their own XML-element in the past. To have id assigned in the + // same order as generated .hpp file do some tweaks here. + boolean valueType = t.name.endsWith("StackFrame") || t.valueType; + type = new Type(t.name, null, valueType ? eventTypeId++ : nextTypeId(t.name), false); + } + type.setAnnotations(aes); + typeMap.put(t.name, type); + } + return typeMap; + } + + private long nextTypeId(String name) { + if (Type.THREAD.getName().equals(name)) { + return Type.THREAD.getId(); + } + if (Type.STRING.getName().equals(name)) { + return Type.STRING.getId(); + } + if (Type.CLASS.getName().equals(name)) { + return Type.CLASS.getId(); + } + for (Type type : Type.getKnownTypes()) { + if (type.getName().equals(name)) { + return type.getId(); + } + } + return structTypeId++; + } + + private String[] buildCategoryArray(String category) { + List categories = new ArrayList<>(); + StringBuilder sb = new StringBuilder(); + for (char c : category.toCharArray()) { + if (c == ',') { + categories.add(sb.toString().trim()); + sb.setLength(0); + } else { + sb.append(c); + } + } + categories.add(sb.toString().trim()); + return categories.toArray(new String[0]); + } + + private void removeXMLConvenience() { + for (TypeElement t : types.values()) { + XmlType xmlType = xmlTypes.get(t.name); + if (xmlType != null && xmlType.javaType != null) { + t.name = xmlType.javaType; // known type, i.e primitive + } else { + if (t.isEvent) { + t.name = Type.EVENT_NAME_PREFIX + t.name; + } else { + t.name = Type.TYPES_PREFIX + t.name; + } + } + } + + for (TypeElement t : types.values()) { + for (FieldElement f : t.fields) { + f.referenceType = types.get(f.typeName); + XmlType xmlType = xmlTypes.get(f.typeName); + if (xmlType != null) { + if (xmlType.javaType != null) { + f.typeName = xmlType.javaType; + } + if (xmlType.contentType != null) { + f.contentType = xmlType.contentType; + } + if (xmlType.unsigned) { + f.unsigned = true; + } + } + if (f.struct && f.referenceType != null) { + f.referenceType.valueType = true; + } + } + } + } +} diff --git a/src/share/classes/jdk/jfr/internal/MetadataReader.java b/src/share/classes/jdk/jfr/internal/MetadataReader.java new file mode 100644 index 0000000000000000000000000000000000000000..481e3700dc63338b95f74e1829d2c0d5024bb29c --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/MetadataReader.java @@ -0,0 +1,271 @@ +/* + * 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. 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.internal; + +import static jdk.jfr.internal.MetadataDescriptor.ATTRIBUTE_CONSTANT_POOL; +import static jdk.jfr.internal.MetadataDescriptor.ATTRIBUTE_DIMENSION; +import static jdk.jfr.internal.MetadataDescriptor.ATTRIBUTE_ID; +import static jdk.jfr.internal.MetadataDescriptor.ATTRIBUTE_NAME; +import static jdk.jfr.internal.MetadataDescriptor.ATTRIBUTE_SIMPLE_TYPE; +import static jdk.jfr.internal.MetadataDescriptor.ATTRIBUTE_SUPER_TYPE; +import static jdk.jfr.internal.MetadataDescriptor.ATTRIBUTE_TYPE_ID; +import static jdk.jfr.internal.MetadataDescriptor.ELEMENT_ANNOTATION; +import static jdk.jfr.internal.MetadataDescriptor.ELEMENT_FIELD; +import static jdk.jfr.internal.MetadataDescriptor.ELEMENT_SETTING; +import static jdk.jfr.internal.MetadataDescriptor.ELEMENT_TYPE; + +import java.io.DataInput; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.SettingDescriptor; +import jdk.jfr.ValueDescriptor; +import jdk.jfr.internal.MetadataDescriptor.Element; + +/** + * Parses metadata. + * + */ +final class MetadataReader { + + private final DataInput input; + private final List pool; + private final MetadataDescriptor descriptor; + private final Map types = new HashMap<>(); + + public MetadataReader(DataInput input) throws IOException { + this.input = input; + int size = input.readInt(); + this.pool = new ArrayList<>(size); + for (int i = 0; i < size; i++) { + this.pool.add(input.readUTF()); + } + descriptor = new MetadataDescriptor(); + Element root = createElement(); + Element metadata = root.elements("metadata").get(0); + declareTypes(metadata); + defineTypes(metadata); + annotateTypes(metadata); + buildEvenTypes(); + Element time = root.elements("region").get(0); + descriptor.gmtOffset = time.attribute(MetadataDescriptor.ATTRIBUTE_GMT_OFFSET, 1); + descriptor.locale = time.attribute(MetadataDescriptor.ATTRIBUTE_LOCALE, ""); + descriptor.root = root; + if (Logger.shouldLog(LogTag.JFR_SYSTEM_PARSER, LogLevel.TRACE)) { + List ts = new ArrayList<>(types.values()); + Collections.sort(ts, (x,y) -> x.getName().compareTo(y.getName())); + for (Type t : ts) { + t.log("Found", LogTag.JFR_SYSTEM_PARSER, LogLevel.TRACE); + } + } + } + + private String readString() throws IOException { + return pool.get(readInt()); + } + + private int readInt() throws IOException { + return input.readInt(); + } + + private Element createElement() throws IOException { + String name = readString(); + Element e = new Element(name); + int attributeCount = readInt(); + for (int i = 0; i < attributeCount; i++) { + e.addAttribute(readString(), readString()); + } + int childrenCount = readInt(); + for (int i = 0; i < childrenCount; i++) { + e.add(createElement()); + } + return e; + } + + private void annotateTypes(Element metadata) throws IOException { + for (Element typeElement : metadata.elements(ELEMENT_TYPE)) { + Type type = getType(ATTRIBUTE_ID, typeElement); + ArrayList aes = new ArrayList<>(); + for (Element annotationElement : typeElement.elements(ELEMENT_ANNOTATION)) { + aes.add(makeAnnotation(annotationElement)); + } + aes.trimToSize(); + type.setAnnotations(aes); + + int index = 0; + if (type instanceof PlatformEventType) { + List settings = ((PlatformEventType) type).getAllSettings(); + for (Element settingElement : typeElement.elements(ELEMENT_SETTING)) { + ArrayList annotations = new ArrayList<>(); + for (Element annotationElement : settingElement.elements(ELEMENT_ANNOTATION)) { + annotations.add(makeAnnotation(annotationElement)); + } + annotations.trimToSize(); + PrivateAccess.getInstance().setAnnotations(settings.get(index), annotations); + index++; + } + } + index = 0; + List fields = type.getFields(); + for (Element fieldElement : typeElement.elements(ELEMENT_FIELD)) { + ArrayList annotations = new ArrayList<>(); + for (Element annotationElement : fieldElement.elements(ELEMENT_ANNOTATION)) { + annotations.add(makeAnnotation(annotationElement)); + } + annotations.trimToSize(); + PrivateAccess.getInstance().setAnnotations(fields.get(index), annotations); + index++; + } + } + } + + private AnnotationElement makeAnnotation(Element annotationElement) throws IOException { + Type annotationType = getType(ATTRIBUTE_TYPE_ID, annotationElement); + List values = new ArrayList<>(); + for (ValueDescriptor v : annotationType.getFields()) { + if (v.isArray()) { + List list = new ArrayList<>(); + int index = 0; + while (true) { + String text = annotationElement.attribute(v.getName() + "-" + index); + if (text == null) { + break; + } + list.add(objectify(v.getTypeName(), text)); + index++; + } + Object object = Utils.makePrimitiveArray(v.getTypeName(), list); + if (object == null) { + throw new IOException("Unsupported type " + list + " in array"); + } + values.add(object); + } else { + String text = annotationElement.attribute(v.getName()); + values.add(objectify(v.getTypeName(), text)); + } + } + return PrivateAccess.getInstance().newAnnotation(annotationType, values, false); + } + + private Object objectify(String typeName, String text) throws IOException { + try { + switch (typeName) { + case "int": + return Integer.valueOf(text); + case "long": + return Long.valueOf(text); + case "double": + return Double.valueOf(text); + case "float": + return Float.valueOf(text); + case "short": + return Short.valueOf(text); + case "char": + if (text.length() != 1) { + throw new IOException("Unexpected size of char"); + } + return text.charAt(0); + case "byte": + return Byte.valueOf(text); + case "boolean": + return Boolean.valueOf(text); + case "java.lang.String": + return text; + } + } catch (IllegalArgumentException iae) { + throw new IOException("Could not parse text representation of " + typeName); + } + throw new IOException("Unsupported type for annotation " + typeName); + } + + private Type getType(String attribute, Element element) { + long id = element.longValue(attribute); + Type type = types.get(id); + if (type == null) { + String name = element.attribute("type"); + throw new IllegalStateException("Type '" + id + "' is not defined for " + name); + } + return type; + } + + private void buildEvenTypes() { + for (Type type : descriptor.types) { + if (type instanceof PlatformEventType) { + descriptor.eventTypes.add(PrivateAccess.getInstance().newEventType((PlatformEventType) type)); + } + } + } + + private void defineTypes(Element metadata) { + for (Element typeElement : metadata.elements(ELEMENT_TYPE)) { + long id = typeElement.attribute(ATTRIBUTE_ID, -1); + Type t = types.get(id); + for (Element fieldElement : typeElement.elements(ELEMENT_SETTING)) { + String name = fieldElement.attribute(ATTRIBUTE_NAME); + String defaultValue = fieldElement.attribute(ATTRIBUTE_NAME); + Type settingType = getType(ATTRIBUTE_TYPE_ID, fieldElement); + PlatformEventType eventType = (PlatformEventType) t; + eventType.add(PrivateAccess.getInstance().newSettingDescriptor(settingType, name, defaultValue, new ArrayList<>(2))); + } + for (Element fieldElement : typeElement.elements(ELEMENT_FIELD)) { + String name = fieldElement.attribute(ATTRIBUTE_NAME); + Type fieldType = getType(ATTRIBUTE_TYPE_ID, fieldElement); + long dimension = fieldElement.attribute(ATTRIBUTE_DIMENSION, 0); + boolean constantPool = fieldElement.attribute(ATTRIBUTE_CONSTANT_POOL) != null; + // Add annotation later, because they may refer to undefined + // types at this stage + t.add(PrivateAccess.getInstance().newValueDescriptor(name, fieldType, new ArrayList<>(), (int) dimension, constantPool, null)); + } + t.trimFields(); + } + } + + private void declareTypes(Element metadata) { + for (Element typeElement : metadata.elements(ELEMENT_TYPE)) { + String typeName = typeElement.attribute(ATTRIBUTE_NAME); + String superType = typeElement.attribute(ATTRIBUTE_SUPER_TYPE); + boolean simpleType = typeElement.attribute(ATTRIBUTE_SIMPLE_TYPE) != null; + long id = typeElement.attribute(ATTRIBUTE_ID, -1); + Type t; + if (Type.SUPER_TYPE_EVENT.equals(superType)) { + t = new PlatformEventType(typeName, id, false, false); + } else { + t = new Type(typeName, superType, id, false, simpleType); + } + types.put(id, t); + descriptor.types.add(t); + } + } + + public MetadataDescriptor getDescriptor() { + return descriptor; + } +} diff --git a/src/share/classes/jdk/jfr/internal/MetadataRepository.java b/src/share/classes/jdk/jfr/internal/MetadataRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..b0b0db71ddb7ebb64175c58d992361b92abc9e1f --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/MetadataRepository.java @@ -0,0 +1,277 @@ +/* + * 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. 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.internal; + +import static jdk.jfr.internal.LogLevel.DEBUG; +import static jdk.jfr.internal.LogTag.JFR_SYSTEM; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Map; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.Period; +import jdk.jfr.StackTrace; +import jdk.jfr.Threshold; +import jdk.jfr.ValueDescriptor; +import jdk.jfr.internal.RequestEngine.RequestHook; +import jdk.jfr.internal.handlers.EventHandler; + +public final class MetadataRepository { + + private static final JVM jvm = JVM.getJVM(); + private static final MetadataRepository instace = new MetadataRepository(); + + private final List nativeEventTypes = new ArrayList<>(100); + private final List nativeControls = new ArrayList(100); + private final TypeLibrary typeLibrary = TypeLibrary.getInstance(); + private final SettingsManager settingsManager = new SettingsManager(); + private boolean staleMetadata = true; + private boolean unregistered; + private long lastUnloaded = -1; + + public MetadataRepository() { + initializeJVMEventTypes(); + } + + private void initializeJVMEventTypes() { + List requestHooks = new ArrayList<>(); + for (Type type : typeLibrary.getTypes()) { + if (type instanceof PlatformEventType) { + PlatformEventType pEventType = (PlatformEventType) type; + EventType eventType = PrivateAccess.getInstance().newEventType(pEventType); + pEventType.setHasDuration(eventType.getAnnotation(Threshold.class) != null); + pEventType.setHasStackTrace(eventType.getAnnotation(StackTrace.class) != null); + pEventType.setHasCutoff(eventType.getAnnotation(Cutoff.class) != null); + pEventType.setHasPeriod(eventType.getAnnotation(Period.class) != null); + // Must add hook before EventControl is created as it removes + // annotations, such as Period and Threshold. + if (pEventType.hasPeriod()) { + pEventType.setEventHook(true); + if (!(Type.EVENT_NAME_PREFIX + "ExecutionSample").equals(type.getName())) { + requestHooks.add(new RequestHook(pEventType)); + } + } + nativeControls.add(new EventControl(pEventType)); + nativeEventTypes.add(eventType); + } + } + RequestEngine.addHooks(requestHooks); + } + + public static MetadataRepository getInstance() { + return instace; + } + + public synchronized List getRegisteredEventTypes() { + List handlers = getEventHandlers(); + List eventTypes = new ArrayList<>(handlers.size() + nativeEventTypes.size()); + for (EventHandler h : handlers) { + if (h.isRegistered()) { + eventTypes.add(h.getEventType()); + } + } + eventTypes.addAll(nativeEventTypes); + return eventTypes; + } + + public synchronized EventType getEventType(Class eventClass) { + EventHandler h = getHandler(eventClass); + if (h != null && h.isRegistered()) { + return h.getEventType(); + } + throw new IllegalStateException("Event class " + eventClass.getName() + " is not registered"); + } + + public synchronized void unregister(Class eventClass) { + Utils.checkRegisterPermission(); + EventHandler handler = getHandler(eventClass); + if (handler != null) { + handler.setRegistered(false); + } + // never registered, ignore call + } + public synchronized EventType register(Class eventClass) { + return register(eventClass, Collections.emptyList(), Collections.emptyList()); + } + + public synchronized EventType register(Class eventClass, List dynamicAnnotations, List dynamicFields) { + Utils.checkRegisterPermission(); + EventHandler handler = getHandler(eventClass); + if (handler == null) { + handler = makeHandler(eventClass, dynamicAnnotations, dynamicFields); + } + handler.setRegistered(true); + typeLibrary.addType(handler.getPlatformEventType()); + if (jvm.isRecording()) { + storeDescriptorInJVM(); // needed for emergency dump + settingsManager.setEventControl(handler.getEventControl()); + settingsManager.updateRetransform(Collections.singletonList((eventClass))); + } else { + setStaleMetadata(); + } + return handler.getEventType(); + } + + private EventHandler getHandler(Class eventClass) { + Utils.ensureValidEventSubclass(eventClass); + SecuritySupport.makeVisibleToJFR(eventClass); + Utils.ensureInitialized(eventClass); + return Utils.getHandler(eventClass); + } + + private EventHandler makeHandler(Class eventClass, List dynamicAnnotations, List dynamicFields) throws InternalError { + SecuritySupport.addHandlerExport(eventClass); + PlatformEventType pEventType = (PlatformEventType) TypeLibrary.createType(eventClass, dynamicAnnotations, dynamicFields); + EventType eventType = PrivateAccess.getInstance().newEventType(pEventType); + EventControl ec = new EventControl(pEventType, eventClass); + Class handlerClass = null; + try { + String eventHandlerName = EventHandlerCreator.makeEventHandlerName(eventType.getId()); + handlerClass = Class.forName(eventHandlerName, false, Event.class.getClassLoader()).asSubclass(EventHandler.class); + // Created eagerly on class load, tag as instrumented + pEventType.setInstrumented(); + Logger.log(JFR_SYSTEM, DEBUG, "Found existing event handler for " + eventType.getName()); + } catch (ClassNotFoundException cne) { + EventHandlerCreator ehc = new EventHandlerCreator(eventType.getId(), ec.getSettingInfos(), eventType, eventClass); + handlerClass = ehc.makeEventHandlerClass(); + Logger.log(LogTag.JFR_SYSTEM, DEBUG, "Created event handler for " + eventType.getName()); + } + EventHandler handler = EventHandlerCreator.instantiateEventHandler(handlerClass, true, eventType, ec); + Utils.setHandler(eventClass, handler); + return handler; + } + + + public synchronized void setSettings(List> list) { + settingsManager.setSettings(list); + } + + synchronized void disableEvents() { + for (EventControl c : getEventControls()) { + c.disable(); + } + } + + public synchronized List getEventControls() { + List controls = new ArrayList<>(); + controls.addAll(nativeControls); + for (EventHandler eh : getEventHandlers()) { + controls.add(eh.getEventControl()); + } + return controls; + } + + private void storeDescriptorInJVM() throws InternalError { + jvm.storeMetadataDescriptor(getBinaryRepresentation()); + staleMetadata = false; + } + + private static List getEventHandlers() { + List> allEventClasses = jvm.getAllEventClasses(); + List eventHandlers = new ArrayList<>(allEventClasses.size()); + for (Class clazz : allEventClasses) { + EventHandler eh = Utils.getHandler(clazz); + if (eh != null) { + eventHandlers.add(eh); + } + } + return eventHandlers; + } + + private byte[] getBinaryRepresentation() { + ByteArrayOutputStream baos = new ByteArrayOutputStream(40000); + DataOutputStream daos = new DataOutputStream(baos); + try { + List types = typeLibrary.getTypes(); + Collections.sort(types); + MetadataDescriptor.write(types, daos); + daos.flush(); + return baos.toByteArray(); + } catch (IOException e) { + // should not happen + throw new InternalError(e); + } + } + + synchronized boolean isEnabled(String eventName) { + return settingsManager.isEnabled(eventName); + } + + synchronized void setStaleMetadata() { + staleMetadata = true; + } + + // Lock around setOutput ensures that other threads dosn't + // emit event after setOutput and unregister the event class, before a call + // to storeDescriptorInJVM + synchronized void setOutput(String filename) { + jvm.setOutput(filename); + + unregisterUnloaded(); + if (unregistered) { + staleMetadata = typeLibrary.clearUnregistered(); + unregistered = false; + } + if (staleMetadata) { + storeDescriptorInJVM(); + } + } + + private void unregisterUnloaded() { + long unloaded = jvm.getUnloadedEventClassCount(); + if (this.lastUnloaded != unloaded) { + this.lastUnloaded = unloaded; + List> eventClasses = jvm.getAllEventClasses(); + HashSet knownIds = new HashSet<>(eventClasses.size()); + for (Class ec: eventClasses) { + knownIds.add(Type.getTypeId(ec)); + } + for (Type type : typeLibrary.getTypes()) { + if (type instanceof PlatformEventType) { + if (!knownIds.contains(type.getId())) { + PlatformEventType pe = (PlatformEventType) type; + if (!pe.isJVM()) { + pe.setRegistered(false); + } + } + } + } + } + } + + synchronized public void setUnregistered() { + unregistered = true; + } + +} diff --git a/src/share/classes/jdk/jfr/internal/MetadataWriter.java b/src/share/classes/jdk/jfr/internal/MetadataWriter.java new file mode 100644 index 0000000000000000000000000000000000000000..952d9637f50ce85a27f8487c83baceb3b1718da3 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/MetadataWriter.java @@ -0,0 +1,225 @@ +/* + * 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. 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.internal; + +import static jdk.jfr.internal.MetadataDescriptor.ATTRIBUTE_CONSTANT_POOL; +import static jdk.jfr.internal.MetadataDescriptor.ATTRIBUTE_DEFAULT_VALUE; +import static jdk.jfr.internal.MetadataDescriptor.ATTRIBUTE_DIMENSION; +import static jdk.jfr.internal.MetadataDescriptor.ATTRIBUTE_GMT_OFFSET; +import static jdk.jfr.internal.MetadataDescriptor.ATTRIBUTE_ID; +import static jdk.jfr.internal.MetadataDescriptor.ATTRIBUTE_LOCALE; +import static jdk.jfr.internal.MetadataDescriptor.ATTRIBUTE_NAME; +import static jdk.jfr.internal.MetadataDescriptor.ATTRIBUTE_SIMPLE_TYPE; +import static jdk.jfr.internal.MetadataDescriptor.ATTRIBUTE_SUPER_TYPE; +import static jdk.jfr.internal.MetadataDescriptor.ATTRIBUTE_TYPE_ID; +import static jdk.jfr.internal.MetadataDescriptor.ELEMENT_ANNOTATION; +import static jdk.jfr.internal.MetadataDescriptor.ELEMENT_FIELD; +import static jdk.jfr.internal.MetadataDescriptor.ELEMENT_SETTING; +import static jdk.jfr.internal.MetadataDescriptor.ELEMENT_TYPE; + +import java.io.DataOutput; +import java.io.IOException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Set; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.SettingDescriptor; +import jdk.jfr.ValueDescriptor; +import jdk.jfr.internal.MetadataDescriptor.Attribute; +import jdk.jfr.internal.MetadataDescriptor.Element; +import jdk.jfr.internal.consumer.RecordingInput; + +/** + * Class responsible for converting a list of types into a format that can be + * parsed by a client. + * + */ +final class MetadataWriter { + + private final Element metadata = new Element("metadata"); + private final Element root = new Element("root"); + + public MetadataWriter(MetadataDescriptor descriptor) { + descriptor.getTypes().forEach(type -> makeTypeElement(metadata, type)); + + root.add(metadata); + Element region = new Element("region"); + region.addAttribute(ATTRIBUTE_LOCALE, descriptor.locale); + region.addAttribute(ATTRIBUTE_GMT_OFFSET, descriptor.gmtOffset); + root.add(region); + } + + public void writeBinary(DataOutput output) throws IOException { + Set stringPool = new HashSet<>(1000); + // Possible improvement, sort string by how often they occur. + // and assign low number to the most frequently used. + buildStringPool(root, stringPool); + HashMap lookup = new LinkedHashMap<>(stringPool.size()); + int index = 0; + int poolSize = stringPool.size(); + writeInt(output, poolSize); + for (String s : stringPool) { + lookup.put(s, index); + writeString(output, s); + index++; + } + write(output, root, lookup); + } + + private void writeString(DataOutput out, String s) throws IOException { + if (s == null ) { + out.writeByte(RecordingInput.STRING_ENCODING_NULL); + return; + } + out.writeByte(RecordingInput.STRING_ENCODING_CHAR_ARRAY); // encoding UTF-16 + int length = s.length(); + writeInt(out, length); + for (int i = 0; i < length; i++) { + writeInt(out, s.charAt(i)); + } + } + + private void writeInt(DataOutput out, int v) throws IOException { + + long s = v & 0xffffffffL; + if (s < 1 << 7) { + out.write((byte) (s)); + return; + } + out.write((byte) (s | 0x80)); // first byte written + s >>= 7; + if (s < 1 << 7) { + out.write((byte) (s)); + return; + } + out.write((byte) (s | 0x80)); // second byte written + s >>= 7; + if (s < 1 << 7) { + out.write((byte) (s)); + return; + } + out.write((byte) (s | 0x80)); // third byte written + s >>= 7; + if (s < 1 << 7) { + out.write((byte) (s)); + return; + } + s >>= 7; + out.write((byte) (s));// fourth byte written + } + + private void buildStringPool(Element element, Set pool) { + pool.add(element.name); + for (Attribute a : element.attributes) { + pool.add(a.name); + pool.add(a.value); + } + for (Element child : element.elements) { + buildStringPool(child, pool); + } + } + + private void write(DataOutput output,Element element, HashMap lookup) throws IOException { + writeInt(output, lookup.get(element.name)); + writeInt(output, element.attributes.size()); + for (Attribute a : element.attributes) { + writeInt(output, lookup.get(a.name)); + writeInt(output, lookup.get(a.value)); + } + writeInt(output, element.elements.size()); + for (Element child : element.elements) { + write(output, child, lookup); + } + } + + private void makeTypeElement(Element root, Type type) { + Element element = root.newChild(ELEMENT_TYPE); + element.addAttribute(ATTRIBUTE_NAME, type.getName()); + String superType = type.getSuperType(); + if (superType != null) { + element.addAttribute(ATTRIBUTE_SUPER_TYPE, superType); + } + if (type.isSimpleType()) { + element.addAttribute(ATTRIBUTE_SIMPLE_TYPE, true); + } + element.addAttribute(ATTRIBUTE_ID, type.getId()); + if (type instanceof PlatformEventType) { + for (SettingDescriptor v : ((PlatformEventType)type).getSettings()) { + makeSettingElement(element, v); + } + } + for (ValueDescriptor v : type.getFields()) { + makeFieldElement(element, v); + } + for (AnnotationElement a : type.getAnnotationElements()) { + makeAnnotation(element, a); + } + } + + private void makeSettingElement(Element typeElement, SettingDescriptor s) { + Element element = typeElement.newChild(ELEMENT_SETTING); + element.addAttribute(ATTRIBUTE_NAME, s.getName()); + element.addAttribute(ATTRIBUTE_TYPE_ID, s.getTypeId()); + element.addAttribute(ATTRIBUTE_DEFAULT_VALUE, s.getDefaultValue()); + for (AnnotationElement a : s.getAnnotationElements()) { + makeAnnotation(element, a); + } + } + + private void makeFieldElement(Element typeElement, ValueDescriptor v) { + Element element = typeElement.newChild(ELEMENT_FIELD); + element.addAttribute(ATTRIBUTE_NAME, v.getName()); + element.addAttribute(ATTRIBUTE_TYPE_ID, v.getTypeId()); + if (v.isArray()) { + element.addAttribute(ATTRIBUTE_DIMENSION, 1); + } + if (PrivateAccess.getInstance().isConstantPool(v)) { + element.addAttribute(ATTRIBUTE_CONSTANT_POOL, true); + } + for (AnnotationElement a : v.getAnnotationElements()) { + makeAnnotation(element, a); + } + } + + private void makeAnnotation(Element entity, AnnotationElement annotation) { + Element element = entity.newChild(ELEMENT_ANNOTATION); + element.addAttribute(ATTRIBUTE_TYPE_ID, annotation.getTypeId()); + List values = annotation.getValues(); + int index = 0; + for (ValueDescriptor v : annotation.getValueDescriptors()) { + Object value = values.get(index++); + if (v.isArray()) { + element.addArrayAttribute(element, v.getName(), value); + } else { + element.addAttribute(v.getName(), value); + } + } + } + +} diff --git a/src/share/classes/jdk/jfr/internal/OldObjectSample.java b/src/share/classes/jdk/jfr/internal/OldObjectSample.java new file mode 100644 index 0000000000000000000000000000000000000000..75bfb9b66810a2a4d8729781e1ed840d55241e87 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/OldObjectSample.java @@ -0,0 +1,98 @@ +/* + * 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.internal; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jdk.jfr.Enabled; +import jdk.jfr.RecordingState; +import jdk.jfr.internal.settings.CutoffSetting; +import jdk.jfr.internal.test.WhiteBox; + +// The Old Object event could have been implemented as a periodic event, but +// due to chunk rotations and how settings are calculated when multiple recordings +// are running at the same time, it would lead to unacceptable overhead. +// +// Instead, the event is only emitted before a recording stops and +// if that recording has the event enabled. +// +// This requires special handling and the purpose of this class is to provide that +// +public final class OldObjectSample { + + private static final String EVENT_NAME = Type.EVENT_NAME_PREFIX + "OldObjectSample"; + private static final String OLD_OBJECT_CUTOFF = EVENT_NAME + "#" + Cutoff.NAME; + private static final String OLD_OBJECT_ENABLED = EVENT_NAME + "#" + Enabled.NAME; + + // Emit if old object is enabled in recording with cutoff for that recording + public static void emit(PlatformRecording recording) { + if (isEnabled(recording)) { + long nanos = CutoffSetting.parseValueSafe(recording.getSettings().get(OLD_OBJECT_CUTOFF)); + long ticks = Utils.nanosToTicks(nanos); + JVM.getJVM().emitOldObjectSamples(ticks, WhiteBox.getWriteAllObjectSamples()); + } + } + + // Emit if old object is enabled for at least one recording, and use the largest + // cutoff for an enabled recording + public static void emit(List recordings, Boolean pathToGcRoots) { + boolean enabled = false; + long cutoffNanos = Boolean.TRUE.equals(pathToGcRoots) ? Long.MAX_VALUE : 0L; + for (PlatformRecording r : recordings) { + if (r.getState() == RecordingState.RUNNING) { + if (isEnabled(r)) { + enabled = true; + long c = CutoffSetting.parseValueSafe(r.getSettings().get(OLD_OBJECT_CUTOFF)); + cutoffNanos = Math.max(c, cutoffNanos); + } + } + } + if (enabled) { + long ticks = Utils.nanosToTicks(cutoffNanos); + JVM.getJVM().emitOldObjectSamples(ticks, WhiteBox.getWriteAllObjectSamples()); + } + } + + public static void updateSettingPathToGcRoots(Map s, Boolean pathToGcRoots) { + if (pathToGcRoots != null) { + s.put(OLD_OBJECT_CUTOFF, pathToGcRoots ? "infinity" : "0 ns"); + } + } + + public static Map createSettingsForSnapshot(PlatformRecording recording, Boolean pathToGcRoots) { + Map settings = new HashMap<>(recording.getSettings()); + updateSettingPathToGcRoots(settings, pathToGcRoots); + return settings; + } + + private static boolean isEnabled(PlatformRecording r) { + Map settings = r.getSettings(); + String s = settings.get(OLD_OBJECT_ENABLED); + return "true".equals(s); + } +} diff --git a/src/share/classes/jdk/jfr/internal/Options.java b/src/share/classes/jdk/jfr/internal/Options.java new file mode 100644 index 0000000000000000000000000000000000000000..23f3919bb3d14fd2b899cd5efaf0807e4421232b --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/Options.java @@ -0,0 +1,162 @@ +/* + * 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. 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.internal; + +import jdk.jfr.internal.SecuritySupport.SafePath; +import sun.misc.Unsafe; + +/** + * Options that control Flight Recorder. + * + * Can be set using JFR.configure + * + */ +public final class Options { + + private final static JVM jvm = JVM.getJVM(); + private final static long WAIT_INTERVAL = 1000; // ms; + + private final static long MIN_MAX_CHUNKSIZE = 1024 * 1024; + + private static final long DEFAULT_GLOBAL_BUFFER_COUNT = 20; + private static final long DEFAULT_GLOBAL_BUFFER_SIZE = 524288; + private static final long DEFAULT_MEMORY_SIZE = DEFAULT_GLOBAL_BUFFER_COUNT * DEFAULT_GLOBAL_BUFFER_SIZE; + private static long DEFAULT_THREAD_BUFFER_SIZE; + private static final int DEFAULT_STACK_DEPTH = 64; + private static final boolean DEFAULT_SAMPLE_THREADS = true; + private static final long DEFAULT_MAX_CHUNK_SIZE = 12 * 1024 * 1024; + private static final SafePath DEFAULT_DUMP_PATH = SecuritySupport.USER_HOME; + + private static long memorySize; + private static long globalBufferSize; + private static long globalBufferCount; + private static long threadBufferSize; + private static int stackDepth; + private static boolean sampleThreads; + private static long maxChunkSize; + private static SafePath dumpPath; + + static { + final long pageSize = Unsafe.getUnsafe().pageSize(); + DEFAULT_THREAD_BUFFER_SIZE = pageSize > 8 * 1024 ? pageSize : 8 * 1024; + reset(); + } + + public static synchronized void setMaxChunkSize(long max) { + if (max < MIN_MAX_CHUNKSIZE) { + throw new IllegalArgumentException("Max chunk size must be at least " + MIN_MAX_CHUNKSIZE); + } + jvm.setFileNotification(max); + maxChunkSize = max; + } + + public static synchronized long getMaxChunkSize() { + return maxChunkSize; + } + + public static synchronized void setMemorySize(long memSize) { + jvm.setMemorySize(memSize); + memorySize = memSize; + } + + public static synchronized long getMemorySize() { + return memorySize; + } + + public static synchronized void setThreadBufferSize(long threadBufSize) { + jvm.setThreadBufferSize(threadBufSize); + threadBufferSize = threadBufSize; + } + + public static synchronized long getThreadBufferSize() { + return threadBufferSize; + } + + public static synchronized long getGlobalBufferSize() { + return globalBufferSize; + } + + public static synchronized void setGlobalBufferCount(long globalBufCount) { + jvm.setGlobalBufferCount(globalBufCount); + globalBufferCount = globalBufCount; + } + + public static synchronized long getGlobalBufferCount() { + return globalBufferCount; + } + + public static synchronized void setGlobalBufferSize(long globalBufsize) { + jvm.setGlobalBufferSize(globalBufsize); + globalBufferSize = globalBufsize; + } + + public static synchronized void setDumpPath(SafePath path) { + dumpPath = path; + } + + public static synchronized SafePath getDumpPath() { + return dumpPath; + } + + public static synchronized void setStackDepth(Integer stackTraceDepth) { + jvm.setStackDepth(stackTraceDepth); + stackDepth = stackTraceDepth; + } + + public static synchronized int getStackDepth() { + return stackDepth; + } + + public static synchronized void setSampleThreads(Boolean sample) { + jvm.setSampleThreads(sample); + sampleThreads = sample; + } + + public static synchronized boolean getSampleThreads() { + return sampleThreads; + } + + private static synchronized void reset() { + setMaxChunkSize(DEFAULT_MAX_CHUNK_SIZE); + setMemorySize(DEFAULT_MEMORY_SIZE); + setGlobalBufferSize(DEFAULT_GLOBAL_BUFFER_SIZE); + setGlobalBufferCount(DEFAULT_GLOBAL_BUFFER_COUNT); + setDumpPath(DEFAULT_DUMP_PATH); + setSampleThreads(DEFAULT_SAMPLE_THREADS); + setStackDepth(DEFAULT_STACK_DEPTH); + setThreadBufferSize(DEFAULT_THREAD_BUFFER_SIZE); + } + + static synchronized long getWaitInterval() { + return WAIT_INTERVAL; + } + + static void ensureInitialized() { + // trigger clinit which will setup JVM defaults. + } + + +} diff --git a/src/share/classes/jdk/jfr/internal/PlatformEventType.java b/src/share/classes/jdk/jfr/internal/PlatformEventType.java new file mode 100644 index 0000000000000000000000000000000000000000..e6f98eb0e3164b779ae3cdc81fcae63639db722b --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/PlatformEventType.java @@ -0,0 +1,281 @@ +/* + * 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. 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.internal; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import jdk.jfr.SettingDescriptor; + +/** + * Implementation of event type. + * + * To avoid memory leaks, this class must not hold strong reference to an event + * class or a setting class + */ +public final class PlatformEventType extends Type { + private final boolean isJVM; + private final boolean isJDK; + private final boolean isMethodSampling; + private final List settings = new ArrayList<>(5); + private final boolean dynamicSettings; + private final int stackTraceOffset; + + // default values + private boolean enabled = false; + private boolean stackTraceEnabled = true; + private long thresholdTicks = 0; + private long period = 0; + private boolean hasHook; + + private boolean beginChunk; + private boolean endChunk; + private boolean hasStackTrace = true; + private boolean hasDuration = true; + private boolean hasPeriod = true; + private boolean hasCutoff = false; + private boolean isInstrumented; + private boolean markForInstrumentation; + private boolean registered = true; + private boolean commitable = enabled && registered; + + + // package private + PlatformEventType(String name, long id, boolean isJDK, boolean dynamicSettings) { + super(name, Type.SUPER_TYPE_EVENT, id); + this.dynamicSettings = dynamicSettings; + this.isJVM = Type.isDefinedByJVM(id); + this.isMethodSampling = name.equals(Type.EVENT_NAME_PREFIX + "ExecutionSample") || name.equals(Type.EVENT_NAME_PREFIX + "NativeMethodSample"); + this.isJDK = isJDK; + this.stackTraceOffset = stackTraceOffset(name, isJDK); + } + + private static int stackTraceOffset(String name, boolean isJDK) { + if (isJDK) { + if (name.equals(Type.EVENT_NAME_PREFIX + "JavaExceptionThrow")) { + return 5; + } + if (name.equals(Type.EVENT_NAME_PREFIX + "JavaErrorThrow")) { + return 5; + } + } + return 4; + } + + public void add(SettingDescriptor settingDescriptor) { + Objects.requireNonNull(settingDescriptor); + settings.add(settingDescriptor); + } + + public List getSettings() { + if (dynamicSettings) { + List list = new ArrayList<>(settings.size()); + for (SettingDescriptor s : settings) { + if (Utils.isSettingVisible(s.getTypeId(), hasHook)) { + list.add(s); + } + } + return list; + } + return settings; + } + + public List getAllSettings() { + return settings; + } + + public void setHasStackTrace(boolean hasStackTrace) { + this.hasStackTrace = hasStackTrace; + } + + public void setHasDuration(boolean hasDuration) { + this.hasDuration = hasDuration; + } + + public void setHasCutoff(boolean hasCutoff) { + this.hasCutoff = hasCutoff; + } + + public void setCutoff(long cutoffNanos) { + if (isJVM) { + long cutoffTicks = Utils.nanosToTicks(cutoffNanos); + JVM.getJVM().setCutoff(getId(), cutoffTicks); + } + } + + public void setHasPeriod(boolean hasPeriod) { + this.hasPeriod = hasPeriod; + } + + public boolean hasStackTrace() { + return this.hasStackTrace; + } + + public boolean hasDuration() { + return this.hasDuration; + } + + public boolean hasPeriod() { + return this.hasPeriod; + } + + public boolean hasCutoff() { + return this.hasCutoff; + } + + public boolean isEnabled() { + return enabled; + } + + public boolean isJVM() { + return isJVM; + } + + public boolean isJDK() { + return isJDK; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + updateCommitable(); + if (isJVM) { + if (isMethodSampling) { + long p = enabled ? period : 0; + JVM.getJVM().setMethodSamplingInterval(getId(), p); + } else { + JVM.getJVM().setEnabled(getId(), enabled); + } + } + } + + public void setPeriod(long periodMillis, boolean beginChunk, boolean endChunk) { + if (isMethodSampling) { + long p = enabled ? periodMillis : 0; + JVM.getJVM().setMethodSamplingInterval(getId(), p); + } + this.beginChunk = beginChunk; + this.endChunk = endChunk; + this.period = periodMillis; + } + + public void setStackTraceEnabled(boolean stackTraceEnabled) { + this.stackTraceEnabled = stackTraceEnabled; + if (isJVM) { + JVM.getJVM().setStackTraceEnabled(getId(), stackTraceEnabled); + } + } + + public void setThreshold(long thresholdNanos) { + this.thresholdTicks = Utils.nanosToTicks(thresholdNanos); + if (isJVM) { + JVM.getJVM().setThreshold(getId(), thresholdTicks); + } + } + + public boolean isEveryChunk() { + return period == 0; + } + + public boolean getStackTraceEnabled() { + return stackTraceEnabled; + } + + public long getThresholdTicks() { + return thresholdTicks; + } + + public long getPeriod() { + return period; + } + + public boolean hasEventHook() { + return hasHook; + } + + public void setEventHook(boolean hasHook) { + this.hasHook = hasHook; + } + + public boolean isBeginChunk() { + return beginChunk; + } + + public boolean isEndChunk() { + return endChunk; + } + + public boolean isInstrumented() { + return isInstrumented; + } + + public void setInstrumented() { + isInstrumented = true; + } + + public void markForInstrumentation(boolean markForInstrumentation) { + this.markForInstrumentation = markForInstrumentation; + } + + public boolean isMarkedForInstrumentation() { + return markForInstrumentation; + } + + public boolean setRegistered(boolean registered) { + if (this.registered != registered) { + this.registered = registered; + updateCommitable(); + LogTag logTag = isJVM() || isJDK() ? LogTag.JFR_SYSTEM_EVENT : LogTag.JFR_EVENT; + if (registered) { + Logger.log(logTag, LogLevel.INFO, "Registered " + getLogName()); + } else { + Logger.log(logTag, LogLevel.INFO, "Unregistered " + getLogName()); + } + if (!registered) { + MetadataRepository.getInstance().setUnregistered(); + } + return true; + } + return false; + } + + private void updateCommitable() { + this.commitable = enabled && registered; + } + + public final boolean isRegistered() { + return registered; + } + + // Efficient check of enabled && registered + public boolean isCommitable() { + return commitable; + } + + public int getStackTraceOffset() { + return stackTraceOffset; + } +} diff --git a/src/share/classes/jdk/jfr/internal/PlatformRecorder.java b/src/share/classes/jdk/jfr/internal/PlatformRecorder.java new file mode 100644 index 0000000000000000000000000000000000000000..cbea2e45aac08707726395ac15185b42a459ba39 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/PlatformRecorder.java @@ -0,0 +1,554 @@ +/* + * 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. 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.internal; + +import static jdk.jfr.internal.LogLevel.INFO; +import static jdk.jfr.internal.LogLevel.TRACE; +import static jdk.jfr.internal.LogLevel.WARN; +import static jdk.jfr.internal.LogTag.JFR; +import static jdk.jfr.internal.LogTag.JFR_SYSTEM; + +import java.io.IOException; +import java.security.AccessControlContext; +import java.security.AccessController; +import java.time.Duration; +import java.time.Instant; +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.Set; +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.CopyOnWriteArrayList; + +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorder; +import jdk.jfr.FlightRecorderListener; +import jdk.jfr.Recording; +import jdk.jfr.RecordingState; +import jdk.jfr.events.ActiveRecordingEvent; +import jdk.jfr.events.ActiveSettingEvent; +import jdk.jfr.internal.SecuritySupport.SecureRecorderListener; +import jdk.jfr.internal.instrument.JDKEvents; + +public final class PlatformRecorder { + + private final List recordings = new ArrayList<>(); + private final static List changeListeners = new ArrayList<>(); + private final Repository repository; + private final Timer timer; + private final static JVM jvm = JVM.getJVM(); + private final EventType activeRecordingEvent; + private final EventType activeSettingEvent; + private final Thread shutdownHook; + + private long recordingCounter = 0; + private RepositoryChunk currentChunk; + + public PlatformRecorder() throws Exception { + repository = Repository.getRepository(); + Logger.log(JFR_SYSTEM, INFO, "Initialized disk repository"); + repository.ensureRepository(); + jvm.createNativeJFR(); + Logger.log(JFR_SYSTEM, INFO, "Created native"); + JDKEvents.initialize(); + 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()); + SecuritySupport.registerShutdownHook(shutdownHook); + timer = createTimer(); + } + + private static Timer createTimer() { + try { + List result = new CopyOnWriteArrayList<>(); + Thread t = SecuritySupport.createThreadWitNoPermissions("Permissionless thread", ()-> { + result.add(new Timer("JFR Recording Scheduler", true)); + }); + t.start(); + t.join(); + return result.get(0); + } catch (InterruptedException e) { + throw new IllegalStateException("Not able to create timer task. " + e.getMessage(), e); + } + } + + public synchronized PlatformRecording newRecording(Map settings) { + return newRecording(settings, ++recordingCounter); + } + + // To be used internally when doing dumps. + // Caller must have recorder lock and close recording before releasing lock + public PlatformRecording newTemporaryRecording() { + if(!Thread.holdsLock(this)) { + throw new InternalError("Caller must have recorder lock"); + } + return newRecording(new HashMap<>(), 0); + } + + private synchronized PlatformRecording newRecording(Map settings, long id) { + PlatformRecording recording = new PlatformRecording(this, id); + if (!settings.isEmpty()) { + recording.setSettings(settings); + } + recordings.add(recording); + return recording; + } + + synchronized void finish(PlatformRecording recording) { + if (recording.getState() == RecordingState.RUNNING) { + recording.stop("Recording closed"); + } + recordings.remove(recording); + } + + public synchronized List getRecordings() { + return Collections.unmodifiableList(new ArrayList(recordings)); + } + + public synchronized static void addListener(FlightRecorderListener changeListener) { + AccessControlContext context = AccessController.getContext(); + SecureRecorderListener sl = new SecureRecorderListener(context, changeListener); + boolean runInitialized; + synchronized (PlatformRecorder.class) { + runInitialized = FlightRecorder.isInitialized(); + changeListeners.add(sl); + } + if (runInitialized) { + sl.recorderInitialized(FlightRecorder.getFlightRecorder()); + } + } + + public synchronized static boolean removeListener(FlightRecorderListener changeListener) { + for (SecureRecorderListener s : new ArrayList<>(changeListeners)) { + if (s.getChangeListener() == changeListener) { + changeListeners.remove(s); + return true; + } + } + return false; + } + + static synchronized List getListeners() { + return new ArrayList<>(changeListeners); + } + + Timer getTimer() { + return timer; + } + + public static void notifyRecorderInitialized(FlightRecorder recorder) { + Logger.log(JFR_SYSTEM, TRACE, "Notifying listeners that Flight Recorder is initialized"); + for (FlightRecorderListener r : getListeners()) { + r.recorderInitialized(recorder); + } + } + + // called by shutdown hook + synchronized void destroy() { + try { + timer.cancel(); + } catch (Exception ex) { + Logger.log(JFR_SYSTEM, WARN, "Shutdown hook could not cancel timer"); + } + + for (PlatformRecording p : getRecordings()) { + if (p.getState() == RecordingState.RUNNING) { + try { + p.stop("Shutdown"); + } catch (Exception ex) { + Logger.log(JFR, WARN, "Recording " + p.getName() + ":" + p.getId() + " could not be stopped"); + } + } + } + + JDKEvents.remove(); + + if (jvm.hasNativeJFR()) { + if (jvm.isRecording()) { + jvm.endRecording_(); + } + jvm.destroyNativeJFR(); + } + repository.clear(); + } + + synchronized void start(PlatformRecording recording) { + // State can only be NEW or DELAYED because of previous checks + Instant now = Instant.now(); + recording.setStartTime(now); + recording.updateTimer(); + Duration duration = recording.getDuration(); + if (duration != null) { + recording.setStopTime(now.plus(duration)); + } + boolean toDisk = recording.isToDisk(); + boolean beginPhysical = true; + for (PlatformRecording s : getRecordings()) { + if (s.getState() == RecordingState.RUNNING) { + beginPhysical = false; + if (s.isToDisk()) { + toDisk = true; + } + } + } + if (beginPhysical) { + RepositoryChunk newChunk = null; + if (toDisk) { + newChunk = repository.newChunk(now); + MetadataRepository.getInstance().setOutput(newChunk.getUnfishedFile().toString()); + } else { + MetadataRepository.getInstance().setOutput(null); + } + currentChunk = newChunk; + jvm.beginRecording_(); + recording.setState(RecordingState.RUNNING); + updateSettings(); + writeMetaEvents(); + } else { + RepositoryChunk newChunk = null; + if (toDisk) { + newChunk = repository.newChunk(now); + RequestEngine.doChunkEnd(); + MetadataRepository.getInstance().setOutput(newChunk.getUnfishedFile().toString()); + } + recording.setState(RecordingState.RUNNING); + updateSettings(); + writeMetaEvents(); + if (currentChunk != null) { + finishChunk(currentChunk, now, recording); + } + currentChunk = newChunk; + } + + RequestEngine.doChunkBegin(); + } + + synchronized void stop(PlatformRecording recording) { + RecordingState state = recording.getState(); + + if (Utils.isAfter(state, RecordingState.RUNNING)) { + throw new IllegalStateException("Can't stop an already stopped recording."); + } + if (Utils.isBefore(state, RecordingState.RUNNING)) { + throw new IllegalStateException("Recording must be started before it can be stopped."); + } + Instant now = Instant.now(); + boolean toDisk = false; + boolean endPhysical = true; + for (PlatformRecording s : getRecordings()) { + RecordingState rs = s.getState(); + if (s != recording && RecordingState.RUNNING == rs) { + endPhysical = false; + if (s.isToDisk()) { + toDisk = true; + } + } + } + OldObjectSample.emit(recording); + + if (endPhysical) { + RequestEngine.doChunkEnd(); + if (recording.isToDisk()) { + if (currentChunk != null) { + MetadataRepository.getInstance().setOutput(null); + finishChunk(currentChunk, now, null); + currentChunk = null; + } + } else { + // last memory + dumpMemoryToDestination(recording); + } + jvm.endRecording_(); + disableEvents(); + } else { + RepositoryChunk newChunk = null; + RequestEngine.doChunkEnd(); + updateSettingsButIgnoreRecording(recording); + if (toDisk) { + newChunk = repository.newChunk(now); + MetadataRepository.getInstance().setOutput(newChunk.getUnfishedFile().toString()); + } else { + MetadataRepository.getInstance().setOutput(null); + } + writeMetaEvents(); + if (currentChunk != null) { + finishChunk(currentChunk, now, null); + } + currentChunk = newChunk; + RequestEngine.doChunkBegin(); + } + recording.setState(RecordingState.STOPPED); + } + + private void dumpMemoryToDestination(PlatformRecording recording) { + WriteableUserPath dest = recording.getDestination(); + if (dest != null) { + MetadataRepository.getInstance().setOutput(dest.getText()); + recording.clearDestination(); + } + } + private void disableEvents() { + MetadataRepository.getInstance().disableEvents(); + } + + void updateSettings() { + updateSettingsButIgnoreRecording(null); + } + + void updateSettingsButIgnoreRecording(PlatformRecording ignoreMe) { + List recordings = getRunningRecordings(); + List> list = new ArrayList<>(recordings.size()); + for (PlatformRecording r : recordings) { + if (r != ignoreMe) { + list.add(r.getSettings()); + } + } + MetadataRepository.getInstance().setSettings(list); + } + + synchronized void rotateDisk() { + Instant now = Instant.now(); + RepositoryChunk newChunk = repository.newChunk(now); + RequestEngine.doChunkEnd(); + MetadataRepository.getInstance().setOutput(newChunk.getUnfishedFile().toString()); + writeMetaEvents(); + if (currentChunk != null) { + finishChunk(currentChunk, now, null); + } + currentChunk = newChunk; + RequestEngine.doChunkBegin(); + } + + private List getRunningRecordings() { + List runningRecordings = new ArrayList<>(); + for (PlatformRecording recording : getRecordings()) { + if (recording.getState() == RecordingState.RUNNING) { + runningRecordings.add(recording); + } + } + return runningRecordings; + } + + private List makeChunkList(Instant startTime, Instant endTime) { + Set chunkSet = new HashSet<>(); + for (PlatformRecording r : getRecordings()) { + chunkSet.addAll(r.getChunks()); + } + if (chunkSet.size() > 0) { + List chunks = new ArrayList<>(chunkSet.size()); + for (RepositoryChunk rc : chunkSet) { + if (rc.inInterval(startTime, endTime)) { + chunks.add(rc); + } + } + // n*log(n), should be able to do n*log(k) with a priority queue, + // where k = number of recordings, n = number of chunks + Collections.sort(chunks, RepositoryChunk.END_TIME_COMPARATOR); + return chunks; + } + + return Collections.emptyList(); + } + + private void startDiskMonitor() { + Thread t = SecuritySupport.createThreadWitNoPermissions("JFR Periodic Tasks", () -> periodicTask()); + SecuritySupport.setDaemonThread(t, true); + t.start(); + } + + private void finishChunk(RepositoryChunk chunk, Instant time, PlatformRecording ignoreMe) { + chunk.finish(time); + for (PlatformRecording r : getRecordings()) { + if (r != ignoreMe && r.getState() == RecordingState.RUNNING) { + r.appendChunk(chunk); + } + } + } + + private void writeMetaEvents() { + + if (activeRecordingEvent.isEnabled()) { + for (PlatformRecording r : getRecordings()) { + if (r.getState() == RecordingState.RUNNING && r.shouldWriteMetadataEvent()) { + ActiveRecordingEvent event = new ActiveRecordingEvent(); + event.id = r.getId(); + event.name = r.getName(); + WriteableUserPath p = r.getDestination(); + event.destination = p == null ? null : p.getText(); + Duration d = r.getDuration(); + event.recordingDuration = d == null ? Long.MAX_VALUE : d.toMillis(); + Duration age = r.getMaxAge(); + event.maxAge = age == null ? Long.MAX_VALUE : age.toMillis(); + Long size = r.getMaxSize(); + event.maxSize = size == null ? Long.MAX_VALUE : size; + Instant start = r.getStartTime(); + event.recordingStart = start == null ? Long.MAX_VALUE : start.toEpochMilli(); + event.commit(); + } + } + } + if (activeSettingEvent.isEnabled()) { + for (EventControl ec : MetadataRepository.getInstance().getEventControls()) { + ec.writeActiveSettingEvent(); + } + } + } + + private void periodicTask() { + if (!jvm.hasNativeJFR()) { + return; + } + while (true) { + synchronized (this) { + if (jvm.shouldRotateDisk()) { + rotateDisk(); + } + } + long minDelta = RequestEngine.doPeriodic(); + long wait = Math.min(minDelta, Options.getWaitInterval()); + takeNap(wait); + } + } + + private void takeNap(long duration) { + try { + synchronized (JVM.FILE_DELTA_CHANGE) { + JVM.FILE_DELTA_CHANGE.wait(duration < 10 ? 10 : duration); + } + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + synchronized Recording newCopy(PlatformRecording r, boolean stop) { + Recording newRec = new Recording(); + PlatformRecording copy = PrivateAccess.getInstance().getPlatformRecording(newRec); + copy.setSettings(r.getSettings()); + copy.setMaxAge(r.getMaxAge()); + copy.setMaxSize(r.getMaxSize()); + copy.setDumpOnExit(r.getDumpOnExit()); + copy.setName("Clone of " + r.getName()); + copy.setToDisk(r.isToDisk()); + copy.setInternalDuration(r.getDuration()); + copy.setStartTime(r.getStartTime()); + copy.setStopTime(r.getStopTime()); + + if (r.getState() == RecordingState.NEW) { + return newRec; + } + if (r.getState() == RecordingState.DELAYED) { + copy.scheduleStart(r.getStartTime()); + return newRec; + } + copy.setState(r.getState()); + // recording has started, copy chunks + for (RepositoryChunk c : r.getChunks()) { + copy.add(c); + } + if (r.getState() == RecordingState.RUNNING) { + if (stop) { + copy.stop("Stopped when cloning recording '" + r.getName() + "'"); + } else { + if (r.getStopTime() != null) { + TimerTask stopTask = copy.createStopTask(); + copy.setStopTask(copy.createStopTask()); + getTimer().schedule(stopTask, r.getStopTime().toEpochMilli()); + } + } + } + return newRec; + } + + public synchronized void fillWithRecordedData(PlatformRecording target, Boolean pathToGcRoots) { + boolean running = false; + boolean toDisk = false; + + for (PlatformRecording r : recordings) { + if (r.getState() == RecordingState.RUNNING) { + running = true; + if (r.isToDisk()) { + toDisk = true; + } + } + } + // If needed, flush data from memory + if (running) { + if (toDisk) { + OldObjectSample.emit(recordings, pathToGcRoots); + rotateDisk(); + } else { + try (PlatformRecording snapshot = newTemporaryRecording()) { + snapshot.setToDisk(true); + snapshot.setShouldWriteActiveRecordingEvent(false); + snapshot.start(); + OldObjectSample.emit(recordings, pathToGcRoots); + snapshot.stop("Snapshot dump"); + fillWithDiskChunks(target); + } + return; + } + } + fillWithDiskChunks(target); + } + + private void fillWithDiskChunks(PlatformRecording target) { + for (RepositoryChunk c : makeChunkList(null, null)) { + target.add(c); + } + target.setState(RecordingState.STOPPED); + Instant startTime = null; + Instant endTime = null; + + for (RepositoryChunk c : target.getChunks()) { + if (startTime == null || c.getStartTime().isBefore(startTime)) { + startTime = c.getStartTime(); + } + if (endTime == null || c.getEndTime().isAfter(endTime)) { + endTime = c.getEndTime(); + } + } + Instant now = Instant.now(); + if (startTime == null) { + startTime = now; + } + if (endTime == null) { + endTime = now; + } + target.setStartTime(startTime); + target.setStopTime(endTime); + target.setInternalDuration(Duration.between(startTime, endTime)); + } +} diff --git a/src/share/classes/jdk/jfr/internal/PlatformRecording.java b/src/share/classes/jdk/jfr/internal/PlatformRecording.java new file mode 100644 index 0000000000000000000000000000000000000000..74707121d37ca09b691c2c5b742d236686eb4081 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/PlatformRecording.java @@ -0,0 +1,778 @@ +/* + * 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. 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.internal; + +import static jdk.jfr.internal.LogLevel.DEBUG; +import static jdk.jfr.internal.LogLevel.WARN; +import static jdk.jfr.internal.LogTag.JFR; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.channels.FileChannel; +import java.nio.file.StandardOpenOption; +import java.security.AccessControlContext; +import java.security.AccessController; +import java.time.Duration; +import java.time.Instant; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.StringJoiner; +import java.util.TimerTask; +import java.util.TreeMap; + +import jdk.jfr.Configuration; +import jdk.jfr.FlightRecorderListener; +import jdk.jfr.Recording; +import jdk.jfr.RecordingState; +import jdk.jfr.internal.SecuritySupport.SafePath; + +public final class PlatformRecording implements AutoCloseable { + + private final PlatformRecorder recorder; + private final long id; + // Recording settings + private Map settings = new LinkedHashMap<>(); + private Duration duration; + private Duration maxAge; + private long maxSize; + + private WriteableUserPath destination; + + private boolean toDisk = true; + private String name; + private boolean dumpOnExit; + private SafePath dumpOnExitDirectory = new SafePath("."); + // Timestamp information + private Instant stopTime; + private Instant startTime; + + // Misc, information + private RecordingState state = RecordingState.NEW; + private long size; + private final LinkedList chunks = new LinkedList<>(); + private volatile Recording recording; + private TimerTask stopTask; + private TimerTask startTask; + private AccessControlContext noDestinationDumpOnExitAccessControlContext; + private boolean shuoldWriteActiveRecordingEvent = true; + + PlatformRecording(PlatformRecorder recorder, long id) { + // Typically the access control context is taken + // when you call dump(Path) or setDdestination(Path), + // but if no destination is set and dumponexit=true + // the control context of the recording is taken when the + // Recording object is constructed. This works well for + // -XX:StartFlightRecording and JFR.dump + this.noDestinationDumpOnExitAccessControlContext = AccessController.getContext(); + this.id = id; + this.recorder = recorder; + this.name = String.valueOf(id); + } + + public void start() { + RecordingState oldState; + RecordingState newState; + synchronized (recorder) { + oldState = getState(); + if (!Utils.isBefore(state, RecordingState.RUNNING)) { + throw new IllegalStateException("Recording can only be started once."); + } + if (startTask != null) { + startTask.cancel(); + startTask = null; + startTime = null; + } + recorder.start(this); + Logger.log(LogTag.JFR, LogLevel.INFO, () -> { + // Only print non-default values so it easy to see + // which options were added + StringJoiner options = new StringJoiner(", "); + if (!toDisk) { + options.add("disk=false"); + } + if (maxAge != null) { + options.add("maxage=" + Utils.formatTimespan(maxAge, "")); + } + if (maxSize != 0) { + options.add("maxsize=" + Utils.formatBytesCompact(maxSize)); + } + if (dumpOnExit) { + options.add("dumponexit=true"); + } + if (duration != null) { + options.add("duration=" + Utils.formatTimespan(duration, "")); + } + if (destination != null) { + options.add("filename=" + destination.getText()); + } + String optionText = options.toString(); + if (optionText.length() != 0) { + optionText = "{" + optionText + "}"; + } + return "Started recording \"" + getName() + "\" (" + getId() + ") " + optionText; + }); + newState = getState(); + } + notifyIfStateChanged(oldState, newState); + } + + public boolean stop(String reason) { + RecordingState oldState; + RecordingState newState; + synchronized (recorder) { + oldState = getState(); + if (stopTask != null) { + stopTask.cancel(); + stopTask = null; + } + recorder.stop(this); + String endText = reason == null ? "" : ". Reason \"" + reason + "\"."; + Logger.log(LogTag.JFR, LogLevel.INFO, "Stopped recording \"" + getName() + "\" (" + getId() + ")" + endText); + this.stopTime = Instant.now(); + newState = getState(); + } + WriteableUserPath dest = getDestination(); + + if (dest != null) { + try { + dumpStopped(dest); + Logger.log(LogTag.JFR, LogLevel.INFO, "Wrote recording \"" + getName() + "\" (" + getId() + ") to " + dest.getText()); + notifyIfStateChanged(newState, oldState); + close(); // remove if copied out + } catch(IOException e) { + // throw e; // BUG8925030 + } + } else { + notifyIfStateChanged(newState, oldState); + } + return true; + } + + public void scheduleStart(Duration delay) { + synchronized (recorder) { + ensureOkForSchedule(); + + startTime = Instant.now().plus(delay); + LocalDateTime now = LocalDateTime.now().plus(delay); + setState(RecordingState.DELAYED); + startTask = createStartTask(); + recorder.getTimer().schedule(startTask, delay.toMillis()); + Logger.log(LogTag.JFR, LogLevel.INFO, "Scheduled recording \"" + getName() + "\" (" + getId() + ") to start at " + now); + } + } + + private void ensureOkForSchedule() { + if (getState() != RecordingState.NEW) { + throw new IllegalStateException("Only a new recoridng can be scheduled for start"); + } + } + + private TimerTask createStartTask() { + // Taking ref. to recording here. + // Opens up for memory leaks. + return new TimerTask() { + @Override + public void run() { + synchronized (recorder) { + if (getState() != RecordingState.DELAYED) { + return; + } + start(); + } + } + }; + } + + void scheduleStart(Instant startTime) { + synchronized (recorder) { + ensureOkForSchedule(); + this.startTime = startTime; + setState(RecordingState.DELAYED); + startTask = createStartTask(); + recorder.getTimer().schedule(startTask, startTime.toEpochMilli()); + } + } + + public Map getSettings() { + synchronized (recorder) { + return settings; + } + } + + public long getSize() { + return size; + } + + public Instant getStopTime() { + synchronized (recorder) { + return stopTime; + } + } + + public Instant getStartTime() { + synchronized (recorder) { + return startTime; + } + } + + public Long getMaxSize() { + synchronized (recorder) { + return maxSize; + } + } + + public Duration getMaxAge() { + synchronized (recorder) { + return maxAge; + } + } + + public String getName() { + synchronized (recorder) { + return name; + } + } + + public RecordingState getState() { + synchronized (recorder) { + return state; + } + } + + @Override + public void close() { + RecordingState oldState; + RecordingState newState; + + synchronized (recorder) { + oldState = getState(); + if (RecordingState.CLOSED != getState()) { + if (startTask != null) { + startTask.cancel(); + startTask = null; + } + recorder.finish(this); + for (RepositoryChunk c : chunks) { + removed(c); + } + chunks.clear(); + setState(RecordingState.CLOSED); + Logger.log(LogTag.JFR, LogLevel.INFO, "Closed recording \"" + getName() + "\" (" + getId() + ")"); + } + newState = getState(); + } + notifyIfStateChanged(newState, oldState); + } + + // To be used internally when doing dumps. + // Caller must have recorder lock and close recording before releasing lock + public PlatformRecording newSnapshotClone(String reason, Boolean pathToGcRoots) throws IOException { + if(!Thread.holdsLock(recorder)) { + throw new InternalError("Caller must have recorder lock"); + } + RecordingState state = getState(); + if (state == RecordingState.CLOSED) { + throw new IOException("Recording \"" + name + "\" (id=" + id + ") has been closed, no contents to write"); + } + if (state == RecordingState.DELAYED || state == RecordingState.NEW) { + throw new IOException("Recording \"" + name + "\" (id=" + id + ") has not started, no contents to write"); + } + if (state == RecordingState.STOPPED) { + PlatformRecording clone = recorder.newTemporaryRecording(); + for (RepositoryChunk r : chunks) { + clone.add(r); + } + return clone; + } + + // Recording is RUNNING, create a clone + 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 + if (!isToDisk()) { + // force memory contents to disk + clone.start(); + } else { + // using existing chunks on disk + for (RepositoryChunk c : chunks) { + clone.add(c); + } + clone.setState(RecordingState.RUNNING); + clone.setStartTime(getStartTime()); + } + if (pathToGcRoots == null) { + clone.setSettings(getSettings()); // needed for old object sample + clone.stop(reason); // dumps to destination path here + } else { + // Risk of violating lock order here, since + // clone.stop() will take recorder lock inside + // metadata lock, but OK if we already + // have recorder lock when we entered metadata lock + synchronized (MetadataRepository.getInstance()) { + clone.setSettings(OldObjectSample.createSettingsForSnapshot(this, pathToGcRoots)); + clone.stop(reason); + } + } + return clone; + } + + public boolean isToDisk() { + synchronized (recorder) { + return toDisk; + } + } + + public void setMaxSize(long maxSize) { + synchronized (recorder) { + if (getState() == RecordingState.CLOSED) { + throw new IllegalStateException("Can't set max age when recording is closed"); + } + this.maxSize = maxSize; + trimToSize(); + } + } + + public void setDestination(WriteableUserPath userSuppliedPath) throws IOException { + synchronized (recorder) { + if (Utils.isState(getState(), RecordingState.STOPPED, RecordingState.CLOSED)) { + throw new IllegalStateException("Destination can't be set on a recording that has been stopped/closed"); + } + this.destination = userSuppliedPath; + } + } + + public WriteableUserPath getDestination() { + synchronized (recorder) { + return destination; + } + } + + void setState(RecordingState state) { + synchronized (recorder) { + this.state = state; + } + } + + void setStartTime(Instant startTime) { + synchronized (recorder) { + this.startTime = startTime; + } + } + + void setStopTime(Instant timeStamp) { + synchronized (recorder) { + stopTime = timeStamp; + } + } + + public long getId() { + synchronized (recorder) { + return id; + } + } + + public void setName(String name) { + synchronized (recorder) { + ensureNotClosed(); + this.name = name; + } + } + + private void ensureNotClosed() { + if (getState() == RecordingState.CLOSED) { + throw new IllegalStateException("Can't change name on a closed recording"); + } + } + + public void setDumpOnExit(boolean dumpOnExit) { + synchronized (recorder) { + this.dumpOnExit = dumpOnExit; + } + } + + public boolean getDumpOnExit() { + synchronized (recorder) { + return dumpOnExit; + } + } + + public void setToDisk(boolean toDisk) { + synchronized (recorder) { + if (Utils.isState(getState(), RecordingState.NEW, RecordingState.DELAYED)) { + this.toDisk = toDisk; + } else { + throw new IllegalStateException("Recording option disk can't be changed after recording has started"); + } + } + } + + public void setSetting(String id, String value) { + synchronized (recorder) { + this.settings.put(id, value); + if (getState() == RecordingState.RUNNING) { + recorder.updateSettings(); + } + } + } + + public void setSettings(Map settings) { + setSettings(settings, true); + } + + private void setSettings(Map settings, boolean update) { + if (Logger.shouldLog(LogTag.JFR_SETTING, LogLevel.INFO) && update) { + TreeMap ordered = new TreeMap<>(settings); + Logger.log(LogTag.JFR_SETTING, LogLevel.INFO, "New settings for recording \"" + getName() + "\" (" + getId() + ")"); + for (Map.Entry entry : ordered.entrySet()) { + String text = entry.getKey() + "=\"" + entry.getValue() + "\""; + Logger.log(LogTag.JFR_SETTING, LogLevel.INFO, text); + } + } + synchronized (recorder) { + this.settings = new LinkedHashMap<>(settings); + if (getState() == RecordingState.RUNNING && update) { + recorder.updateSettings(); + } + } + } + + private void notifyIfStateChanged(RecordingState newState, RecordingState oldState) { + if (oldState == newState) { + return; + } + for (FlightRecorderListener cl : PlatformRecorder.getListeners()) { + try { + cl.recordingStateChanged(getRecording()); + } catch (RuntimeException re) { + Logger.log(JFR, WARN, "Error notifying recorder listener:" + re.getMessage()); + } + } + } + + public void setRecording(Recording recording) { + this.recording = recording; + } + + public Recording getRecording() { + return recording; + } + + @Override + public String toString() { + return getName() + " (id=" + getId() + ") " + getState(); + } + + public void setConfiguration(Configuration c) { + setSettings(c.getSettings()); + } + + public void setMaxAge(Duration maxAge) { + synchronized (recorder) { + if (getState() == RecordingState.CLOSED) { + throw new IllegalStateException("Can't set max age when recording is closed"); + } + this.maxAge = maxAge; + if (maxAge != null) { + trimToAge(Instant.now().minus(maxAge)); + } + } + } + + void appendChunk(RepositoryChunk chunk) { + if (!chunk.isFinished()) { + throw new Error("not finished chunk " + chunk.getStartTime()); + } + synchronized (recorder) { + if (!toDisk) { + return; + } + if (maxAge != null) { + trimToAge(chunk.getEndTime().minus(maxAge)); + } + chunks.addLast(chunk); + added(chunk); + trimToSize(); + } + } + + private void trimToSize() { + if (maxSize == 0) { + return; + } + while (size > maxSize && chunks.size() > 1) { + RepositoryChunk c = chunks.removeFirst(); + removed(c); + } + } + + private void trimToAge(Instant oldest) { + while (!chunks.isEmpty()) { + RepositoryChunk oldestChunk = chunks.peek(); + if (oldestChunk.getEndTime().isAfter(oldest)) { + return; + } + chunks.removeFirst(); + removed(oldestChunk); + } + } + + void add(RepositoryChunk c) { + chunks.add(c); + added(c); + } + + private void added(RepositoryChunk c) { + c.use(); + size += c.getSize(); + Logger.log(JFR, DEBUG, () -> "Recording \"" + name + "\" (" + id + ") added chunk " + c.toString() + ", current size=" + size); + } + + private void removed(RepositoryChunk c) { + size -= c.getSize(); + Logger.log(JFR, DEBUG, () -> "Recording \"" + name + "\" (" + id + ") removed chunk " + c.toString() + ", current size=" + size); + c.release(); + } + + public List getChunks() { + return chunks; + } + + public InputStream open(Instant start, Instant end) throws IOException { + synchronized (recorder) { + if (getState() != RecordingState.STOPPED) { + throw new IOException("Recording must be stopped before it can be read."); + } + List chunksToUse = new ArrayList(); + for (RepositoryChunk chunk : chunks) { + if (chunk.isFinished()) { + Instant chunkStart = chunk.getStartTime(); + Instant chunkEnd = chunk.getEndTime(); + if (start == null || !chunkEnd.isBefore(start)) { + if (end == null || !chunkStart.isAfter(end)) { + chunksToUse.add(chunk); + } + } + } + } + if (chunksToUse.isEmpty()) { + return null; + } + return new ChunkInputStream(chunksToUse); + } + } + + public Duration getDuration() { + synchronized (recorder) { + return duration; + } + } + + void setInternalDuration(Duration duration) { + this.duration = duration; + } + + public void setDuration(Duration duration) { + synchronized (recorder) { + if (Utils.isState(getState(), RecordingState.STOPPED, RecordingState.CLOSED)) { + throw new IllegalStateException("Duration can't be set after a recording has been stopped/closed"); + } + setInternalDuration(duration); + if (getState() != RecordingState.NEW) { + updateTimer(); + } + } + } + + void updateTimer() { + if (stopTask != null) { + stopTask.cancel(); + stopTask = null; + } + if (getState() == RecordingState.CLOSED) { + return; + } + if (duration != null) { + stopTask = createStopTask(); + recorder.getTimer().schedule(stopTask, new Date(startTime.plus(duration).toEpochMilli())); + } + } + + TimerTask createStopTask() { + return new TimerTask() { + @Override + public void run() { + try { + stop("End of duration reached"); + } catch (Throwable t) { + // Prevent malicious user to propagate exception callback in the wrong context + Logger.log(LogTag.JFR, LogLevel.ERROR, "Could not stop recording."); + } + } + }; + } + + public Recording newCopy(boolean stop) { + return recorder.newCopy(this, stop); + } + + void setStopTask(TimerTask stopTask) { + synchronized (recorder) { + this.stopTask = stopTask; + } + } + + void clearDestination() { + destination = null; + } + + public AccessControlContext getNoDestinationDumpOnExitAccessControlContext() { + return noDestinationDumpOnExitAccessControlContext; + } + + void setShouldWriteActiveRecordingEvent(boolean shouldWrite) { + this.shuoldWriteActiveRecordingEvent = shouldWrite; + } + + boolean shouldWriteMetadataEvent() { + return shuoldWriteActiveRecordingEvent; + } + + // Dump running and stopped recordings + public void dump(WriteableUserPath writeableUserPath) throws IOException { + synchronized (recorder) { + try(PlatformRecording p = newSnapshotClone("Dumped by user", null)) { + p.dumpStopped(writeableUserPath); + } + } + } + + public void dumpStopped(WriteableUserPath userPath) throws IOException { + synchronized (recorder) { + userPath.doPriviligedIO(() -> { + try (ChunksChannel cc = new ChunksChannel(chunks); FileChannel fc = FileChannel.open(userPath.getReal(), StandardOpenOption.WRITE, StandardOpenOption.APPEND)) { + cc.transferTo(fc); + fc.force(true); + } + return null; + }); + } + } + + public void filter(Instant begin, Instant end, Long maxSize) { + synchronized (recorder) { + List result = removeAfter(end, removeBefore(begin, new ArrayList<>(chunks))); + if (maxSize != null) { + if (begin != null && end == null) { + result = reduceFromBeginning(maxSize, result); + } else { + result = reduceFromEnd(maxSize, result); + } + } + int size = 0; + for (RepositoryChunk r : result) { + size += r.getSize(); + r.use(); + } + this.size = size; + for (RepositoryChunk r : chunks) { + r.release(); + } + chunks.clear(); + chunks.addAll(result); + } + } + + private static List removeBefore(Instant time, List input) { + if (time == null) { + return input; + } + List result = new ArrayList<>(input.size()); + for (RepositoryChunk r : input) { + if (!r.getEndTime().isBefore(time)) { + result.add(r); + } + } + return result; + } + + private static List removeAfter(Instant time, List input) { + if (time == null) { + return input; + } + List result = new ArrayList<>(input.size()); + for (RepositoryChunk r : input) { + if (!r.getStartTime().isAfter(time)) { + result.add(r); + } + } + return result; + } + + private static List reduceFromBeginning(Long maxSize, List input) { + if (maxSize == null || input.isEmpty()) { + return input; + } + List result = new ArrayList<>(input.size()); + long total = 0; + for (RepositoryChunk r : input) { + total += r.getSize(); + if (total > maxSize) { + break; + } + result.add(r); + } + // always keep at least one chunk + if (result.isEmpty()) { + result.add(input.get(0)); + } + return result; + } + + private static List reduceFromEnd(Long maxSize, List input) { + Collections.reverse(input); + List result = reduceFromBeginning(maxSize, input); + Collections.reverse(result); + return result; + } + + public void setDumpOnExitDirectory(SafePath directory) { + this.dumpOnExitDirectory = directory; + } + + public SafePath getDumpOnExitDirectory() { + return this.dumpOnExitDirectory; + } +} diff --git a/src/share/classes/jdk/jfr/internal/PrivateAccess.java b/src/share/classes/jdk/jfr/internal/PrivateAccess.java new file mode 100644 index 0000000000000000000000000000000000000000..b79a384eea107da4eacd1264598c3e03b9e21730 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/PrivateAccess.java @@ -0,0 +1,97 @@ +/* + * 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. 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.internal; + +import java.util.List; +import java.util.Map; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.Configuration; +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorderPermission; +import jdk.jfr.Recording; +import jdk.jfr.SettingDescriptor; +import jdk.jfr.ValueDescriptor; + +/** + * Provides access to package private function in jdk.jfr. + *

    + * The static initializer in this class loads the Settings class, which will + * call {@link #setPrivateAccess(PrivateAccess)} on this class, which can be + * used call to package protected methods. + * + * This is similar to how java.lang accesses package private methods in + * java.lang.reflect. + */ +public abstract class PrivateAccess { + private volatile static PrivateAccess instance; + + public static PrivateAccess getInstance() { + // Can't be initialized in because it may + // deadlock with FlightRecordeerPermission. + if (instance == null) { + // Will trigger + // FlightRecordeerPermission. + // which will call PrivateAccess.setPrivateAccess + new FlightRecorderPermission(Utils.REGISTER_EVENT); + } + return instance; + } + + public static void setPrivateAccess(PrivateAccess pa) { + instance = pa; + } + + public abstract Type getType(Object o); + + public abstract Configuration newConfiguration(String name, String label, String description, String provider, Map settings, String contents); + + public abstract EventType newEventType(PlatformEventType eventTypes); + + public abstract AnnotationElement newAnnotation(Type annotationType, List values, boolean boot); + + public abstract ValueDescriptor newValueDescriptor(String name, Type fieldType, List annotations, int dimension, boolean constantPool, String fieldName); + + public abstract PlatformRecording getPlatformRecording(Recording r); + + public abstract PlatformEventType getPlatformEventType(EventType eventType); + + public abstract boolean isConstantPool(ValueDescriptor v); + + public abstract String getFieldName(ValueDescriptor v); + + public abstract ValueDescriptor newValueDescriptor(Class type, String name); + + public abstract SettingDescriptor newSettingDescriptor(Type type, String name, String def, List aes); + + public abstract void setAnnotations(ValueDescriptor v, List a); + + public abstract void setAnnotations(SettingDescriptor s, List a); + + public abstract boolean isUnsigned(ValueDescriptor v); + + public abstract PlatformRecorder getPlatformRecorder(); +} diff --git a/src/share/classes/jdk/jfr/internal/Repository.java b/src/share/classes/jdk/jfr/internal/Repository.java new file mode 100644 index 0000000000000000000000000000000000000000..f48f8c60324d4cbfc6611df652e30f3231787fc5 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/Repository.java @@ -0,0 +1,165 @@ +/* + * 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 + * 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.internal; + +import java.io.IOException; +import java.nio.file.Path; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.HashSet; +import java.util.Set; + +import jdk.jfr.internal.SecuritySupport.SafePath; + +public final class Repository { + + private static final int MAX_REPO_CREATION_RETRIES = 1000; + private static final JVM jvm = JVM.getJVM(); + private static final Repository instance = new Repository(); + + public final static DateTimeFormatter REPO_DATE_FORMAT = DateTimeFormatter + .ofPattern("yyyy_MM_dd_HH_mm_ss"); + + private final Set cleanupDirectories = new HashSet<>(); + private SafePath baseLocation; + private SafePath repository; + + private Repository() { + } + + public static Repository getRepository() { + return instance; + } + + public synchronized void setBasePath(SafePath baseLocation) throws Exception { + // Probe to see if repository can be created, needed for fail fast + // during JVM startup or JFR.configure + this.repository = createRepository(baseLocation); + try { + // Remove so we don't "leak" repositories, if JFR is never started + // and shutdown hook not added. + SecuritySupport.delete(repository); + } catch (IOException ioe) { + Logger.log(LogTag.JFR, LogLevel.INFO, "Could not delete disk repository " + repository); + } + this.baseLocation = baseLocation; + } + + synchronized void ensureRepository() throws Exception { + if (baseLocation == null) { + setBasePath(SecuritySupport.JAVA_IO_TMPDIR); + } + } + + synchronized RepositoryChunk newChunk(Instant timestamp) { + try { + if (!SecuritySupport.existDirectory(repository)) { + this.repository = createRepository(baseLocation); + jvm.setRepositoryLocation(repository.toString()); + cleanupDirectories.add(repository); + } + return new RepositoryChunk(repository, timestamp); + } catch (Exception e) { + String errorMsg = String.format("Could not create chunk in repository %s, %s", repository, e.getMessage()); + Logger.log(LogTag.JFR, LogLevel.ERROR, errorMsg); + jvm.abort(errorMsg); + throw new InternalError("Could not abort after JFR disk creation error"); + } + } + + private static SafePath createRepository(SafePath basePath) throws Exception { + SafePath canonicalBaseRepositoryPath = createRealBasePath(basePath); + SafePath f = null; + + String basename = REPO_DATE_FORMAT.format(LocalDateTime.now()) + "_" + JVM.getJVM().getPid(); + String name = basename; + + int i = 0; + for (; i < MAX_REPO_CREATION_RETRIES; i++) { + f = new SafePath(canonicalBaseRepositoryPath.toPath().resolve(name)); + if (tryToUseAsRepository(f)) { + break; + } + name = basename + "_" + i; + } + + if (i == MAX_REPO_CREATION_RETRIES) { + throw new Exception("Unable to create JFR repository directory using base location (" + basePath + ")"); + } + SafePath canonicalRepositoryPath = SecuritySupport.toRealPath(f); + return canonicalRepositoryPath; + } + + private static SafePath createRealBasePath(SafePath safePath) throws Exception { + if (SecuritySupport.exists(safePath)) { + if (!SecuritySupport.isWritable(safePath)) { + throw new IOException("JFR repository directory (" + safePath.toString() + ") exists, but isn't writable"); + } + return SecuritySupport.toRealPath(safePath); + } + SafePath p = SecuritySupport.createDirectories(safePath); + return SecuritySupport.toRealPath(p); + } + + private static boolean tryToUseAsRepository(final SafePath path) { + Path parent = path.toPath().getParent(); + if (parent == null) { + return false; + } + try { + try { + SecuritySupport.createDirectories(path); + } catch (Exception e) { + // file already existed or some other problem occurred + } + if (!SecuritySupport.exists(path)) { + return false; + } + if (!SecuritySupport.isDirectory(path)) { + return false; + } + return true; + } catch (IOException io) { + return false; + } + } + + synchronized void clear() { + for (SafePath p : cleanupDirectories) { + try { + SecuritySupport.clearDirectory(p); + Logger.log(LogTag.JFR, LogLevel.INFO, "Removed repository " + p); + } catch (IOException e) { + Logger.log(LogTag.JFR, LogLevel.ERROR, "Repository " + p + " could not be removed at shutdown: " + e.getMessage()); + } + } + } + + public synchronized SafePath getRepositoryPath() { + return repository; + } +} diff --git a/src/share/classes/jdk/jfr/internal/RepositoryChunk.java b/src/share/classes/jdk/jfr/internal/RepositoryChunk.java new file mode 100644 index 0000000000000000000000000000000000000000..373f17205c612c902117636afcd4c45032e62dee --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/RepositoryChunk.java @@ -0,0 +1,210 @@ +/* + * 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 + * 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.internal; + +import java.io.IOException; +import java.io.RandomAccessFile; +import java.nio.channels.ReadableByteChannel; +import java.nio.file.Path; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZonedDateTime; +import java.util.Comparator; +import java.util.Objects; + +import jdk.jfr.internal.SecuritySupport.SafePath; + +final class RepositoryChunk { + private static final int MAX_CHUNK_NAMES = 100; + + static final Comparator END_TIME_COMPARATOR = new Comparator() { + @Override + public int compare(RepositoryChunk c1, RepositoryChunk c2) { + return c1.endTime.compareTo(c2.endTime); + } + }; + + private final SafePath repositoryPath; + private final SafePath unFinishedFile; + private final SafePath file; + private final Instant startTime; + private final RandomAccessFile unFinishedRAF; + + private Instant endTime = null; // unfinished + private int refCount = 0; + private long size; + + RepositoryChunk(SafePath path, Instant startTime) throws Exception { + ZonedDateTime z = ZonedDateTime.now(); + String fileName = Repository.REPO_DATE_FORMAT.format( + LocalDateTime.ofInstant(startTime, z.getZone())); + this.startTime = startTime; + this.repositoryPath = path; + this.unFinishedFile = findFileName(repositoryPath, fileName, ".part"); + this.file = findFileName(repositoryPath, fileName, ".jfr"); + this.unFinishedRAF = SecuritySupport.createRandomAccessFile(unFinishedFile); + SecuritySupport.touch(file); + } + + private static SafePath findFileName(SafePath directory, String name, String extension) throws Exception { + Path p = directory.toPath().resolve(name + extension); + for (int i = 1; i < MAX_CHUNK_NAMES; i++) { + SafePath s = new SafePath(p); + if (!SecuritySupport.exists(s)) { + return s; + } + String extendedName = String.format("%s_%02d%s", name, i, extension); + p = directory.toPath().resolve(extendedName); + } + p = directory.toPath().resolve(name + "_" + System.currentTimeMillis() + extension); + return SecuritySupport.toRealPath(new SafePath(p)); + } + + public SafePath getUnfishedFile() { + return unFinishedFile; + } + + void finish(Instant endTime) { + try { + finishWithException(endTime); + } catch (IOException e) { + Logger.log(LogTag.JFR, LogLevel.ERROR, "Could not finish chunk. " + e.getMessage()); + } + } + + private void finishWithException(Instant endTime) throws IOException { + unFinishedRAF.close(); + this.size = finish(unFinishedFile, file); + this.endTime = endTime; + Logger.log(LogTag.JFR_SYSTEM, LogLevel.DEBUG, () -> "Chunk finished: " + file); + } + + private static long finish(SafePath unFinishedFile, SafePath file) throws IOException { + Objects.requireNonNull(unFinishedFile); + Objects.requireNonNull(file); + SecuritySupport.delete(file); + SecuritySupport.moveReplace(unFinishedFile, file); + return SecuritySupport.getFileSize(file); + } + + public Instant getStartTime() { + return startTime; + } + + public Instant getEndTime() { + return endTime; + } + + private void delete(SafePath f) { + try { + SecuritySupport.delete(f); + Logger.log(LogTag.JFR, LogLevel.DEBUG, () -> "Repository chunk " + f + " deleted"); + } catch (IOException e) { + Logger.log(LogTag.JFR, LogLevel.ERROR, () -> "Repository chunk " + f + " could not be deleted: " + e.getMessage()); + if (f != null) { + SecuritySupport.deleteOnExit(f); + } + } + } + + private void destroy() { + if (!isFinished()) { + finish(Instant.MIN); + } + if (file != null) { + delete(file); + } + try { + unFinishedRAF.close(); + } catch (IOException e) { + Logger.log(LogTag.JFR, LogLevel.ERROR, () -> "Could not close random access file: " + unFinishedFile.toString() + ". File will not be deleted due to: " + e.getMessage()); + } + } + + public synchronized void use() { + ++refCount; + Logger.log(LogTag.JFR_SYSTEM, LogLevel.DEBUG, () -> "Use chunk " + toString() + " ref count now " + refCount); + } + + public synchronized void release() { + --refCount; + Logger.log(LogTag.JFR_SYSTEM, LogLevel.DEBUG, () -> "Release chunk " + toString() + " ref count now " + refCount); + if (refCount == 0) { + destroy(); + } + } + + @Override + @SuppressWarnings("deprecation") + protected void finalize() { + boolean destroy = false; + synchronized (this) { + if (refCount > 0) { + destroy = true; + } + } + if (destroy) { + destroy(); + } + } + + public long getSize() { + return size; + } + + public boolean isFinished() { + return endTime != null; + } + + @Override + public String toString() { + if (isFinished()) { + return file.toString(); + } + return unFinishedFile.toString(); + } + + ReadableByteChannel newChannel() throws IOException { + if (!isFinished()) { + throw new IOException("Chunk not finished"); + } + return ((SecuritySupport.newFileChannelToRead(file))); + } + + public boolean inInterval(Instant startTime, Instant endTime) { + if (startTime != null && getEndTime().isBefore(startTime)) { + return false; + } + if (endTime != null && getStartTime().isAfter(endTime)) { + return false; + } + return true; + } + + public SafePath getFile() { + return file; + } +} diff --git a/src/share/classes/jdk/jfr/internal/RequestEngine.java b/src/share/classes/jdk/jfr/internal/RequestEngine.java new file mode 100644 index 0000000000000000000000000000000000000000..3455f1f99cdf3091336149991486e9e9602b57d9 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/RequestEngine.java @@ -0,0 +1,256 @@ +/* + * 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. 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.internal; + +import java.security.AccessControlContext; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.function.Predicate; +import jdk.jfr.Event; +import jdk.jfr.EventType; + +public final class RequestEngine { + + private final static JVM jvm = JVM.getJVM(); + + final static class RequestHook { + private final Runnable hook; + private final PlatformEventType type; + private final AccessControlContext accessControllerContext; + private long delta; + + // Java events + private RequestHook(AccessControlContext acc, PlatformEventType eventType, Runnable hook) { + this.hook = hook; + this.type = eventType; + this.accessControllerContext = acc; + } + + // native events + RequestHook(PlatformEventType eventType) { + this(null, eventType, null); + } + + private void execute() { + try { + if (accessControllerContext == null) { // native + if (type.isJDK()) { + hook.run(); + } else { + jvm.emitEvent(type.getId(), JVM.counterTime(), 0); + } + Logger.log(LogTag.JFR_SYSTEM_EVENT, LogLevel.DEBUG, ()-> "Executed periodic hook for " + type.getLogName()); + } else { + executeSecure(); + } + } catch (Throwable e) { + // Prevent malicious user to propagate exception callback in the wrong context + Logger.log(LogTag.JFR_SYSTEM_EVENT, LogLevel.WARN, "Exception occured during execution of period hook for " + type.getLogName()); + } + } + + private void executeSecure() { + AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Void run() { + try { + hook.run(); + Logger.log(LogTag.JFR_EVENT, LogLevel.DEBUG, ()-> "Executed periodic hook for " + type.getLogName()); + } catch (Throwable t) { + // Prevent malicious user to propagate exception callback in the wrong context + Logger.log(LogTag.JFR_EVENT, LogLevel.WARN, "Exception occured during execution of period hook for " + type.getLogName()); + } + return null; + } + }, accessControllerContext); + } + } + + private final static List entries = new CopyOnWriteArrayList<>(); + private static long lastTimeMillis; + + public static void addHook(AccessControlContext acc, PlatformEventType type, Runnable hook) { + Objects.requireNonNull(acc); + addHookInternal(acc, type, hook); + } + + private static void addHookInternal(AccessControlContext acc, PlatformEventType type, Runnable hook) { + RequestHook he = new RequestHook(acc, type, hook); + for (RequestHook e : entries) { + if (e.hook == hook) { + throw new IllegalArgumentException("Hook has already been added"); + } + } + he.type.setEventHook(true); + // Insertion takes O(2*n), could be O(1) with HashMap, but + // thinking is that CopyOnWriteArrayList is faster + // to iterate over, which will happen more over time. + entries.add(he); + logHook("Added", type); + } + + public static void addTrustedJDKHook(Class eventClass, Runnable runnable) { + if (eventClass.getClassLoader() != null) { + throw new SecurityException("Hook can only be registered for event classes that are loaded by the bootstrap class loader"); + } + if (runnable.getClass().getClassLoader() != null) { + throw new SecurityException("Runnable hook class must be loaded by the bootstrap class loader"); + } + EventType eType = MetadataRepository.getInstance().getEventType(eventClass); + PlatformEventType pType = PrivateAccess.getInstance().getPlatformEventType(eType); + addHookInternal(null, pType, runnable); + } + + private static void logHook(String action, PlatformEventType type) { + if (type.isJDK() || type.isJVM()) { + Logger.log(LogTag.JFR_SYSTEM_EVENT, LogLevel.INFO, action + " periodic hook for " + type.getLogName()); + } else { + Logger.log(LogTag.JFR_EVENT, LogLevel.INFO, action + " periodic hook for " + type.getLogName()); + } + } + + // Takes O(2*n), see addHook. + public static boolean removeHook(Runnable hook) { + for (RequestHook rh : entries) { + if (rh.hook == hook) { + entries.remove(rh); + rh.type.setEventHook(false); + logHook("Removed", rh.type); + return true; + } + } + return false; + } + + // Only to be used for JVM events. No access control contest + // or check if hook already exists + static void addHooks(List newEntries) { + List addEntries = new ArrayList<>(); + for (RequestHook rh : newEntries) { + rh.type.setEventHook(true); + addEntries.add(rh); + logHook("Added", rh.type); + } + entries.addAll(newEntries); + } + + static void doChunkEnd() { + doChunk(x -> x.isEndChunk()); + } + + static void doChunkBegin() { + doChunk(x -> x.isBeginChunk()); + } + + private static void doChunk(Predicate predicate) { + for (RequestHook requestHook : entries) { + PlatformEventType s = requestHook.type; + if (s.isEnabled() && predicate.test(s)) { + requestHook.execute(); + } + } + } + + static long doPeriodic() { + return run_requests(entries); + } + + // code copied from native impl. + private static long run_requests(Collection entries) { + long last = lastTimeMillis; + // Bug 9000556 - current time millis has rather lame resolution + // The use of os::elapsed_counter() is deliberate here, we don't + // want it exchanged for os::ft_elapsed_counter(). + // Keeping direct call os::elapsed_counter() here for reliable + // real time values in order to decide when registered requestable + // events are due. + long now = System.currentTimeMillis(); + long min = 0; + long delta = 0; + + if (last == 0) { + last = now; + } + + // time from then to now + delta = now - last; + + if (delta < 0) { + // to handle time adjustments + // for example Daylight Savings + lastTimeMillis = now; + return 0; + } + for (RequestHook he : entries) { + long left = 0; + PlatformEventType es = he.type; + // Not enabled, skip. + if (!es.isEnabled() || es.isEveryChunk()) { + continue; + } + long r_period = es.getPeriod(); + long r_delta = he.delta; + + // add time elapsed. + r_delta += delta; + + // above threshold? + if (r_delta >= r_period) { + // Bug 9000556 - don't try to compensate + // for wait > period + r_delta = 0; + he.execute(); + ; + } + + // calculate time left + left = (r_period - r_delta); + + /** + * nothing outside checks that a period is >= 0, so left can end up + * negative here. ex. (r_period =(-1)) - (r_delta = 0) if it is, + * handle it. + */ + if (left < 0) { + left = 0; + } + + // assign delta back + he.delta = r_delta; + + if (min == 0 || left < min) { + min = left; + } + } + lastTimeMillis = now; + return min; + } +} diff --git a/src/share/classes/jdk/jfr/internal/SecuritySupport.java b/src/share/classes/jdk/jfr/internal/SecuritySupport.java new file mode 100644 index 0000000000000000000000000000000000000000..769231409e0e5314f7b244beea47946f885733dc --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/SecuritySupport.java @@ -0,0 +1,391 @@ +/* + * 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. 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.internal; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.RandomAccessFile; +import java.io.Reader; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.ReflectPermission; +import java.nio.channels.FileChannel; +import java.nio.channels.ReadableByteChannel; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.StandardOpenOption; +import java.nio.file.attribute.BasicFileAttributes; +import java.security.AccessControlContext; +import java.security.AccessController; +import java.security.Permission; +import java.security.PrivilegedAction; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Objects; +import java.util.PropertyPermission; +import java.util.concurrent.Callable; + +import sun.misc.Unsafe; +import jdk.jfr.Event; +import jdk.jfr.FlightRecorder; +import jdk.jfr.FlightRecorderListener; +import jdk.jfr.FlightRecorderPermission; +import jdk.jfr.Recording; + +/** + * Contains JFR code that does + * {@link AccessController#doPrivileged(PrivilegedAction)} + */ +public final class SecuritySupport { + private final static Unsafe unsafe = Unsafe.getUnsafe(); + public final static SafePath JFC_DIRECTORY = getPathInProperty("java.home", "lib/jfr"); + + static final SafePath USER_HOME = getPathInProperty("user.home", null); + static final SafePath JAVA_IO_TMPDIR = getPathInProperty("java.io.tmpdir", null); + + final static class SecureRecorderListener implements FlightRecorderListener { + + private final AccessControlContext context; + private final FlightRecorderListener changeListener; + + SecureRecorderListener(AccessControlContext context, FlightRecorderListener changeListener) { + this.context = Objects.requireNonNull(context); + this.changeListener = Objects.requireNonNull(changeListener); + } + + @Override + public void recordingStateChanged(Recording recording) { + AccessController.doPrivileged((PrivilegedAction) () -> { + try { + changeListener.recordingStateChanged(recording); + } catch (Throwable t) { + // Prevent malicious user to propagate exception callback in the wrong context + Logger.log(LogTag.JFR, LogLevel.WARN, "Unexpected exception in listener " + changeListener.getClass()+ " at recording state change"); + } + return null; + }, context); + } + + @Override + public void recorderInitialized(FlightRecorder recorder) { + AccessController.doPrivileged((PrivilegedAction) () -> { + try { + changeListener.recorderInitialized(recorder); + } catch (Throwable t) { + // Prevent malicious user to propagate exception callback in the wrong context + Logger.log(LogTag.JFR, LogLevel.WARN, "Unexpected exception in listener " + changeListener.getClass()+ " when initializing FlightRecorder"); + } + return null; + }, context); + } + + public FlightRecorderListener getChangeListener() { + return changeListener; + } + } + + private static final class DirectoryCleaner extends SimpleFileVisitor { + @Override + public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IOException { + Files.delete(path); + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { + if (exc != null) { + throw exc; + } + Files.delete(dir); + return FileVisitResult.CONTINUE; + } + } + + /** + * Path created by the default file provider,and not + * a malicious provider. + * + */ + public static final class SafePath { + private final Path path; + private final String text; + + public SafePath(Path p) { + // sanitize + text = p.toString(); + path = Paths.get(text); + } + + public SafePath(String path) { + this(Paths.get(path)); + } + + public Path toPath() { + return path; + } + + public String toString() { + return text; + } + } + + private interface RunnableWithCheckedException { + public void run() throws Exception; + } + + private interface CallableWithoutCheckException { + public T call(); + } + + private static U doPrivilegedIOWithReturn(Callable function) throws IOException { + try { + return AccessController.doPrivileged(new PrivilegedExceptionAction() { + @Override + public U run() throws Exception { + return function.call(); + } + }, null); + } catch (PrivilegedActionException e) { + Throwable t = e.getCause(); + if (t instanceof IOException) { + throw (IOException) t; + } + throw new IOException("Unexpected error during I/O operation. " + t.getMessage(), t); + } + } + + private static void doPriviligedIO(RunnableWithCheckedException function) throws IOException { + doPrivilegedIOWithReturn(() -> { + function.run(); + return null; + }); + } + + private static void doPrivileged(Runnable function, Permission... perms) { + AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Void run() { + function.run(); + return null; + } + }, null, perms); + } + + private static void doPrivileged(Runnable function) { + AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Void run() { + function.run(); + return null; + } + }); + } + + private static T doPrivilegedWithReturn(CallableWithoutCheckException function, Permission... perms) { + return AccessController.doPrivileged(new PrivilegedAction() { + @Override + public T run() { + return function.call(); + } + }, null, perms); + } + + public static List getPredefinedJFCFiles() { + List list = new ArrayList<>(); + try { + Iterator pathIterator = doPrivilegedIOWithReturn(() -> { + return Files.newDirectoryStream(JFC_DIRECTORY.toPath(), "*").iterator(); + }); + while (pathIterator.hasNext()) { + Path path = pathIterator.next(); + if (path.toString().endsWith(".jfc")) { + list.add(new SafePath(path)); + } + } + } catch (IOException ioe) { + Logger.log(LogTag.JFR, LogLevel.WARN, "Could not access .jfc-files in " + JFC_DIRECTORY + ", " + ioe.getMessage()); + } + return list; + } + + static void makeVisibleToJFR(Class clazz) { + // nothing to do for JDK8 + } + + /** + * Adds a qualified export of the internal.jdk.jfr.internal.handlers package + * (for EventHandler) + */ + static void addHandlerExport(Class clazz) { + // nothing to do for JDK8 + } + + public static void registerEvent(Class eventClass) { + doPrivileged(() -> FlightRecorder.register(eventClass), new FlightRecorderPermission(Utils.REGISTER_EVENT)); + } + + static boolean getBooleanProperty(String propertyName) { + return doPrivilegedWithReturn(() -> Boolean.getBoolean(propertyName), new PropertyPermission(propertyName, "read")); + } + + private static SafePath getPathInProperty(String prop, String subPath) { + return doPrivilegedWithReturn(() -> { + String path = System.getProperty(prop); + if (path == null) { + return null; + } + File file = subPath == null ? new File(path) : new File(path, subPath); + return new SafePath(file.getAbsolutePath()); + }, new PropertyPermission("*", "read")); + } + + // Called by JVM during initialization of JFR + static Thread createRecorderThread(ThreadGroup systemThreadGroup, ClassLoader contextClassLoader) { + // The thread should have permission = new Permission[0], and not "modifyThreadGroup" and "modifyThread" on the stack, + // but it's hard circumvent if we are going to pass in system thread group in the constructor + Thread thread = doPrivilegedWithReturn(() -> new Thread(systemThreadGroup, "JFR Recorder Thread"), new RuntimePermission("modifyThreadGroup"), new RuntimePermission("modifyThread")); + doPrivileged(() -> thread.setContextClassLoader(contextClassLoader), new RuntimePermission("setContextClassLoader"), new RuntimePermission("modifyThread")); + return thread; + } + + static void registerShutdownHook(Thread shutdownHook) { + doPrivileged(() -> Runtime.getRuntime().addShutdownHook(shutdownHook), new RuntimePermission("shutdownHooks")); + } + + static void setUncaughtExceptionHandler(Thread thread, Thread.UncaughtExceptionHandler eh) { + doPrivileged(() -> thread.setUncaughtExceptionHandler(eh), new RuntimePermission("modifyThread")); + } + + static void moveReplace(SafePath from, SafePath to) throws IOException { + doPrivilegedIOWithReturn(() -> Files.move(from.toPath(), to.toPath())); + } + + static void clearDirectory(SafePath safePath) throws IOException { + doPriviligedIO(() -> Files.walkFileTree(safePath.toPath(), new DirectoryCleaner())); + } + + static SafePath toRealPath(SafePath safePath) throws Exception { + return new SafePath(doPrivilegedIOWithReturn(() -> safePath.toPath().toRealPath())); + } + + static boolean existDirectory(SafePath directory) throws IOException { + return doPrivilegedIOWithReturn(() -> Files.exists(directory.toPath())); + } + + static RandomAccessFile createRandomAccessFile(SafePath path) throws Exception { + return doPrivilegedIOWithReturn(() -> new RandomAccessFile(path.toPath().toFile(), "rw")); + } + + public static InputStream newFileInputStream(SafePath safePath) throws IOException { + return doPrivilegedIOWithReturn(() -> Files.newInputStream(safePath.toPath())); + } + + public static long getFileSize(SafePath safePath) throws IOException { + return doPrivilegedIOWithReturn(() -> Files.size(safePath.toPath())); + } + + static SafePath createDirectories(SafePath safePath) throws IOException { + Path p = doPrivilegedIOWithReturn(() -> Files.createDirectories(safePath.toPath())); + return new SafePath(p); + } + + public static boolean exists(SafePath safePath) throws IOException { + return doPrivilegedIOWithReturn(() -> Files.exists(safePath.toPath())); + } + + public static boolean isDirectory(SafePath safePath) throws IOException { + return doPrivilegedIOWithReturn(() -> Files.isDirectory(safePath.toPath())); + } + + static void delete(SafePath localPath) throws IOException { + doPriviligedIO(() -> Files.delete(localPath.toPath())); + } + + static boolean isWritable(SafePath safePath) throws IOException { + return doPrivilegedIOWithReturn(() -> Files.isWritable(safePath.toPath())); + } + + static void deleteOnExit(SafePath safePath) { + doPrivileged(() -> safePath.toPath().toFile().deleteOnExit()); + } + + static ReadableByteChannel newFileChannelToRead(SafePath safePath) throws IOException { + return doPrivilegedIOWithReturn(() -> FileChannel.open(safePath.toPath(), StandardOpenOption.READ)); + } + + public static InputStream getResourceAsStream(String name) throws IOException { + return doPrivilegedIOWithReturn(() -> SecuritySupport.class.getResourceAsStream(name)); + } + + public static Reader newFileReader(SafePath safePath) throws FileNotFoundException, IOException { + return doPrivilegedIOWithReturn(() -> Files.newBufferedReader(safePath.toPath())); + } + + static void touch(SafePath path) throws IOException { + doPriviligedIO(() -> new RandomAccessFile(path.toPath().toFile(), "rw").close()); + } + + static void setAccessible(Method method) { + doPrivileged(() -> method.setAccessible(true), new ReflectPermission("suppressAccessChecks")); + } + + static void setAccessible(Field field) { + doPrivileged(() -> field.setAccessible(true), new ReflectPermission("suppressAccessChecks")); + } + + static void setAccessible(Constructor constructor) { + doPrivileged(() -> constructor.setAccessible(true), new ReflectPermission("suppressAccessChecks")); + } + + static void ensureClassIsInitialized(Class clazz) { + unsafe.ensureClassInitialized(clazz); + } + + static Class defineClass(String name, byte[] bytes, ClassLoader classLoader) { + return unsafe.defineClass(name, bytes, 0, bytes.length, classLoader, null); + } + + static Thread createThreadWitNoPermissions(String threadName, Runnable runnable) { + return doPrivilegedWithReturn(() -> new Thread(runnable, threadName), new Permission[0]); + } + + static void setDaemonThread(Thread t, boolean daeomn) { + doPrivileged(()-> t.setDaemon(daeomn), new RuntimePermission("modifyThread")); + } + + public static SafePath getAbsolutePath(SafePath path) throws IOException { + return new SafePath(doPrivilegedIOWithReturn((()-> path.toPath().toAbsolutePath()))); + } +} diff --git a/src/share/classes/jdk/jfr/internal/SettingsManager.java b/src/share/classes/jdk/jfr/internal/SettingsManager.java new file mode 100644 index 0000000000000000000000000000000000000000..592f216c1865ab0aff283680b3399fff6d666a09 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/SettingsManager.java @@ -0,0 +1,292 @@ +/* + * 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. 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.internal; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.StringJoiner; + +import jdk.jfr.Event; +import jdk.jfr.internal.handlers.EventHandler; + +final class SettingsManager { + + private static class InternalSetting { + + private final String identifier; + private Map> enabledMap = new LinkedHashMap<>(5); + private Map> allMap = new LinkedHashMap<>(5); + private boolean enabled; + + /** + * Settings identifier, for example "com.example.HelloWorld" or "56" + * (id of event) + * + * @param settingsId + */ + public InternalSetting(String settingsId) { + this.identifier = settingsId; + } + + public Set getValues(String key) { + if (enabled) { + return enabledMap.get(key); + } else { + return allMap.get(key); + } + } + + public void add(String attribute, String value) { + if ("enabled".equals(attribute) && "true".equals(value)) { + enabled = true; + allMap = null; // no need to keep these around + } + addToMap(enabledMap, attribute, value); + if (allMap != null) { + addToMap(allMap, attribute, value); + } + } + + private void addToMap(Map> map, String attribute, String value) { + Set values = map.get(attribute); + if (values == null) { + values = new HashSet(5); + map.put(attribute, values); + } + values.add(value); + + } + + public String getSettingsId() { + return identifier; + } + + public void add(InternalSetting enabled) { + for (Map.Entry> entry : enabled.enabledMap.entrySet()) { + for (String value : entry.getValue()) { + add(entry.getKey(), value); + } + } + } + + public boolean isEnabled() { + return enabled; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(identifier); + sb.append(": "); + sb.append(enabledMap.toString()); + return sb.toString(); + } + + public void finish() { + if (!enabled) { + // settings from disabled + // events should not impact results, but + // we can't clear enabledMap since enabled=false + // needs be there, so events that are enabled + // by default are turned off + Map> disabledMap = new HashMap<>(2); + Set values = new HashSet<>(2); + values.add("false"); + disabledMap.put("enabled", values); + enabledMap = disabledMap; + } + } + } + + private Map availableSettings = new LinkedHashMap<>(); + + void setSettings(List> activeSettings) { + // store settings so they are available if a new event class is loaded + availableSettings = createSettingsMap(activeSettings); + List eventControls = MetadataRepository.getInstance().getEventControls(); + if (!JVM.getJVM().isRecording()) { + for (EventControl ec : eventControls) { + ec.disable(); + } + } else { + if (Logger.shouldLog(LogTag.JFR_SETTING, LogLevel.INFO)) { + Collections.sort(eventControls, (x,y) -> x.getEventType().getName().compareTo(y.getEventType().getName())); + } + for (EventControl ec : eventControls) { + setEventControl(ec); + } + } + if (JVM.getJVM().getAllowedToDoEventRetransforms()) { + updateRetransform(JVM.getJVM().getAllEventClasses()); + } + } + + public void updateRetransform(List> eventClasses) { + List> classes = new ArrayList<>(); + for(Class eventClass: eventClasses) { + EventHandler eh = Utils.getHandler(eventClass); + if (eh != null ) { + PlatformEventType eventType = eh.getPlatformEventType(); + if (eventType.isMarkedForInstrumentation()) { + classes.add(eventClass); + eventType.markForInstrumentation(false); + // A bit premature to set it here, but hard to check + // after call to retransformClasses. + eventType.setInstrumented(); + } + } + } + if (!classes.isEmpty()) { + JVM.getJVM().retransformClasses(classes.toArray(new Class[0])); + } + } + + private Map createSettingsMap(List> activeSettings) { + Map map = new LinkedHashMap<>(activeSettings.size()); + for (Map rec : activeSettings) { + for (InternalSetting internal : makeInternalSettings(rec)) { + InternalSetting is = map.get(internal.getSettingsId()); + if (is == null) { + map.put(internal.getSettingsId(), internal); + } else { + is.add(internal); + } + } + } + return map; + } + + private Collection makeInternalSettings(Map rec) { + Map internals = new LinkedHashMap<>(); + for (Map.Entry entry : rec.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + int index = key.indexOf("#"); + if (index > 1 && index < key.length() - 2) { + String eventName = key.substring(0, index); + eventName = Utils.upgradeLegacyJDKEvent(eventName); + InternalSetting s = internals.get(eventName); + String settingName = key.substring(index + 1).trim(); + if (s == null) { + s = new InternalSetting(eventName); + internals.put(eventName, s); + } + s.add(settingName, value); + } + } + for (InternalSetting s : internals.values()) { + s.finish(); + } + + return internals.values(); + } + + void setEventControl(EventControl ec) { + InternalSetting is = getInternalSetting(ec); + Logger.log(LogTag.JFR_SETTING, LogLevel.INFO, "Applied settings for " + ec.getEventType().getLogName() + " {"); + for (Entry entry : ec.getEntries()) { + Set values = null; + String settingName = entry.getKey(); + if (is != null) { + values = is.getValues(settingName); + } + Control control = entry.getValue(); + if (values != null) { + control.apply(values); + String after = control.getLastValue(); + if (Logger.shouldLog(LogTag.JFR_SETTING, LogLevel.INFO)) { + if (Utils.isSettingVisible(control, ec.getEventType().hasEventHook())) { + if (values.size() > 1) { + StringJoiner sj = new StringJoiner(", ", "{", "}"); + for (String s : values) { + sj.add("\"" + s + "\""); + } + String message = " " + settingName + "= " + sj.toString() + " => \"" + after + "\""; + Logger.log(LogTag.JFR_SETTING, LogLevel.INFO, message); + } else { + String message = " " + settingName + "=\"" + control.getLastValue() + "\""; + Logger.log(LogTag.JFR_SETTING, LogLevel.INFO, message); + } + } + } + } else { + control.setDefault(); + if (Logger.shouldLog(LogTag.JFR_SETTING, LogLevel.INFO)) { + String message = " " + settingName + "=\"" + control.getLastValue() + "\""; + Logger.log(LogTag.JFR_SETTING, LogLevel.INFO, message); + } + } + } + ec.writeActiveSettingEvent(); + Logger.log(LogTag.JFR_SETTING, LogLevel.INFO, "}"); + } + + private InternalSetting getInternalSetting(EventControl ec) { + String name = ec.getEventType().getName(); + InternalSetting nameBased = availableSettings.get(name); + InternalSetting idBased = availableSettings.get(ec.getSettingsId()); + + if (nameBased == null && idBased == null) { + return null; + } + if (idBased == null) { + return nameBased; + } + if (nameBased == null) { + return idBased; + } + InternalSetting mixed = new InternalSetting(nameBased.getSettingsId()); + mixed.add(nameBased); + mixed.add(idBased); + return mixed; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + for (InternalSetting enabled : availableSettings.values()) { + sb.append(enabled.toString()); + sb.append("\n"); + } + return sb.toString(); + } + + boolean isEnabled(String eventName) { + InternalSetting is = availableSettings.get(eventName); + if (is == null) { + return false; + } + return is.isEnabled(); + } +} diff --git a/src/share/classes/jdk/jfr/internal/ShutdownHook.java b/src/share/classes/jdk/jfr/internal/ShutdownHook.java new file mode 100644 index 0000000000000000000000000000000000000000..3295b9a7472b2a256dae8db8893c68e2f4028686 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/ShutdownHook.java @@ -0,0 +1,105 @@ +/* + * 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. 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.internal; + +import java.io.IOException; +import java.security.AccessControlContext; +import java.security.AccessController; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; + +import jdk.jfr.RecordingState; + +/** + * Class responsible for dumping recordings on exit + * + */ +final class ShutdownHook implements Runnable { + private final PlatformRecorder recorder; + Object tlabDummyObject; + + ShutdownHook(PlatformRecorder recorder) { + this.recorder = recorder; + } + + @Override + public void run() { + // this allocation is done in order to fetch a new TLAB before + // starting any "real" operations. In low memory situations, + // we would like to take an OOM as early as possible. + tlabDummyObject = new Object(); + + for (PlatformRecording recording : recorder.getRecordings()) { + if (recording.getDumpOnExit() && recording.getState() == RecordingState.RUNNING) { + dump(recording); + } + } + recorder.destroy(); + } + + private void dump(PlatformRecording recording) { + try { + WriteableUserPath dest = recording.getDestination(); + if (dest == null) { + dest = makeDumpOnExitPath(recording); + recording.setDestination(dest); + } + if (dest != null) { + recording.stop("Dump on exit"); + } + } catch (Exception e) { + Logger.log(LogTag.JFR, LogLevel.DEBUG, () -> "Could not dump recording " + recording.getName() + " on exit."); + } + } + + private WriteableUserPath makeDumpOnExitPath(PlatformRecording recording) { + try { + String name = Utils.makeFilename(recording.getRecording()); + AccessControlContext acc = recording.getNoDestinationDumpOnExitAccessControlContext(); + return AccessController.doPrivileged(new PrivilegedExceptionAction() { + @Override + public WriteableUserPath run() throws Exception { + return new WriteableUserPath(recording.getDumpOnExitDirectory().toPath().resolve(name)); + } + }, acc); + } catch (PrivilegedActionException e) { + Throwable t = e.getCause(); + if (t instanceof SecurityException) { + Logger.log(LogTag.JFR, LogLevel.WARN, "Not allowed to create dump path for recording " + recording.getId() + " on exit."); + } + if (t instanceof IOException) { + Logger.log(LogTag.JFR, LogLevel.WARN, "Could not dump " + recording.getId() + " on exit."); + } + return null; + } + } + + static final class ExceptionHandler implements Thread.UncaughtExceptionHandler { + public void uncaughtException(Thread t, Throwable e) { + JVM.getJVM().uncaughtException(t, e); + } + } +} diff --git a/src/share/classes/jdk/jfr/internal/StringPool.java b/src/share/classes/jdk/jfr/internal/StringPool.java new file mode 100644 index 0000000000000000000000000000000000000000..c789dce6c7709dbad927972db90e711db59e66db --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/StringPool.java @@ -0,0 +1,135 @@ +/* + * 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. 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.internal; + +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicLong; + +import sun.misc.Unsafe; + +public final class StringPool { + + private static final Unsafe unsafe = Unsafe.getUnsafe(); + + static final int MIN_LIMIT = 16; + static final int MAX_LIMIT = 128; /* 0 MAX means disabled */ + private static final long epochAddress; + private static final SimpleStringIdPool sp = new SimpleStringIdPool(); + static { + epochAddress = JVM.getJVM().getEpochAddress(); + sp.reset(); + } + public static long addString(String s) { + return sp.addString(s); + } + private static boolean getCurrentEpoch() { + return unsafe.getByte(epochAddress) == 1; + } + private static class SimpleStringIdPool { + /* string id index */ + private final AtomicLong sidIdx = new AtomicLong(); + /* epoch of cached strings */ + private boolean poolEpoch; + /* the cache */ + private final ConcurrentHashMap cache; + /* max size */ + private final int MAX_SIZE = 32*1024; + /* max size bytes*/ + private final long MAX_SIZE_UTF16 = 16*1024*1024; + /* max size bytes*/ + private long currentSizeUTF16; + + /* looking at a biased data set 4 is a good value */ + private final String[] preCache = new String[]{"", "" , "" ,""}; + /* index of oldest */ + private int preCacheOld = 0; + /* loop mask */ + private static final int preCacheMask = 0x03; + + SimpleStringIdPool() { + cache = new ConcurrentHashMap<>(MAX_SIZE, 0.75f); + } + void reset() { + reset(getCurrentEpoch()); + } + private void reset(boolean epoch) { + this.cache.clear(); + this.poolEpoch = epoch; + this.currentSizeUTF16 = 0; + } + private long addString(String s) { + boolean currentEpoch = getCurrentEpoch(); + if (poolEpoch == currentEpoch) { + /* pool is for current chunk */ + Long lsid = this.cache.get(s); + if (lsid != null) { + return lsid.longValue(); + } + } else { + /* pool is for an old chunk */ + reset(currentEpoch); + } + if (!preCache(s)) { + /* we should not pool this string */ + return -1; + } + if (cache.size() > MAX_SIZE || currentSizeUTF16 > MAX_SIZE_UTF16) { + /* pool was full */ + reset(currentEpoch); + } + return storeString(s); + } + + private long storeString(String s) { + long sid = this.sidIdx.getAndIncrement(); + /* we can race but it is ok */ + this.cache.put(s, sid); + boolean currentEpoch; + synchronized(SimpleStringIdPool.class) { + currentEpoch = JVM.addStringConstant(poolEpoch, sid, s); + currentSizeUTF16 += s.length(); + } + /* did we write in chunk that this pool represent */ + return currentEpoch == poolEpoch ? sid : -1; + } + private boolean preCache(String s) { + if (preCache[0].equals(s)) { + return true; + } + if (preCache[1].equals(s)) { + return true; + } + if (preCache[2].equals(s)) { + return true; + } + if (preCache[3].equals(s)) { + return true; + } + preCacheOld = (preCacheOld - 1) & preCacheMask; + preCache[preCacheOld] = s; + return false; + } + } +} diff --git a/src/share/classes/jdk/jfr/internal/Type.java b/src/share/classes/jdk/jfr/internal/Type.java new file mode 100644 index 0000000000000000000000000000000000000000..aff93a5c4a0ff4db39dcb52d2b6c3f426f2b5921 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/Type.java @@ -0,0 +1,326 @@ +/* + * 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. 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.internal; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.Event; +import jdk.jfr.SettingControl; +import jdk.jfr.ValueDescriptor; + +/** + * Internal data structure that describes a type, + * + * Used to create event types, value descriptor and annotations. + * + */ +public class Type implements Comparable { + public static final String SUPER_TYPE_ANNOTATION = java.lang.annotation.Annotation.class.getName(); + public static final String SUPER_TYPE_SETTING = SettingControl.class.getName(); + public static final String SUPER_TYPE_EVENT = Event.class.getName(); + public static final String EVENT_NAME_PREFIX = "jdk."; + public static final String TYPES_PREFIX = "jdk.types."; + public static final String SETTINGS_PREFIX = "jdk.settings."; + + + // Initialization of known types + private final static Map> knownTypes = new HashMap<>(); + static final Type BOOLEAN = register(boolean.class, new Type("boolean", null, 4)); + static final Type CHAR = register(char.class, new Type("char", null, 5)); + static final Type FLOAT = register(float.class, new Type("float", null, 6)); + static final Type DOUBLE = register(double.class, new Type("double", null, 7)); + static final Type BYTE = register(byte.class, new Type("byte", null, 8)); + static final Type SHORT = register(short.class, new Type("short", null, 9)); + static final Type INT = register(int.class, new Type("int", null, 10)); + static final Type LONG = register(long.class, new Type("long", null, 11)); + static final Type CLASS = register(Class.class, new Type("java.lang.Class", null, 20)); + static final Type STRING = register(String.class, new Type("java.lang.String", null, 21)); + static final Type THREAD = register(Thread.class, new Type("java.lang.Thread", null, 22)); + static final Type STACK_TRACE = register(null, new Type(TYPES_PREFIX + "StackTrace", null, 23)); + + private final AnnotationConstruct annos = new AnnotationConstruct(); + private final String name; + private final String superType; + private final boolean constantPool; + private final long id; + private List fields = new ArrayList<>(); + private Boolean simpleType; // calculated lazy + private boolean remove = true; + /** + * Creates a type + * + * @param javaTypeName i.e "java.lang.String" + * @param superType i.e "java.lang.Annotation" + * @param id the class id that represents the class in the JVM + * + */ + public Type(String javaTypeName, String superType, long typeId) { + this(javaTypeName, superType, typeId, false); + } + + Type(String javaTypeName, String superType, long typeId, boolean contantPool) { + this(javaTypeName, superType, typeId, contantPool, null); + } + + Type(String javaTypeName, String superType, long typeId, boolean contantPool, Boolean simpleType) { + Objects.requireNonNull(javaTypeName); + + if (!isValidJavaIdentifier(javaTypeName)) { + throw new IllegalArgumentException(javaTypeName + " is not a valid Java identifier"); + } + this.constantPool = contantPool; + this.superType = superType; + this.name = javaTypeName; + this.id = typeId; + this.simpleType = simpleType; + } + + static boolean isDefinedByJVM(long id) { + return id < JVM.RESERVED_CLASS_ID_LIMIT; + } + + public static long getTypeId(Class clazz) { + Type type = Type.getKnownType(clazz); + return type == null ? JVM.getJVM().getTypeId(clazz) : type.getId(); + } + + static Collection getKnownTypes() { + return knownTypes.keySet(); + } + + public static boolean isValidJavaIdentifier(String identifier) { + if (identifier.isEmpty()) { + return false; + } + if (!Character.isJavaIdentifierStart(identifier.charAt(0))) { + return false; + } + for (int i = 1; i < identifier.length(); i++) { + char c = identifier.charAt(i); + if (c != '.') { + if (!Character.isJavaIdentifierPart(c)) { + return false; + } + } + } + return true; + } + + public static boolean isValidJavaFieldType(String name) { + for (Map.Entry> entry : knownTypes.entrySet()) { + Class clazz = entry.getValue(); + if (clazz != null && name.equals(clazz.getName())) { + return true; + } + } + return false; + } + + public static Type getKnownType(String typeName) { + for (Type type : knownTypes.keySet()) { + if (type.getName().equals(typeName)) { + return type; + } + } + return null; + } + + static boolean isKnownType(Class type) { + if (type.isPrimitive()) { + return true; + } + if (type.equals(Class.class) || type.equals(Thread.class) || type.equals(String.class)) { + return true; + } + return false; + } + + public static Type getKnownType(Class clazz) { + for (Map.Entry> entry : knownTypes.entrySet()) { + if (clazz != null && clazz.equals(entry.getValue())) { + return entry.getKey(); + } + } + return null; + } + + public String getName() { + return name; + } + + public String getLogName() { + return getName() + "(" + getId() + ")"; + } + + public List getFields() { + if (fields instanceof ArrayList) { + ((ArrayList) fields).trimToSize(); + fields = Collections.unmodifiableList(fields); + } + return fields; + } + + public boolean isSimpleType() { + if (simpleType == null) { + simpleType = calculateSimpleType(); + } + return simpleType.booleanValue(); + } + + private boolean calculateSimpleType() { + if (fields.size() != 1) { + return false; + } + // annotation, settings and event can never be simple types + return superType == null; + } + + public boolean isDefinedByJVM() { + return id < JVM.RESERVED_CLASS_ID_LIMIT; + } + + private static Type register(Class clazz, Type type) { + knownTypes.put(type, clazz); + return type; + } + + public void add(ValueDescriptor valueDescriptor) { + Objects.requireNonNull(valueDescriptor); + fields.add(valueDescriptor); + } + + void trimFields() { + getFields(); + } + + void setAnnotations(List annotations) { + annos.setAnnotationElements(annotations); + } + + public String getSuperType() { + return superType; + } + + public long getId() { + return id; + } + + public boolean isConstantPool() { + return constantPool; + } + + public String getLabel() { + return annos.getLabel(); + } + + public List getAnnotationElements() { + return annos.getUnmodifiableAnnotationElements(); + } + + public T getAnnotation(Class clazz) { + return annos.getAnnotation(clazz); + } + + public String getDescription() { + return annos.getDescription(); + } + + @Override + public int hashCode() { + return Long.hashCode(id); + } + + @Override + public boolean equals(Object object) { + if (object instanceof Type) { + Type that = (Type) object; + return that.id == this.id; + } + return false; + } + + @Override + public int compareTo(Type that) { + return Long.compare(this.id, that.id); + } + + void log(String action, LogTag logTag, LogLevel level) { + if (Logger.shouldLog(logTag, level) && !isSimpleType()) { + Logger.log(logTag, LogLevel.TRACE, action + " " + typeText() + " " + getLogName() + " {"); + for (ValueDescriptor v : getFields()) { + String array = v.isArray() ? "[]" : ""; + Logger.log(logTag, LogLevel.TRACE, " " + v.getTypeName() + array + " " + v.getName() + ";"); + } + Logger.log(logTag, LogLevel.TRACE, "}"); + } else { + if (Logger.shouldLog(logTag, LogLevel.INFO) && !isSimpleType()) { + Logger.log(logTag, LogLevel.INFO, action + " " + typeText() + " " + getLogName()); + } + } + } + + private String typeText() { + if (this instanceof PlatformEventType) { + return "event type"; + } + if (Type.SUPER_TYPE_SETTING.equals(superType)) { + return "setting type"; + } + if (Type.SUPER_TYPE_ANNOTATION.equals(superType)) { + return "annotation type"; + } + return "type"; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getLogName()); + if (!getFields().isEmpty()) { + sb.append(" {\n"); + for (ValueDescriptor td : getFields()) { + sb.append(" type=" + td.getTypeName() + "(" + td.getTypeId() + ") name=" + td.getName() + "\n"); + } + sb.append("}\n"); + } + return sb.toString(); + } + + public void setRemove(boolean remove) { + this.remove = remove; + } + + public boolean getRemove() { + return remove; + } +} diff --git a/src/share/classes/jdk/jfr/internal/TypeLibrary.java b/src/share/classes/jdk/jfr/internal/TypeLibrary.java new file mode 100644 index 0000000000000000000000000000000000000000..40544e944b4a06e5d25415c90b25fccf100159f3 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/TypeLibrary.java @@ -0,0 +1,492 @@ +/* + * 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. 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.internal; + +import java.io.IOException; +import java.lang.annotation.Annotation; +import java.lang.annotation.Repeatable; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Queue; +import java.util.Set; +import java.util.function.Consumer; +import java.util.function.Predicate; +import java.util.stream.Stream; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.Description; +import jdk.jfr.Event; +import jdk.jfr.Label; +import jdk.jfr.MetadataDefinition; +import jdk.jfr.Name; +import jdk.jfr.SettingDescriptor; +import jdk.jfr.Timespan; +import jdk.jfr.Timestamp; +import jdk.jfr.ValueDescriptor; + +public final class TypeLibrary { + + private static TypeLibrary instance; + private static final Map types = new LinkedHashMap<>(100); + static final ValueDescriptor DURATION_FIELD = createDurationField(); + static final ValueDescriptor THREAD_FIELD = createThreadField(); + static final ValueDescriptor STACK_TRACE_FIELD = createStackTraceField(); + static final ValueDescriptor START_TIME_FIELD = createStartTimeField(); + + private TypeLibrary(List jvmTypes) { + visitReachable(jvmTypes, t -> !types.containsKey(t.getId()), t -> types.put(t.getId(), t)); + if (Logger.shouldLog(LogTag.JFR_SYSTEM_METADATA, LogLevel.INFO)) { + Stream s = types.values().stream().sorted((x, y) -> Long.compare(x.getId(), y.getId())); + s.forEach(t -> t.log("Added", LogTag.JFR_SYSTEM_METADATA, LogLevel.INFO)); + } + } + + private static ValueDescriptor createStartTimeField() { + List annos = createStandardAnnotations("Start Time", null); + annos.add(new jdk.jfr.AnnotationElement(Timestamp.class, Timestamp.TICKS)); + return PrivateAccess.getInstance().newValueDescriptor(EventInstrumentation.FIELD_START_TIME, Type.LONG, annos, 0, false, + EventInstrumentation.FIELD_START_TIME); + + } + + private static ValueDescriptor createStackTraceField() { + List annos = new ArrayList<>(); + annos = createStandardAnnotations("Stack Trace", "Stack Trace starting from the method the event was committed in"); + return PrivateAccess.getInstance().newValueDescriptor(EventInstrumentation.FIELD_STACK_TRACE, Type.STACK_TRACE, annos, 0, true, + EventInstrumentation.FIELD_STACK_TRACE); + } + + private static ValueDescriptor createThreadField() { + List annos = new ArrayList<>(); + annos = createStandardAnnotations("Event Thread", "Thread in which event was committed in"); + return PrivateAccess.getInstance().newValueDescriptor(EventInstrumentation.FIELD_EVENT_THREAD, Type.THREAD, annos, 0, true, + EventInstrumentation.FIELD_EVENT_THREAD); + } + + private static ValueDescriptor createDurationField() { + List annos = new ArrayList<>(); + annos = createStandardAnnotations("Duration", null); + annos.add(new jdk.jfr.AnnotationElement(Timespan.class, Timespan.TICKS)); + return PrivateAccess.getInstance().newValueDescriptor(EventInstrumentation.FIELD_DURATION, Type.LONG, annos, 0, false, EventInstrumentation.FIELD_DURATION); + } + + public static TypeLibrary getInstance() { + synchronized (TypeLibrary.class) { + if (instance == null) { + List jvmTypes; + try { + jvmTypes = MetadataHandler.createTypes(); + Collections.sort(jvmTypes, (a,b) -> Long.compare(a.getId(), b.getId())); + } catch (IOException e) { + throw new Error("JFR: Could not read metadata"); + } + instance = new TypeLibrary(jvmTypes); + } + return instance; + } + } + + public List getTypes() { + return new ArrayList<>(types.values()); + } + + public static Type createAnnotationType(Class a) { + if (shouldPersist(a)) { + Type type = defineType(a, Type.SUPER_TYPE_ANNOTATION, false); + if (type != null) { + SecuritySupport.makeVisibleToJFR(a); + for (Method method : a.getDeclaredMethods()) { + type.add(PrivateAccess.getInstance().newValueDescriptor(method.getReturnType(), method.getName())); + } + ArrayList aes = new ArrayList<>(); + for (Annotation annotation : resolveRepeatedAnnotations(a.getAnnotations())) { + AnnotationElement ae = createAnnotation(annotation); + if (ae != null) { + aes.add(ae); + } + } + aes.trimToSize(); + type.setAnnotations(aes); + } + return getType(a); + } + return null; + } + + static AnnotationElement createAnnotation(Annotation annotation) { + Class annotationType = annotation.annotationType(); + Type type = createAnnotationType(annotationType); + if (type != null) { + List values = new ArrayList<>(); + for (ValueDescriptor v : type.getFields()) { + values.add(invokeAnnotation(annotation, v.getName())); + } + + return PrivateAccess.getInstance().newAnnotation(type, values, annotation.annotationType().getClassLoader() == null); + } + return null; + } + + private static Object invokeAnnotation(Annotation annotation, String methodName) { + final Method m; + try { + m = annotation.getClass().getMethod(methodName, new Class[0]); + } catch (NoSuchMethodException e1) { + throw (Error) new InternalError("Could not loacate method " + methodName + " in annotation " + annotation.getClass().getName()); + } + SecuritySupport.setAccessible(m); + try { + return m.invoke(annotation, new Object[0]); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + throw (Error) new InternalError("Could not get value for method " + methodName + " in annotation " + annotation.getClass().getName()); + } + } + + private static boolean shouldPersist(Class a) { + if (a == MetadataDefinition.class || a.getAnnotation(MetadataDefinition.class) == null) { + return false; + } + return true; + } + + private static boolean isDefined(Class clazz) { + return types.containsKey(Type.getTypeId(clazz)); + } + + private static Type getType(Class clazz) { + return types.get(Type.getTypeId(clazz)); + } + + private static Type defineType(Class clazz, String superType, boolean eventType) { + if (!isDefined(clazz)) { + Name name = clazz.getAnnotation(Name.class); + String typeName = name != null ? name.value() : clazz.getName(); + long id = Type.getTypeId(clazz); + Type t; + if (eventType) { + t = new PlatformEventType(typeName, id, clazz.getClassLoader() == null, true); + } else { + t = new Type(typeName, superType, id); + } + types.put(t.getId(), t); + return t; + } + return null; + } + public static Type createType(Class clazz) { + return createType(clazz, Collections.emptyList(), Collections.emptyList()); + } + + public static Type createType(Class clazz, List dynamicAnnotations, List dynamicFields) { + + if (Thread.class == clazz) { + return Type.THREAD; + } + + if (Class.class.isAssignableFrom(clazz)) { + return Type.CLASS; + } + + if (String.class.equals(clazz)) { + return Type.STRING; + } + + if (isDefined(clazz)) { + return getType(clazz); + } + + if (clazz.isPrimitive()) { + return defineType(clazz, null,false); + } + + if (clazz.isArray()) { + throw new InternalError("Arrays not supported"); + } + + // STRUCT + String superType = null; + boolean eventType = false; + if (Event.class.isAssignableFrom(clazz)) { + superType = Type.SUPER_TYPE_EVENT; + eventType= true; + } + if (Control.class.isAssignableFrom(clazz)) { + superType = Type.SUPER_TYPE_SETTING; + } + + // forward declare to avoid infinite recursion + defineType(clazz, superType, eventType); + Type type = getType(clazz); + + if (eventType) { + addImplicitFields(type, true, true, true, true ,false); + addUserFields(clazz, type, dynamicFields); + type.trimFields(); + } + addAnnotations(clazz, type, dynamicAnnotations); + + if (clazz.getClassLoader() == null) { + type.log("Added", LogTag.JFR_SYSTEM_METADATA, LogLevel.INFO); + } else { + type.log("Added", LogTag.JFR_METADATA, LogLevel.INFO); + } + return type; + } + + private static void addAnnotations(Class clazz, Type type, List dynamicAnnotations) { + ArrayList aes = new ArrayList<>(); + if (dynamicAnnotations.isEmpty()) { + for (Annotation a : Utils.getAnnotations(clazz)) { + AnnotationElement ae = createAnnotation(a); + if (ae != null) { + aes.add(ae); + } + } + } else { + List newTypes = new ArrayList<>(); + aes.addAll(dynamicAnnotations); + for (AnnotationElement ae : dynamicAnnotations) { + newTypes.add(PrivateAccess.getInstance().getType(ae)); + } + addTypes(newTypes); + } + type.setAnnotations(aes); + aes.trimToSize(); + } + + private static void addUserFields(Class clazz, Type type, List dynamicFields) { + Map dynamicFieldSet = new HashMap<>(); + for (ValueDescriptor dynamicField : dynamicFields) { + dynamicFieldSet.put(dynamicField.getName(), dynamicField); + } + List newTypes = new ArrayList<>(); + for (Field field : Utils.getVisibleEventFields(clazz)) { + ValueDescriptor vd = dynamicFieldSet.get(field.getName()); + if (vd != null) { + if (!vd.getTypeName().equals(field.getType().getName())) { + throw new InternalError("Type expected to match for field " + vd.getName() + " expected " + field.getName() + " but got " + vd.getName()); + } + for (AnnotationElement ae : vd.getAnnotationElements()) { + newTypes.add(PrivateAccess.getInstance().getType(ae)); + } + newTypes.add(PrivateAccess.getInstance().getType(vd)); + } else { + vd = createField(field); + } + if (vd != null) { + type.add(vd); + } + } + addTypes(newTypes); + } + + // By convention all events have these fields. + static void addImplicitFields(Type type, boolean requestable, boolean hasDuration, boolean hasThread, boolean hasStackTrace, boolean hasCutoff) { + createAnnotationType(Timespan.class); + createAnnotationType(Timestamp.class); + createAnnotationType(Label.class); + defineType(long.class, null,false); + addFields(type, requestable, hasDuration, hasThread, hasStackTrace, hasCutoff); + } + + private static void addFields(Type type, boolean requestable, boolean hasDuration, boolean hasThread, boolean hasStackTrace, boolean hasCutoff) { + type.add(START_TIME_FIELD); + if (hasDuration || hasCutoff) { + type.add(DURATION_FIELD); + } + if (hasThread) { + type.add(THREAD_FIELD); + } + if (hasStackTrace) { + type.add(STACK_TRACE_FIELD); + } + } + + private static List createStandardAnnotations(String name, String description) { + List annotationElements = new ArrayList<>(2); + annotationElements.add(new jdk.jfr.AnnotationElement(Label.class, name)); + if (description != null) { + annotationElements.add(new jdk.jfr.AnnotationElement(Description.class, description)); + } + return annotationElements; + } + + private static ValueDescriptor createField(Field field) { + int mod = field.getModifiers(); + if (Modifier.isTransient(mod)) { + return null; + } + if (Modifier.isStatic(mod)) { + return null; + } + Class fieldType = field.getType(); + if (!Type.isKnownType(fieldType)) { + return null; + } + boolean constantPool = Thread.class == fieldType || fieldType == Class.class; + Type type = createType(fieldType); + String fieldName = field.getName(); + Name name = field.getAnnotation(Name.class); + String useName = fieldName; + if (name != null) { + useName = name.value(); + } + List ans = new ArrayList<>(); + for (Annotation a : resolveRepeatedAnnotations(field.getAnnotations())) { + AnnotationElement ae = createAnnotation(a); + if (ae != null) { + ans.add(ae); + } + } + return PrivateAccess.getInstance().newValueDescriptor(useName, type, ans, 0, constantPool, fieldName); + } + + private static List resolveRepeatedAnnotations(Annotation[] annotations) { + List annos = new ArrayList<>(annotations.length); + for (Annotation a : annotations) { + boolean repeated = false; + Method m; + try { + m = a.annotationType().getMethod("value"); + Class returnType = m.getReturnType(); + if (returnType.isArray()) { + Class ct = returnType.getComponentType(); + if (Annotation.class.isAssignableFrom(ct) && ct.getAnnotation(Repeatable.class) != null) { + Object res = m.invoke(a, new Object[0]); + if (res != null && Annotation[].class.isAssignableFrom(res.getClass())) { + for (Annotation rep : (Annotation[]) m.invoke(a, new Object[0])) { + annos.add(rep); + } + repeated = true; + } + } + } + } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + // Ignore, can't access repeatable information + } + if (!repeated) { + annos.add(a); + } + } + return annos; + } + + // Purpose of this method is to mark types that are reachable + // from registered event types. Those types that are not reachable can + // safely be removed + public boolean clearUnregistered() { + Logger.log(LogTag.JFR_METADATA, LogLevel.TRACE, "Cleaning out obsolete metadata"); + List registered = new ArrayList<>(); + for (Type type : types.values()) { + if (type instanceof PlatformEventType) { + if (((PlatformEventType) type).isRegistered()) { + registered.add(type); + } + } + } + visitReachable(registered, t -> t.getRemove(), t -> t.setRemove(false)); + List removeIds = new ArrayList<>(); + for (Type type : types.values()) { + if (type.getRemove() && !Type.isDefinedByJVM(type.getId())) { + removeIds.add(type.getId()); + if (Logger.shouldLog(LogTag.JFR_METADATA, LogLevel.TRACE)) { + Logger.log(LogTag.JFR_METADATA, LogLevel.TRACE, "Removed obsolete metadata " + type.getName()); + } + } + // Optimization, set to true now to avoid iterating + // types first thing at next call to clearUnregistered + type.setRemove(true); + } + for (Long id : removeIds) { + types.remove(id); + } + return !removeIds.isEmpty(); + } + + public void addType(Type type) { + addTypes(Collections.singletonList(type)); + } + + public static void addTypes(List ts) { + if (!ts.isEmpty()) { + visitReachable(ts, t -> !types.containsKey(t.getId()), t -> types.put(t.getId(), t)); + } + } + + /** + * Iterates all reachable types from a start collection + * + * @param rootSet the types to start from + * @param p if a type should be accepted + * @param c action to take on an accepted type + */ + private static void visitReachable(Collection rootSet, Predicate p, Consumer c) { + Queue typeQ = new ArrayDeque<>(rootSet); + while (!typeQ.isEmpty()) { + Type type = typeQ.poll(); + if (p.test(type)) { + c.accept(type); + visitAnnotations(typeQ, type.getAnnotationElements()); + for (ValueDescriptor v : type.getFields()) { + typeQ.add(PrivateAccess.getInstance().getType(v)); + visitAnnotations(typeQ, v.getAnnotationElements()); + } + if (type instanceof PlatformEventType) { + PlatformEventType pe = (PlatformEventType) type; + for (SettingDescriptor s : pe.getAllSettings()) { + typeQ.add(PrivateAccess.getInstance().getType(s)); + visitAnnotations(typeQ, s.getAnnotationElements()); + } + } + } + } + } + + private static void visitAnnotations(Queue typeQ, List aes) { + Queue aQ = new ArrayDeque<>(aes); + Set visited = new HashSet<>(); + while (!aQ.isEmpty()) { + AnnotationElement ae = aQ.poll(); + if (!visited.contains(ae)) { + Type ty = PrivateAccess.getInstance().getType(ae); + typeQ.add(ty); + visited.add(ae); + } + aQ.addAll(ae.getAnnotationElements()); + } + } +} diff --git a/src/share/classes/jdk/jfr/internal/Utils.java b/src/share/classes/jdk/jfr/internal/Utils.java new file mode 100644 index 0000000000000000000000000000000000000000..9c2a858fbb485564915c58394d3e5da79328f2f2 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/Utils.java @@ -0,0 +1,554 @@ +/* + * 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. 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.internal; + +import static java.util.concurrent.TimeUnit.MICROSECONDS; +import static java.util.concurrent.TimeUnit.MILLISECONDS; +import static java.util.concurrent.TimeUnit.NANOSECONDS; +import static java.util.concurrent.TimeUnit.SECONDS; + +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.RandomAccessFile; +import java.lang.annotation.Annotation; +import java.lang.annotation.Repeatable; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.nio.file.Path; +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import jdk.internal.org.objectweb.asm.ClassReader; +import jdk.internal.org.objectweb.asm.util.CheckClassAdapter; +import jdk.jfr.Event; +import jdk.jfr.FlightRecorderPermission; +import jdk.jfr.Recording; +import jdk.jfr.RecordingState; +import jdk.jfr.internal.handlers.EventHandler; +import jdk.jfr.internal.settings.PeriodSetting; +import jdk.jfr.internal.settings.StackTraceSetting; +import jdk.jfr.internal.settings.ThresholdSetting; + +public final class Utils { + + private static final String INFINITY = "infinity"; + + private static Boolean SAVE_GENERATED; + + public static final String EVENTS_PACKAGE_NAME = "jdk.jfr.events"; + public static final String INSTRUMENT_PACKAGE_NAME = "jdk.jfr.internal.instrument"; + public static final String HANDLERS_PACKAGE_NAME = "jdk.jfr.internal.handlers"; + public static final String REGISTER_EVENT = "registerEvent"; + public static final String ACCESS_FLIGHT_RECORDER = "accessFlightRecorder"; + + private final static String LEGACY_EVENT_NAME_PREFIX = "com.oracle.jdk."; + + public static void checkAccessFlightRecorder() throws SecurityException { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(new FlightRecorderPermission(ACCESS_FLIGHT_RECORDER)); + } + } + + public static void checkRegisterPermission() throws SecurityException { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(new FlightRecorderPermission(REGISTER_EVENT)); + } + } + + private static enum TimespanUnit { + NANOSECONDS("ns", 1000), MICROSECONDS("us", 1000), MILLISECONDS("ms", 1000), SECONDS("s", 60), MINUTES("m", 60), HOURS("h", 24), DAYS("d", 7); + + final String text; + final long amount; + + TimespanUnit(String unit, long amount) { + this.text = unit; + this.amount = amount; + } + } + + // Tjis method can't handle Long.MIN_VALUE because absolute value is negative + private static String formatDataAmount(String formatter, long amount) { + int exp = (int) (Math.log(Math.abs(amount)) / Math.log(1024)); + char unitPrefix = "kMGTPE".charAt(exp - 1); + return String.format(formatter, amount / Math.pow(1024, exp), unitPrefix); + } + + public static String formatBytesCompact(long bytes) { + if (bytes < 1024) { + return String.valueOf(bytes); + } + return formatDataAmount("%.1f%cB", bytes); + } + + public static String formatBits(long bits) { + if (bits == 1 || bits == -1) { + return bits + " bit"; + } + if (bits < 1024 && bits > -1024) { + return bits + " bits"; + } + return formatDataAmount("%.1f %cbit", bits); + } + + public static String formatBytes(long bytes) { + if (bytes == 1 || bytes == -1) { + return bytes + " byte"; + } + if (bytes < 1024 && bytes > -1024) { + return bytes + " bytes"; + } + return formatDataAmount("%.1f %cB", bytes); + } + + public static String formatBytesPerSecond(long bytes) { + if (bytes < 1024 && bytes > -1024) { + return bytes + " byte/s"; + } + return formatDataAmount("%.1f %cB/s", bytes); + } + + public static String formatBitsPerSecond(long bits) { + if (bits < 1024 && bits > -1024) { + return bits + " bps"; + } + return formatDataAmount("%.1f %cbps", bits); + } + public static String formatTimespan(Duration dValue, String separation) { + if (dValue == null) { + return "0"; + } + long value = dValue.toNanos(); + TimespanUnit result = TimespanUnit.NANOSECONDS; + for (TimespanUnit unit : TimespanUnit.values()) { + result = unit; + long amount = unit.amount; + if (result == TimespanUnit.DAYS || value < amount || value % amount != 0) { + break; + } + value /= amount; + } + return String.format("%d%s%s", value, separation, result.text); + } + + public static long parseTimespanWithInfinity(String s) { + if (INFINITY.equals(s)) { + return Long.MAX_VALUE; + } + return parseTimespan(s); + } + + public static long parseTimespan(String s) { + if (s.endsWith("ns")) { + return Long.parseLong(s.substring(0, s.length() - 2).trim()); + } + if (s.endsWith("us")) { + return NANOSECONDS.convert(Long.parseLong(s.substring(0, s.length() - 2).trim()), MICROSECONDS); + } + if (s.endsWith("ms")) { + return NANOSECONDS.convert(Long.parseLong(s.substring(0, s.length() - 2).trim()), MILLISECONDS); + } + if (s.endsWith("s")) { + return NANOSECONDS.convert(Long.parseLong(s.substring(0, s.length() - 1).trim()), SECONDS); + } + if (s.endsWith("m")) { + return 60 * NANOSECONDS.convert(Long.parseLong(s.substring(0, s.length() - 1).trim()), SECONDS); + } + if (s.endsWith("h")) { + return 60 * 60 * NANOSECONDS.convert(Long.parseLong(s.substring(0, s.length() - 1).trim()), SECONDS); + } + if (s.endsWith("d")) { + return 24 * 60 * 60 * NANOSECONDS.convert(Long.parseLong(s.substring(0, s.length() - 1).trim()), SECONDS); + } + + try { + Long.parseLong(s); + } catch (NumberFormatException nfe) { + throw new NumberFormatException("'" + s + "' is not a valid timespan. Shoule be numeric value followed by a unit, i.e. 20 ms. Valid units are ns, us, s, m, h and d."); + } + // Only accept values with units + throw new NumberFormatException("Timespan + '" + s + "' is missing unit. Valid units are ns, us, s, m, h and d."); + } + + /** + * Return all annotations as they are visible in the source code + * + * @param clazz class to return annotations from + * + * @return list of annotation + * + */ + static List getAnnotations(Class clazz) { + List annos = new ArrayList<>(); + for (Annotation a : clazz.getAnnotations()) { + annos.addAll(getAnnotation(a)); + } + return annos; + } + + private static List getAnnotation(Annotation a) { + Class annotated = a.annotationType(); + Method valueMethod = getValueMethod(annotated); + if (valueMethod != null) { + Class returnType = valueMethod.getReturnType(); + if (returnType.isArray()) { + Class candidate = returnType.getComponentType(); + Repeatable r = candidate.getAnnotation(Repeatable.class); + if (r != null) { + Class repeatClass = r.value(); + if (annotated == repeatClass) { + return getAnnotationValues(a, valueMethod); + } + } + } + } + List annos = new ArrayList<>(); + annos.add(a); + return annos; + } + + static boolean isAfter(RecordingState stateToTest, RecordingState b) { + return stateToTest.ordinal() > b.ordinal(); + } + + static boolean isBefore(RecordingState stateToTest, RecordingState b) { + return stateToTest.ordinal() < b.ordinal(); + } + + static boolean isState(RecordingState stateToTest, RecordingState... states) { + for (RecordingState s : states) { + if (s == stateToTest) { + return true; + } + } + return false; + } + + private static List getAnnotationValues(Annotation a, Method valueMethod) { + try { + return Arrays.asList((Annotation[]) valueMethod.invoke(a, new Object[0])); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + return new ArrayList<>(); + } + } + + private static Method getValueMethod(Class annotated) { + try { + return annotated.getMethod("value", new Class[0]); + } catch (NoSuchMethodException e) { + return null; + } + } + + public static void touch(Path dumpFile) throws IOException { + RandomAccessFile raf = new RandomAccessFile(dumpFile.toFile(), "rw"); + raf.close(); + } + + public static Class unboxType(Class t) { + if (t == Integer.class) { + return int.class; + } + if (t == Long.class) { + return long.class; + } + if (t == Float.class) { + return float.class; + } + if (t == Double.class) { + return double.class; + } + if (t == Byte.class) { + return byte.class; + } + if (t == Short.class) { + return short.class; + } + if (t == Boolean.class) { + return boolean.class; + } + if (t == Character.class) { + return char.class; + } + return t; + } + + static long nanosToTicks(long nanos) { + return (long) (nanos * JVM.getJVM().getTimeConversionFactor()); + } + + static synchronized EventHandler getHandler(Class eventClass) { + Utils.ensureValidEventSubclass(eventClass); + try { + Field f = eventClass.getDeclaredField(EventInstrumentation.FIELD_EVENT_HANDLER); + SecuritySupport.setAccessible(f); + return (EventHandler) f.get(null); + } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { + throw new InternalError("Could not access event handler"); + } + } + + static synchronized void setHandler(Class eventClass, EventHandler handler) { + Utils.ensureValidEventSubclass(eventClass); + try { + Field field = eventClass.getDeclaredField(EventInstrumentation.FIELD_EVENT_HANDLER); + SecuritySupport.setAccessible(field); + field.set(null, handler); + } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { + throw new InternalError("Could not access event handler"); + } + } + + public static Map sanitizeNullFreeStringMap(Map settings) { + HashMap map = new HashMap<>(settings.size()); + for (Map.Entry e : settings.entrySet()) { + String key = e.getKey(); + if (key == null) { + throw new NullPointerException("Null key is not allowed in map"); + } + String value = e.getValue(); + if (value == null) { + throw new NullPointerException("Null value is not allowed in map"); + } + map.put(key, value); + } + return map; + } + + public static List sanitizeNullFreeList(List elements, Class clazz) { + List sanitized = new ArrayList<>(elements.size()); + for (T element : elements) { + if (element == null) { + throw new NullPointerException("Null is not an allowed element in list"); + } + if (element.getClass() != clazz) { + throw new ClassCastException(); + } + sanitized.add(element); + } + return sanitized; + } + + static List getVisibleEventFields(Class clazz) { + Utils.ensureValidEventSubclass(clazz); + List fields = new ArrayList<>(); + for (Class c = clazz; c != Event.class; c = c.getSuperclass()) { + for (Field field : c.getDeclaredFields()) { + // skip private field in base classes + if (c == clazz || !Modifier.isPrivate(field.getModifiers())) { + fields.add(field); + } + } + } + return fields; + } + + public static void ensureValidEventSubclass(Class eventClass) { + if (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)) { + throw new IllegalArgumentException("Must be a subclass to " + Event.class.getName()); + } + } + + public static void writeGeneratedASM(String className, byte[] bytes) { + if (SAVE_GENERATED == null) { + // We can't calculate value statically because it will force + // initialization of SecuritySupport, which cause + // UnsatisfiedLinkedError on JDK 8 or non-Oracle JDKs + SAVE_GENERATED = SecuritySupport.getBooleanProperty("jfr.save.generated.asm"); + } + if (SAVE_GENERATED) { + try { + try (FileOutputStream fos = new FileOutputStream(className + ".class")) { + fos.write(bytes); + } + + try (FileWriter fw = new FileWriter(className + ".asm"); PrintWriter pw = new PrintWriter(fw)) { + ClassReader cr = new ClassReader(bytes); + CheckClassAdapter.verify(cr, true, pw); + } + Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.INFO, "Instrumented code saved to " + className + ".class and .asm"); + } catch (IOException e) { + Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.INFO, "Could not save instrumented code, for " + className + ".class and .asm"); + } + } + } + + public static void ensureInitialized(Class eventClass) { + SecuritySupport.ensureClassIsInitialized(eventClass); + } + + public static Object makePrimitiveArray(String typeName, List values) { + int length = values.size(); + switch (typeName) { + case "int": + int[] ints = new int[length]; + for (int i = 0; i < length; i++) { + ints[i] = (int) values.get(i); + } + return ints; + case "long": + long[] longs = new long[length]; + for (int i = 0; i < length; i++) { + longs[i] = (long) values.get(i); + } + return longs; + + case "float": + float[] floats = new float[length]; + for (int i = 0; i < length; i++) { + floats[i] = (float) values.get(i); + } + return floats; + + case "double": + double[] doubles = new double[length]; + for (int i = 0; i < length; i++) { + doubles[i] = (double) values.get(i); + } + return doubles; + + case "short": + short[] shorts = new short[length]; + for (int i = 0; i < length; i++) { + shorts[i] = (short) values.get(i); + } + return shorts; + case "char": + char[] chars = new char[length]; + for (int i = 0; i < length; i++) { + chars[i] = (char) values.get(i); + } + return chars; + case "byte": + byte[] bytes = new byte[length]; + for (int i = 0; i < length; i++) { + bytes[i] = (byte) values.get(i); + } + return bytes; + case "boolean": + boolean[] booleans = new boolean[length]; + for (int i = 0; i < length; i++) { + booleans[i] = (boolean) values.get(i); + } + return booleans; + case "java.lang.String": + String[] strings = new String[length]; + for (int i = 0; i < length; i++) { + strings[i] = (String) values.get(i); + } + return strings; + } + return null; + } + + public static boolean isSettingVisible(Control c, boolean hasEventHook) { + if (c instanceof ThresholdSetting) { + return !hasEventHook; + } + if (c instanceof PeriodSetting) { + return hasEventHook; + } + if (c instanceof StackTraceSetting) { + return !hasEventHook; + } + return true; + } + + public static boolean isSettingVisible(long typeId, boolean hasEventHook) { + if (ThresholdSetting.isType(typeId)) { + return !hasEventHook; + } + if (PeriodSetting.isType(typeId)) { + return hasEventHook; + } + if (StackTraceSetting.isType(typeId)) { + return !hasEventHook; + } + return true; + } + + public static Type getValidType(Class type, String name) { + Objects.requireNonNull(type, "Null is not a valid type for value descriptor " + name); + if (type.isArray()) { + type = type.getComponentType(); + if (type != String.class && !type.isPrimitive()) { + throw new IllegalArgumentException("Only arrays of primitives and Strings are allowed"); + } + } + + Type knownType = Type.getKnownType(type); + if (knownType == null || knownType == Type.STACK_TRACE) { + throw new IllegalArgumentException("Only primitive types, java.lang.Thread, java.lang.String and java.lang.Class are allowed for value descriptors. " + type.getName()); + } + return knownType; + } + + public static List smallUnmodifiable(List list) { + if (list.isEmpty()) { + return Collections.emptyList(); + } + if (list.size() == 1) { + return Collections.singletonList(list.get(0)); + } + return Collections.unmodifiableList(list); + } + + public static String upgradeLegacyJDKEvent(String eventName) { + if (eventName.length() <= LEGACY_EVENT_NAME_PREFIX.length()) { + return eventName; + } + if (eventName.startsWith(LEGACY_EVENT_NAME_PREFIX)) { + int index = eventName.lastIndexOf("."); + if (index == LEGACY_EVENT_NAME_PREFIX.length() - 1) { + return Type.EVENT_NAME_PREFIX + eventName.substring(index + 1); + } + } + return eventName; + } + + public static String makeFilename(Recording recording) { + String pid = JVM.getJVM().getPid(); + String date = Repository.REPO_DATE_FORMAT.format(LocalDateTime.now()); + String idText = recording == null ? "" : "-id-" + Long.toString(recording.getId()); + return "hotspot-" + "pid-" + pid + idText + "-" + date + ".jfr"; + } +} diff --git a/src/share/classes/jdk/jfr/internal/WriteableUserPath.java b/src/share/classes/jdk/jfr/internal/WriteableUserPath.java new file mode 100644 index 0000000000000000000000000000000000000000..37a5a5a814104400c1ab26ff4ed517718de775b7 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/WriteableUserPath.java @@ -0,0 +1,129 @@ +/* + * 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. 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.internal; + +import java.io.BufferedWriter; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.security.AccessControlContext; +import java.security.AccessController; +import java.security.PrivilegedExceptionAction; +import java.util.concurrent.Callable; + +/** + * Purpose of this class is to simplify analysis of security risks. + *

    + * Paths in the public API should be wrapped in this class so we + * at all time know what kind of paths we are dealing with. + *

    + * A user supplied path must never be used in an unsafe context, such as a + * shutdown hook or any other thread created by JFR. + *

    + * All operation using this path must happen in {@link #doPriviligedIO(Callable)} + */ +public final class WriteableUserPath { + private final AccessControlContext controlContext; + private final Path original; + private final Path real; + private final String text; + + // Not to ensure security, but to help + // against programming errors + private volatile boolean inPrivileged; + + public WriteableUserPath(Path path) throws IOException { + controlContext = AccessController.getContext(); + // verify that the path is writeable + if (Files.exists(path) && !Files.isWritable(path)) { + // throw same type of exception as FileOutputStream + // constructor, if file can't be opened. + throw new FileNotFoundException("Could not write to file: " + path.toAbsolutePath()); + } + // will throw if non-writeable + BufferedWriter fw = Files.newBufferedWriter(path); + fw.close(); + this.original = path; + this.real = path.toRealPath(); + this.text = real.toString(); + } + + /** + * Returns a potentially malicious path where the user may have implemented + * their own version of Path. This method should never be called in an + * unsafe context and the Path value should never be passed along to other + * methods. + * + * @return path from a potentially malicious user + */ + public Path getPotentiallyMaliciousOriginal() { + return original; + } + + /** + * Returns a string representation of the path. + * + * @return path as text + */ + public String getText() { + return text; + } + + /** + * Returns a potentially malicious path where the user may have implemented + * their own version of Path. This method should never be called in an + * unsafe context and the Path value should never be passed along to other + * methods. + * + * @return path from a potentially malicious user + */ + public Path getReal() { + if (!inPrivileged) { + throw new InternalError("A user path was accessed outside the context it was supplied in"); + } + return real; + } + + public void doPriviligedIO(Callable function) throws IOException { + try { + inPrivileged = true; + AccessController.doPrivileged(new PrivilegedExceptionAction() { + @Override + public Void run() throws Exception { + function.call(); + return null; + } + }, controlContext); + } catch (Throwable t) { + // prevent malicious user to propagate exception callback + // in the wrong context + throw new IOException("Unexpected error during I/O operation"); + } finally { + inPrivileged = false; + } + } +} diff --git a/src/share/classes/jdk/jfr/internal/consumer/ChunkHeader.java b/src/share/classes/jdk/jfr/internal/consumer/ChunkHeader.java new file mode 100644 index 0000000000000000000000000000000000000000..fcdf14adf011ed6855ddea1cf2e8453a8d7dce4b --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/consumer/ChunkHeader.java @@ -0,0 +1,184 @@ +/* + * 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. 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.internal.consumer; + +import java.io.DataInput; +import java.io.IOException; + +import jdk.jfr.internal.LogLevel; +import jdk.jfr.internal.LogTag; +import jdk.jfr.internal.Logger; +import jdk.jfr.internal.MetadataDescriptor; + +public final class ChunkHeader { + private static final long METADATA_TYPE_ID = 0; + private static final byte[] FILE_MAGIC = { 'F', 'L', 'R', '\0' }; + + private final short major; + private final short minor; + private final long chunkSize; + private final long chunkStartTicks; + private final long ticksPerSecond; + private final long chunkStartNanos; + private final long metadataPosition; + // private final long absoluteInitialConstantPoolPosition; + private final long absoluteChunkEnd; + private final long absoluteEventStart; + private final long absoluteChunkStart; + private final boolean lastChunk; + private final RecordingInput input; + private final long durationNanos; + private final long id; + private long constantPoolPosition; + + public ChunkHeader(RecordingInput input) throws IOException { + this(input, 0, 0); + } + + private ChunkHeader(RecordingInput input, long absoluteChunkStart, long id) throws IOException { + input.position(absoluteChunkStart); + if (input.position() >= input.size()) { + throw new IOException("Chunk contains no data"); + } + verifyMagic(input); + this.input = input; + this.id = id; + Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk " + id); + Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: startPosition=" + absoluteChunkStart); + major = input.readRawShort(); + Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: major=" + major); + minor = input.readRawShort(); + Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: minor=" + minor); + if (major != 1 && major != 2) { + throw new IOException("File version " + major + "." + minor + ". Only Flight Recorder files of version 1.x and 2.x can be read by this JDK."); + } + chunkSize = input.readRawLong(); + Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: chunkSize=" + chunkSize); + this.constantPoolPosition = input.readRawLong(); + Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: constantPoolPosition=" + constantPoolPosition); + metadataPosition = input.readRawLong(); + Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: metadataPosition=" + metadataPosition); + chunkStartNanos = input.readRawLong(); // nanos since epoch + Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: startNanos=" + chunkStartNanos); + durationNanos = input.readRawLong(); // duration nanos, not used + Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: durationNanos=" + durationNanos); + chunkStartTicks = input.readRawLong(); + Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: startTicks=" + chunkStartTicks); + ticksPerSecond = input.readRawLong(); + Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Chunk: ticksPerSecond=" + ticksPerSecond); + input.readRawInt(); // features, not used + + // set up boundaries + this.absoluteChunkStart = absoluteChunkStart; + absoluteChunkEnd = absoluteChunkStart + chunkSize; + lastChunk = input.size() == absoluteChunkEnd; + absoluteEventStart = input.position(); + + // read metadata + input.position(absoluteEventStart); + } + + public ChunkHeader nextHeader() throws IOException { + return new ChunkHeader(input, absoluteChunkEnd, id + 1); + } + + public MetadataDescriptor readMetadata() throws IOException { + input.position(absoluteChunkStart + metadataPosition); + input.readInt(); // size + long id = input.readLong(); // event type id + if (id != METADATA_TYPE_ID) { + throw new IOException("Expected metadata event. Type id=" + id + ", should have been " + METADATA_TYPE_ID); + } + input.readLong(); // start time + input.readLong(); // duration + long metadataId = input.readLong(); + Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.TRACE, "Metadata id=" + metadataId); + // No need to read if metadataId == lastMetadataId, but we + // do it for verification purposes. + return MetadataDescriptor.read(input); + } + + public boolean isLastChunk() { + return lastChunk; + } + + public short getMajor() { + return major; + } + + public short getMinor() { + return minor; + } + + public long getAbsoluteChunkStart() { + return absoluteChunkStart; + } + + public long getConstantPoolPosition() { + return constantPoolPosition; + } + + public long getStartTicks() { + return chunkStartTicks; + } + + public double getTicksPerSecond() { + return ticksPerSecond; + } + + public long getStartNanos() { + return chunkStartNanos; + } + + public long getEnd() { + return absoluteChunkEnd; + } + + public long getSize() { + return chunkSize; + } + + public long getDurationNanos() { + return durationNanos; + } + + public RecordingInput getInput() { + return input; + } + + private static void verifyMagic(DataInput input) throws IOException { + for (byte c : FILE_MAGIC) { + if (input.readByte() != c) { + throw new IOException("Not a Flight Recorder file"); + } + } + } + + public long getEventStart() { + return absoluteEventStart; + } + +} diff --git a/src/share/classes/jdk/jfr/internal/consumer/RecordingInput.java b/src/share/classes/jdk/jfr/internal/consumer/RecordingInput.java new file mode 100644 index 0000000000000000000000000000000000000000..b766894f3f0d98e31373f4fdb0f2c0a051f1cce6 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/consumer/RecordingInput.java @@ -0,0 +1,339 @@ +/* + * 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. 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.internal.consumer; + +import java.io.DataInput; +import java.io.EOFException; +import java.io.File; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.nio.charset.Charset; + +public final class RecordingInput implements DataInput, AutoCloseable { + + public static final byte STRING_ENCODING_NULL = 0; + public static final byte STRING_ENCODING_EMPTY_STRING = 1; + public static final byte STRING_ENCODING_CONSTANT_POOL = 2; + public static final byte STRING_ENCODING_UTF8_BYTE_ARRAY = 3; + public static final byte STRING_ENCODING_CHAR_ARRAY = 4; + public static final byte STRING_ENCODING_LATIN1_BYTE_ARRAY = 5; + + private final static int DEFAULT_BLOCK_SIZE = 16 * 1024 * 1024; + private final static Charset UTF8 = Charset.forName("UTF-8"); + private final static Charset LATIN1 = Charset.forName("ISO-8859-1"); + + private static final class Block { + private byte[] bytes = new byte[0]; + private long blockPosition; + + boolean contains(long position) { + return position >= blockPosition && position < blockPosition + bytes.length; + } + + public void read(RandomAccessFile file, int amount) throws IOException { + blockPosition = file.getFilePointer(); + // reuse byte array, if possible + if (amount != bytes.length) { + bytes = new byte[amount]; + } + file.readFully(bytes); + } + + public byte get(long position) { + return bytes[(int) (position - blockPosition)]; + } + } + + private final RandomAccessFile file; + private final long size; + private Block currentBlock = new Block(); + private Block previousBlock = new Block(); + private long position; + private final int blockSize; + + private RecordingInput(File f, int blockSize) throws IOException { + this.size = f.length(); + this.blockSize = blockSize; + this.file = new RandomAccessFile(f, "r"); + if (size < 8) { + throw new IOException("Not a valid Flight Recorder file. File length is only " + size + " bytes."); + } + } + + public RecordingInput(File f) throws IOException { + this(f, DEFAULT_BLOCK_SIZE); + } + + @Override + public final byte readByte() throws IOException { + if (!currentBlock.contains(position)) { + position(position); + } + return currentBlock.get(position++); + } + + @Override + public final void readFully(byte[] dest, int offset, int length) throws IOException { + // TODO: Optimize, use Arrays.copy if all bytes are in current block + // array + for (int i = 0; i < length; i++) { + dest[i + offset] = readByte(); + } + } + + @Override + public final void readFully(byte[] dst) throws IOException { + readFully(dst, 0, dst.length); + } + + public final short readRawShort() throws IOException { + // copied from java.io.Bits + byte b0 = readByte(); + byte b1 = readByte(); + return (short) ((b1 & 0xFF) + (b0 << 8)); + } + + @Override + public final double readDouble() throws IOException { + // copied from java.io.Bits + return Double.longBitsToDouble(readRawLong()); + } + + @Override + public final float readFloat() throws IOException { + // copied from java.io.Bits + return Float.intBitsToFloat(readRawInt()); + } + + public final int readRawInt() throws IOException { + // copied from java.io.Bits + byte b0 = readByte(); + byte b1 = readByte(); + byte b2 = readByte(); + byte b3 = readByte(); + return ((b3 & 0xFF)) + ((b2 & 0xFF) << 8) + ((b1 & 0xFF) << 16) + ((b0) << 24); + } + + public final long readRawLong() throws IOException { + // copied from java.io.Bits + byte b0 = readByte(); + byte b1 = readByte(); + byte b2 = readByte(); + byte b3 = readByte(); + byte b4 = readByte(); + byte b5 = readByte(); + byte b6 = readByte(); + byte b7 = readByte(); + return ((b7 & 0xFFL)) + ((b6 & 0xFFL) << 8) + ((b5 & 0xFFL) << 16) + ((b4 & 0xFFL) << 24) + ((b3 & 0xFFL) << 32) + ((b2 & 0xFFL) << 40) + ((b1 & 0xFFL) << 48) + (((long) b0) << 56); + } + + public final long position() throws IOException { + return position; + } + + public final void position(long newPosition) throws IOException { + if (!currentBlock.contains(newPosition)) { + if (!previousBlock.contains(newPosition)) { + if (newPosition > size()) { + throw new EOFException("Trying to read at " + newPosition + ", but file is only " + size() + " bytes."); + } + long blockStart = trimToFileSize(calculateBlockStart(newPosition)); + file.seek(blockStart); + // trim amount to file size + long amount = Math.min(size() - blockStart, blockSize); + previousBlock.read(file, (int) amount); + } + // swap previous and current + Block tmp = currentBlock; + currentBlock = previousBlock; + previousBlock = tmp; + } + position = newPosition; + } + + private final long trimToFileSize(long position) throws IOException { + return Math.min(size(), Math.max(0, position)); + } + + private final long calculateBlockStart(long newPosition) { + // align to end of current block + if (currentBlock.contains(newPosition - blockSize)) { + return currentBlock.blockPosition + currentBlock.bytes.length; + } + // align before current block + if (currentBlock.contains(newPosition + blockSize)) { + return currentBlock.blockPosition - blockSize; + } + // not near current block, pick middle + return newPosition - blockSize / 2; + } + + public final long size() throws IOException { + return size; + } + + public final void close() throws IOException { + file.close(); + } + + @Override + public final int skipBytes(int n) throws IOException { + long position = position(); + position(position + n); + return (int) (position() - position); + } + + @Override + public final boolean readBoolean() throws IOException { + return readByte() != 0; + } + + @Override + public int readUnsignedByte() throws IOException { + return readByte() & 0x00FF; + } + + @Override + public int readUnsignedShort() throws IOException { + return readShort() & 0xFFFF; + } + + @Override + public final String readLine() throws IOException { + throw new UnsupportedOperationException(); + } + + // NOTE, this method should really be called readString + // but can't be renamed without making RecordingInput a + // public class. + // + // This method DOES Not read as expected (s2 + utf8 encoded character) + // instead it read: + // byte encoding + // int size + // data (byte or char) + // + // where encoding + // + // 0, means null + // 1, means UTF8 encoded byte array + // 2, means char array + // 3, means latin-1 (ISO-8859-1) encoded byte array + // 4, means "" + @Override + public String readUTF() throws IOException { + return readEncodedString(readByte()); + } + + public String readEncodedString(byte encoding) throws IOException { + if (encoding == STRING_ENCODING_NULL) { + return null; + } + if (encoding == STRING_ENCODING_EMPTY_STRING) { + return ""; + } + int size = readInt(); + if (encoding == STRING_ENCODING_CHAR_ARRAY) { + char[] c = new char[size]; + for (int i = 0; i < size; i++) { + c[i] = readChar(); + } + return new String(c); + } + byte[] bytes = new byte[size]; + readFully(bytes); // TODO: optimize, check size, and copy only if needed + if (encoding == STRING_ENCODING_UTF8_BYTE_ARRAY) { + return new String(bytes, UTF8); + } + + if (encoding == STRING_ENCODING_LATIN1_BYTE_ARRAY) { + return new String(bytes, LATIN1); + } + throw new IOException("Unknown string encoding " + encoding); + } + + @Override + public char readChar() throws IOException { + return (char) readLong(); + } + + @Override + public short readShort() throws IOException { + return (short) readLong(); + } + + @Override + public int readInt() throws IOException { + return (int) readLong(); + } + + @Override + public long readLong() throws IOException { + // can be optimized by branching checks, but will do for now + byte b0 = readByte(); + long ret = (b0 & 0x7FL); + if (b0 >= 0) { + return ret; + } + int b1 = readByte(); + ret += (b1 & 0x7FL) << 7; + if (b1 >= 0) { + return ret; + } + int b2 = readByte(); + ret += (b2 & 0x7FL) << 14; + if (b2 >= 0) { + return ret; + } + int b3 = readByte(); + ret += (b3 & 0x7FL) << 21; + if (b3 >= 0) { + return ret; + } + int b4 = readByte(); + ret += (b4 & 0x7FL) << 28; + if (b4 >= 0) { + return ret; + } + int b5 = readByte(); + ret += (b5 & 0x7FL) << 35; + if (b5 >= 0) { + return ret; + } + int b6 = readByte(); + ret += (b6 & 0x7FL) << 42; + if (b6 >= 0) { + return ret; + } + int b7 = readByte(); + ret += (b7 & 0x7FL) << 49; + if (b7 >= 0) { + return ret; + } + int b8 = readByte(); // read last byte raw + return ret + (((long) (b8 & 0XFF)) << 56); + } +} diff --git a/src/share/classes/jdk/jfr/internal/consumer/RecordingInternals.java b/src/share/classes/jdk/jfr/internal/consumer/RecordingInternals.java new file mode 100644 index 0000000000000000000000000000000000000000..34be20f8a0960943b036311f6b70602be721475e --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/consumer/RecordingInternals.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.internal.consumer; + +import java.io.IOException; +import java.util.List; + +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedObject; +import jdk.jfr.consumer.RecordingFile; +import jdk.jfr.internal.Type; + +public abstract class RecordingInternals { + + public static RecordingInternals INSTANCE; + + public abstract boolean isLastEventInChunk(RecordingFile file); + + public abstract Object getOffsetDataTime(RecordedObject event, String name); + + public abstract List readTypes(RecordingFile file) throws IOException; + + public abstract void sort(List events); + +} diff --git a/src/share/classes/jdk/jfr/internal/dcmd/AbstractDCmd.java b/src/share/classes/jdk/jfr/internal/dcmd/AbstractDCmd.java new file mode 100644 index 0000000000000000000000000000000000000000..030a97a1bea544d24f9cb234d973084c02f4c397 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/dcmd/AbstractDCmd.java @@ -0,0 +1,201 @@ +/* + * 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 + * 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.internal.dcmd; + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.file.Files; +import java.nio.file.InvalidPathException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.time.Duration; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; +import jdk.jfr.internal.JVM; +import jdk.jfr.internal.SecuritySupport; +import jdk.jfr.internal.SecuritySupport.SafePath; +import jdk.jfr.internal.Utils; + +/** + * Base class for JFR diagnostic commands + * + */ +abstract class AbstractDCmd { + + private final StringWriter result; + private final PrintWriter log; + + protected AbstractDCmd() { + result = new StringWriter(); + log = new PrintWriter(result); + } + + protected final FlightRecorder getFlightRecorder() { + return FlightRecorder.getFlightRecorder(); + } + + public final String getResult() { + return result.toString(); + } + + public String getPid() { + // Invoking ProcessHandle.current().pid() would require loading more + // classes during startup so instead JVM.getJVM().getPid() is used. + // The pid will not be exposed to running Java application, only when starting + // JFR from command line (-XX:StartFlightRecordin) or jcmd (JFR.start and JFR.check) + return JVM.getJVM().getPid(); + } + + protected final SafePath resolvePath(Recording recording, String filename) throws InvalidPathException { + if (filename == null) { + return makeGenerated(recording, Paths.get(".")); + } + Path path = Paths.get(filename); + if (Files.isDirectory(path)) { + return makeGenerated(recording, path); + } + return new SafePath(path.toAbsolutePath().normalize()); + } + + private SafePath makeGenerated(Recording recording, Path directory) { + return new SafePath(directory.toAbsolutePath().resolve(Utils.makeFilename(recording)).normalize()); + } + + protected final Recording findRecording(String name) throws DCmdException { + try { + return findRecordingById(Integer.parseInt(name)); + } catch (NumberFormatException nfe) { + // User specified a name, not an id. + return findRecordingByName(name); + } + } + + protected final void reportOperationComplete(String actionPrefix, String name, SafePath file) { + print(actionPrefix); + print(" recording"); + if (name != null) { + print(" \"" + name + "\""); + } + if (file != null) { + print(","); + try { + print(" "); + long bytes = SecuritySupport.getFileSize(file); + printBytes(bytes); + } catch (IOException e) { + // Ignore, not essential + } + println(" written to:"); + println(); + printPath(file); + } else { + println("."); + } + } + + protected final List getRecordings() { + List list = new ArrayList<>(getFlightRecorder().getRecordings()); + Collections.sort(list, Comparator.comparing(Recording::getId)); + return list; + } + + static String quoteIfNeeded(String text) { + if (text.contains(" ")) { + return "\\\"" + text + "\\\""; + } else { + return text; + } + } + + protected final void println() { + log.println(); + } + + protected final void print(String s) { + log.print(s); + } + + protected final void print(String s, Object... args) { + log.printf(s, args); + } + + protected final void println(String s, Object... args) { + print(s, args); + println(); + } + + protected final void printBytes(long bytes) { + print(Utils.formatBytes(bytes)); + } + + protected final void printTimespan(Duration timespan, String separator) { + print(Utils.formatTimespan(timespan, separator)); + } + + protected final void printPath(SafePath path) { + if (path == null) { + print("N/A"); + return; + } + try { + printPath(SecuritySupport.getAbsolutePath(path).toPath()); + } catch (IOException ioe) { + printPath(path.toPath()); + } + } + + protected final void printPath(Path path) { + try { + println(path.toAbsolutePath().toString()); + } catch (SecurityException e) { + // fall back on filename + println(path.toString()); + } + } + + private Recording findRecordingById(int id) throws DCmdException { + for (Recording r : getFlightRecorder().getRecordings()) { + if (r.getId() == id) { + return r; + } + } + throw new DCmdException("Could not find %d.\n\nUse JFR.check without options to see list of all available recordings.", id); + } + + private Recording findRecordingByName(String name) throws DCmdException { + for (Recording recording : getFlightRecorder().getRecordings()) { + if (name.equals(recording.getName())) { + return recording; + } + } + throw new DCmdException("Could not find %s.\n\nUse JFR.check without options to see list of all available recordings.", name); + } +} diff --git a/src/share/classes/jdk/jfr/internal/dcmd/DCmdCheck.java b/src/share/classes/jdk/jfr/internal/dcmd/DCmdCheck.java new file mode 100644 index 0000000000000000000000000000000000000000..0cffba6a67bda5ec1de989f681f373f5ef4eafca --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/dcmd/DCmdCheck.java @@ -0,0 +1,164 @@ +/* + * 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 + * 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.internal.dcmd; + +import java.time.Duration; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.StringJoiner; + +import jdk.jfr.EventType; +import jdk.jfr.Recording; +import jdk.jfr.SettingDescriptor; +import jdk.jfr.internal.LogLevel; +import jdk.jfr.internal.LogTag; +import jdk.jfr.internal.Logger; +import jdk.jfr.internal.Utils; + +/** + * JFR.check - invoked from native + * + */ +final class DCmdCheck extends AbstractDCmd { + /** + * Execute JFR.check + * + * @param recordingText name or id of the recording to check, or + * null to show a list of all recordings. + * + * @param verbose if event settings should be included. + * + * @return result output + * + * @throws DCmdException if the check could not be completed. + */ + public String execute(String recordingText, Boolean verbose) throws DCmdException { + executeInternal(recordingText, verbose); + return getResult(); + } + + private void executeInternal(String name, Boolean verbose) throws DCmdException { + if (Logger.shouldLog(LogTag.JFR_DCMD, LogLevel.DEBUG)) { + Logger.log(LogTag.JFR_DCMD, LogLevel.DEBUG, "Executing DCmdCheck: name=" + name + ", verbose=" + verbose); + } + + if (verbose == null) { + verbose = Boolean.FALSE; + } + + if (name != null) { + printRecording(findRecording(name), verbose); + return; + } + + List recordings = getRecordings(); + if (!verbose && recordings.isEmpty()) { + println("No available recordings."); + println(); + println("Use jcmd " + getPid() + " JFR.start to start a recording."); + return; + } + boolean first = true; + for (Recording recording : recordings) { + // Print separation between recordings, + if (!first) { + println(); + if (Boolean.TRUE.equals(verbose)) { + println(); + } + } + first = false; + printRecording(recording, verbose); + } + } + + private void printRecording(Recording recording, boolean verbose) { + printGeneral(recording); + if (verbose) { + println(); + printSetttings(recording); + } + } + + private void printGeneral(Recording recording) { + print("Recording " + recording.getId() + ": name=" + recording.getName()); + + Duration duration = recording.getDuration(); + if (duration != null) { + print(" duration="); + printTimespan(duration, ""); + } + + long maxSize = recording.getMaxSize(); + if (maxSize != 0) { + print(" maxsize="); + print(Utils.formatBytesCompact(maxSize)); + } + Duration maxAge = recording.getMaxAge(); + if (maxAge != null) { + print(" maxage="); + printTimespan(maxAge, ""); + } + + print(" (" + recording.getState().toString().toLowerCase() + ")"); + println(); + } + + private void printSetttings(Recording recording) { + Map settings = recording.getSettings(); + for (EventType eventType : sortByEventPath(getFlightRecorder().getEventTypes())) { + StringJoiner sj = new StringJoiner(",", "[", "]"); + sj.setEmptyValue(""); + for (SettingDescriptor s : eventType.getSettingDescriptors()) { + String settingsPath = eventType.getName() + "#" + s.getName(); + if (settings.containsKey(settingsPath)) { + sj.add(s.getName() + "=" + settings.get(settingsPath)); + } + } + String settingsText = sj.toString(); + if (!settingsText.isEmpty()) { + print(" %s (%s)", eventType.getLabel(), eventType.getName()); + println(); + println(" " + settingsText); + } + } + } + + private static List sortByEventPath(Collection events) { + List sorted = new ArrayList<>(); + sorted.addAll(events); + Collections.sort(sorted, new Comparator() { + @Override + public int compare(EventType e1, EventType e2) { + return e1.getName().compareTo(e2.getName()); + } + }); + return sorted; + } +} diff --git a/src/share/classes/jdk/jfr/internal/dcmd/DCmdConfigure.java b/src/share/classes/jdk/jfr/internal/dcmd/DCmdConfigure.java new file mode 100644 index 0000000000000000000000000000000000000000..f15053a7caafd02106fd65f288589c68d068da43 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/dcmd/DCmdConfigure.java @@ -0,0 +1,217 @@ +/* + * 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. 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.internal.dcmd; + + + +import jdk.jfr.internal.LogLevel; +import jdk.jfr.internal.LogTag; +import jdk.jfr.internal.Logger; +import jdk.jfr.internal.Options; +import jdk.jfr.internal.Repository; +import jdk.jfr.internal.SecuritySupport.SafePath; + +/** + * JFR.configure - invoked from native + * + */ +//Instantiated by native +final class DCmdConfigure extends AbstractDCmd { + /** + * Execute JFR.configure. + * + * @param repositoryPath the path + * @param dumpPath path to dump to on fatal error (oom) + * @param stackDepth depth of stack traces + * @param globalBufferCount number of global buffers + * @param globalBufferSize size of global buffers + * @param threadBufferSize size of thread buffer for events + * @param maxChunkSize threshold at which a new chunk is created in the disk repository + * @param sampleThreads if thread sampling should be enabled + * + * @return result + + * @throws DCmdException + * if the dump could not be completed + */ + public String execute + ( + String repositoryPath, + String dumpPath, + Integer stackDepth, + Long globalBufferCount, + Long globalBufferSize, + Long threadBufferSize, + Long memorySize, + Long maxChunkSize, + Boolean sampleThreads + + ) throws DCmdException { + if (Logger.shouldLog(LogTag.JFR_DCMD, LogLevel.DEBUG)) { + Logger.log(LogTag.JFR_DCMD, LogLevel.DEBUG, "Executing DCmdConfigure: repositorypath=" + repositoryPath + + ", dumppath=" + dumpPath + + ", stackdepth=" + stackDepth + + ", globalbuffercount=" + globalBufferCount + + ", globalbuffersize=" + globalBufferSize + + ", thread_buffer_size" + threadBufferSize + + ", memorysize" + memorySize + + ", maxchunksize=" + maxChunkSize + + ", samplethreads" + sampleThreads); + } + + + boolean updated = false; + if (repositoryPath != null) { + try { + SafePath s = new SafePath(repositoryPath); + Repository.getRepository().setBasePath(s); + Logger.log(LogTag.JFR, LogLevel.INFO, "Base repository path set to " + repositoryPath); + } catch (Exception e) { + throw new DCmdException("Could not use " + repositoryPath + " as repository. " + e.getMessage(), e); + } + printRepositoryPath(); + updated = true; + } + + if (dumpPath != null) { + Options.setDumpPath(new SafePath(dumpPath)); + Logger.log(LogTag.JFR, LogLevel.INFO, "Emergency dump path set to " + dumpPath); + printDumpPath(); + updated = true; + } + + if (stackDepth != null) { + Options.setStackDepth(stackDepth); + Logger.log(LogTag.JFR, LogLevel.INFO, "Stack depth set to " + stackDepth); + printStackDepth(); + updated = true; + } + + if (globalBufferCount != null) { + Options.setGlobalBufferCount(globalBufferCount); + Logger.log(LogTag.JFR, LogLevel.INFO, "Global buffer count set to " + globalBufferCount); + printGlobalBufferCount(); + updated = true; + } + + if (globalBufferSize != null) { + Options.setGlobalBufferSize(globalBufferSize); + Logger.log(LogTag.JFR, LogLevel.INFO, "Global buffer size set to " + globalBufferSize); + printGlobalBufferSize(); + updated = true; + } + + if (threadBufferSize != null) { + Options.setThreadBufferSize(threadBufferSize); + Logger.log(LogTag.JFR, LogLevel.INFO, "Thread buffer size set to " + threadBufferSize); + printThreadBufferSize(); + updated = true; + } + + if (memorySize != null) { + Options.setMemorySize(memorySize); + Logger.log(LogTag.JFR, LogLevel.INFO, "Memory size set to " + memorySize); + printMemorySize(); + updated = true; + } + + if (maxChunkSize != null) { + Options.setMaxChunkSize(maxChunkSize); + Logger.log(LogTag.JFR, LogLevel.INFO, "Max chunk size set to " + maxChunkSize); + printMaxChunkSize(); + updated = true; + } + + if (sampleThreads != null) { + Options.setSampleThreads(sampleThreads); + Logger.log(LogTag.JFR, LogLevel.INFO, "Sample threads set to " + sampleThreads); + printSampleThreads(); + updated = true; + } + + if (!updated) { + println("Current configuration:"); + println(); + printRepositoryPath(); + printStackDepth(); + printGlobalBufferCount(); + printGlobalBufferSize(); + printThreadBufferSize(); + printMemorySize(); + printMaxChunkSize(); + printSampleThreads(); + } + return getResult(); + } + + private void printRepositoryPath() { + print("Repository path: "); + printPath(Repository.getRepository().getRepositoryPath()); + println(); + } + + private void printDumpPath() { + print("Dump path: "); + printPath(Options.getDumpPath()); + println(); + } + + private void printSampleThreads() { + println("Sample threads: " + Options.getSampleThreads()); + } + + private void printStackDepth() { + println("Stack depth: " + Options.getStackDepth()); + } + + private void printGlobalBufferCount() { + println("Global buffer count: " + Options.getGlobalBufferCount()); + } + + private void printGlobalBufferSize() { + print("Global buffer size: "); + printBytes(Options.getGlobalBufferSize()); + println(); + } + + private void printThreadBufferSize() { + print("Thread buffer size: "); + printBytes(Options.getThreadBufferSize()); + println(); + } + + private void printMemorySize() { + print("Memory size: "); + printBytes(Options.getMemorySize()); + println(); + } + + private void printMaxChunkSize() { + print("Max chunk size: "); + printBytes(Options.getMaxChunkSize()); + println(); + } +} diff --git a/src/share/classes/jdk/jfr/internal/dcmd/DCmdDump.java b/src/share/classes/jdk/jfr/internal/dcmd/DCmdDump.java new file mode 100644 index 0000000000000000000000000000000000000000..0fad0c5b8c1067736d7093a8da3645ed200fea2a --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/dcmd/DCmdDump.java @@ -0,0 +1,205 @@ +/* + * 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 + * 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.internal.dcmd; + +import java.io.IOException; +import java.nio.file.InvalidPathException; +import java.time.Duration; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeParseException; + +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; +import jdk.jfr.internal.LogLevel; +import jdk.jfr.internal.LogTag; +import jdk.jfr.internal.Logger; +import jdk.jfr.internal.PlatformRecorder; +import jdk.jfr.internal.PlatformRecording; +import jdk.jfr.internal.PrivateAccess; +import jdk.jfr.internal.SecuritySupport.SafePath; +import jdk.jfr.internal.Utils; +import jdk.jfr.internal.WriteableUserPath; + +/** + * JFR.dump + * + */ +// Instantiated by native +final class DCmdDump extends AbstractDCmd { + /** + * Execute JFR.dump. + * + * @param name name or id of the recording to dump, or null to dump everything + * + * @param filename file path where recording should be written, not null + * @param maxAge how far back in time to dump, may be null + * @param maxSize how far back in size to dump data from, may be null + * @param begin point in time to dump data from, may be null + * @param end point in time to dump data to, may be null + * @param pathToGcRoots if Java heap should be swept for reference chains + * + * @return result output + * + * @throws DCmdException if the dump could not be completed + */ + public String execute(String name, String filename, Long maxAge, Long maxSize, String begin, String end, Boolean pathToGcRoots) throws DCmdException { + if (Logger.shouldLog(LogTag.JFR_DCMD, LogLevel.DEBUG)) { + Logger.log(LogTag.JFR_DCMD, LogLevel.DEBUG, + "Executing DCmdDump: name=" + name + + ", filename=" + filename + + ", maxage=" + maxAge + + ", maxsize=" + maxSize + + ", begin=" + begin + + ", end" + end + + ", path-to-gc-roots=" + pathToGcRoots); + } + + if (FlightRecorder.getFlightRecorder().getRecordings().isEmpty()) { + throw new DCmdException("No recordings to dump from. Use JFR.start to start a recording."); + } + + if (maxAge != null) { + if (end != null || begin != null) { + throw new DCmdException("Dump failed, maxage can't be combined with begin or end."); + } + + if (maxAge < 0) { + throw new DCmdException("Dump failed, maxage can't be negative."); + } + if (maxAge == 0) { + maxAge = Long.MAX_VALUE / 2; // a high value that won't overflow + } + } + + if (maxSize!= null) { + if (maxSize < 0) { + throw new DCmdException("Dump failed, maxsize can't be negative."); + } + if (maxSize == 0) { + maxSize = Long.MAX_VALUE / 2; // a high value that won't overflow + } + } + + Instant beginTime = parseTime(begin, "begin"); + Instant endTime = parseTime(end, "end"); + + if (beginTime != null && endTime != null) { + if (endTime.isBefore(beginTime)) { + throw new DCmdException("Dump failed, begin must preceed end."); + } + } + + Duration duration = null; + if (maxAge != null) { + duration = Duration.ofNanos(maxAge); + beginTime = Instant.now().minus(duration); + } + Recording recording = null; + if (name != null) { + recording = findRecording(name); + } + PlatformRecorder recorder = PrivateAccess.getInstance().getPlatformRecorder(); + synchronized (recorder) { + dump(recorder, recording, name, filename, maxSize, pathToGcRoots, beginTime, endTime); + } + return getResult(); + } + + public void dump(PlatformRecorder recorder, Recording recording, String name, String filename, Long maxSize, Boolean pathToGcRoots, Instant beginTime, Instant endTime) throws DCmdException { + 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()); + } + } + + private Instant parseTime(String time, String parameter) throws DCmdException { + if (time == null) { + return null; + } + try { + return Instant.parse(time); + } catch (DateTimeParseException dtp) { + // fall through + } + try { + LocalDateTime ldt = LocalDateTime.parse(time); + return ZonedDateTime.of(ldt, ZoneId.systemDefault()).toInstant(); + } catch (DateTimeParseException dtp) { + // fall through + } + try { + LocalTime lt = LocalTime.parse(time); + LocalDate ld = LocalDate.now(); + Instant instant = ZonedDateTime.of(ld, lt, ZoneId.systemDefault()).toInstant(); + Instant now = Instant.now(); + if (instant.isAfter(now) && !instant.isBefore(now.plusSeconds(3600))) { + // User must have meant previous day + ld = ld.minusDays(1); + } + return ZonedDateTime.of(ld, lt, ZoneId.systemDefault()).toInstant(); + } catch (DateTimeParseException dtp) { + // fall through + } + + if (time.startsWith("-")) { + try { + long durationNanos = Utils.parseTimespan(time.substring(1)); + Duration duration = Duration.ofNanos(durationNanos); + return Instant.now().minus(duration); + } catch (NumberFormatException nfe) { + // fall through + } + } + throw new DCmdException("Dump failed, not a valid %s time.", parameter); + } + + private PlatformRecording newSnapShot(PlatformRecorder recorder, Recording recording, Boolean pathToGcRoots) throws DCmdException, IOException { + if (recording == null) { + // Operate on all recordings + PlatformRecording snapshot = recorder.newTemporaryRecording(); + recorder.fillWithRecordedData(snapshot, pathToGcRoots); + return snapshot; + } + + PlatformRecording pr = PrivateAccess.getInstance().getPlatformRecording(recording); + return pr.newSnapshotClone("Dumped by user", pathToGcRoots); + } + +} diff --git a/src/share/classes/jdk/jfr/internal/dcmd/DCmdException.java b/src/share/classes/jdk/jfr/internal/dcmd/DCmdException.java new file mode 100644 index 0000000000000000000000000000000000000000..226bff7a3bbe81ad2c08bb03ae93143253fd84c5 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/dcmd/DCmdException.java @@ -0,0 +1,69 @@ +/* + * 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 + * 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.internal.dcmd; + +import java.util.Formatter; + +/** + * Thrown to indicate that a diagnostic command could not be executed + * successfully. + */ +final class DCmdException extends Exception { + private static final long serialVersionUID = -3792411099340016465L; + + /** + * Constructs a new exception with message derived from a format string. + * + * @param format format string as described in {@link Formatter} class. + * + * @param args arguments referenced by the format specifiers in the format + * string. + * + */ + public DCmdException(String format, Object... args) { + super(format(format, args)); + } + + /** + * Constructs a new exception with message derived from a format string. + * + * @param cause exception that stopped the diagnostic command to complete. + * + * @param format format string as described in {@link Formatter} class. + * + * @param args arguments referenced by the format specifiers in the format + * string. + * + */ + public DCmdException(Throwable cause, String format, Object... args) { + super(format(format, args), cause); + } + + private static String format(String message, Object... args) { + try (Formatter formatter = new Formatter()) { + return formatter.format(message, args).toString(); + } + } +} diff --git a/src/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java b/src/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java new file mode 100644 index 0000000000000000000000000000000000000000..c198e9b03eac1d9fc2e687be7d180557bc16c29d --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/dcmd/DCmdStart.java @@ -0,0 +1,259 @@ +/* + * 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 + * 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.internal.dcmd; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.InvalidPathException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.text.ParseException; +import java.time.Duration; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; +import jdk.jfr.internal.JVM; +import jdk.jfr.internal.LogLevel; +import jdk.jfr.internal.LogTag; +import jdk.jfr.internal.Logger; +import jdk.jfr.internal.OldObjectSample; +import jdk.jfr.internal.PrivateAccess; +import jdk.jfr.internal.SecuritySupport.SafePath; +import jdk.jfr.internal.Type; +import jdk.jfr.internal.jfc.JFC; + +/** + * JFR.start + * + */ +//Instantiated by native +final class DCmdStart extends AbstractDCmd { + + /** + * Execute JFR.start. + * + * @param name optional name that can be used to identify recording. + * @param settings names of settings files to use, i.e. "default" or + * "default.jfc". + * @param delay delay before recording is started, in nanoseconds. Must be + * at least 1 second. + * @param duration duration of the recording, in nanoseconds. Must be at + * least 1 second. + * @param disk if recording should be persisted to disk + * @param path file path where recording data should be written + * @param maxAge how long recording data should be kept in the disk + * repository, or 0 if no limit should be set. + * + * @param maxSize the minimum amount data to keep in the disk repository + * before it is discarded, or 0 if no limit should be + * set. + * + * @param dumpOnExit if recording should dump on exit + * + * @return result output + * + * @throws DCmdException if recording could not be started + */ + @SuppressWarnings("resource") + public String execute(String name, String[] settings, Long delay, Long duration, Boolean disk, String path, Long maxAge, Long maxSize, Boolean dumpOnExit, Boolean pathToGcRoots) throws DCmdException { + if (Logger.shouldLog(LogTag.JFR_DCMD, LogLevel.DEBUG)) { + Logger.log(LogTag.JFR_DCMD, LogLevel.DEBUG, "Executing DCmdStart: name=" + name + + ", settings=" + (settings != null ? Arrays.asList(settings) : "(none)") + + ", delay=" + delay + + ", duration=" + duration + + ", disk=" + disk+ + ", filename=" + path + + ", maxage=" + maxAge + + ", maxsize=" + maxSize + + ", dumponexit =" + dumpOnExit + + ", path-to-gc-roots=" + pathToGcRoots); + } + if (name != null) { + try { + Integer.parseInt(name); + throw new DCmdException("Name of recording can't be numeric"); + } catch (NumberFormatException nfe) { + // ok, can't be mixed up with name + } + } + + if (duration == null && Boolean.FALSE.equals(dumpOnExit) && path != null) { + throw new DCmdException("Filename can only be set for a time bound recording or if dumponexit=true. Set duration/dumponexit or omit filename."); + } + if (settings.length == 1 && settings[0].length() == 0) { + throw new DCmdException("No settings specified. Use settings=none to start without any settings"); + } + Map s = new HashMap<>(); + for (String configName : settings) { + try { + s.putAll(JFC.createKnown(configName).getSettings()); + } catch(FileNotFoundException e) { + throw new DCmdException("Could not find settings file'" + configName + "'", e); + } catch (IOException | ParseException e) { + throw new DCmdException("Could not parse settings file '" + settings[0] + "'", e); + } + } + + OldObjectSample.updateSettingPathToGcRoots(s, pathToGcRoots); + + if (duration != null) { + if (duration < 1000L * 1000L * 1000L) { + // to avoid typo, duration below 1s makes no sense + throw new DCmdException("Could not start recording, duration must be at least 1 second."); + } + } + + if (delay != null) { + if (delay < 1000L * 1000L * 1000) { + // to avoid typo, delay shorter than 1s makes no sense. + throw new DCmdException("Could not start recording, delay must be at least 1 second."); + } + } + + if (!FlightRecorder.isInitialized() && delay == null) { + initializeWithForcedInstrumentation(s); + } + + Recording recording = new Recording(); + if (name != null) { + recording.setName(name); + } + + if (disk != null) { + recording.setToDisk(disk.booleanValue()); + } + recording.setSettings(s); + SafePath safePath = null; + + if (path != null) { + try { + if (dumpOnExit == null) { + // default to dumponexit=true if user specified filename + dumpOnExit = Boolean.TRUE; + } + Path p = Paths.get(path); + if (Files.isDirectory(p) && Boolean.TRUE.equals(dumpOnExit)) { + // Decide destination filename at dump time + // Purposely avoid generating filename in Recording#setDestination due to + // security concerns + PrivateAccess.getInstance().getPlatformRecording(recording).setDumpOnExitDirectory(new SafePath(p)); + } else { + safePath = resolvePath(recording, path); + recording.setDestination(safePath.toPath()); + } + } catch (IOException | InvalidPathException e) { + recording.close(); + throw new DCmdException("Could not start recording, not able to write to file %s. %s ", path, e.getMessage()); + } + } + + if (maxAge != null) { + recording.setMaxAge(Duration.ofNanos(maxAge)); + } + + if (maxSize != null) { + recording.setMaxSize(maxSize); + } + + if (duration != null) { + recording.setDuration(Duration.ofNanos(duration)); + } + + if (dumpOnExit != null) { + recording.setDumpOnExit(dumpOnExit); + } + + if (delay != null) { + Duration dDelay = Duration.ofNanos(delay); + recording.scheduleStart(dDelay); + print("Recording " + recording.getId() + " scheduled to start in "); + printTimespan(dDelay, " "); + print("."); + } else { + recording.start(); + print("Started recording " + recording.getId() + "."); + } + + if (recording.isToDisk() && duration == null && maxAge == null && maxSize == null) { + print(" No limit specified, using maxsize=250MB as default."); + recording.setMaxSize(250*1024L*1024L); + } + + if (safePath != null && duration != null) { + println(" The result will be written to:"); + println(); + printPath(safePath); + } else { + println(); + println(); + String cmd = duration == null ? "dump" : "stop"; + String fileOption = path == null ? "filename=FILEPATH " : ""; + String recordingspecifier = "name=" + recording.getId(); + // if user supplied a name, use it. + if (name != null) { + recordingspecifier = "name=" + quoteIfNeeded(name); + } + print("Use jcmd " + getPid() + " JFR." + cmd + " " + recordingspecifier + " " + fileOption + "to copy recording data to file."); + println(); + } + return getResult(); + } + + + // Instruments JDK-events on class load to reduce startup time + private void initializeWithForcedInstrumentation(Map settings) { + if (!hasJDKEvents(settings)) { + return; + } + JVM jvm = JVM.getJVM(); + try { + jvm.setForceInstrumentation(true); + FlightRecorder.getFlightRecorder(); + } finally { + jvm.setForceInstrumentation(false); + } + } + + private boolean hasJDKEvents(Map settings) { + String[] eventNames = new String[7]; + eventNames[0] = "FileRead"; + eventNames[1] = "FileWrite"; + eventNames[2] = "SocketRead"; + eventNames[3] = "SocketWrite"; + eventNames[4] = "JavaErrorThrow"; + eventNames[5] = "JavaExceptionThrow"; + eventNames[6] = "FileForce"; + for (String eventName : eventNames) { + if ("true".equals(settings.get(Type.EVENT_NAME_PREFIX + eventName + "#enabled"))) { + return true; + } + } + return false; + } +} diff --git a/src/share/classes/jdk/jfr/internal/dcmd/DCmdStop.java b/src/share/classes/jdk/jfr/internal/dcmd/DCmdStop.java new file mode 100644 index 0000000000000000000000000000000000000000..71490b1915a4e6f3023e9e1fdaefd730cce96fef --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/dcmd/DCmdStop.java @@ -0,0 +1,87 @@ +/* + * 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 + * 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.internal.dcmd; + +import java.io.IOException; +import java.nio.file.InvalidPathException; +import java.nio.file.Paths; + +import jdk.jfr.Recording; +import jdk.jfr.internal.LogLevel; +import jdk.jfr.internal.LogTag; +import jdk.jfr.internal.Logger; +import jdk.jfr.internal.SecuritySupport.SafePath; + +/** + * JFR.stop + * + */ +// Instantiated by native +final class DCmdStop extends AbstractDCmd { + + /** + * Execute JFR.stop + * + * Requires that either name or id is set. + * + * @param name name or id of the recording to stop. + * + * @param filename file path where data should be written after recording has + * been stopped, or null if recording shouldn't be written + * to disk. + * @return result text + * + * @throws DCmdException if recording could not be stopped + */ + public String execute(String name, String filename) throws DCmdException { + if (Logger.shouldLog(LogTag.JFR_DCMD, LogLevel.DEBUG)) { + Logger.log(LogTag.JFR_DCMD, LogLevel.DEBUG, "Executing DCmdStart: name=" + name + ", filename=" + filename); + } + + try { + SafePath safePath = null; + Recording recording = findRecording(name); + if (filename != null) { + try { + // Ensure path is valid. Don't generate safePath if filename == null, as a user may + // want to stop recording without a dump + safePath = resolvePath(null, filename); + recording.setDestination(Paths.get(filename)); + } catch (IOException | InvalidPathException e) { + throw new DCmdException("Failed to stop %s. Could not set destination for \"%s\" to file %s", recording.getName(), filename, e.getMessage()); + } + } + recording.stop(); + reportOperationComplete("Stopped", recording.getName(), safePath); + recording.close(); + return getResult(); + } catch (InvalidPathException | DCmdException e) { + if (filename != null) { + throw new DCmdException("Could not write recording \"%s\" to file. %s", name, e.getMessage()); + } + throw new DCmdException(e, "Could not stop recording \"%s\".", name, e.getMessage()); + } + } +} diff --git a/src/share/classes/jdk/jfr/internal/handlers/EventHandler.java b/src/share/classes/jdk/jfr/internal/handlers/EventHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..52af9c13b46fe98fa3768db090ef7e219f01c1be --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/handlers/EventHandler.java @@ -0,0 +1,123 @@ +/* + * 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. 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.internal.handlers; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +import jdk.jfr.EventType; +import jdk.jfr.internal.EventControl; +import jdk.jfr.internal.JVM; +import jdk.jfr.internal.PlatformEventType; +import jdk.jfr.internal.PrivateAccess; +import jdk.jfr.internal.StringPool; + +// Users should not be subclass for security reasons. +public abstract class EventHandler { + // Accessed by generated sub class + protected final PlatformEventType platformEventType; + + private final EventType eventType; + private final EventControl eventControl; + + // Accessed by generated sub class + protected EventHandler(boolean registered, EventType eventType, EventControl eventControl) { + if (System.getSecurityManager() != null) { + // Do not allow user subclasses when security is enforced. + if (EventHandler.class.getClassLoader() != this.getClass().getClassLoader()) { + throw new SecurityException("Illegal subclass"); + } + } + this.eventType = eventType; + this.platformEventType = PrivateAccess.getInstance().getPlatformEventType(eventType); + this.eventControl = eventControl; + platformEventType.setRegistered(registered); + } + + final protected StringPool createStringFieldWriter() { + return new StringPool(); + } + + // Accessed by generated code in event class + public final boolean shouldCommit(long duration) { + return isEnabled() && duration >= platformEventType.getThresholdTicks(); + } + + // Accessed by generated code in event class + // Accessed by generated sub class + public final boolean isEnabled() { + return platformEventType.isCommitable(); + } + + public final EventType getEventType() { + return eventType; + } + + public final PlatformEventType getPlatformEventType() { + return platformEventType; + } + + public final EventControl getEventControl() { + return eventControl; + } + + public static long timestamp() { + return JVM.counterTime(); + } + + public static long duration(long startTime) { + if (startTime == 0) { + // User forgot to invoke begin, or instrumentation was + // added after the user invoked begin. + // Returning 0 will make it an instant event + return 0; + } + return timestamp() - startTime; + } + + // Prevent a malicious user from instantiating a generated event handlers. + @Override + public final Object clone() throws java.lang.CloneNotSupportedException { + throw new CloneNotSupportedException(); + } + + private final void writeObject(ObjectOutputStream out) throws IOException { + throw new IOException("Object cannot be serialized"); + } + + private final void readObject(ObjectInputStream in) throws IOException { + throw new IOException("Class cannot be deserialized"); + } + + public boolean isRegistered() { + return platformEventType.isRegistered(); + } + + public boolean setRegistered(boolean registered) { + return platformEventType.setRegistered(registered); + } +} diff --git a/src/share/classes/jdk/jfr/internal/instrument/ConstructorTracerWriter.java b/src/share/classes/jdk/jfr/internal/instrument/ConstructorTracerWriter.java new file mode 100644 index 0000000000000000000000000000000000000000..e9edede9d68cbd2d238fec640ed70d3f81fd3a34 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/instrument/ConstructorTracerWriter.java @@ -0,0 +1,86 @@ +/* + * 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 + * 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.internal.instrument; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; + +import jdk.internal.org.objectweb.asm.ClassReader; +import jdk.internal.org.objectweb.asm.ClassVisitor; +import jdk.internal.org.objectweb.asm.ClassWriter; +import jdk.internal.org.objectweb.asm.MethodVisitor; +import jdk.internal.org.objectweb.asm.Opcodes; +import jdk.internal.org.objectweb.asm.Type; + +final class ConstructorTracerWriter extends ClassVisitor { + + private ConstructorWriter useInputParameter, noUseInputParameter; + + static byte[] generateBytes(Class clz, byte[] oldBytes) throws IOException { + InputStream in = new ByteArrayInputStream(oldBytes); + ClassReader cr = new ClassReader(in); + ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); + ConstructorTracerWriter ctw = new ConstructorTracerWriter(cw, clz); + cr.accept(ctw, 0); + return cw.toByteArray(); + } + + private ConstructorTracerWriter(ClassVisitor cv, Class classToChange) { + super(Opcodes.ASM5, cv); + useInputParameter = new ConstructorWriter(classToChange, true); + noUseInputParameter = new ConstructorWriter(classToChange, false); + } + + private boolean isConstructor(String name) { + return name.equals(""); + } + + private boolean takesStringParameter(String desc) { + Type[] types = Type.getArgumentTypes(desc); + if (types.length > 0 && types[0].getClassName().equals(String.class.getName())) { + return true; + } + return false; + } + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + + MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); + + // Get a hold of the constructors that takes a String as a parameter + if (isConstructor(name)) { + if (takesStringParameter(desc)) { + useInputParameter.setMethodVisitor(mv); + return useInputParameter; + } + noUseInputParameter.setMethodVisitor(mv); + return noUseInputParameter; + } + return mv; + } +} diff --git a/src/share/classes/jdk/jfr/internal/instrument/ConstructorWriter.java b/src/share/classes/jdk/jfr/internal/instrument/ConstructorWriter.java new file mode 100644 index 0000000000000000000000000000000000000000..f4c040e5658a744326744d03a8be906e7d7301ea --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/instrument/ConstructorWriter.java @@ -0,0 +1,89 @@ +/* + * 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 + * 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.internal.instrument; + +import static jdk.internal.org.objectweb.asm.Opcodes.ACONST_NULL; +import static jdk.internal.org.objectweb.asm.Opcodes.ALOAD; +import static jdk.internal.org.objectweb.asm.Opcodes.INVOKESTATIC; +import static jdk.internal.org.objectweb.asm.Opcodes.RETURN; +import jdk.internal.org.objectweb.asm.MethodVisitor; +import jdk.internal.org.objectweb.asm.Opcodes; + +final class ConstructorWriter extends MethodVisitor { + + private boolean useInputParameter; + private String shortClassName; + private String fullClassName; + + ConstructorWriter(Class classToChange, boolean useInputParameter) { + super(Opcodes.ASM5); + this.useInputParameter = useInputParameter; + shortClassName = classToChange.getSimpleName(); + fullClassName = classToChange.getName().replace('.', '/'); + } + + @Override + public void visitInsn(int opcode) + { + if (opcode == RETURN) { + if (useInputParameter) { + useInput(); + } else { + noInput(); + } + } + mv.visitInsn(opcode); + } + @SuppressWarnings("deprecation") + private void useInput() + { + //Load 'this' from local variable 0 + //Load first input parameter + //Invoke ThrowableTracer.traceCLASS(this, parameter) for current class + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.visitMethodInsn(INVOKESTATIC, "jdk/jfr/internal/instrument/ThrowableTracer", + "trace" + shortClassName, "(L" + fullClassName + + ";Ljava/lang/String;)V"); + } + + @SuppressWarnings("deprecation") + private void noInput() + { + //Load 'this' from local variable 0 + //Load "" + //Invoke ThrowableTracer.traceCLASS(this, "") for current class + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(ACONST_NULL); + mv.visitMethodInsn(INVOKESTATIC, "jdk/jfr/internal/instrument/ThrowableTracer", + "trace" + shortClassName, "(L" + fullClassName + + ";Ljava/lang/String;)V"); + } + + public void setMethodVisitor(MethodVisitor mv) { + this.mv = mv; + } +} diff --git a/src/share/classes/jdk/jfr/internal/instrument/FileChannelImplInstrumentor.java b/src/share/classes/jdk/jfr/internal/instrument/FileChannelImplInstrumentor.java new file mode 100644 index 0000000000000000000000000000000000000000..18d09c48c9d0c7826ab77e95c32163c988aeea76 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/instrument/FileChannelImplInstrumentor.java @@ -0,0 +1,197 @@ +/* + * 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 + * 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.internal.instrument; + +import java.io.IOException; +import java.nio.ByteBuffer; + +import jdk.jfr.events.FileForceEvent; +import jdk.jfr.events.FileReadEvent; +import jdk.jfr.events.FileWriteEvent; + +/** + * See {@link JITracer} for an explanation of this code. + */ +@JIInstrumentationTarget("sun.nio.ch.FileChannelImpl") +final class FileChannelImplInstrumentor { + + private FileChannelImplInstrumentor() { + } + + private String path; + + @SuppressWarnings("deprecation") + @JIInstrumentationMethod + public void force(boolean metaData) throws IOException { + FileForceEvent event = FileForceEvent.EVENT.get(); + if (!event.isEnabled()) { + force(metaData); + return; + } + try { + event.begin(); + force(metaData); + } finally { + event.path = path; + event.metaData = metaData; + event.commit(); + event.reset(); + } + } + + @SuppressWarnings("deprecation") + @JIInstrumentationMethod + public int read(ByteBuffer dst) throws IOException { + FileReadEvent event = FileReadEvent.EVENT.get(); + if (!event.isEnabled()) { + return read(dst); + } + int bytesRead = 0; + try { + event.begin(); + bytesRead = read(dst); + } finally { + if (bytesRead < 0) { + event.endOfFile = true; + } else { + event.bytesRead = bytesRead; + } + event.path = path; + event.commit(); + event.reset(); + } + return bytesRead; + } + + @SuppressWarnings("deprecation") + @JIInstrumentationMethod + public int read(ByteBuffer dst, long position) throws IOException { + FileReadEvent event = FileReadEvent.EVENT.get(); + if (!event.isEnabled()) { + return read(dst, position); + } + int bytesRead = 0; + try { + event.begin(); + bytesRead = read(dst, position); + } finally { + if (bytesRead < 0) { + event.endOfFile = true; + } else { + event.bytesRead = bytesRead; + } + event.path = path; + event.commit(); + event.reset(); + } + return bytesRead; + } + + @SuppressWarnings("deprecation") + @JIInstrumentationMethod + public long read(ByteBuffer[] dsts, int offset, int length) throws IOException { + FileReadEvent event = FileReadEvent.EVENT.get(); + if (!event.isEnabled()) { + return read(dsts, offset, length); + } + long bytesRead = 0; + try { + event.begin(); + bytesRead = read(dsts, offset, length); + } finally { + if (bytesRead < 0) { + event.endOfFile = true; + } else { + event.bytesRead = bytesRead; + } + event.path = path; + event.commit(); + event.reset(); + } + return bytesRead; + } + + @SuppressWarnings("deprecation") + @JIInstrumentationMethod + public int write(ByteBuffer src) throws IOException { + FileWriteEvent event = FileWriteEvent.EVENT.get(); + if (!event.isEnabled()) { + return write(src); + } + int bytesWritten = 0; + try { + event.begin(); + bytesWritten = write(src); + } finally { + event.bytesWritten = bytesWritten > 0 ? bytesWritten : 0; + event.path = path; + event.commit(); + event.reset(); + } + return bytesWritten; + } + + @SuppressWarnings("deprecation") + @JIInstrumentationMethod + public int write(ByteBuffer src, long position) throws IOException { + FileWriteEvent event = FileWriteEvent.EVENT.get(); + if (!event.isEnabled()) { + return write(src, position); + } + + int bytesWritten = 0; + try { + event.begin(); + bytesWritten = write(src, position); + } finally { + event.bytesWritten = bytesWritten > 0 ? bytesWritten : 0; + event.path = path; + event.commit(); + event.reset(); + } + return bytesWritten; + } + + @SuppressWarnings("deprecation") + @JIInstrumentationMethod + public long write(ByteBuffer[] srcs, int offset, int length) throws IOException { + FileWriteEvent event = FileWriteEvent.EVENT.get(); + if (!event.isEnabled()) { + return write(srcs, offset, length); + } + long bytesWritten = 0; + try { + event.begin(); + bytesWritten = write(srcs, offset, length); + } finally { + event.bytesWritten = bytesWritten > 0 ? bytesWritten : 0; + event.path = path; + event.commit(); + event.reset(); + } + return bytesWritten; + } +} diff --git a/src/share/classes/jdk/jfr/internal/instrument/FileInputStreamInstrumentor.java b/src/share/classes/jdk/jfr/internal/instrument/FileInputStreamInstrumentor.java new file mode 100644 index 0000000000000000000000000000000000000000..1a0699b7760f18d404cc8fb5c3d41b7abbe11fab --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/instrument/FileInputStreamInstrumentor.java @@ -0,0 +1,115 @@ +/* + * 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 + * 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.internal.instrument; + +import java.io.IOException; + +import jdk.jfr.events.FileReadEvent; + +/** + * See {@link JITracer} for an explanation of this code. + */ +@JIInstrumentationTarget("java.io.FileInputStream") +final class FileInputStreamInstrumentor { + + private FileInputStreamInstrumentor() { + } + + private String path; + + @SuppressWarnings("deprecation") + @JIInstrumentationMethod + public int read() throws IOException { + FileReadEvent event = FileReadEvent.EVENT.get(); + if (!event.isEnabled()) { + return read(); + } + int result = 0; + try { + event.begin(); + result = read(); + if (result < 0) { + event.endOfFile = true; + } else { + event.bytesRead = 1; + } + } finally { + event.path = path; + event.commit(); + event.reset(); + } + return result; + } + + @SuppressWarnings("deprecation") + @JIInstrumentationMethod + public int read(byte b[]) throws IOException { + FileReadEvent event = FileReadEvent.EVENT.get(); + if (!event.isEnabled()) { + return read(b); + } + int bytesRead = 0; + try { + event.begin(); + bytesRead = read(b); + } finally { + if (bytesRead < 0) { + event.endOfFile = true; + } else { + event.bytesRead = bytesRead; + } + event.path = path; + event.commit(); + event.reset(); + } + return bytesRead; + } + + @SuppressWarnings("deprecation") + @JIInstrumentationMethod + public int read(byte b[], int off, int len) throws IOException { + FileReadEvent event = FileReadEvent.EVENT.get(); + if (!event.isEnabled()) { + return read(b, off, len); + } + int bytesRead = 0; + try { + event.begin(); + bytesRead = read(b, off, len); + } finally { + if (bytesRead < 0) { + event.endOfFile = true; + } else { + event.bytesRead = bytesRead; + } + event.path = path; + event.commit(); + event.reset(); + } + return bytesRead; + } + +} diff --git a/src/share/classes/jdk/jfr/internal/instrument/FileOutputStreamInstrumentor.java b/src/share/classes/jdk/jfr/internal/instrument/FileOutputStreamInstrumentor.java new file mode 100644 index 0000000000000000000000000000000000000000..21139854eac25551e3c7e2cd93156d7c4e4a0f86 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/instrument/FileOutputStreamInstrumentor.java @@ -0,0 +1,99 @@ +/* + * 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 + * 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.internal.instrument; + +import java.io.IOException; + +import jdk.jfr.events.FileWriteEvent; + +/** + * See {@link JITracer} for an explanation of this code. + */ +@JIInstrumentationTarget("java.io.FileOutputStream") +final class FileOutputStreamInstrumentor { + + private FileOutputStreamInstrumentor() { + } + + private String path; + + @SuppressWarnings("deprecation") + @JIInstrumentationMethod + public void write(int b) throws IOException { + FileWriteEvent event = FileWriteEvent.EVENT.get(); + if (!event.isEnabled()) { + write(b); + return; + } + try { + event.begin(); + write(b); + event.bytesWritten = 1; + } finally { + event.path = path; + event.commit(); + event.reset(); + } + } + + @SuppressWarnings("deprecation") + @JIInstrumentationMethod + public void write(byte b[]) throws IOException { + FileWriteEvent event = FileWriteEvent.EVENT.get(); + if (!event.isEnabled()) { + write(b); + return; + } + try { + event.begin(); + write(b); + event.bytesWritten = b.length; + } finally { + event.path = path; + event.commit(); + event.reset(); + } + } + + @SuppressWarnings("deprecation") + @JIInstrumentationMethod + public void write(byte b[], int off, int len) throws IOException { + FileWriteEvent event = FileWriteEvent.EVENT.get(); + if (!event.isEnabled()) { + write(b, off, len); + return; + } + try { + event.begin(); + write(b, off, len); + event.bytesWritten = len; + } finally { + event.path = path; + event.commit(); + event.reset(); + } + } +} diff --git a/src/share/classes/jdk/jfr/internal/instrument/JDKEvents.java b/src/share/classes/jdk/jfr/internal/instrument/JDKEvents.java new file mode 100644 index 0000000000000000000000000000000000000000..e45f531e76bb29efdf726bfade46f1f81aafd196 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/instrument/JDKEvents.java @@ -0,0 +1,144 @@ +/* + * 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. 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.internal.instrument; + +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Event; +import jdk.jfr.events.ActiveRecordingEvent; +import jdk.jfr.events.ActiveSettingEvent; +import jdk.jfr.events.ErrorThrownEvent; +import jdk.jfr.events.ExceptionStatisticsEvent; +import jdk.jfr.events.ExceptionThrownEvent; +import jdk.jfr.events.FileForceEvent; +import jdk.jfr.events.FileReadEvent; +import jdk.jfr.events.FileWriteEvent; +import jdk.jfr.events.SocketReadEvent; +import jdk.jfr.events.SocketWriteEvent; +import jdk.jfr.internal.JVM; +import jdk.jfr.internal.LogLevel; +import jdk.jfr.internal.LogTag; +import jdk.jfr.internal.Logger; +import jdk.jfr.internal.RequestEngine; +import jdk.jfr.internal.SecuritySupport; + +public final class JDKEvents { + + private static final Class[] eventClasses = { + FileForceEvent.class, + FileReadEvent.class, + FileWriteEvent.class, + SocketReadEvent.class, + SocketWriteEvent.class, + ExceptionThrownEvent.class, + ExceptionStatisticsEvent.class, + ErrorThrownEvent.class, + ActiveSettingEvent.class, + ActiveRecordingEvent.class + }; + + // This is a list of the classes with instrumentation code that should be applied. + private static final Class[] instrumentationClasses = new Class[] { + FileInputStreamInstrumentor.class, + FileOutputStreamInstrumentor.class, + RandomAccessFileInstrumentor.class, + FileChannelImplInstrumentor.class, + SocketInputStreamInstrumentor.class, + SocketOutputStreamInstrumentor.class, + SocketChannelImplInstrumentor.class + }; + + private static final Class[] targetClasses = new Class[instrumentationClasses.length]; + private static final JVM jvm = JVM.getJVM(); + private static final Runnable emitExceptionStatistics = JDKEvents::emitExceptionStatistics; + private static boolean initializationTriggered; + + @SuppressWarnings("unchecked") + public synchronized static void initialize() { + try { + if (initializationTriggered == false) { + for (Class eventClass : eventClasses) { + SecuritySupport.registerEvent((Class) eventClass); + } + initializationTriggered = true; + RequestEngine.addTrustedJDKHook(ExceptionStatisticsEvent.class, emitExceptionStatistics); + } + } catch (Exception e) { + Logger.log(LogTag.JFR_SYSTEM, LogLevel.WARN, "Could not initialize JDK events. " + e.getMessage()); + } + } + + public static void addInstrumentation() { + try { + List> list = new ArrayList<>(); + for (int i = 0; i < instrumentationClasses.length; i++) { + JIInstrumentationTarget tgt = instrumentationClasses[i].getAnnotation(JIInstrumentationTarget.class); + Class clazz = Class.forName(tgt.value()); + targetClasses[i] = clazz; + list.add(clazz); + } + list.add(java.lang.Throwable.class); + list.add(java.lang.Error.class); + Logger.log(LogTag.JFR_SYSTEM, LogLevel.INFO, "Retransformed JDK classes"); + jvm.retransformClasses(list.toArray(new Class[list.size()])); + } catch (Exception e) { + Logger.log(LogTag.JFR_SYSTEM, LogLevel.WARN, "Could not add instrumentation for JDK events. " + e.getMessage()); + } + } + + private static void emitExceptionStatistics() { + ExceptionStatisticsEvent t = new ExceptionStatisticsEvent(); + t.throwables = ThrowableTracer.numThrowables(); + t.commit(); + } + + @SuppressWarnings("deprecation") + public static byte[] retransformCallback(Class klass, byte[] oldBytes) throws Throwable { + if (java.lang.Throwable.class == klass) { + Logger.log(LogTag.JFR_SYSTEM, LogLevel.TRACE, "Instrumenting java.lang.Throwable"); + return ConstructorTracerWriter.generateBytes(java.lang.Throwable.class, oldBytes); + } + + if (java.lang.Error.class == klass) { + Logger.log(LogTag.JFR_SYSTEM, LogLevel.TRACE, "Instrumenting java.lang.Error"); + return ConstructorTracerWriter.generateBytes(java.lang.Error.class, oldBytes); + } + + for (int i = 0; i < targetClasses.length; i++) { + if (targetClasses[i].equals(klass)) { + Class c = instrumentationClasses[i]; + Logger.log(LogTag.JFR_SYSTEM, LogLevel.TRACE, () -> "Processing instrumentation class: " + c); + return new JIClassInstrumentation(instrumentationClasses[i], klass, oldBytes).getNewBytes(); + } + } + return oldBytes; + } + + public static void remove() { + RequestEngine.removeHook(JDKEvents::emitExceptionStatistics); + } +} diff --git a/src/share/classes/jdk/jfr/internal/instrument/JIClassInstrumentation.java b/src/share/classes/jdk/jfr/internal/instrument/JIClassInstrumentation.java new file mode 100644 index 0000000000000000000000000000000000000000..fe796e85ded9bfd51478cfb6660d9e3e4072a423 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/instrument/JIClassInstrumentation.java @@ -0,0 +1,140 @@ +/* + * 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 + * 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.internal.instrument; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; + +import jdk.internal.org.objectweb.asm.ClassReader; +import jdk.internal.org.objectweb.asm.ClassVisitor; +import jdk.internal.org.objectweb.asm.ClassWriter; +import jdk.internal.org.objectweb.asm.Opcodes; +import jdk.internal.org.objectweb.asm.tree.ClassNode; +import jdk.jfr.internal.SecuritySupport; +import jdk.jfr.internal.Utils; + +/** + * This class will perform byte code instrumentation given an "instrumentor" class. + * + * @see JITracer + * + * @author Staffan Larsen + */ +@Deprecated +final class JIClassInstrumentation { + private final Class instrumentor; + private final String targetName; + private final String instrumentorName; + private final byte[] newBytes; + private final ClassReader targetClassReader; + private final ClassReader instrClassReader; + + /** + * Creates an instance and performs the instrumentation. + * + * @param instrumentor instrumentor class + * @param target target class + * @param old_target_bytes bytes in target + * + * @throws ClassNotFoundException + * @throws IOException + */ + JIClassInstrumentation(Class instrumentor, Class target, byte[] old_target_bytes) throws ClassNotFoundException, IOException { + instrumentorName = instrumentor.getName(); + this.targetName = target.getName(); + this.instrumentor = instrumentor; + this.targetClassReader = new ClassReader(old_target_bytes); + this.instrClassReader = new ClassReader(getOriginalClassBytes(instrumentor)); + this.newBytes = makeBytecode(); + Utils.writeGeneratedASM(target.getName(), newBytes); + } + + private static byte[] getOriginalClassBytes(Class clazz) throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + String name = "/" + clazz.getName().replace(".", "/") + ".class"; + InputStream is = SecuritySupport.getResourceAsStream(name); + int bytesRead; + byte[] buffer = new byte[16384]; + while ((bytesRead = is.read(buffer, 0, buffer.length)) != -1) { + baos.write(buffer, 0, bytesRead); + } + baos.flush(); + is.close(); + return baos.toByteArray(); + } + + private byte[] makeBytecode() throws IOException, ClassNotFoundException { + + // Find the methods to instrument and inline + + final List instrumentationMethods = new ArrayList<>(); + for (final Method m : instrumentor.getDeclaredMethods()) { + JIInstrumentationMethod im = m.getAnnotation(JIInstrumentationMethod.class); + if (im != null) { + instrumentationMethods.add(m); + } + } + + // We begin by inlining the target's methods into the instrumentor + + ClassNode temporary = new ClassNode(); + ClassVisitor inliner = new JIInliner( + Opcodes.ASM5, + temporary, + targetName, + instrumentorName, + targetClassReader, + instrumentationMethods); + instrClassReader.accept(inliner, ClassReader.EXPAND_FRAMES); + + // Now we have the target's methods inlined into the instrumentation code (in 'temporary'). + // We now need to replace the target's method with the code in the + // instrumentation method. + + ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); + JIMethodMergeAdapter ma = new JIMethodMergeAdapter( + cw, + temporary, + instrumentationMethods, + instrumentor.getAnnotationsByType(JITypeMapping.class)); + targetClassReader.accept(ma, ClassReader.EXPAND_FRAMES); + + return cw.toByteArray(); + } + + /** + * Get the instrumented byte codes that can be used to retransform the class. + * + * @return bytes + */ + public byte[] getNewBytes() { + return newBytes.clone(); + } +} diff --git a/src/share/classes/jdk/jfr/internal/instrument/JIInliner.java b/src/share/classes/jdk/jfr/internal/instrument/JIInliner.java new file mode 100644 index 0000000000000000000000000000000000000000..dd03b70c366bf90f84bd75cc0deb5e8c752bbc16 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/instrument/JIInliner.java @@ -0,0 +1,113 @@ +/* + * 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 + * 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.internal.instrument; + +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.List; + +import jdk.internal.org.objectweb.asm.ClassReader; +import jdk.internal.org.objectweb.asm.ClassVisitor; +import jdk.internal.org.objectweb.asm.MethodVisitor; +import jdk.internal.org.objectweb.asm.Opcodes; +import jdk.internal.org.objectweb.asm.Type; +import jdk.internal.org.objectweb.asm.tree.ClassNode; +import jdk.internal.org.objectweb.asm.tree.MethodNode; +import jdk.jfr.internal.LogLevel; +import jdk.jfr.internal.LogTag; +import jdk.jfr.internal.Logger; + +@Deprecated +final class JIInliner extends ClassVisitor { + private final String targetClassName; + private final String instrumentationClassName; + private final ClassNode targetClassNode; + private final List instrumentationMethods; + + /** + * A ClassVisitor which will check all methods of the class it visits against the instrumentationMethods + * list. If a method is on that list, the method will be further processed for inlining into that + * method. + */ + JIInliner(int api, ClassVisitor cv, String targetClassName, String instrumentationClassName, + ClassReader targetClassReader, + List instrumentationMethods) { + super(api, cv); + this.targetClassName = targetClassName; + this.instrumentationClassName = instrumentationClassName; + this.instrumentationMethods = instrumentationMethods; + + ClassNode cn = new ClassNode(Opcodes.ASM5); + targetClassReader.accept(cn, ClassReader.EXPAND_FRAMES); + this.targetClassNode = cn; + } + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); + + if (isInstrumentationMethod(name, desc)) { + MethodNode methodToInline = findTargetMethodNode(name, desc); + if (methodToInline == null) { + throw new IllegalArgumentException("Could not find the method to instrument in the target class"); + } + if (Modifier.isNative(methodToInline.access)) { + throw new IllegalArgumentException("Cannot instrument native methods: " + targetClassNode.name + "." + methodToInline.name + methodToInline.desc); + } + + Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.DEBUG, "Inliner processing method " + name + desc); + + JIMethodCallInliner mci = new JIMethodCallInliner(access, + desc, + mv, + methodToInline, + targetClassName, + instrumentationClassName); + return mci; + } + + return mv; + } + + private boolean isInstrumentationMethod(String name, String desc) { + for(Method m : instrumentationMethods) { + if (m.getName().equals(name) && Type.getMethodDescriptor(m).equals(desc)) { + return true; + } + } + return false; + } + + private MethodNode findTargetMethodNode(String name, String desc) { + for (MethodNode mn : targetClassNode.methods) { + if (mn.desc.equals(desc) && mn.name.equals(name)) { + return mn; + } + } + throw new IllegalArgumentException("could not find MethodNode for " + + name + desc); + } +} diff --git a/src/share/classes/jdk/jfr/internal/instrument/JIInstrumentationMethod.java b/src/share/classes/jdk/jfr/internal/instrument/JIInstrumentationMethod.java new file mode 100644 index 0000000000000000000000000000000000000000..bebaad4c8159277b0ecea95bf1990964ed80a182 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/instrument/JIInstrumentationMethod.java @@ -0,0 +1,36 @@ +/* + * 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 + * 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.internal.instrument; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@interface JIInstrumentationMethod { +} diff --git a/src/share/classes/jdk/jfr/internal/instrument/JIInstrumentationTarget.java b/src/share/classes/jdk/jfr/internal/instrument/JIInstrumentationTarget.java new file mode 100644 index 0000000000000000000000000000000000000000..d48a4e3ac5f3809fee9d7c8e2828242b9f787329 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/instrument/JIInstrumentationTarget.java @@ -0,0 +1,37 @@ +/* + * 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 + * 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.internal.instrument; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface JIInstrumentationTarget { + String value(); +} diff --git a/src/share/classes/jdk/jfr/internal/instrument/JIMethodCallInliner.java b/src/share/classes/jdk/jfr/internal/instrument/JIMethodCallInliner.java new file mode 100644 index 0000000000000000000000000000000000000000..a94c35b26d5ff97c3087ae59029872b2aafafad3 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/instrument/JIMethodCallInliner.java @@ -0,0 +1,149 @@ +/* + * 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 + * 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.internal.instrument; + +import java.util.ArrayList; +import java.util.List; + +import jdk.internal.org.objectweb.asm.Label; +import jdk.internal.org.objectweb.asm.MethodVisitor; +import jdk.internal.org.objectweb.asm.Opcodes; +import jdk.internal.org.objectweb.asm.commons.LocalVariablesSorter; +import jdk.internal.org.objectweb.asm.commons.Remapper; +import jdk.internal.org.objectweb.asm.commons.SimpleRemapper; +import jdk.internal.org.objectweb.asm.tree.MethodNode; +import jdk.jfr.internal.LogLevel; +import jdk.jfr.internal.LogTag; +import jdk.jfr.internal.Logger; + +/** + * Class responsible for finding the call to inline and inlining it. + * + * This code is heavily influenced by section 3.2.6 "Inline Method" in + * "Using ASM framework to implement common bytecode transformation patterns", + * E. Kuleshov, AOSD.07, March 2007, Vancouver, Canada. + * http://asm.ow2.org/index.html + */ +@Deprecated +final class JIMethodCallInliner extends LocalVariablesSorter { + + private final String oldClass; + private final String newClass; + private final MethodNode inlineTarget; + private final List blocks = new ArrayList<>(); + private boolean inlining; + + /** + * inlineTarget defines the method to inline and also contains the actual + * code to inline. + * + * @param access + * @param desc + * @param mv + * @param inlineTarget + * @param oldClass + * @param newClass + * @param logger + */ + public JIMethodCallInliner(int access, String desc, MethodVisitor mv, + MethodNode inlineTarget, String oldClass, String newClass) { + super(Opcodes.ASM5, access, desc, mv); + this.oldClass = oldClass; + this.newClass = newClass; + this.inlineTarget = inlineTarget; + + Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.DEBUG, "MethodCallInliner: targetMethod=" + newClass + "." + + inlineTarget.name + inlineTarget.desc); + } + + @Override + public void visitMethodInsn(int opcode, String owner, String name, + String desc, boolean itf) { + // Now we are looking at method call in the source method + if (!shouldBeInlined(owner, name, desc)) { + // If this method call should not be inlined, just keep it + mv.visitMethodInsn(opcode, owner, name, desc, itf); + return; + } + // If the call should be inlined, we create a MethodInliningAdapter + // The MIA will walk the instructions in the inlineTarget and add them + // to the current method, doing the necessary name remappings. + Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.DEBUG, "Inlining call to " + name + desc); + Remapper remapper = new SimpleRemapper(oldClass, newClass); + Label end = new Label(); + inlining = true; + inlineTarget.instructions.resetLabels(); + JIMethodInliningAdapter mia = new JIMethodInliningAdapter(this, end, + opcode == Opcodes.INVOKESTATIC ? Opcodes.ACC_STATIC : 0, desc, + remapper); + inlineTarget.accept(mia); + inlining = false; + super.visitLabel(end); + } + + /** + * Determine if the method should be inlined or not. + */ + private boolean shouldBeInlined(String owner, String name, String desc) { + return inlineTarget.desc.equals(desc) && inlineTarget.name.equals(name) + && owner.equals(newClass.replace('.', '/')); + } + + @Override + public void visitTryCatchBlock(Label start, Label end, Label handler, + String type) { + if (!inlining) { + // try-catch blocks are saved here and replayed at the end + // of the method (in visitMaxs) + blocks.add(new CatchBlock(start, end, handler, type)); + } else { + super.visitTryCatchBlock(start, end, handler, type); + } + } + + @Override + public void visitMaxs(int stack, int locals) { + for (CatchBlock b : blocks) { + super.visitTryCatchBlock(b.start, b.end, b.handler, b.type); + } + super.visitMaxs(stack, locals); + } + + static final class CatchBlock { + + final Label start; + final Label end; + final Label handler; + final String type; + + CatchBlock(Label start, Label end, Label handler, String type) { + this.start = start; + this.end = end; + this.handler = handler; + this.type = type; + } + } +} diff --git a/src/share/classes/jdk/jfr/internal/instrument/JIMethodInliningAdapter.java b/src/share/classes/jdk/jfr/internal/instrument/JIMethodInliningAdapter.java new file mode 100644 index 0000000000000000000000000000000000000000..2f5458c4d9012dc68541da1fb90708f0137f137f --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/instrument/JIMethodInliningAdapter.java @@ -0,0 +1,76 @@ +/* + * 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 + * 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.internal.instrument; + +import jdk.internal.org.objectweb.asm.Label; +import jdk.internal.org.objectweb.asm.Opcodes; +import jdk.internal.org.objectweb.asm.Type; +import jdk.internal.org.objectweb.asm.commons.LocalVariablesSorter; +import jdk.internal.org.objectweb.asm.commons.Remapper; +import jdk.internal.org.objectweb.asm.commons.RemappingMethodAdapter; + +@Deprecated +final class JIMethodInliningAdapter extends RemappingMethodAdapter { + private final LocalVariablesSorter lvs; + private final Label end; + + public JIMethodInliningAdapter(LocalVariablesSorter mv, Label end, int acc, String desc, Remapper remapper) { + super(acc, desc, mv, remapper); + this.lvs = mv; + this.end = end; + int offset = isStatic(acc) ? 0 : 1; + Type[] args = Type.getArgumentTypes(desc); + for (int i = args.length - 1; i >= 0; i--) { + super.visitVarInsn(args[i].getOpcode(Opcodes.ISTORE), i + offset); + } + if (offset > 0) { + super.visitVarInsn(Opcodes.ASTORE, 0); + } + } + + private boolean isStatic(int acc) { + return (acc & Opcodes.ACC_STATIC) != 0; + } + + @Override + public void visitInsn(int opcode) { + if (opcode == Opcodes.RETURN || opcode == Opcodes.IRETURN + || opcode == Opcodes.ARETURN || opcode == Opcodes.LRETURN) { + super.visitJumpInsn(Opcodes.GOTO, end); + } else { + super.visitInsn(opcode); + } + } + + @Override + public void visitMaxs(int stack, int locals) { + } + + @Override + protected int newLocalMapping(Type type) { + return lvs.newLocal(type); + } +} diff --git a/src/share/classes/jdk/jfr/internal/instrument/JIMethodMergeAdapter.java b/src/share/classes/jdk/jfr/internal/instrument/JIMethodMergeAdapter.java new file mode 100644 index 0000000000000000000000000000000000000000..9c24cab4f1e36c8e391626be80083a08c3bf14a4 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/instrument/JIMethodMergeAdapter.java @@ -0,0 +1,120 @@ +/* + * 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 + * 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.internal.instrument; + +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jdk.internal.org.objectweb.asm.ClassVisitor; +import jdk.internal.org.objectweb.asm.MethodVisitor; +import jdk.internal.org.objectweb.asm.Opcodes; +import jdk.internal.org.objectweb.asm.Type; +import jdk.internal.org.objectweb.asm.commons.RemappingMethodAdapter; +import jdk.internal.org.objectweb.asm.commons.SimpleRemapper; +import jdk.internal.org.objectweb.asm.tree.ClassNode; +import jdk.internal.org.objectweb.asm.tree.MethodNode; +import jdk.jfr.internal.LogLevel; +import jdk.jfr.internal.LogTag; +import jdk.jfr.internal.Logger; + +/** + * This class will merge (some) methods from one class into another one. + * + * @author Staffan Larsen + */ +@Deprecated +final class JIMethodMergeAdapter extends ClassVisitor { + + private final ClassNode cn; + private final List methodFilter; + private final Map typeMap; + + /** + * Methods in methodFilter that exist in cn will be merged into cv. If the method already exists, + * the original method will be deleted. + * + * @param cv + * @param cn - a ClassNode with Methods that will be merged into this class + * @param methodFilter - only methods in this list will be merged + * @param typeMappings - while merging, type references in the methods will be changed according to this map + */ + public JIMethodMergeAdapter(ClassVisitor cv, ClassNode cn, List methodFilter, JITypeMapping[] typeMappings) { + super(Opcodes.ASM5, cv); + this.cn = cn; + this.methodFilter = methodFilter; + + this.typeMap = new HashMap<>(); + for (JITypeMapping tm : typeMappings) { + typeMap.put(tm.from().replace('.', '/'), tm.to().replace('.', '/')); + } + } + + @Override + public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { + super.visit(version, access, name, signature, superName, interfaces); + typeMap.put(cn.name, name); + } + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + if(methodInFilter(name, desc)) { + // If the method is one that we will be replacing, delete the method + Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.DEBUG, "Deleting " + name + desc); + return null; + } + return super.visitMethod(access, name, desc, signature, exceptions); + } + + @Override + public void visitEnd() { + SimpleRemapper remapper = new SimpleRemapper(typeMap); + for (MethodNode mn : cn.methods) { + // Check if the method is in the list of methods to copy + if (methodInFilter(mn.name, mn.desc)) { + Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.DEBUG, "Copying method: " + mn.name + mn.desc); + Logger.log(LogTag.JFR_SYSTEM_BYTECODE, LogLevel.DEBUG, " with mapper: " + typeMap); + + String[] exceptions = new String[mn.exceptions.size()]; + mn.exceptions.toArray(exceptions); + MethodVisitor mv = cv.visitMethod(mn.access, mn.name, mn.desc, mn.signature, exceptions); + mn.instructions.resetLabels(); + mn.accept(new RemappingMethodAdapter(mn.access, mn.desc, mv, remapper)); + } + } + super.visitEnd(); + } + + private boolean methodInFilter(String name, String desc) { + for(Method m : methodFilter) { + if (m.getName().equals(name) && Type.getMethodDescriptor(m).equals(desc)) { + return true; + } + } + return false; + } +} diff --git a/src/share/classes/jdk/jfr/internal/instrument/JITypeMapping.java b/src/share/classes/jdk/jfr/internal/instrument/JITypeMapping.java new file mode 100644 index 0000000000000000000000000000000000000000..f8a356ac69300854ed76d5be3ad58a48f40f99b1 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/instrument/JITypeMapping.java @@ -0,0 +1,35 @@ +/* + * 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 + * 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.internal.instrument; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +@interface JITypeMapping { + String from(); + String to(); +} diff --git a/src/share/classes/jdk/jfr/internal/instrument/RandomAccessFileInstrumentor.java b/src/share/classes/jdk/jfr/internal/instrument/RandomAccessFileInstrumentor.java new file mode 100644 index 0000000000000000000000000000000000000000..c376700112c1cde5c7517b63a066cc5bbb7d8a18 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/instrument/RandomAccessFileInstrumentor.java @@ -0,0 +1,173 @@ +/* + * 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 + * 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.internal.instrument; + +import java.io.IOException; + +import jdk.jfr.events.FileReadEvent; +import jdk.jfr.events.FileWriteEvent; + +/** + * See {@link JITracer} for an explanation of this code. + */ +@JIInstrumentationTarget("java.io.RandomAccessFile") +final class RandomAccessFileInstrumentor { + + private RandomAccessFileInstrumentor() { + } + + private String path; + + @SuppressWarnings("deprecation") + @JIInstrumentationMethod + public int read() throws IOException { + FileReadEvent event = FileReadEvent.EVENT.get(); + if (!event.isEnabled()) { + return read(); + } + int result = 0; + try { + event.begin(); + result = read(); + if (result < 0) { + event.endOfFile = true; + } else { + event.bytesRead = 1; + } + } finally { + event.path = path; + event.commit(); + event.reset(); + } + return result; + } + + @SuppressWarnings("deprecation") + @JIInstrumentationMethod + public int read(byte b[]) throws IOException { + FileReadEvent event = FileReadEvent.EVENT.get(); + if (!event.isEnabled()) { + return read(b); + } + int bytesRead = 0; + try { + event.begin(); + bytesRead = read(b); + } finally { + if (bytesRead < 0) { + event.endOfFile = true; + } else { + event.bytesRead = bytesRead; + } + event.path = path; + event.commit(); + event.reset(); + } + return bytesRead; + } + + @SuppressWarnings("deprecation") + @JIInstrumentationMethod + public int read(byte b[], int off, int len) throws IOException { + FileReadEvent event = FileReadEvent.EVENT.get(); + if (!event.isEnabled()) { + return read(b, off, len); + } + int bytesRead = 0; + try { + event.begin(); + bytesRead = read(b, off, len); + } finally { + if (bytesRead < 0) { + event.endOfFile = true; + } else { + event.bytesRead = bytesRead; + } + event.path = path; + event.commit(); + event.reset(); + } + return bytesRead; + } + + @SuppressWarnings("deprecation") + @JIInstrumentationMethod + public void write(int b) throws IOException { + FileWriteEvent event = FileWriteEvent.EVENT.get(); + if (!event.isEnabled()) { + write(b); + return; + } + try { + event.begin(); + write(b); + event.bytesWritten = 1; + } finally { + event.path = path; + event.commit(); + event.reset(); + } + } + + @SuppressWarnings("deprecation") + @JIInstrumentationMethod + public void write(byte b[]) throws IOException { + FileWriteEvent event = FileWriteEvent.EVENT.get(); + if (!event.isEnabled()) { + write(b); + return; + } + try { + event.begin(); + write(b); + event.bytesWritten = b.length; + } finally { + event.path = path; + event.commit(); + event.reset(); + } + } + + @SuppressWarnings("deprecation") + @JIInstrumentationMethod + public void write(byte b[], int off, int len) throws IOException { + FileWriteEvent event = FileWriteEvent.EVENT.get(); + if (!event.isEnabled()) { + write(b, off, len); + return; + } + try { + event.begin(); + write(b, off, len); + event.bytesWritten = len; + } finally { + event.path = path; + event.commit(); + event.reset(); + } + } + +} diff --git a/src/share/classes/jdk/jfr/internal/instrument/SocketChannelImplInstrumentor.java b/src/share/classes/jdk/jfr/internal/instrument/SocketChannelImplInstrumentor.java new file mode 100644 index 0000000000000000000000000000000000000000..7291c69e943914a367d3dee0640ab333b63e67bd --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/instrument/SocketChannelImplInstrumentor.java @@ -0,0 +1,174 @@ +/* + * 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 + * 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.internal.instrument; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.nio.ByteBuffer; + +import jdk.jfr.events.SocketReadEvent; +import jdk.jfr.events.SocketWriteEvent; + +/** + * See {@link JITracer} for an explanation of this code. + */ +@JIInstrumentationTarget("sun.nio.ch.SocketChannelImpl") +final class SocketChannelImplInstrumentor { + + private SocketChannelImplInstrumentor() { + } + + private InetSocketAddress remoteAddress; + + @SuppressWarnings("deprecation") + @JIInstrumentationMethod + public int read(ByteBuffer dst) throws IOException { + SocketReadEvent event = SocketReadEvent.EVENT.get(); + if (!event.isEnabled()) { + return read(dst); + } + int bytesRead = 0; + try { + event.begin(); + bytesRead = read(dst); + } finally { + event.end(); + if (event.shouldCommit()) { + String hostString = remoteAddress.getAddress().toString(); + int delimiterIndex = hostString.lastIndexOf('/'); + + event.host = hostString.substring(0, delimiterIndex); + event.address = hostString.substring(delimiterIndex + 1); + event.port = remoteAddress.getPort(); + if (bytesRead < 0) { + event.endOfStream = true; + } else { + event.bytesRead = bytesRead; + } + event.timeout = 0; + + event.commit(); + event.reset(); + } + } + return bytesRead; + } + + @SuppressWarnings("deprecation") + @JIInstrumentationMethod + public long read(ByteBuffer[] dsts, int offset, int length) throws IOException { + SocketReadEvent event = SocketReadEvent.EVENT.get(); + if(!event.isEnabled()) { + return read(dsts, offset, length); + } + + long bytesRead = 0; + try { + event.begin(); + bytesRead = read(dsts, offset, length); + } finally { + event.end(); + if (event.shouldCommit()) { + String hostString = remoteAddress.getAddress().toString(); + int delimiterIndex = hostString.lastIndexOf('/'); + + event.host = hostString.substring(0, delimiterIndex); + event.address = hostString.substring(delimiterIndex + 1); + event.port = remoteAddress.getPort(); + if (bytesRead < 0) { + event.endOfStream = true; + } else { + event.bytesRead = bytesRead; + } + event.timeout = 0; + + event.commit(); + event.reset(); + } + } + return bytesRead; + } + + @SuppressWarnings("deprecation") + @JIInstrumentationMethod + public int write(ByteBuffer buf) throws IOException { + SocketWriteEvent event = SocketWriteEvent.EVENT.get(); + if (!event.isEnabled()) { + return write(buf); + } + + int bytesWritten = 0; + try { + event.begin(); + bytesWritten = write(buf); + } finally { + event.end(); + if (event.shouldCommit()) { + String hostString = remoteAddress.getAddress().toString(); + int delimiterIndex = hostString.lastIndexOf('/'); + + event.host = hostString.substring(0, delimiterIndex); + event.address = hostString.substring(delimiterIndex + 1); + event.port = remoteAddress.getPort(); + event.bytesWritten = bytesWritten < 0 ? 0 : bytesWritten; + + event.commit(); + event.reset(); + } + } + return bytesWritten; + } + + @SuppressWarnings("deprecation") + @JIInstrumentationMethod + public long write(ByteBuffer[] srcs, int offset, int length) throws IOException { + SocketWriteEvent event = SocketWriteEvent.EVENT.get(); + if (!event.isEnabled()) { + return write(srcs, offset, length); + } + long bytesWritten = 0; + try { + event.begin(); + bytesWritten = write(srcs, offset, length); + } finally { + event.end(); + if (event.shouldCommit()) { + String hostString = remoteAddress.getAddress().toString(); + int delimiterIndex = hostString.lastIndexOf('/'); + + event.host = hostString.substring(0, delimiterIndex); + event.address = hostString.substring(delimiterIndex + 1); + event.port = remoteAddress.getPort(); + event.bytesWritten = bytesWritten < 0 ? 0 : bytesWritten; + + event.commit(); + event.reset(); + } + } + return bytesWritten; + } + +} diff --git a/src/share/classes/jdk/jfr/internal/instrument/SocketInputStreamInstrumentor.java b/src/share/classes/jdk/jfr/internal/instrument/SocketInputStreamInstrumentor.java new file mode 100644 index 0000000000000000000000000000000000000000..618d5567a71c419f5efb03de759be3364429d39c --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/instrument/SocketInputStreamInstrumentor.java @@ -0,0 +1,88 @@ +/* + * 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 + * 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.internal.instrument; + +import java.io.IOException; +import java.net.InetAddress; + +import jdk.jfr.events.SocketReadEvent; + +/** + * See {@link JITracer} for an explanation of this code. + */ +@JIInstrumentationTarget("java.net.SocketInputStream") +@JITypeMapping(from = "jdk.jfr.internal.instrument.SocketInputStreamInstrumentor$AbstractPlainSocketImpl", + to = "java.net.AbstractPlainSocketImpl") +final class SocketInputStreamInstrumentor { + + private SocketInputStreamInstrumentor() { + } + + @SuppressWarnings("deprecation") + @JIInstrumentationMethod + int read(byte b[], int off, int length, int timeout) throws IOException { + SocketReadEvent event = SocketReadEvent.EVENT.get(); + if (!event.isEnabled()) { + return read(b, off, length, timeout); + } + int bytesRead = 0; + try { + event.begin(); + bytesRead = read(b, off, length, timeout); + } finally { + event.end(); + if (event.shouldCommit()) { + String hostString = impl.address.toString(); + int delimiterIndex = hostString.lastIndexOf('/'); + + event.host = hostString.substring(0, delimiterIndex); + event.address = hostString.substring(delimiterIndex + 1); + event.port = impl.port; + if (bytesRead < 0) { + event.endOfStream = true; + } else { + event.bytesRead = bytesRead; + } + event.timeout = timeout; + + event.commit(); + event.reset(); + } + } + return bytesRead; + } + + private AbstractPlainSocketImpl impl = null; + + void silenceFindBugsUnwrittenField(InetAddress dummy) { + impl.address = dummy; + } + + static class AbstractPlainSocketImpl { + InetAddress address; + int port; + } +} diff --git a/src/share/classes/jdk/jfr/internal/instrument/SocketOutputStreamInstrumentor.java b/src/share/classes/jdk/jfr/internal/instrument/SocketOutputStreamInstrumentor.java new file mode 100644 index 0000000000000000000000000000000000000000..a0f62cadc4bb6b8125df148c1c5c6d8140250274 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/instrument/SocketOutputStreamInstrumentor.java @@ -0,0 +1,84 @@ +/* + * 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 + * 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.internal.instrument; + +import java.io.IOException; +import java.net.InetAddress; + +import jdk.jfr.events.SocketWriteEvent; + +/** + * See {@link JITracer} for an explanation of this code. + */ +@JIInstrumentationTarget("java.net.SocketOutputStream") +@JITypeMapping(from = "jdk.jfr.internal.instrument.SocketOutputStreamInstrumentor$AbstractPlainSocketImpl", + to = "java.net.AbstractPlainSocketImpl") +final class SocketOutputStreamInstrumentor { + + private SocketOutputStreamInstrumentor() { + } + + @SuppressWarnings("deprecation") + @JIInstrumentationMethod + private void socketWrite(byte b[], int off, int len) throws IOException { + SocketWriteEvent event = SocketWriteEvent.EVENT.get(); + if (!event.isEnabled()) { + socketWrite(b, off, len); + return; + } + int bytesWritten = 0; + try { + event.begin(); + socketWrite(b, off, len); + bytesWritten = len; + } finally { + event.end() ; + if (event.shouldCommit()) { + String hostString = impl.address.toString(); + int delimiterIndex = hostString.lastIndexOf('/'); + + event.host = hostString.substring(0, delimiterIndex); + event.address = hostString.substring(delimiterIndex + 1); + event.port = impl.port; + event.bytesWritten = bytesWritten < 0 ? 0 : bytesWritten; + + event.commit(); + event.reset(); + } + } + } + + private AbstractPlainSocketImpl impl = null; + + void silenceFindBugsUnwrittenField(InetAddress dummy) { + impl.address = dummy; + } + + static class AbstractPlainSocketImpl { + InetAddress address; + int port; + } +} diff --git a/src/share/classes/jdk/jfr/internal/instrument/ThrowableTracer.java b/src/share/classes/jdk/jfr/internal/instrument/ThrowableTracer.java new file mode 100644 index 0000000000000000000000000000000000000000..236082738da9cc1653fc0a61843856eddce90975 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/instrument/ThrowableTracer.java @@ -0,0 +1,64 @@ +/* + * 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 + * 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.internal.instrument; + +import java.util.concurrent.atomic.AtomicLong; + +import jdk.jfr.events.ErrorThrownEvent; +import jdk.jfr.events.ExceptionThrownEvent; + +public final class ThrowableTracer { + + private static AtomicLong numThrowables = new AtomicLong(0); + + public static void traceError(Error e, String message) { + if (e instanceof OutOfMemoryError) { + return; + } + ErrorThrownEvent errorEvent = new ErrorThrownEvent(); + errorEvent.message = message; + errorEvent.thrownClass = e.getClass(); + errorEvent.commit(); + + ExceptionThrownEvent exceptionEvent = new ExceptionThrownEvent(); + exceptionEvent.message = message; + exceptionEvent.thrownClass = e.getClass(); + exceptionEvent.commit(); + numThrowables.incrementAndGet(); + } + + public static void traceThrowable(Throwable t, String message) { + ExceptionThrownEvent event = new ExceptionThrownEvent(); + event.message = message; + event.thrownClass = t.getClass(); + event.commit(); + numThrowables.incrementAndGet(); + } + + public static long numThrowables() { + return numThrowables.get(); + } +} diff --git a/src/share/classes/jdk/jfr/internal/jfc/JFC.java b/src/share/classes/jdk/jfr/internal/jfc/JFC.java new file mode 100644 index 0000000000000000000000000000000000000000..83cb63097cb411e6c4c3d3c0acaa496c8bdafe2a --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/jfc/JFC.java @@ -0,0 +1,247 @@ +/* + * 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. 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.internal.jfc; + +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.NoSuchFileException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import jdk.jfr.Configuration; +import jdk.jfr.internal.LogLevel; +import jdk.jfr.internal.LogTag; +import jdk.jfr.internal.Logger; +import jdk.jfr.internal.SecuritySupport; +import jdk.jfr.internal.SecuritySupport.SafePath; + +/** + * {@link Configuration} factory for JFC files. * + */ +public final class JFC { + private static final int BUFFER_SIZE = 8192; + private static final int MAXIMUM_FILE_SIZE = 1024 * 1024; + private static final int MAX_BUFFER_SIZE = Integer.MAX_VALUE - 8; + private static volatile List knownConfigurations; + + /** + * Reads a known configuration file (located into a string, but doesn't + * parse it until it's being used. + */ + private static final class KnownConfiguration { + private final String content; + private final String filename; + private final String name; + private Configuration configuration; + + public KnownConfiguration(SafePath knownPath) throws IOException { + this.content = readContent(knownPath); + this.name = nameFromPath(knownPath.toPath()); + this.filename = nullSafeFileName(knownPath.toPath()); + } + + public boolean isNamed(String name) { + return filename.equals(name) || this.name.equals(name); + } + + public Configuration getConfigurationFile() throws IOException, ParseException { + if (configuration == null) { + configuration = JFCParser.createConfiguration(name, content); + } + return configuration; + } + + public String getName() { + return name; + } + + private static String readContent(SafePath knownPath) throws IOException { + if (SecuritySupport.getFileSize(knownPath) > MAXIMUM_FILE_SIZE) { + throw new IOException("Configuration with more than " + + MAXIMUM_FILE_SIZE + " characters can't be read."); + } + try (InputStream r = SecuritySupport.newFileInputStream(knownPath)) { + return JFC.readContent(r); + } + } + } + + private JFC() { + // private utility class + } + + /** + * Reads a configuration from a file. + * + * @param path the file containing the configuration, not {@code null} + * @return {@link Configuration}, not {@code null} + * @throws ParseException if the file can't be parsed + * @throws IOException if the file can't be read + * + * @throws SecurityException if a security manager exists and its + * checkRead method denies read access to the file. + * @see java.io.File#getPath() + * @see java.lang.SecurityManager#checkRead(java.lang.String) + */ + public static Configuration create(String name, Reader reader) throws IOException, ParseException { + return JFCParser.createConfiguration(name, reader); + } + + private static String nullSafeFileName(Path file) throws IOException { + Path filename = file.getFileName(); + if (filename == null) { + throw new IOException("Path has no file name"); + } + return filename.toString(); + } + + public static String nameFromPath(Path file) throws IOException { + String f = nullSafeFileName(file); + if (f.endsWith(JFCParser.FILE_EXTENSION)) { + return f.substring(0, f.length() - JFCParser.FILE_EXTENSION.length()); + } else { + return f; + } + } + + // Invoked by DCmdStart + public static Configuration createKnown(String name) throws IOException, ParseException { + // Known name, no need for permission + for (KnownConfiguration known : getKnownConfigurations()) { + if (known.isNamed(name)) { + return known.getConfigurationFile(); + } + } + // Check JFC directory + SafePath path = SecuritySupport.JFC_DIRECTORY; + if (path != null && SecuritySupport.exists(path)) { + for (String extension : Arrays.asList("", JFCParser.FILE_EXTENSION)) { + SafePath file = new SafePath(path.toPath().resolveSibling(name + extension)); + if (SecuritySupport.exists(file) && !SecuritySupport.isDirectory(file)) { + try (Reader r = SecuritySupport.newFileReader(file)) { + String jfcName = nameFromPath(file.toPath()); + return JFCParser.createConfiguration(jfcName, r); + } + } + } + } + + // Assume path included in name + + Path localPath = Paths.get(name); + String jfcName = nameFromPath(localPath); + try (Reader r = Files.newBufferedReader(localPath)) { + return JFCParser.createConfiguration(jfcName, r); + } + } + + private static String readContent(InputStream source) throws IOException { + byte[] bytes = read(source, BUFFER_SIZE); + return new String(bytes, StandardCharsets.UTF_8); + } + + // copied from java.io.file.Files to avoid dependency on JDK 9 code + private static byte[] read(InputStream source, int initialSize) throws IOException { + int capacity = initialSize; + byte[] buf = new byte[capacity]; + int nread = 0; + int n; + for (;;) { + // read to EOF which may read more or less than initialSize (eg: file + // is truncated while we are reading) + while ((n = source.read(buf, nread, capacity - nread)) > 0) + nread += n; + + // if last call to source.read() returned -1, we are done + // otherwise, try to read one more byte; if that failed we're done too + if (n < 0 || (n = source.read()) < 0) + break; + + // one more byte was read; need to allocate a larger buffer + if (capacity <= MAX_BUFFER_SIZE - capacity) { + capacity = Math.max(capacity << 1, BUFFER_SIZE); + } else { + if (capacity == MAX_BUFFER_SIZE) + throw new OutOfMemoryError("Required array size too large"); + capacity = MAX_BUFFER_SIZE; + } + buf = Arrays.copyOf(buf, capacity); + buf[nread++] = (byte)n; + } + return (capacity == nread) ? buf : Arrays.copyOf(buf, nread); + } + + + /** + * Returns list of predefined configurations available. + * + * @return list of configurations, not null + */ + public static List getConfigurations() { + List configs = new ArrayList<>(); + for (KnownConfiguration knownConfig : getKnownConfigurations()) { + try { + configs.add(knownConfig.getConfigurationFile()); + } catch (IOException e) { + Logger.log(LogTag.JFR, LogLevel.WARN, "Could not load configuration " + knownConfig.getName() + ". " + e.getMessage()); + } catch (ParseException e) { + Logger.log(LogTag.JFR, LogLevel.WARN, "Could not parse configuration " + knownConfig.getName() + ". " + e.getMessage()); + } + } + return configs; + } + + private static List getKnownConfigurations() { + if (knownConfigurations == null) { + List configProxies = new ArrayList<>(); + for (SafePath p : SecuritySupport.getPredefinedJFCFiles()) { + try { + configProxies.add(new KnownConfiguration(p)); + } catch (IOException ioe) { + // ignore + } + } + knownConfigurations = configProxies; + } + return knownConfigurations; + } + + public static Configuration getPredefined(String name) throws IOException, ParseException { + for (KnownConfiguration knownConfig : getKnownConfigurations()) { + if (knownConfig.getName().equals(name)) { + return knownConfig.getConfigurationFile(); + } + } + throw new NoSuchFileException("Could not locate configuration with name " + name); + } +} diff --git a/src/share/classes/jdk/jfr/internal/jfc/JFCParser.java b/src/share/classes/jdk/jfr/internal/jfc/JFCParser.java new file mode 100644 index 0000000000000000000000000000000000000000..812f3008c203907eecd6b769c9e0a2cc4cd219ea --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/jfc/JFCParser.java @@ -0,0 +1,85 @@ +/* + * 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 + * 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.internal.jfc; + +import java.io.CharArrayReader; +import java.io.CharArrayWriter; +import java.io.IOException; +import java.io.Reader; +import java.text.ParseException; +import jdk.internal.org.xml.sax.InputSource; +import jdk.internal.org.xml.sax.SAXException; +import jdk.internal.util.xml.SAXParser; +import jdk.internal.util.xml.impl.SAXParserImpl; +import jdk.jfr.Configuration; + +import jdk.jfr.internal.PrivateAccess; + +/** + * Parses a JDK Flight Recorder Configuration file (.jfc) + */ +final class JFCParser { + static final String FILE_EXTENSION = ".jfc"; + private static final int MAXIMUM_FILE_SIZE = 1024 * 1024; + + public static Configuration createConfiguration(String name, Reader reader) throws IOException, ParseException { + return createConfiguration(name, readContent(reader)); + } + + public static Configuration createConfiguration(String name, String content) throws IOException, ParseException { + try { + JFCParserHandler ch = new JFCParserHandler(); + parseXML(content, ch); + return PrivateAccess.getInstance().newConfiguration(name, ch.label, ch.description, ch.provider, ch.settings, content); + } catch (IllegalArgumentException iae) { + throw new ParseException(iae.getMessage(), -1); + } catch (SAXException e) { + ParseException pe = new ParseException("Error reading JFC file. " + e.getMessage(), -1); + pe.initCause(e); + throw pe; + } + } + + private static void parseXML(String content, JFCParserHandler ch) throws SAXException, IOException { + CharArrayReader r = new CharArrayReader(content.toCharArray()); + SAXParser parser = new SAXParserImpl(); + parser.parse(new InputSource(r), ch); + } + + private static String readContent(Reader r) throws IOException { + CharArrayWriter writer = new CharArrayWriter(1024); + int count = 0; + int ch; + while ((ch = r.read()) != -1) { + writer.write(ch); + count++; + if (count >= MAXIMUM_FILE_SIZE) { + throw new IOException("Presets with more than " + MAXIMUM_FILE_SIZE + " characters can't be read."); + } + } + return new String(writer.toCharArray()); + } +} diff --git a/src/share/classes/jdk/jfr/internal/jfc/JFCParserHandler.java b/src/share/classes/jdk/jfr/internal/jfc/JFCParserHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..f85cefa5a6d69a8934ab2ff02523dfce4527043b --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/jfc/JFCParserHandler.java @@ -0,0 +1,106 @@ +/* + * 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. 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.internal.jfc; +import java.util.LinkedHashMap; +import java.util.Map; + +import jdk.internal.org.xml.sax.Attributes; +import jdk.internal.org.xml.sax.SAXException; +import jdk.internal.org.xml.sax.helpers.DefaultHandler; + +final class JFCParserHandler extends DefaultHandler { + private static final String ELEMENT_CONFIGURATION = "configuration"; + private static final String ELEMENT_EVENT_TYPE = "event"; + private static final String ELEMENT_SETTING = "setting"; + private static final String ATTRIBUTE_NAME = "name"; + private static final String ATTRIBUTE_LABEL = "label"; + private static final String ATTRIBUTE_DESCRIPTION = "description"; + private static final String ATTRIBUTE_PROVIDER = "provider"; + private static final String ATTRIBUTE_VERSION = "version"; + + final Map settings = new LinkedHashMap(); + private String currentEventPath; + private String currentSettingsName; + private StringBuilder currentCharacters; + String label; + String provider; + String description; + + @Override + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { + switch (qName.toLowerCase()) { + case ELEMENT_CONFIGURATION: + String version = attributes.getValue(ATTRIBUTE_VERSION); + if (version == null || !version.startsWith("2.")) { + throw new SAXException("This version of Flight Recorder can only read JFC file format version 2.x"); + } + label = attributes.getValue(ATTRIBUTE_LABEL); + description = getOptional(attributes, ATTRIBUTE_DESCRIPTION, ""); + provider = getOptional(attributes, ATTRIBUTE_PROVIDER, ""); + break; + case ELEMENT_EVENT_TYPE: + currentEventPath = attributes.getValue(ATTRIBUTE_NAME); + break; + case ELEMENT_SETTING: + currentSettingsName = attributes.getValue(ATTRIBUTE_NAME); + break; + } + currentCharacters = null; + } + + private String getOptional(Attributes attributes, String name, String defaultValue) { + String value = attributes.getValue(name); + return value == null ? defaultValue : value; + } + + @Override + public void characters(char[] ch, int start, int length) throws SAXException { + if (currentCharacters == null) { + currentCharacters = new StringBuilder(length); + } + currentCharacters.append(ch, start, length); + } + + @Override + public void endElement(String uri, String localName, String qName) { + switch (qName.toLowerCase()) { + case ELEMENT_CONFIGURATION: + break; + case ELEMENT_EVENT_TYPE: + currentEventPath = null; + break; + case ELEMENT_SETTING: + String settingsValue = currentCharacters == null ? "" : currentCharacters.toString(); + settings.put(currentEventPath + "#" + currentSettingsName, "" + settingsValue); + currentSettingsName = null; + break; + } + } + + public Map getSettings() { + return settings; + } +} diff --git a/src/share/classes/jdk/jfr/internal/jfc/jfc.xsd b/src/share/classes/jdk/jfr/internal/jfc/jfc.xsd new file mode 100644 index 0000000000000000000000000000000000000000..ee47ba506ebd5667aec0cb134943015d5a03062b --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/jfc/jfc.xsd @@ -0,0 +1,177 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/share/classes/jdk/jfr/internal/jfc/package-info.java b/src/share/classes/jdk/jfr/internal/jfc/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..cac7467f9bdf24c76cebe4c9cdd5ebf59b64d623 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/jfc/package-info.java @@ -0,0 +1,31 @@ +/* + * 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 + * 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 package contains classes for configuring Flight Recorder using JFC-files. + * + * @since 8 + */ +package jdk.jfr.internal.jfc; diff --git a/src/share/classes/jdk/jfr/internal/management/ManagementSupport.java b/src/share/classes/jdk/jfr/internal/management/ManagementSupport.java new file mode 100644 index 0000000000000000000000000000000000000000..ccbdd1a78d760943a62853c0dced687db8941509 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/management/ManagementSupport.java @@ -0,0 +1,89 @@ +/* + * 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. 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.internal.management; + +import java.time.Duration; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import jdk.jfr.EventType; +import jdk.jfr.internal.JVMSupport; +import jdk.jfr.internal.LogLevel; +import jdk.jfr.internal.LogTag; +import jdk.jfr.internal.Logger; +import jdk.jfr.internal.MetadataRepository; +import jdk.jfr.internal.Utils; +import jdk.jfr.internal.instrument.JDKEvents; + +/** + * The management API in module jdk.management.jfr should be built on top of the + * public API in jdk.jfr. Before putting more functionality here, consider if it + * should not be part of the public API, and if not, please provide motivation + * + */ +public final class ManagementSupport { + + // Purpose of this method is to expose the event types to the + // FlightRecorderMXBean without instantiating Flight Recorder. + // + // This allows: + // + // 1) discoverability, so event settings can be exposed without the need to + // create a new Recording in FlightrecorderMXBean. + // + // 2) a graphical JMX client to list all attributes to the user, without + // loading JFR memory buffers. This is especially important when there is + // no intent to use Flight Recorder. + // + // An alternative design would be to make FlightRecorder#getEventTypes + // static, but it would the make the API look strange + // + public static List getEventTypes() { + // would normally be checked when a Flight Recorder instance is created + Utils.checkAccessFlightRecorder(); + if (JVMSupport.isNotAvailable()) { + return new ArrayList<>(); + } + JDKEvents.initialize(); // make sure JDK events are available + return Collections.unmodifiableList(MetadataRepository.getInstance().getRegisteredEventTypes()); + } + + // Reuse internal code for parsing a timespan + public static long parseTimespan(String s) { + return Utils.parseTimespan(s); + } + + // Reuse internal code for formatting settings + public static final String formatTimespan(Duration dValue, String separation) { + return Utils.formatTimespan(dValue, separation); + } + + // Reuse internal logging mechanism + public static void logError(String message) { + Logger.log(LogTag.JFR, LogLevel.ERROR, message); + } +} diff --git a/src/share/classes/jdk/jfr/internal/settings/BooleanValue.java b/src/share/classes/jdk/jfr/internal/settings/BooleanValue.java new file mode 100644 index 0000000000000000000000000000000000000000..d8f46d76787cd690ca02a2fff028aee6dcd708e7 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/settings/BooleanValue.java @@ -0,0 +1,74 @@ +/* + * 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. 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.internal.settings; + +import java.util.Set; + +/** + * Helper class for settings that use boolean numbers + * + */ +final class BooleanValue { + private String value = "false"; + private boolean booleanValue; + + private BooleanValue(boolean b) { + booleanValue = b; + value = b ? "true" : "false"; + } + + public String union(Set values) { + for (String v : values) { + if ("true".equals(v)) { + return "true"; + } + } + return "false"; + } + + public void setValue(String value) { + this.value = value; + this.booleanValue = Boolean.valueOf(value); + } + + public final String getValue() { + return this.value; + } + + public boolean getBoolean() { + return booleanValue; + } + + public static BooleanValue valueOf(String defaultValue) { + if ("true".equals(defaultValue)) { + return new BooleanValue(true); + } + if ("false".equals(defaultValue)) { + return new BooleanValue(false); + } + throw new InternalError("Unknown default value for settings '" + defaultValue + "'"); + } +} diff --git a/src/share/classes/jdk/jfr/internal/settings/CutoffSetting.java b/src/share/classes/jdk/jfr/internal/settings/CutoffSetting.java new file mode 100644 index 0000000000000000000000000000000000000000..7be4a6ce2eae6798385d4237628a1508d3c4720b --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/settings/CutoffSetting.java @@ -0,0 +1,97 @@ +/* + * 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.internal.settings; + +import java.util.Objects; +import java.util.Set; + +import jdk.jfr.Description; +import jdk.jfr.Label; +import jdk.jfr.MetadataDefinition; +import jdk.jfr.Name; +import jdk.jfr.Timespan; +import jdk.jfr.internal.Control; +import jdk.jfr.internal.PlatformEventType; +import jdk.jfr.internal.Type; +import jdk.jfr.internal.Utils; + +@MetadataDefinition +@Label("Cutoff") +@Description("Limit running time of event") +@Name(Type.SETTINGS_PREFIX + "Cutoff") +@Timespan +public final class CutoffSetting extends Control { + private final static long typeId = Type.getTypeId(CutoffSetting.class); + + private String value = "0 ns"; + private final PlatformEventType eventType; + + public CutoffSetting(PlatformEventType eventType, String defaultValue) { + super(defaultValue); + this.eventType = Objects.requireNonNull(eventType); + } + + @Override + public String combine(Set values) { + long max = 0; + String text = "0 ns"; + for (String value : values) { + long l = Utils.parseTimespanWithInfinity(value); + if (l > max) { + text = value; + max = l; + } + } + return text; + } + + @Override + public void setValue(String value) { + long l = Utils.parseTimespanWithInfinity(value); + this.value = value; + eventType.setCutoff(l); + } + + @Override + public String getValue() { + return value; + } + + public static boolean isType(long typeId) { + return CutoffSetting.typeId == typeId; + } + + public static long parseValueSafe(String value) { + if (value == null) { + return 0L; + } + try { + return Utils.parseTimespanWithInfinity(value); + } catch (NumberFormatException nfe) { + return 0L; + } + } +} diff --git a/src/share/classes/jdk/jfr/internal/settings/EnabledSetting.java b/src/share/classes/jdk/jfr/internal/settings/EnabledSetting.java new file mode 100644 index 0000000000000000000000000000000000000000..3688c3fbdfadf028e3442246e8e20ec6fb0543f1 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/settings/EnabledSetting.java @@ -0,0 +1,75 @@ +/* + * 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. 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.internal.settings; + +import java.util.Objects; +import java.util.Set; + +import jdk.jfr.Description; +import jdk.jfr.BooleanFlag; +import jdk.jfr.Label; +import jdk.jfr.MetadataDefinition; +import jdk.jfr.Name; +import jdk.jfr.internal.PlatformEventType; +import jdk.jfr.internal.Type; +import jdk.jfr.internal.Control; + +@MetadataDefinition +@Label("Enabled") +@Description("Record event") +@Name(Type.SETTINGS_PREFIX + "Enabled") +@BooleanFlag +public final class EnabledSetting extends Control { + private final BooleanValue booleanValue; + private final PlatformEventType eventType; + + public EnabledSetting(PlatformEventType eventType, String defaultValue) { + super(defaultValue); + this.booleanValue = BooleanValue.valueOf(defaultValue); + this.eventType = Objects.requireNonNull(eventType); + } + + @Override + public String combine(Set values) { + return booleanValue.union(values); + } + + @Override + public void setValue(String value) { + booleanValue.setValue(value); + eventType.setEnabled(booleanValue.getBoolean()); + if (eventType.isEnabled() && !eventType.isJVM()) { + if (!eventType.isInstrumented()) { + eventType.markForInstrumentation(true); + } + } + } + + @Override + public String getValue() { + return booleanValue.getValue(); + } +} diff --git a/src/share/classes/jdk/jfr/internal/settings/PeriodSetting.java b/src/share/classes/jdk/jfr/internal/settings/PeriodSetting.java new file mode 100644 index 0000000000000000000000000000000000000000..f33a0f9c616b4f0144630a02e12e619fdd4b1c20 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/settings/PeriodSetting.java @@ -0,0 +1,136 @@ +/* + * 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. 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.internal.settings; + +import java.util.Objects; +import java.util.Set; + +import jdk.jfr.Description; +import jdk.jfr.Label; +import jdk.jfr.MetadataDefinition; +import jdk.jfr.Name; +import jdk.jfr.internal.PlatformEventType; +import jdk.jfr.internal.Control; +import jdk.jfr.internal.Type; +import jdk.jfr.internal.Utils; + +@MetadataDefinition +@Label("Period") +@Description("Record event at interval") +@Name(Type.SETTINGS_PREFIX + "Period") +public final class PeriodSetting extends Control { + private static final long typeId = Type.getTypeId(PeriodSetting.class); + + public static final String EVERY_CHUNK = "everyChunk"; + public static final String BEGIN_CHUNK = "beginChunk"; + public static final String END_CHUNK = "endChunk"; + public static final String NAME = "period"; + private final PlatformEventType eventType; + private String value = EVERY_CHUNK; + + public PeriodSetting(PlatformEventType eventType, String defaultValue) { + super(defaultValue); + this.eventType = Objects.requireNonNull(eventType); + } + + @Override + public String combine(Set values) { + + boolean beginChunk = false; + boolean endChunk = false; + Long min = null; + String text = null; + for (String value : values) { + switch (value) { + case EVERY_CHUNK: + beginChunk = true; + endChunk = true; + break; + case BEGIN_CHUNK: + beginChunk = true; + break; + case END_CHUNK: + endChunk = true; + break; + default: + long l = Utils.parseTimespanWithInfinity(value); + // Always accept first specified value + if (min == null) { + text = value; + min = l; + } else { + if (l < min) { + text = value; + min = l; + } + } + } + } + // A specified interval trumps *_CHUNK + if (min != null) { + return text; + } + if (beginChunk && !endChunk) { + return BEGIN_CHUNK; + } + if (!beginChunk && endChunk) { + return END_CHUNK; + } + return EVERY_CHUNK; // also default + } + + @Override + public void setValue(String value) { + switch (value) { + case EVERY_CHUNK: + eventType.setPeriod(0, true, true); + break; + case BEGIN_CHUNK: + eventType.setPeriod(0, true, false); + break; + case END_CHUNK: + eventType.setPeriod(0, false, true); + break; + default: + long nanos = Utils.parseTimespanWithInfinity(value); + if (nanos != Long.MAX_VALUE) { + eventType.setPeriod(nanos / 1_000_000, false, false); + } else { + eventType.setPeriod(Long.MAX_VALUE, false, false); + } + } + this.value = value; + } + + @Override + public String getValue() { + return value; + } + + public static boolean isType(long typeId) { + return PeriodSetting.typeId == typeId; + } +} diff --git a/src/share/classes/jdk/jfr/internal/settings/StackTraceSetting.java b/src/share/classes/jdk/jfr/internal/settings/StackTraceSetting.java new file mode 100644 index 0000000000000000000000000000000000000000..07c73ee13f89a54cb0f0b1d9b03b60683142e8d2 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/settings/StackTraceSetting.java @@ -0,0 +1,75 @@ +/* + * 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. 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.internal.settings; + +import java.util.Objects; +import java.util.Set; + +import jdk.jfr.Description; +import jdk.jfr.BooleanFlag; +import jdk.jfr.Label; +import jdk.jfr.MetadataDefinition; +import jdk.jfr.Name; +import jdk.jfr.internal.PlatformEventType; +import jdk.jfr.internal.Control; +import jdk.jfr.internal.Type; + +@MetadataDefinition +@Label("Stack Trace") +@Name(Type.SETTINGS_PREFIX + "StackTrace") +@Description("Record stack traces") +@BooleanFlag +public final class StackTraceSetting extends Control { + private final static long typeId = Type.getTypeId(StackTraceSetting.class); + private final BooleanValue booleanValue; + private final PlatformEventType eventType; + + public StackTraceSetting(PlatformEventType eventType, String defaultValue) { + super(defaultValue); + this.booleanValue = BooleanValue.valueOf(defaultValue); + this.eventType = Objects.requireNonNull(eventType); + } + + @Override + public String combine(Set values) { + return booleanValue.union(values); + } + + @Override + public void setValue(String value) { + booleanValue.setValue(value); + eventType.setStackTraceEnabled(booleanValue.getBoolean()); + } + + @Override + public String getValue() { + return booleanValue.getValue(); + } + + public static boolean isType(long typeId) { + return StackTraceSetting.typeId == typeId; + } +} diff --git a/src/share/classes/jdk/jfr/internal/settings/ThresholdSetting.java b/src/share/classes/jdk/jfr/internal/settings/ThresholdSetting.java new file mode 100644 index 0000000000000000000000000000000000000000..84479b55781f0057ed988ed92d499ac1393890c5 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/settings/ThresholdSetting.java @@ -0,0 +1,90 @@ +/* + * 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. 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.internal.settings; + +import java.util.Objects; +import java.util.Set; + +import jdk.jfr.Description; +import jdk.jfr.Label; +import jdk.jfr.MetadataDefinition; +import jdk.jfr.Name; +import jdk.jfr.Timespan; +import jdk.jfr.internal.PlatformEventType; +import jdk.jfr.internal.Control; +import jdk.jfr.internal.Type; +import jdk.jfr.internal.Utils; +@MetadataDefinition +@Label("Threshold") +@Name(Type.SETTINGS_PREFIX + "Threshold") +@Description("Record event with duration above or equal to threshold") +@Timespan +public final class ThresholdSetting extends Control { + private final static long typeId = Type.getTypeId(ThresholdSetting.class); + private String value = "0 ns"; + private final PlatformEventType eventType; + + public ThresholdSetting(PlatformEventType eventType, String defaultValue) { + super(defaultValue); + this.eventType = Objects.requireNonNull(eventType); + } + + @Override + public String combine(Set values) { + Long min = null; + String text = null; + for (String value : values) { + long l = Utils.parseTimespanWithInfinity(value); + // always accept first value + if (min == null) { + min = l; + text = value; + } else { + if (l < min) { + text = value; + min = l; + } + } + } + return text == null ? "0 ns" : text; + } + + @Override + public void setValue(String value) { + long l = Utils.parseTimespanWithInfinity(value); + this.value = value; + eventType.setThreshold(l); + } + + @Override + public String getValue() { + return value; + } + + public static boolean isType(long typeId) { + return ThresholdSetting.typeId == typeId; + } +} diff --git a/src/share/classes/jdk/jfr/internal/test/WhiteBox.java b/src/share/classes/jdk/jfr/internal/test/WhiteBox.java new file mode 100644 index 0000000000000000000000000000000000000000..4cd3c6f6667c8e582b57d2d5fb08fec31a1b2f2d --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/test/WhiteBox.java @@ -0,0 +1,48 @@ +/* + * 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.internal.test; + +public final class WhiteBox { + + private static boolean writeAllObjectSamples; + + /** + * If OldObjectSample event is enabled, calling this method + * ensures that all object samples are written, including short-lived objects. + * Purpose of this method is to increase determinism in tests. + * + * @param writeAllObjectSamples if all samples should be written or not + * + */ + public static void setWriteAllObjectSamples(boolean writeAllSamples) { + writeAllObjectSamples = writeAllSamples; + } + + public static boolean getWriteAllObjectSamples() { + return writeAllObjectSamples; + } + +} diff --git a/src/share/classes/jdk/jfr/internal/tool/Assemble.java b/src/share/classes/jdk/jfr/internal/tool/Assemble.java new file mode 100644 index 0000000000000000000000000000000000000000..44a834d9f8689becaa33480cea0b3e0186562736 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/tool/Assemble.java @@ -0,0 +1,127 @@ +/* + * 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. 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.internal.tool; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.nio.channels.FileChannel; +import java.nio.file.DirectoryStream; +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.Deque; +import java.util.List; + +final class Assemble extends Command { + + @Override + public String getName() { + return "assemble"; + } + + @Override + public List getOptionSyntax() { + return Collections.singletonList(" "); + } + + @Override + public String getDescription() { + return "Assemble leftover chunks from a disk repository into a recording file"; + } + + @Override + public void displayOptionUsage(PrintStream stream) { + stream.println(" Directory where the repository is located"); + stream.println(); + stream.println(" Name of the recording file (.jfr) to create"); + } + + @Override + public void execute(Deque options) throws UserSyntaxException, UserDataException { + ensureMinArgumentCount(options, 2); + ensureMaxArgumentCount(options, 2); + Path repository = getDirectory(options.pop()); + + Path file = Paths.get(options.pop()); + ensureFileDoesNotExist(file); + ensureJFRFile(file); + + try (FileOutputStream fos = new FileOutputStream(file.toFile())) { + List files = listJFRFiles(repository); + if (files.isEmpty()) { + throw new UserDataException("no *.jfr files found at " + repository); + } + println(); + println("Assembling files... "); + println(); + transferTo(files, file, fos.getChannel()); + println(); + println("Finished."); + } catch (IOException e) { + throw new UserDataException("could not open destination file " + file + ". " + e.getMessage()); + } + } + + private List listJFRFiles(Path path) throws UserDataException { + try { + List files = new ArrayList<>(); + if (Files.isDirectory(path)) { + try (DirectoryStream stream = Files.newDirectoryStream(path, "*.jfr")) { + for (Path p : stream) { + if (!Files.isDirectory(p) && Files.isReadable(p)) { + files.add(p); + } + } + } + } + files.sort((u, v) -> u.getFileName().compareTo(v.getFileName())); + return files; + } catch (IOException ioe) { + throw new UserDataException("could not list *.jfr for directory " + path + ". " + ioe.getMessage()); + } + } + + private void transferTo(List sourceFiles, Path output, FileChannel out) throws UserDataException { + long pos = 0; + for (Path p : sourceFiles) { + println(" " + p.toString()); + try (FileChannel sourceChannel = FileChannel.open(p)) { + long rem = Files.size(p); + while (rem > 0) { + long n = Math.min(rem, 1024 * 1024); + long w = out.transferFrom(sourceChannel, pos, n); + pos += w; + rem -= w; + } + } catch (IOException ioe) { + throw new UserDataException("could not copy recording chunk " + p + " to new file. " + ioe.getMessage()); + } + } + } +} diff --git a/src/share/classes/jdk/jfr/internal/tool/Command.java b/src/share/classes/jdk/jfr/internal/tool/Command.java new file mode 100644 index 0000000000000000000000000000000000000000..cecd3ed767adbc8ac9d60ce79e8a42ca676aaaae --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/tool/Command.java @@ -0,0 +1,306 @@ +/* + * 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. 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.internal.tool; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOError; +import java.io.IOException; +import java.io.PrintStream; +import java.io.RandomAccessFile; +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.Collections; +import java.util.Deque; +import java.util.List; + +abstract class Command { + public final static String title = "Tool for working with Flight Recorder files (.jfr)"; + private final static Command HELP = new Help(); + private final static List COMMANDS = createCommands(); + + private static List createCommands() { + List commands = new ArrayList<>(); + commands.add(new Print()); + commands.add(new Metadata()); + commands.add(new Summary()); + commands.add(new Assemble()); + commands.add(new Disassemble()); + commands.add(new Version()); + commands.add(HELP); + return Collections.unmodifiableList(commands); + } + + static void displayHelp() { + System.out.println(title); + System.out.println(); + displayAvailableCommands(System.out); + } + + abstract public String getName(); + + abstract public String getDescription(); + + abstract public void execute(Deque argList) throws UserSyntaxException, UserDataException; + + protected String getTitle() { + return getDescription(); + } + + static void displayAvailableCommands(PrintStream stream) { + boolean first = true; + for (Command c : Command.COMMANDS) { + if (!first) { + System.out.println(); + } + displayCommand(stream, c); + stream.println(" " + c.getDescription()); + first = false; + } + } + + protected static void displayCommand(PrintStream stream, Command c) { + boolean firstSyntax = true; + String alias = buildAlias(c); + String initial = " jfr " + c.getName(); + for (String syntaxLine : c.getOptionSyntax()) { + if (firstSyntax) { + if (syntaxLine.length() != 0) { + stream.println(initial + " " + syntaxLine + alias); + } else { + stream.println(initial + alias); + } + } else { + for (int i = 0; i < initial.length(); i++) { + stream.print(" "); + } + stream.println(" " + syntaxLine); + } + firstSyntax = false; + } + } + + private static String buildAlias(Command c) { + List aliases = c.getAliases(); + if (aliases.isEmpty()) { + return ""; + } + StringBuilder sb = new StringBuilder(); + if (aliases.size() == 1) { + sb.append(" (alias "); + sb.append(aliases.get(0)); + sb.append(")"); + return sb.toString(); + } + sb.append(" (aliases "); + for (int i = 0; i< aliases.size(); i ++ ) { + sb.append(aliases.get(i)); + if (i < aliases.size() -1) { + sb.append(", "); + } + } + sb.append(")"); + return sb.toString(); + } + + public static List getCommands() { + return COMMANDS; + } + + public static Command valueOf(String commandName) { + for (Command command : COMMANDS) { + if (command.getName().equals(commandName)) { + return command; + } + } + return null; + } + + public List getOptionSyntax() { + return Collections.singletonList(""); + } + + public void displayOptionUsage(PrintStream stream) { + } + + protected boolean acceptOption(Deque options, String expected) throws UserSyntaxException { + if (expected.equals(options.peek())) { + if (options.size() < 2) { + throw new UserSyntaxException("missing value for " + options.peek()); + } + options.remove(); + return true; + } + return false; + } + + protected void warnForWildcardExpansion(String option, String filter) throws UserDataException { + // Users should quote their wildcards to avoid expansion by the shell + try { + if (!filter.contains(File.pathSeparator)) { + Path p = Paths.get(".", filter); + if (!Files.exists(p)) { + return; + } + } + throw new UserDataException("wildcards should be quoted, for example " + option + " \"Foo*\""); + } catch (InvalidPathException ipe) { + // ignore + } + } + + protected boolean acceptFilterOption(Deque options, String expected) throws UserSyntaxException { + if (!acceptOption(options, expected)) { + return false; + } + if (options.isEmpty()) { + throw new UserSyntaxException("missing filter after " + expected); + } + String filter = options.peek(); + if (filter.startsWith("--")) { + throw new UserSyntaxException("missing filter after " + expected); + } + return true; + } + + final protected void ensureMaxArgumentCount(Deque options, int maxCount) throws UserSyntaxException { + if (options.size() > maxCount) { + throw new UserSyntaxException("too many arguments"); + } + } + + final protected void ensureMinArgumentCount(Deque options, int minCount) throws UserSyntaxException { + if (options.size() < minCount) { + throw new UserSyntaxException("too few arguments"); + } + } + + final protected Path getDirectory(String pathText) throws UserDataException { + try { + Path path = Paths.get(pathText).toAbsolutePath(); + if (!Files.exists((path))) { + throw new UserDataException("directory does not exist, " + pathText); + } + if (!Files.isDirectory(path)) { + throw new UserDataException("path must be directory, " + pathText); + } + return path; + } catch (InvalidPathException ipe) { + throw new UserDataException("invalid path '" + pathText + "'"); + } + } + + final protected Path getJFRInputFile(Deque options) throws UserSyntaxException, UserDataException { + if (options.isEmpty()) { + throw new UserSyntaxException("missing file"); + } + String file = options.removeLast(); + if (file.startsWith("--")) { + throw new UserSyntaxException("missing file"); + } + try { + Path path = Paths.get(file).toAbsolutePath(); + ensureAccess(path); + ensureJFRFile(path); + return path; + } catch (IOError ioe) { + throw new UserDataException("i/o error reading file '" + file + "', " + ioe.getMessage()); + } catch (InvalidPathException ipe) { + throw new UserDataException("invalid path '" + file + "'"); + } + } + + private void ensureAccess(Path path) throws UserDataException { + try (RandomAccessFile rad = new RandomAccessFile(path.toFile(), "r")) { + if (rad.length() == 0) { + throw new UserDataException("file is empty '" + path + "'"); + } + rad.read(); // try to read 1 byte + } catch (FileNotFoundException e) { + throw new UserDataException("could not find file '" + path + "'"); + } catch (IOException e) { + throw new UserDataException("i/o error reading file '" + path + "', " + e.getMessage()); + } + } + + final protected void couldNotReadError(Path p, IOException e) throws UserDataException { + throw new UserDataException("could not read recording at " + p.toAbsolutePath() + ". " + e.getMessage()); + } + + final protected Path ensureFileDoesNotExist(Path file) throws UserDataException { + if (Files.exists(file)) { + throw new UserDataException("file '" + file + "' already exists"); + } + return file; + } + + final protected void ensureJFRFile(Path path) throws UserDataException { + if (!path.toString().endsWith(".jfr")) { + throw new UserDataException("filename must end with '.jfr'"); + } + } + + protected void displayUsage(PrintStream stream) { + displayCommand(stream, this); + stream.println(); + displayOptionUsage(stream); + } + + final protected void println() { + System.out.println(); + } + + final protected void print(String text) { + System.out.print(text); + } + + final protected void println(String text) { + System.out.println(text); + } + + final protected boolean matches(String command) { + for (String s : getNames()) { + if (s.equals(command)) { + return true; + } + } + return false; + } + + protected List getAliases() { + return Collections.emptyList(); + } + + public List getNames() { + List names = new ArrayList<>(); + names.add(getName()); + names.addAll(getAliases()); + return names; + } +} diff --git a/src/share/classes/jdk/jfr/internal/tool/Disassemble.java b/src/share/classes/jdk/jfr/internal/tool/Disassemble.java new file mode 100644 index 0000000000000000000000000000000000000000..17ad5d176f1513b6d35c87adab24f29ecb162fd5 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/tool/Disassemble.java @@ -0,0 +1,250 @@ +/* + * 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. 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.internal.tool; + +import java.io.BufferedInputStream; +import java.io.DataInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintStream; +import java.nio.file.Files; +import java.nio.file.InvalidPathException; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Deque; +import java.util.List; + +import jdk.jfr.internal.consumer.ChunkHeader; +import jdk.jfr.internal.consumer.RecordingInput; + +final class Disassemble extends Command { + + @Override + public String getName() { + return "disassemble"; + } + + @Override + public List getOptionSyntax() { + List list = new ArrayList<>(); + list.add("[--output ]"); + list.add("[--max-chunks ]"); + list.add("[--max-size ]"); + list.add(""); + return list; + } + + @Override + public void displayOptionUsage(PrintStream stream) { + stream.println(" --output The location to write the disassembled file,"); + stream.println(" by default the current directory"); + stream.println(""); + stream.println(" --max-chunks Maximum number of chunks per disassembled file,"); + stream.println(" by default 5. The chunk size varies, but is "); + stream.println(" typically around 15 MB."); + stream.println(""); + stream.println(" --max-size Maximum number of bytes per file."); + stream.println(""); + stream.println(" Location of the recording file (.jfr)"); + } + + @Override + public String getDescription() { + return "Disassamble a recording file into smaller files/chunks"; + } + + @Override + public void execute(Deque options) throws UserSyntaxException, UserDataException { + if (options.isEmpty()) { + throw new UserSyntaxException("missing file"); + } + Path file = getJFRInputFile(options); + int maxChunks = Integer.MAX_VALUE; + int maxsize = Integer.MAX_VALUE; + String output = System.getProperty("user.dir"); + int optionCount = options.size(); + while (optionCount > 0) { + if (acceptOption(options, "--output")) { + output = options.pop(); + } + if (acceptOption(options, "--max-size")) { + String value = options.pop(); + try { + maxsize = Integer.parseInt(value); + if (maxsize < 1) { + throw new UserDataException("max size must be at least 1"); + } + } catch (NumberFormatException nfe) { + throw new UserDataException("not a valid value for --max-size."); + } + } + if (acceptOption(options, "--max-chunks")) { + String value = options.pop(); + try { + maxChunks = Integer.parseInt(value); + if (maxChunks < 1) { + throw new UserDataException("max chunks must be at least 1."); + } + } catch (NumberFormatException nfe) { + throw new UserDataException("not a valid value for --max-size."); + } + } + if (optionCount == options.size()) { + // No progress made + throw new UserSyntaxException("unknown option " + options.peek()); + } + optionCount = options.size(); + } + Path outputPath = getDirectory(output); + + println(); + println("Examining recording " + file + " ..."); + List sizes; + if (maxsize != Integer.MAX_VALUE && maxChunks == Integer.MAX_VALUE) { + try { + long fileSize = Files.size(file); + if (maxsize >=fileSize) { + println(); + println("File size (" + fileSize +") does not exceed max size (" + maxsize + ")"); + return; + } + } catch (IOException e) { + throw new UserDataException("unexpected i/o error when determining file size" + e.getMessage()); + } + } + if (maxsize == Integer.MAX_VALUE && maxChunks == Integer.MAX_VALUE) { + maxChunks = 5; + } + + try { + sizes = findChunkSizes(file); + } catch (IOException e) { + throw new UserDataException("unexpected i/o error. " + e.getMessage()); + } + if (maxsize == Integer.MAX_VALUE == sizes.size() <= maxChunks) { + throw new UserDataException("number of chunks in recording (" + sizes.size() + ") doesn't exceed max chunks (" + maxChunks + ")"); + } + println(); + if (sizes.size() > 0) { + List combinedSizes = combineChunkSizes(sizes, maxChunks, maxsize); + print("File consists of " + sizes.size() + " chunks. The recording will be split into "); + println(combinedSizes.size() + " files"); + println(); + splitFile(outputPath, file, combinedSizes); + } else { + throw new UserDataException("no JFR chunks found in file."); + } + } + + private List findChunkSizes(Path p) throws IOException { + try (RecordingInput input = new RecordingInput(p.toFile())) { + List sizes = new ArrayList<>(); + ChunkHeader ch = new ChunkHeader(input); + sizes.add(ch.getSize()); + while (!ch.isLastChunk()) { + ch = ch.nextHeader(); + sizes.add(ch.getSize()); + } + return sizes; + } + } + + private List combineChunkSizes(List sizes, int maxChunks, long maxSize) { + List reduced = new ArrayList(); + int chunks = 1; + long fileSize = sizes.get(0); + for (int i = 1; i < sizes.size(); i++) { + long size = sizes.get(i); + if (fileSize + size > maxSize) { + reduced.add(fileSize); + chunks = 1; + fileSize = size; + continue; + } + fileSize += size; + if (chunks == maxChunks) { + reduced.add(fileSize); + fileSize = 0; + chunks = 1; + continue; + } + chunks++; + } + if (fileSize != 0) { + reduced.add(fileSize); + } + return reduced; + } + + private void splitFile(Path directory, Path file, List splitPositions) throws UserDataException { + int padAmountZeros = String.valueOf(splitPositions.size() - 1).length(); + String fileName = file.getFileName().toString(); + String fileFormatter = fileName.subSequence(0, fileName.length() - 4) + "_%0" + padAmountZeros + "d.jfr"; + for (int i = 0; i < splitPositions.size(); i++) { + String formattedFilename = String.format(fileFormatter, i); + try { + Path p = directory.resolve(formattedFilename); + if (Files.exists(p)) { + throw new UserDataException("can't create disassembled file " + p + ", a file with that name already exist"); + } + } catch (InvalidPathException ipe) { + throw new UserDataException("can't construct path with filename" + formattedFilename); + } + } + + try (DataInputStream stream = new DataInputStream(new BufferedInputStream(new FileInputStream(file.toFile())))) { + for (int i = 0; i < splitPositions.size(); i++) { + Long l = splitPositions.get(i); + byte[] bytes = readBytes(stream, l.intValue()); + String formattedFilename = String.format(fileFormatter, i); + Path p = directory.resolve(formattedFilename); + File splittedFile = p.toFile(); + println("Writing " + splittedFile + " ... " + bytes.length); + FileOutputStream fos = new FileOutputStream(splittedFile); + fos.write(bytes); + fos.close(); + } + } catch (IOException ioe) { + throw new UserDataException("i/o error writing file " + file); + } + } + + private byte[] readBytes(InputStream stream, int count) throws UserDataException, IOException { + byte[] data = new byte[count]; + int totalRead = 0; + while (totalRead < data.length) { + int read = stream.read(data, totalRead, data.length - totalRead); + if (read == -1) { + throw new UserDataException("unexpected end of data"); + } + totalRead += read; + } + return data; + } +} diff --git a/src/share/classes/jdk/jfr/internal/tool/EventPrintWriter.java b/src/share/classes/jdk/jfr/internal/tool/EventPrintWriter.java new file mode 100644 index 0000000000000000000000000000000000000000..546f48117d74f35456318749ccaca48c5b7f1f3a --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/tool/EventPrintWriter.java @@ -0,0 +1,139 @@ +/* + * 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.internal.tool; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.PrintWriter; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Predicate; + +import jdk.jfr.EventType; +import jdk.jfr.Timespan; +import jdk.jfr.Timestamp; +import jdk.jfr.ValueDescriptor; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedObject; +import jdk.jfr.consumer.RecordingFile; +import jdk.jfr.internal.consumer.RecordingInternals; + +abstract class EventPrintWriter extends StructuredWriter { + + enum ValueType { + TIMESPAN, TIMESTAMP, OTHER + } + + protected static final String STACK_TRACE_FIELD = "stackTrace"; + protected static final String EVENT_THREAD_FIELD = "eventThread"; + + private Predicate eventFilter = x -> true; + private int stackDepth; + + // cach that will speed up annotation lookup + private Map typeOfValues = new HashMap<>(); + + EventPrintWriter(PrintWriter p) { + super(p); + } + + abstract protected void print(List events); + + void print(Path source) throws FileNotFoundException, IOException { + List events = new ArrayList<>(500_000); + printBegin(); + try (RecordingFile file = new RecordingFile(source)) { + while (file.hasMoreEvents()) { + RecordedEvent event = file.readEvent(); + if (acceptEvent(event)) { + events.add(event); + } + if (RecordingInternals.INSTANCE.isLastEventInChunk(file)) { + RecordingInternals.INSTANCE.sort(events); + print(events); + events.clear(); + } + } + } + printEnd(); + flush(true); + } + + protected void printEnd() { + } + + protected void printBegin() { + } + + public final void setEventFilter(Predicate eventFilter) { + this.eventFilter = eventFilter; + } + + protected final boolean acceptEvent(RecordedEvent event) { + return eventFilter.test(event.getEventType()); + } + + protected final int getStackDepth() { + return stackDepth; + } + + protected final boolean isLateField(String name) { + return name.equals(EVENT_THREAD_FIELD) || name.equals(STACK_TRACE_FIELD); + } + + public void setStackDepth(int stackDepth) { + this.stackDepth = stackDepth; + } + + protected Object getValue(RecordedObject object, ValueDescriptor v) { + ValueType valueType = typeOfValues.get(v); + if (valueType == null) { + valueType = determineValueType(v); + typeOfValues.put(v, valueType); + } + switch (valueType) { + case TIMESPAN: + return object.getDuration(v.getName()); + case TIMESTAMP: + return RecordingInternals.INSTANCE.getOffsetDataTime(object, v.getName()); + default: + return object.getValue(v.getName()); + } + } + // It's expensive t check + private ValueType determineValueType(ValueDescriptor v) { + if (v.getAnnotation(Timespan.class) != null) { + return ValueType.TIMESPAN; + } + if (v.getAnnotation(Timestamp.class) != null) { + return ValueType.TIMESTAMP; + } + return ValueType.OTHER; + } +} diff --git a/src/share/classes/jdk/jfr/internal/tool/Help.java b/src/share/classes/jdk/jfr/internal/tool/Help.java new file mode 100644 index 0000000000000000000000000000000000000000..03f4c49a71eb30f30051b9307eab05ea05d99dfa --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/tool/Help.java @@ -0,0 +1,76 @@ +/* + * 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. 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.internal.tool; + +import java.io.PrintStream; +import java.util.Arrays; +import java.util.Collections; +import java.util.Deque; +import java.util.List; + +final class Help extends Command { + + @Override + public String getName() { + return "help"; + } + + @Override + public List getOptionSyntax() { + return Collections.singletonList("[]"); + } + + protected List getAliases() { + return Arrays.asList("--help", "-h", "-?"); + } + + @Override + public void displayOptionUsage(PrintStream stream) { + println(" The name of the command to get help for"); + } + + @Override + public String getDescription() { + return "Display all available commands, or help about a specific command"; + } + + @Override + public void execute(Deque options) throws UserSyntaxException, UserDataException { + if (options.isEmpty()) { + Command.displayHelp(); + return; + } + ensureMaxArgumentCount(options, 1); + String commandName = options.remove(); + Command c = Command.valueOf(commandName); + if (c == null) { + throw new UserDataException("unknown command '" + commandName + "'"); + } + println(c.getTitle()); + println(); + c.displayUsage(System.out); + } +} diff --git a/src/share/classes/jdk/jfr/internal/tool/JSONWriter.java b/src/share/classes/jdk/jfr/internal/tool/JSONWriter.java new file mode 100644 index 0000000000000000000000000000000000000000..0e008c87325063bb5e6a186379181e0c88c2418c --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/tool/JSONWriter.java @@ -0,0 +1,261 @@ +/* + * 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. 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.internal.tool; + +import java.io.PrintWriter; +import java.util.List; + +import jdk.jfr.EventType; +import jdk.jfr.ValueDescriptor; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedFrame; +import jdk.jfr.consumer.RecordedObject; + +final class JSONWriter extends EventPrintWriter { + + private boolean first = true; + + public JSONWriter(PrintWriter writer) { + super(writer); + } + + @Override + protected void printBegin() { + printObjectBegin(); + printDataStructureName("recording"); + printObjectBegin(); + printDataStructureName("events"); + printArrayBegin(); + } + + @Override + protected void print(List events) { + for (RecordedEvent event : events) { + printNewDataStructure(first, true, null); + printEvent(event); + flush(false); + first = false; + } + } + + @Override + protected void printEnd() { + printArrayEnd();; + printObjectEnd(); + printObjectEnd(); + } + + private void printEvent(RecordedEvent event) { + printObjectBegin(); + EventType type = event.getEventType(); + printValue(true, false, "type", type.getName()); + printNewDataStructure(false, false, "values"); + printObjectBegin(); + boolean first = true; + for (ValueDescriptor v : event.getFields()) { + printValueDescriptor(first, false, v, getValue(event, v)); + first = false; + } + printObjectEnd(); + printObjectEnd(); + } + + void printValue(boolean first, boolean arrayElement, String name, Object value) { + printNewDataStructure(first, arrayElement, name); + if (!printIfNull(value)) { + if (value instanceof Boolean) { + printAsString(value); + return; + } + if (value instanceof Double) { + Double dValue = (Double) value; + if (Double.isNaN(dValue) || Double.isInfinite(dValue)) { + printNull(); + return; + } + printAsString(value); + return; + } + if (value instanceof Float) { + Float fValue = (Float) value; + if (Float.isNaN(fValue) || Float.isInfinite(fValue)) { + printNull(); + return; + } + printAsString(value); + return; + } + if (value instanceof Number) { + printAsString(value); + return; + } + print("\""); + printEscaped(String.valueOf(value)); + print("\""); + } + } + + public void printObject(RecordedObject object) { + printObjectBegin(); + boolean first = true; + for (ValueDescriptor v : object.getFields()) { + printValueDescriptor(first, false, v, getValue(object, v)); + first = false; + } + printObjectEnd(); + } + + private void printArray(ValueDescriptor v, Object[] array) { + printArrayBegin(); + boolean first = true; + int depth = 0; + for (Object arrayElement : array) { + if (!(arrayElement instanceof RecordedFrame) || depth < getStackDepth()) { + printValueDescriptor(first, true, v, arrayElement); + } + depth++; + first = false; + } + printArrayEnd(); + } + + private void printValueDescriptor(boolean first, boolean arrayElement, ValueDescriptor vd, Object value) { + if (vd.isArray() && !arrayElement) { + printNewDataStructure(first, arrayElement, vd.getName()); + if (!printIfNull(value)) { + printArray(vd, (Object[]) value); + } + return; + } + if (!vd.getFields().isEmpty()) { + printNewDataStructure(first, arrayElement, vd.getName()); + if (!printIfNull(value)) { + printObject((RecordedObject) value); + } + return; + } + printValue(first, arrayElement, vd.getName(), value); + } + + private void printNewDataStructure(boolean first, boolean arrayElement, String name) { + if (!first) { + print(", "); + if (!arrayElement) { + println(); + } + } + if (!arrayElement) { + printDataStructureName(name); + } + } + + private boolean printIfNull(Object value) { + if (value == null) { + printNull(); + return true; + } + return false; + } + + private void printNull() { + print("null"); + } + + private void printDataStructureName(String text) { + printIndent(); + print("\""); + print(text); + print("\": "); + } + + private void printObjectEnd() { + retract(); + println(); + printIndent(); + print("}"); + } + + private void printObjectBegin() { + println("{"); + indent(); + } + + private void printArrayEnd() { + print("]"); + } + + private void printArrayBegin() { + print("["); + } + + private void printEscaped(String text) { + for (int i = 0; i < text.length(); i++) { + printEscaped(text.charAt(i)); + } + } + + private void printEscaped(char c) { + if (c == '\b') { + print("\\b"); + return; + } + if (c == '\n') { + print("\\n"); + return; + } + if (c == '\t') { + print("\\t"); + return; + } + if (c == '\f') { + print("\\f"); + return; + } + if (c == '\r') { + print("\\r"); + return; + } + if (c == '\"') { + print("\\\""); + return; + } + if (c == '\\') { + print("\\\\"); + return; + } + if (c == '/') { + print("\\/"); + return; + } + if (c > 0x7F || c < 32) { + print("\\u"); + // 0x10000 will pad with zeros. + print(Integer.toHexString(0x10000 + (int) c).substring(1)); + return; + } + print(c); + } +} diff --git a/src/share/classes/jdk/jfr/internal/tool/Main.java b/src/share/classes/jdk/jfr/internal/tool/Main.java new file mode 100644 index 0000000000000000000000000000000000000000..785ffda91338f5ebad08d5aff4b8905711967995 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/tool/Main.java @@ -0,0 +1,110 @@ +/* + * 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. 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.internal.tool; + +import java.util.Arrays; +import java.util.Deque; +import java.util.LinkedList; + +/** + * Launcher class for the JDK_HOME\bin\jfr tool + * + */ +public final class Main { + + private static final int EXIT_OK = 0; + private static final int EXIT_FAILED = 1; + private static final int EXIT_WRONG_ARGUMENTS = 2; + + public static void main(String... args) { + Deque argList = new LinkedList<>(Arrays.asList(args)); + if (argList.isEmpty()) { + System.out.println(Command.title); + System.out.println(); + System.out.println("Before using this tool, you must have a recording file."); + System.out.println("A file can be created by starting a recording from command line:"); + System.out.println(); + System.out.println(" java -XX:StartFlightRecording:filename=recording.jfr,duration=30s ... "); + System.out.println(); + System.out.println("A recording can also be started on already running Java Virtual Machine:"); + System.out.println(); + System.out.println(" jcmd (to list available pids)"); + System.out.println(" jcmd JFR.start"); + System.out.println(); + System.out.println("Recording data can be dumped to file using the JFR.dump command:"); + System.out.println(); + System.out.println(" jcmd JFR.dump filename=recording.jfr"); + System.out.println(); + System.out.println("The contents of the recording can then be printed, for example:"); + System.out.println(); + System.out.println(" jfr print recording.jfr"); + System.out.println(); + System.out.println(" jfr print --events CPULoad,GarbageCollection recording.jfr"); + System.out.println(); + System.out.println(" jfr print --json --events CPULoad recording.jfr"); + System.out.println(); + System.out.println(" jfr print --categories \"GC,JVM,Java*\" recording.jfr"); + System.out.println(); + System.out.println(" jfr print --events \"jdk.*\" --stack-depth 64 recording.jfr"); + System.out.println(); + System.out.println(" jfr summary recording.jfr"); + System.out.println(); + System.out.println(" jfr metadata recording.jfr"); + System.out.println(); + System.out.println("For more information about available commands, use 'jfr help'"); + System.exit(EXIT_OK); + } + String command = argList.remove(); + for (Command c : Command.getCommands()) { + if (c.matches(command)) { + try { + c.execute(argList); + System.exit(EXIT_OK); + } catch (UserDataException ude) { + System.err.println("jfr " + c.getName() + ": " + ude.getMessage()); + System.exit(EXIT_FAILED); + } catch (UserSyntaxException use) { + System.err.println("jfr " + c.getName() + ": " + use.getMessage()); + System.err.println(); + System.err.println("Usage:"); + System.err.println(); + c.displayUsage(System.err); + System.exit(EXIT_WRONG_ARGUMENTS); + } catch (Throwable e) { + System.err.println("jfr " + c.getName() + ": unexpected internal error, " + e.getMessage()); + e.printStackTrace(); + System.exit(EXIT_FAILED); + } + } + } + System.err.println("jfr: unknown command '" + command + "'"); + System.err.println(); + System.err.println("List of available commands:"); + System.err.println(); + Command.displayAvailableCommands(System.err); + System.exit(EXIT_WRONG_ARGUMENTS); + } +} diff --git a/src/share/classes/jdk/jfr/internal/tool/Metadata.java b/src/share/classes/jdk/jfr/internal/tool/Metadata.java new file mode 100644 index 0000000000000000000000000000000000000000..44c989c6ee047b39266aef1eb321609fadf971fb --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/tool/Metadata.java @@ -0,0 +1,139 @@ +/* + * 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.internal.tool; + +import java.io.IOException; +import java.io.PrintWriter; +import java.nio.file.Path; +import java.util.Collections; +import java.util.Comparator; +import java.util.Deque; +import java.util.List; + +import jdk.jfr.consumer.RecordingFile; +import jdk.jfr.internal.Type; +import jdk.jfr.internal.consumer.RecordingInternals; + +final class Metadata extends Command { + + private static class TypeComparator implements Comparator { + + @Override + public int compare(Type t1, Type t2) { + int g1 = groupValue(t1); + int g2 = groupValue(t2); + if (g1 == g2) { + String n1 = t1.getName(); + String n2 = t2.getName(); + String package1 = n1.substring(0, n1.lastIndexOf('.') + 1); + String package2 = n2.substring(0, n2.lastIndexOf('.') + 1); + + if (package1.equals(package2)) { + return n1.compareTo(n2); + } else { + // Ensure that jdk.* are printed first + // This makes it easier to find user defined events at the end. + if (Type.SUPER_TYPE_EVENT.equals(t1.getSuperType()) && !package1.equals(package2)) { + if (package1.equals("jdk.jfr")) { + return -1; + } + if (package2.equals("jdk.jfr")) { + return 1; + } + } + return package1.compareTo(package2); + } + } else { + return Integer.compare(groupValue(t1), groupValue(t2)); + } + } + + int groupValue(Type t) { + String superType = t.getSuperType(); + if (superType == null) { + return 1; + } + if (Type.SUPER_TYPE_ANNOTATION.equals(superType)) { + return 3; + } + if (Type.SUPER_TYPE_SETTING.equals(superType)) { + return 4; + } + if (Type.SUPER_TYPE_EVENT.equals(superType)) { + return 5; + } + return 2; // reserved for enums in the future + } + } + + @Override + public String getName() { + return "metadata"; + } + + @Override + public List getOptionSyntax() { + return Collections.singletonList(""); + } + + @Override + public String getDescription() { + return "Display event metadata, such as labels, descriptions and field layout"; + } + + @Override + public void execute(Deque options) throws UserSyntaxException, UserDataException { + Path file = getJFRInputFile(options); + + boolean showIds = false; + int optionCount = options.size(); + while (optionCount > 0) { + if (acceptOption(options, "--ids")) { + showIds = true; + } + if (optionCount == options.size()) { + // No progress made + throw new UserSyntaxException("unknown option " + options.peek()); + } + optionCount = options.size(); + } + + try (PrintWriter pw = new PrintWriter(System.out)) { + PrettyWriter prettyWriter = new PrettyWriter(pw); + prettyWriter.setShowIds(showIds); + try (RecordingFile rf = new RecordingFile(file)) { + List types = RecordingInternals.INSTANCE.readTypes(rf); + Collections.sort(types, new TypeComparator()); + for (Type type : types) { + prettyWriter.printType(type); + } + prettyWriter.flush(true); + } catch (IOException ioe) { + couldNotReadError(file, ioe); + } + } + } +} diff --git a/src/share/classes/jdk/jfr/internal/tool/PrettyWriter.java b/src/share/classes/jdk/jfr/internal/tool/PrettyWriter.java new file mode 100644 index 0000000000000000000000000000000000000000..6b081d3d1e2edaf3c873943ac59551cbaf5a96ad --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/tool/PrettyWriter.java @@ -0,0 +1,634 @@ +/* + * 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. 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.internal.tool; + +import java.io.PrintWriter; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.List; +import java.util.StringJoiner; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.DataAmount; +import jdk.jfr.Frequency; +import jdk.jfr.MemoryAddress; +import jdk.jfr.Percentage; +import jdk.jfr.ValueDescriptor; +import jdk.jfr.consumer.RecordedClass; +import jdk.jfr.consumer.RecordedClassLoader; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedFrame; +import jdk.jfr.consumer.RecordedMethod; +import jdk.jfr.consumer.RecordedObject; +import jdk.jfr.consumer.RecordedStackTrace; +import jdk.jfr.consumer.RecordedThread; +import jdk.jfr.internal.PrivateAccess; +import jdk.jfr.internal.Type; +import jdk.jfr.internal.Utils; + +/** + * Print events in a human-readable format. + * + * This class is also used by {@link RecordedObject#toString()} + */ +public final class PrettyWriter extends EventPrintWriter { + private static final String TYPE_OLD_OBJECT = Type.TYPES_PREFIX + "OldObject"; + private final static DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ofPattern("HH:mm:ss.SSS"); + private final static Long ZERO = 0L; + private boolean showIds; + private RecordedEvent currentEvent; + + public PrettyWriter(PrintWriter destination) { + super(destination); + } + + @Override + protected void print(List events) { + for (RecordedEvent e : events) { + print(e); + flush(false); + } + } + + public void printType(Type t) { + if (showIds) { + print("// id: "); + println(String.valueOf(t.getId())); + } + int commentIndex = t.getName().length() + 10; + String typeName = t.getName(); + int index = typeName.lastIndexOf("."); + if (index != -1) { + println("@Name(\"" + typeName + "\")"); + } + printAnnotations(commentIndex, t.getAnnotationElements()); + print("class " + typeName.substring(index + 1)); + String superType = t.getSuperType(); + if (superType != null) { + print(" extends " + superType); + } + println(" {"); + indent(); + boolean first = true; + for (ValueDescriptor v : t.getFields()) { + printField(commentIndex, v, first); + first = false; + } + retract(); + println("}"); + println(); + } + + private void printField(int commentIndex, ValueDescriptor v, boolean first) { + if (!first) { + println(); + } + printAnnotations(commentIndex, v.getAnnotationElements()); + printIndent(); + Type vType = PrivateAccess.getInstance().getType(v); + if (Type.SUPER_TYPE_SETTING.equals(vType.getSuperType())) { + print("static "); + } + print(makeSimpleType(v.getTypeName())); + if (v.isArray()) { + print("[]"); + } + print(" "); + print(v.getName()); + print(";"); + printCommentRef(commentIndex, v.getTypeId()); + } + + private void printCommentRef(int commentIndex, long typeId) { + if (showIds) { + int column = getColumn(); + if (column > commentIndex) { + print(" "); + } else { + while (column < commentIndex) { + print(" "); + column++; + } + } + println(" // id=" + typeId); + } else { + println(); + } + } + + private void printAnnotations(int commentIndex, List annotations) { + for (AnnotationElement a : annotations) { + printIndent(); + print("@"); + print(makeSimpleType(a.getTypeName())); + List vs = a.getValueDescriptors(); + if (!vs.isEmpty()) { + printAnnotation(a); + printCommentRef(commentIndex, a.getTypeId()); + } else { + println(); + } + } + } + + private void printAnnotation(AnnotationElement a) { + StringJoiner sj = new StringJoiner(", ", "(", ")"); + List vs = a.getValueDescriptors(); + for (ValueDescriptor v : vs) { + Object o = a.getValue(v.getName()); + if (vs.size() == 1 && v.getName().equals("value")) { + sj.add(textify(o)); + } else { + sj.add(v.getName() + "=" + textify(o)); + } + } + print(sj.toString()); + } + + private String textify(Object o) { + if (o.getClass().isArray()) { + Object[] array = (Object[]) o; + if (array.length == 1) { + return quoteIfNeeded(array[0]); + } + StringJoiner s = new StringJoiner(", ", "{", "}"); + for (Object ob : array) { + s.add(quoteIfNeeded(ob)); + } + return s.toString(); + } else { + return quoteIfNeeded(o); + } + } + + private String quoteIfNeeded(Object o) { + if (o instanceof String) { + return "\"" + o + "\""; + } else { + return String.valueOf(o); + } + } + + private String makeSimpleType(String typeName) { + int index = typeName.lastIndexOf("."); + return typeName.substring(index + 1); + } + + public void print(RecordedEvent event) { + currentEvent = event; + print(event.getEventType().getName(), " "); + println("{"); + indent(); + for (ValueDescriptor v : event.getFields()) { + String name = v.getName(); + if (!isZeroDuration(event, name) && !isLateField(name)) { + printFieldValue(event, v); + } + } + if (event.getThread() != null) { + printIndent(); + print(EVENT_THREAD_FIELD + " = "); + printThread(event.getThread(), ""); + } + if (event.getStackTrace() != null) { + printIndent(); + print(STACK_TRACE_FIELD + " = "); + printStackTrace(event.getStackTrace()); + } + retract(); + printIndent(); + println("}"); + println(); + } + + private boolean isZeroDuration(RecordedEvent event, String name) { + return name.equals("duration") && ZERO.equals(event.getValue("duration")); + } + + private void printStackTrace(RecordedStackTrace stackTrace) { + println("["); + List frames = stackTrace.getFrames(); + indent(); + int i = 0; + while (i < frames.size() && i < getStackDepth()) { + RecordedFrame frame = frames.get(i); + if (frame.isJavaFrame()) { + printIndent(); + printValue(frame, null, ""); + println(); + i++; + } + } + if (stackTrace.isTruncated() || i == getStackDepth()) { + printIndent(); + println("..."); + } + retract(); + printIndent(); + println("]"); + } + + public void print(RecordedObject struct, String postFix) { + println("{"); + indent(); + for (ValueDescriptor v : struct.getFields()) { + printFieldValue(struct, v); + } + retract(); + printIndent(); + println("}" + postFix); + } + + private void printFieldValue(RecordedObject struct, ValueDescriptor v) { + printIndent(); + print(v.getName(), " = "); + printValue(getValue(struct, v), v, ""); + } + + private void printArray(Object[] array) { + println("["); + indent(); + for (int i = 0; i < array.length; i++) { + printIndent(); + printValue(array[i], null, i + 1 < array.length ? ", " : ""); + } + retract(); + printIndent(); + println("]"); + } + + private void printValue(Object value, ValueDescriptor field, String postFix) { + if (value == null) { + println("N/A" + postFix); + return; + } + if (value instanceof RecordedObject) { + if (value instanceof RecordedThread) { + printThread((RecordedThread) value, postFix); + return; + } + if (value instanceof RecordedClass) { + printClass((RecordedClass) value, postFix); + return; + } + if (value instanceof RecordedClassLoader) { + printClassLoader((RecordedClassLoader) value, postFix); + return; + } + if (value instanceof RecordedFrame) { + RecordedFrame frame = (RecordedFrame) value; + if (frame.isJavaFrame()) { + printJavaFrame((RecordedFrame) value, postFix); + return; + } + } + if (value instanceof RecordedMethod) { + println(formatMethod((RecordedMethod) value)); + return; + } + if (field.getTypeName().equals(TYPE_OLD_OBJECT)) { + printOldObject((RecordedObject) value); + return; + } + print((RecordedObject) value, postFix); + return; + } + if (value.getClass().isArray()) { + printArray((Object[]) value); + return; + } + + if (value instanceof Double) { + Double d = (Double) value; + if (Double.isNaN(d) || d == Double.NEGATIVE_INFINITY) { + println("N/A"); + return; + } + } + if (value instanceof Float) { + Float f = (Float) value; + if (Float.isNaN(f) || f == Float.NEGATIVE_INFINITY) { + println("N/A"); + return; + } + } + if (value instanceof Long) { + Long l = (Long) value; + if (l == Long.MIN_VALUE) { + println("N/A"); + return; + } + } + if (value instanceof Integer) { + Integer i = (Integer) value; + if (i == Integer.MIN_VALUE) { + println("N/A"); + return; + } + } + + if (field.getContentType() != null) { + if (printFormatted(field, value)) { + return; + } + } + + String text = String.valueOf(value); + if (value instanceof String) { + text = "\"" + text + "\""; + } + println(text); + } + + private void printOldObject(RecordedObject object) { + println(" ["); + indent(); + printIndent(); + try { + printReferenceChain(object); + } catch (IllegalArgumentException iae) { + // Could not find a field + // Not possible to validate fields beforehand using RecordedObject#hasField + // since nested objects, for example object.referrer.array.index, requires + // an actual array object (which may be null). + } + retract(); + printIndent(); + println("]"); + } + + private void printReferenceChain(RecordedObject object) { + printObject(object, currentEvent.getLong("arrayElements")); + for (RecordedObject ref = object.getValue("referrer"); ref != null; ref = object.getValue("referrer")) { + long skip = ref.getLong("skip"); + if (skip > 0) { + printIndent(); + println("..."); + } + String objectHolder = ""; + long size = Long.MIN_VALUE; + RecordedObject array = ref.getValue("array"); + if (array != null) { + long index = array.getLong("index"); + size = array.getLong("size"); + objectHolder = "[" + index + "]"; + } + RecordedObject field = ref.getValue("field"); + if (field != null) { + objectHolder = field.getString("name"); + } + printIndent(); + print(objectHolder); + print(" : "); + object = ref.getValue("object"); + if (object != null) { + printObject(object, size); + } + } + } + + void printObject(RecordedObject object, long arraySize) { + RecordedClass clazz = object.getClass("type"); + if (clazz != null) { + String className = clazz.getName(); + if (className!= null && className.startsWith("[")) { + className = decodeDescriptors(className, arraySize > 0 ? Long.toString(arraySize) : "").get(0); + } + print(className); + String description = object.getString("description"); + if (description != null) { + print(" "); + print(description); + } + } + println(); + } + + private void printClassLoader(RecordedClassLoader cl, String postFix) { + // Purposely not printing class loader name to avoid cluttered output + RecordedClass clazz = cl.getType(); + print(clazz == null ? "null" : clazz.getName()); + if (clazz != null) { + print(" ("); + print("id = "); + print(String.valueOf(cl.getId())); + println(")"); + } + } + + private void printJavaFrame(RecordedFrame f, String postFix) { + print(formatMethod(f.getMethod())); + int line = f.getLineNumber(); + if (line >= 0) { + print(" line: " + line); + } + print(postFix); + } + + private String formatMethod(RecordedMethod m) { + StringBuilder sb = new StringBuilder(); + sb.append(m.getType().getName()); + sb.append("."); + sb.append(m.getName()); + sb.append("("); + StringJoiner sj = new StringJoiner(", "); + String md = m.getDescriptor().replace("/", "."); + String parameter = md.substring(1, md.lastIndexOf(")")); + for (String qualifiedName : decodeDescriptors(parameter, "")) { + String typeName = qualifiedName.substring(qualifiedName.lastIndexOf('.') + 1); + sj.add(typeName); + } + sb.append(sj); + sb.append(")"); + return sb.toString(); + } + + private void printClass(RecordedClass clazz, String postFix) { + RecordedClassLoader classLoader = clazz.getClassLoader(); + String classLoaderName = "null"; + if (classLoader != null) { + if (classLoader.getName() != null) { + classLoaderName = classLoader.getName(); + } else { + classLoaderName = classLoader.getType().getName(); + } + } + String className = clazz.getName(); + if (className.startsWith("[")) { + className = decodeDescriptors(className, "").get(0); + } + println(className + " (classLoader = " + classLoaderName + ")" + postFix); + } + + List decodeDescriptors(String descriptor, String arraySize) { + List descriptors = new ArrayList<>(); + for (int index = 0; index < descriptor.length(); index++) { + String arrayBrackets = ""; + while (descriptor.charAt(index) == '[') { + arrayBrackets = arrayBrackets + "[" + arraySize + "]" ; + arraySize = ""; + index++; + } + char c = descriptor.charAt(index); + String type; + switch (c) { + case 'L': + int endIndex = descriptor.indexOf(';', index); + type = descriptor.substring(index + 1, endIndex); + index = endIndex; + break; + case 'I': + type = "int"; + break; + case 'J': + type = "long"; + break; + case 'Z': + type = "boolean"; + break; + case 'D': + type = "double"; + break; + case 'F': + type = "float"; + break; + case 'S': + type = "short"; + break; + case 'C': + type = "char"; + break; + case 'B': + type = "byte"; + break; + default: + type = ""; + } + descriptors.add(type + arrayBrackets); + } + return descriptors; + } + + private void printThread(RecordedThread thread, String postFix) { + long javaThreadId = thread.getJavaThreadId(); + if (javaThreadId > 0) { + println("\"" + thread.getJavaName() + "\" (javaThreadId = " + thread.getJavaThreadId() + ")" + postFix); + } else { + println("\"" + thread.getOSName() + "\" (osThreadId = " + thread.getOSThreadId() + ")" + postFix); + } + } + + private boolean printFormatted(ValueDescriptor field, Object value) { + if (value instanceof Duration) { + Duration d = (Duration) value; + if (d.getSeconds() == Long.MIN_VALUE && d.getNano() == 0) { + println("N/A"); + return true; + } + double s = d.getNano() / 1000_000_000.0 + (int) (d.getSeconds() % 60); + if (s < 1.0) { + if (s < 0.001) { + println(String.format("%.3f", s * 1_000_000) + " us"); + } else { + println(String.format("%.3f", s * 1_000) + " ms"); + } + } else { + if (s < 1000.0) { + println(String.format("%.3f", s) + " s"); + } else { + println(String.format("%.0f", s) + " s"); + } + } + return true; + } + if (value instanceof OffsetDateTime) { + OffsetDateTime odt = (OffsetDateTime) value; + if (odt.equals(OffsetDateTime.MIN)) { + println("N/A"); + return true; + } + println(TIME_FORMAT.format(odt)); + return true; + } + Percentage percentage = field.getAnnotation(Percentage.class); + if (percentage != null) { + if (value instanceof Number) { + double d = ((Number) value).doubleValue(); + println(String.format("%.2f", d * 100) + "%"); + return true; + } + } + DataAmount dataAmount = field.getAnnotation(DataAmount.class); + if (dataAmount != null) { + if (value instanceof Number) { + Number n = (Number) value; + long amount = n.longValue(); + if (field.getAnnotation(Frequency.class) != null) { + if (dataAmount.value().equals(DataAmount.BYTES)) { + println(Utils.formatBytesPerSecond(amount)); + return true; + } + if (dataAmount.value().equals(DataAmount.BITS)) { + println(Utils.formatBitsPerSecond(amount)); + return true; + } + } else { + if (dataAmount.value().equals(DataAmount.BYTES)) { + println(Utils.formatBytes(amount)); + return true; + } + if (dataAmount.value().equals(DataAmount.BITS)) { + println(Utils.formatBits(amount)); + return true; + } + } + } + } + MemoryAddress memoryAddress = field.getAnnotation(MemoryAddress.class); + if (memoryAddress != null) { + if (value instanceof Number) { + long d = ((Number) value).longValue(); + println(String.format("0x%08X", d)); + return true; + } + } + Frequency frequency = field.getAnnotation(Frequency.class); + if (frequency != null) { + if (value instanceof Number) { + println(value + " Hz"); + return true; + } + } + + return false; + } + + public void setShowIds(boolean showIds) { + this.showIds = showIds; + } +} diff --git a/src/share/classes/jdk/jfr/internal/tool/Print.java b/src/share/classes/jdk/jfr/internal/tool/Print.java new file mode 100644 index 0000000000000000000000000000000000000000..8977dd0de303d9e3515745459480402224b26887 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/tool/Print.java @@ -0,0 +1,262 @@ +/* + * 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. 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.internal.tool; + +import java.io.IOException; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.nio.charset.Charset; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Deque; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.function.Predicate; + +import jdk.jfr.EventType; + +final class Print extends Command { + @Override + public String getName() { + return "print"; + } + + @Override + public List getOptionSyntax() { + List list = new ArrayList<>(); + list.add("[--xml|--json]"); + list.add("[--categories ]"); + list.add("[--events ]"); + list.add("[--stack-depth ]"); + list.add(""); + return list; + } + + @Override + protected String getTitle() { + return "Print contents of a recording file"; + } + + @Override + public String getDescription() { + return getTitle() + ". See 'jfr help print' for details."; + } + + @Override + public void displayOptionUsage(PrintStream stream) { + stream.println(" --xml Print recording in XML format"); + stream.println(); + stream.println(" --json Print recording in JSON format"); + stream.println(); + stream.println(" --categories Select events matching a category name."); + stream.println(" The filter is a comma-separated list of names,"); + stream.println(" simple and/or qualified, and/or quoted glob patterns"); + stream.println(); + stream.println(" --events Select events matching an event name."); + stream.println(" The filter is a comma-separated list of names,"); + stream.println(" simple and/or qualified, and/or quoted glob patterns"); + stream.println(); + stream.println(" --stack-depth Number of frames in stack traces, by default 5"); + stream.println(); + stream.println(" Location of the recording file (.jfr)"); + stream.println(); + stream.println(); + stream.println("Example usage:"); + stream.println(); + stream.println(" jfr print --events OldObjectSample recording.jfr"); + stream.println(); + stream.println(" jfr print --events CPULoad,GarbageCollection recording.jfr"); + stream.println(); + stream.println(" jfr print --categories \"GC,JVM,Java*\" recording.jfr"); + stream.println(); + stream.println(" jfr print --events \"jdk.*\" --stack-depth 64 recording.jfr"); + stream.println(); + stream.println(" jfr print --json --events CPULoad recording.jfr"); + } + + @Override + public void execute(Deque options) throws UserSyntaxException, UserDataException { + Path file = getJFRInputFile(options); + PrintWriter pw = new PrintWriter(System.out, false); + Predicate eventFilter = null; + int stackDepth = 5; + EventPrintWriter eventWriter = null; + int optionCount = options.size(); + while (optionCount > 0) { + if (acceptFilterOption(options, "--events")) { + String filter = options.remove(); + warnForWildcardExpansion("--events", filter); + eventFilter = addEventFilter(filter, eventFilter); + } + if (acceptFilterOption(options, "--categories")) { + String filter = options.remove(); + warnForWildcardExpansion("--categories", filter); + eventFilter = addCategoryFilter(filter, eventFilter); + } + if (acceptOption(options, "--stack-depth")) { + String value = options.pop(); + try { + stackDepth = Integer.parseInt(value); + if (stackDepth < 0) { + throw new UserSyntaxException("stack depth must be zero or a positive integer."); + } + } catch (NumberFormatException nfe) { + throw new UserSyntaxException("not a valid value for --stack-depth"); + } + } + if (acceptFormatterOption(options, eventWriter, "--json")) { + eventWriter = new JSONWriter(pw); + } + if (acceptFormatterOption(options, eventWriter, "--xml")) { + eventWriter = new XMLWriter(pw); + } + if (optionCount == options.size()) { + // No progress made + throw new UserSyntaxException("unknown option " + options.peek()); + } + optionCount = options.size(); + } + if (eventWriter == null) { + eventWriter = new PrettyWriter(pw); // default to pretty printer + } + eventWriter.setStackDepth(stackDepth); + if (eventFilter != null) { + eventFilter = addCache(eventFilter, eventType -> eventType.getId()); + eventWriter.setEventFilter(eventFilter); + } + try { + eventWriter.print(file); + } catch (IOException ioe) { + couldNotReadError(file, ioe); + } + pw.flush(); + } + + private static boolean acceptFormatterOption(Deque options, EventPrintWriter eventWriter, String expected) throws UserSyntaxException { + if (expected.equals(options.peek())) { + if (eventWriter != null) { + throw new UserSyntaxException("only one format can be specified at a time"); + } + options.remove(); + return true; + } + return false; + } + + private static Predicate addCache(final Predicate filter, Function cacheFunction) { + Map cache = new HashMap<>(); + return t -> cache.computeIfAbsent(cacheFunction.apply(t), x -> filter.test(t)); + } + + private static Predicate recurseIfPossible(Predicate filter) { + return x -> filter != null && filter.test(x); + } + + private static Predicate addCategoryFilter(String filterText, Predicate eventFilter) throws UserSyntaxException { + List filters = explodeFilter(filterText); + return recurseIfPossible(eventType -> { + for (String category : eventType.getCategoryNames()) { + for (String filter : filters) { + if (match(category, filter)) { + return true; + } + if (category.contains(" ") && acronomify(category).equals(filter)) { + return true; + } + } + } + return false; + }); + } + + private static String acronomify(String multipleWords) { + boolean newWord = true; + String acronym = ""; + for (char c : multipleWords.toCharArray()) { + if (newWord) { + if (Character.isAlphabetic(c) && Character.isUpperCase(c)) { + acronym += c; + } + } + newWord = Character.isWhitespace(c); + } + return acronym; + } + + private static Predicate addEventFilter(String filterText, final Predicate eventFilter) throws UserSyntaxException { + List filters = explodeFilter(filterText); + return recurseIfPossible(eventType -> { + for (String filter : filters) { + String fullEventName = eventType.getName(); + if (match(fullEventName, filter)) { + return true; + } + String eventName = fullEventName.substring(fullEventName.lastIndexOf(".") + 1); + if (match(eventName, filter)) { + return true; + } + } + return false; + }); + } + + private static boolean match(String text, String filter) { + if (filter.length() == 0) { + // empty filter string matches if string is empty + return text.length() == 0; + } + if (filter.charAt(0) == '*') { // recursive check + filter = filter.substring(1); + for (int n = 0; n <= text.length(); n++) { + if (match(text.substring(n), filter)) + return true; + } + } else if (text.length() == 0) { + // empty string and non-empty filter does not match + return false; + } else if (filter.charAt(0) == '?') { + // eat any char and move on + return match(text.substring(1), filter.substring(1)); + } else if (filter.charAt(0) == text.charAt(0)) { + // eat chars and move on + return match(text.substring(1), filter.substring(1)); + } + return false; + } + + private static List explodeFilter(String filter) throws UserSyntaxException { + List list = new ArrayList<>(); + for (String s : filter.split(",")) { + s = s.trim(); + if (!s.isEmpty()) { + list.add(s); + } + } + return list; + } +} diff --git a/src/share/classes/jdk/jfr/internal/tool/StructuredWriter.java b/src/share/classes/jdk/jfr/internal/tool/StructuredWriter.java new file mode 100644 index 0000000000000000000000000000000000000000..f6b5ae2d068cc8e4e959790d588febf03f2d143b --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/tool/StructuredWriter.java @@ -0,0 +1,121 @@ +/* + * 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. 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.internal.tool; + +import java.io.PrintWriter; + +abstract class StructuredWriter { + private final static String LINE_SEPARATOR = String.format("%n"); + + private final PrintWriter out; + private final StringBuilder builder = new StringBuilder(4000); + + private char[] indentionArray = new char[0]; + private int indent = 0; + private int column; + // print first event immediately so tool feels responsive + private boolean first = true; + + StructuredWriter(PrintWriter p) { + out = p; + } + + final protected int getColumn() { + return column; + } + + // Flush to print writer + public final void flush(boolean hard) { + if (hard) { + out.print(builder.toString()); + builder.setLength(0); + return; + } + if (first || builder.length() > 100_000) { + out.print(builder.toString()); + builder.setLength(0); + first = false; + } + } + + final public void printIndent() { + builder.append(indentionArray, 0, indent); + column += indent; + } + + final public void println() { + builder.append(LINE_SEPARATOR); + column = 0; + } + + final public void print(String... texts) { + for (String text : texts) { + print(text); + } + } + + final public void printAsString(Object o) { + print(String.valueOf(o)); + } + + final public void print(String text) { + builder.append(text); + column += text.length(); + } + + final public void print(char c) { + builder.append(c); + column++; + } + + final public void print(int value) { + print(String.valueOf(value)); + } + + final public void indent() { + indent += 2; + updateIndent(); + } + + final public void retract() { + indent -= 2; + updateIndent(); + } + + final public void println(String text) { + print(text); + println(); + } + + private void updateIndent() { + if (indent > indentionArray.length) { + indentionArray = new char[indent]; + for (int i = 0; i < indentionArray.length; i++) { + indentionArray[i] = ' '; + } + } + } +} diff --git a/src/share/classes/jdk/jfr/internal/tool/Summary.java b/src/share/classes/jdk/jfr/internal/tool/Summary.java new file mode 100644 index 0000000000000000000000000000000000000000..e282d6b7e3307f81adb3a95f3570bbac82059d38 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/tool/Summary.java @@ -0,0 +1,162 @@ +/* + * 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. 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.internal.tool; + +import java.io.IOException; +import java.io.PrintStream; +import java.nio.file.Path; +import java.time.Instant; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Deque; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; + +import jdk.jfr.EventType; +import jdk.jfr.internal.MetadataDescriptor; +import jdk.jfr.internal.Type; +import jdk.jfr.internal.consumer.ChunkHeader; +import jdk.jfr.internal.consumer.RecordingInput; + +final class Summary extends Command { + private final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withLocale(Locale.UK).withZone(ZoneOffset.UTC); + + @Override + public String getName() { + return "summary"; + } + + private static class Statistics { + Statistics(String name) { + this.name = name; + } + String name; + long count; + long size; + } + + @Override + public List getOptionSyntax() { + return Collections.singletonList(""); + } + + @Override + public void displayOptionUsage(PrintStream stream) { + stream.println(" Location of the recording file (.jfr) to display information about"); + } + + @Override + public String getDescription() { + return "Display general information about a recording file (.jfr)"; + } + + @Override + public void execute(Deque options) throws UserSyntaxException, UserDataException { + ensureMaxArgumentCount(options, 1); + Path p = getJFRInputFile(options); + try { + printInformation(p); + } catch (IOException e) { + couldNotReadError(p, e); + } + } + + private void printInformation(Path p) throws IOException { + long totalDuration = 0; + long chunks = 0; + + try (RecordingInput input = new RecordingInput(p.toFile())) { + ChunkHeader first = new ChunkHeader(input); + ChunkHeader ch = first; + String eventPrefix = Type.EVENT_NAME_PREFIX; + if (first.getMajor() == 1) { + eventPrefix = "com.oracle.jdk."; + } + HashMap stats = new HashMap<>(); + stats.put(0L, new Statistics(eventPrefix + "Metadata")); + stats.put(1L, new Statistics(eventPrefix + "CheckPoint")); + int minWidth = 0; + while (true) { + long chunkEnd = ch.getEnd(); + MetadataDescriptor md = ch.readMetadata(); + + for (EventType eventType : md.getEventTypes()) { + stats.computeIfAbsent(eventType.getId(), (e) -> new Statistics(eventType.getName())); + minWidth = Math.max(minWidth, eventType.getName().length()); + } + + totalDuration += ch.getDurationNanos(); + chunks++; + input.position(ch.getEventStart()); + while (input.position() < chunkEnd) { + long pos = input.position(); + int size = input.readInt(); + long eventTypeId = input.readLong(); + Statistics s = stats.get(eventTypeId); + if (s != null) { + s.count++; + s.size += size; + } + input.position(pos + size); + } + if (ch.isLastChunk()) { + break; + } + ch = ch.nextHeader(); + } + println(); + long epochSeconds = first.getStartNanos() / 1_000_000_000L; + long adjustNanos = first.getStartNanos() - epochSeconds * 1_000_000_000L; + println(" Version: " + first.getMajor() + "." + first.getMinor()); + println(" Chunks: " + chunks); + println(" Start: " + DATE_FORMAT.format(Instant.ofEpochSecond(epochSeconds, adjustNanos)) + " (UTC)"); + println(" Duration: " + (totalDuration + 500_000_000) / 1_000_000_000 + " s"); + + List statsList = new ArrayList<>(stats.values()); + Collections.sort(statsList, (u, v) -> Long.compare(v.count, u.count)); + println(); + String header = " Count Size (bytes) "; + String typeHeader = " Event Type"; + minWidth = Math.max(minWidth, typeHeader.length()); + println(typeHeader + pad(minWidth - typeHeader.length(), ' ') + header); + println(pad(minWidth + header.length(), '=')); + for (Statistics s : statsList) { + System.out.printf(" %-" + minWidth + "s%10d %12d\n", s.name, s.count, s.size); + } + } + } + + private String pad(int count, char c) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < count; i++) { + sb.append(c); + } + return sb.toString(); + } +} diff --git a/src/share/classes/jdk/jfr/internal/tool/UserDataException.java b/src/share/classes/jdk/jfr/internal/tool/UserDataException.java new file mode 100644 index 0000000000000000000000000000000000000000..a21ae95f6713cf91e7e7132ce5761e611d130e8b --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/tool/UserDataException.java @@ -0,0 +1,49 @@ +/* + * 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.internal.tool; + +/** + * Exception that is thrown if there is something wrong with the input, for instance + * a file that can't be read or a numerical value that is out of range. + *

    + * When this exception is thrown, a user will typically not want to see the + * command line syntax, but instead information about what was wrong with the + * input. + */ +final class UserDataException extends Exception { + private static final long serialVersionUID = 6656457380115167810L; + /** + * The error message. + * + * The first letter should not be capitalized, so a context can be printed prior + * to the error message. + * + * @param errorMessage + */ + public UserDataException(String errorMessage) { + super(errorMessage); + } +} diff --git a/src/share/classes/jdk/jfr/internal/tool/UserSyntaxException.java b/src/share/classes/jdk/jfr/internal/tool/UserSyntaxException.java new file mode 100644 index 0000000000000000000000000000000000000000..db6224ccee3540278ec358e62df19c7806720386 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/tool/UserSyntaxException.java @@ -0,0 +1,45 @@ +/* + * 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.internal.tool; + +/** + * Exception that is thrown if options don't follow the syntax of the command. + */ +final class UserSyntaxException extends Exception { + private static final long serialVersionUID = 3437009454344160933L; + + /** + * The error message. + * + * The first letter should not be capitalized, so a context can be printed prior + * to the error message. + * + * @param errorMessage + */ + public UserSyntaxException(String message) { + super(message); + } +} diff --git a/src/share/classes/jdk/jfr/internal/tool/Version.java b/src/share/classes/jdk/jfr/internal/tool/Version.java new file mode 100644 index 0000000000000000000000000000000000000000..c1002745a5ef9ad754ad4b95c94fb0b65042c28f --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/tool/Version.java @@ -0,0 +1,51 @@ +/* + * 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.internal.tool; + +import java.util.Arrays; +import java.util.Deque; +import java.util.List; + +final class Version extends Command { + @Override + public String getName() { + return "version"; + } + + @Override + public String getDescription() { + return "Display version of the jfr tool"; + } + + @Override + public void execute(Deque options) { + System.out.println("1.0"); + } + + protected List getAliases() { + return Arrays.asList("--version"); + } +} diff --git a/src/share/classes/jdk/jfr/internal/tool/XMLWriter.java b/src/share/classes/jdk/jfr/internal/tool/XMLWriter.java new file mode 100644 index 0000000000000000000000000000000000000000..2db1688239b5318b93baa0a5185d242d7f4e92d4 --- /dev/null +++ b/src/share/classes/jdk/jfr/internal/tool/XMLWriter.java @@ -0,0 +1,200 @@ +/* + * 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. 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.internal.tool; + +import java.io.PrintWriter; +import java.util.List; + +import jdk.jfr.EventType; +import jdk.jfr.ValueDescriptor; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedFrame; +import jdk.jfr.consumer.RecordedObject; + +final class XMLWriter extends EventPrintWriter { + public XMLWriter(PrintWriter destination) { + super(destination); + } + + @Override + protected void printBegin() { + println(""); + println(""); + indent(); + printIndent(); + println(""); + indent(); + } + + @Override + protected void printEnd() { + retract(); + printIndent(); + println(""); + retract(); + println(""); + } + + @Override + protected void print(List events) { + for (RecordedEvent event : events) { + printEvent(event); + } + } + + private void printEvent(RecordedEvent event) { + EventType type = event.getEventType(); + printIndent(); + print(""); + println(); + indent(); + for (ValueDescriptor v : event.getFields()) { + printValueDescriptor(v, getValue(event, v), -1); + } + retract(); + printIndent(); + println(""); + println(); + } + + private void printAttribute(String name, String value) { + print(" ", name, "=\"", value, "\""); + } + + public void printObject(RecordedObject struct) { + println(); + indent(); + for (ValueDescriptor v : struct.getFields()) { + printValueDescriptor(v, getValue(struct, v), -1); + } + retract(); + } + + private void printArray(ValueDescriptor v, Object[] array) { + println(); + indent(); + int depth = 0; + for (int index = 0; index < array.length; index++) { + Object arrayElement = array[index]; + if (!(arrayElement instanceof RecordedFrame) || depth < getStackDepth()) { + printValueDescriptor(v, array[index], index); + } + depth++; + } + retract(); + } + + private void printValueDescriptor(ValueDescriptor vd, Object value, int index) { + boolean arrayElement = index != -1; + String name = arrayElement ? null : vd.getName(); + if (vd.isArray() && !arrayElement) { + if (printBeginElement("array", name, value, index)) { + printArray(vd, (Object[]) value); + printIndent(); + printEndElement("array"); + } + return; + } + if (!vd.getFields().isEmpty()) { + if (printBeginElement("struct", name, value, index)) { + printObject((RecordedObject) value); + printIndent(); + printEndElement("struct"); + } + return; + } + if (printBeginElement("value", name, value, index)) { + printEscaped(String.valueOf(value)); + printEndElement("value"); + } + } + + private boolean printBeginElement(String elementName, String name, Object value, int index) { + printIndent(); + print("<", elementName); + if (name != null) { + printAttribute("name", name); + } + if (index != -1) { + printAttribute("index", Integer.toString(index)); + } + if (value == null) { + printAttribute("xsi:nil", "true"); + println("/>"); + return false; + } + if (value.getClass().isArray()) { + Object[] array = (Object[]) value; + printAttribute("size", Integer.toString(array.length)); + } + print(">"); + return true; + } + + private void printEndElement(String elementName) { + print(""); + } + + private void printEscaped(String text) { + for (int i = 0; i < text.length(); i++) { + printEscaped(text.charAt(i)); + } + } + + private void printEscaped(char c) { + if (c == 34) { + print("""); + return; + } + if (c == 38) { + print("&"); + return; + } + if (c == 39) { + print("'"); + return; + } + if (c == 60) { + print("<"); + return; + } + if (c == 62) { + print(">"); + return; + } + if (c > 0x7F) { + print("&#"); + print((int) c); + print(';'); + return; + } + print(c); + } +} diff --git a/src/share/classes/jdk/jfr/package-info.java b/src/share/classes/jdk/jfr/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..29acf83c33bb56a1377ce0cf0ab6859a30e5c8a7 --- /dev/null +++ b/src/share/classes/jdk/jfr/package-info.java @@ -0,0 +1,196 @@ +/* + * 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 + * 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 package provides classes to create events and control Flight Recorder. + *

    + * Defining events + *

    + * Flight Recorder collects data as events. An event has a time stamp, duration + * and usually an application-specific payload, useful for diagnosing the + * running application up to the failure or crash. + *

    + * To define a Flight Recorder event, extend {@link jdk.jfr.Event} and add + * fields that matches the data types of the payload. Metadata about fields, + * such as labels, descriptions and units, can be added by using the annotations + * available in the jdk.jfr package, or by using a user-defined + * annotation that has the {@link jdk.jfr.MetadataDefinition} annotation. + *

    + * After an event class is defined, instances can be created (event objects). + * Data is stored in the event by assigning data to fields. Event timing can be + * explicitly controlled by using the begin and {@code end} methods + * available in the Event class. + *

    + * Gathering data to store in an event can be expensive. The + * {@link Event#shouldCommit()} method can be used to verify whether an event + * instance would actually be written to the system when the + * {@code Event#commit()} method is invoked. If + * {@link Event#shouldCommit()} returns {@code false}, then those operations can be + * avoided. + *

    + * Sometimes the field layout of an event is not known at compile time. In that + * case, an event can be dynamically defined. However, dynamic events might not + * have the same level of performance as statically defined ones and tools might + * not be able to identify and visualize the data without knowing the layout. + *

    + * To dynamically define an event, use the {@link jdk.jfr.EventFactory} class + * and define fields by using the {@link jdk.jfr.ValueDescriptor} class, and + * define annotations by using the {@link jdk.jfr.AnnotationElement} class. Use + * the factory to allocate an event and the + * {@link jdk.jfr.Event#set(int, Object)} method to populate it. + *

    + * Controlling Flight Recorder + *

    + * Flight Recorder can be controlled locally by using the jcmd + * command line tool or remotely by using the FlightRecorderMXBean + * interface, registered in the platform MBeanServer. When direct programmatic + * access is needed, a Flight Recorder instance can be obtained by invoking + * {@link jdk.jfr.FlightRecorder#getFlightRecorder()} and a recording created by + * using {@link jdk.jfr.Recording} class, from which the amount of data to + * record is configured. + *

    + * Settings and configuration + *

    + * A setting consists of a name/value pair, where name specifies the + * event and setting to configure, and the value specifies what to set + * it to. + *

    + * The name can be formed in the following ways: + *

    + * {@code + * + "#" + + * } + *

    + * or + *

    + * {@code + * + "#" + + * } + *

    + * For example, to set the sample interval of the CPU Load event to once every + * second, use the name {@code "jdk.CPULoad#period"} and the value + * {@code "1 s"}. If multiple events use the same name, for example if an event + * class is loaded in multiple class loaders, and differentiation is needed + * between them, then the name is {@code "56#period"}. The ID for an event is + * obtained by invoking {@link jdk.jfr.EventType#getId()} method and is valid + * for the Java Virtual Machine instance that the event is registered in. + *

    + * A list of available event names is retrieved by invoking + * {@link jdk.jfr.FlightRecorder#getEventTypes()} and + * {@link jdk.jfr.EventType#getName()}. A list of available settings for an + * event type is obtained by invoking + * {@link jdk.jfr.EventType#getSettingDescriptors()} and + * {@link jdk.jfr.ValueDescriptor#getName()}. + *

    + * Predefined settings + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Event setting names and their purpose.
    NameDescriptionDefault valueFormatExample values
    {@code enabled}Specifies whether the event is recorded{@code "true"}String representation of a {@code Boolean} ({@code "true"} or + * {@code "false"}){@code "true"}
    + * {@code "false"}
    {@code threshold}Specifies the duration below which an event is not recorded{@code "0"} (no limit){@code "0"} if no threshold is used, otherwise a string representation of + * a positive {@code Long} followed by a space and one of the following units: + *
      + *
    • {@code "ns"} (nanoseconds) + *
    • {@code "us"} (microseconds) + *
    • {@code "ms"} (milliseconds) + *
    • {@code "s"} (seconds) + *
    • {@code "m"} (minutes) + *
    • {@code "h"} (hours) + *
    • {@code "d"} (days) + *
    + *
    {@code "0"}
    + * {@code "10 ms"}
    + * "1 s"
    {@code period}Specifies the interval at which the event is emitted, if it is + * periodic{@code "everyChunk"}{@code "everyChunk"}, if a periodic event should be emitted with every + * file rotation, otherwise a string representation of a positive {@code Long} + * value followed by an empty space and one of the following units: + *
      + *
    • {@code "ns"} (nanoseconds) + *
    • {@code "us"} (microseconds) + *
    • {@code "ms"} (milliseconds) + *
    • {@code "s"} (seconds) + *
    • {@code "m"} (minutes) + *
    • {@code "h"} (hours) + *
    • {@code "d"} (days) + *
    + *
    {@code "20 ms"}
    + * {@code "1 s"}
    + * {@code "everyChunk"}
    {@code stackTrace}Specifies whether the stack trace from the {@code Event#commit()} method + * is recorded{@code "true"}String representation of a {@code Boolean} ({@code "true"} or + * {@code "false"}){@code "true"},
    + * {@code "false"}
    + *

    + * Null-handling + *

    + * All methods define whether they accept or return {@code null} in the Javadoc. + * Typically this is expressed as {@code "not null"}. If a {@code null} + * parameter is used where it is not allowed, a + * {@code java.lang.NullPointerException} is thrown. If a {@code null} + * parameters is passed to a method that throws other exceptions, such as + * {@code java.io.IOException}, the {@code java.lang.NullPointerException} takes + * precedence, unless the Javadoc for the method explicitly states how + * {@code null} is handled, i.e. by throwing + * {@code java.lang.IllegalArgumentException}. + * + * @since 8 + */ +package jdk.jfr; diff --git a/src/share/classes/jdk/management/jfr/ConfigurationInfo.java b/src/share/classes/jdk/management/jfr/ConfigurationInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..0d08bfd1af738f36d4c952a17268e0a01c77e0a3 --- /dev/null +++ b/src/share/classes/jdk/management/jfr/ConfigurationInfo.java @@ -0,0 +1,241 @@ +/* + * 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 + * 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.management.jfr; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import javax.management.openmbean.CompositeData; +import javax.management.openmbean.TabularData; + +import jdk.jfr.Configuration; + + +/** + * Management representation of a {@code Configuration}. + * + * @see Configuration + * + * @since 8 + */ +public final class ConfigurationInfo { + private final Map settings; + private final String name; + private final String label; + private final String description; + private final String provider; + private final String contents; + + ConfigurationInfo(Configuration config) { + this.settings = config.getSettings(); + this.name = config.getName(); + this.label = config.getLabel(); + this.description = config.getDescription(); + this.provider = config.getProvider(); + this.contents = config.getContents(); + } + + private ConfigurationInfo(CompositeData cd) { + this.settings = createMap(cd.get("settings")); + this.name = (String) cd.get("name"); + this.label = (String) cd.get("label"); + this.description = (String) cd.get("description"); + this.provider = (String) cd.get("provider"); + this.contents = (String) cd.get("contents"); + } + + private static Map createMap(Object o) { + if (o instanceof TabularData) { + TabularData td = (TabularData) o; + Collection values = td.values(); + Map map = new HashMap<>(values.size()); + for (Object value : td.values()) { + if (value instanceof CompositeData) { + CompositeData cdRow = (CompositeData) value; + Object k = cdRow.get("key"); + Object v = cdRow.get("value"); + if (k instanceof String && v instanceof String) { + map.put((String) k, (String) v); + } + } + } + return Collections.unmodifiableMap(map); + } + return Collections.emptyMap(); + } + + /** + * Returns the provider of the configuration associated with this + * {@code ConfigurationInfo} (for example, {@code "OpenJDK"}). + * + * @return the provider, or {@code null} if doesn't exist + * + * @see Configuration#getProvider() + */ + public String getProvider() { + return provider; + } + + /** + * Returns the textual representation of the configuration associated with + * this {@code ConfigurationInfo}, typically the contents of the + * configuration file that was used to create the configuration. + * + * @return contents, or {@code null} if doesn't exist + * + * @see Configuration#getContents() + */ + public String getContents() { + return contents; + } + + /** + * Returns the settings for the configuration associated with this + * {@code ConfigurationInfo}. + * + * @return a {@code Map} with settings, not {@code null} + * + * @see Configuration#getSettings() + */ + public Map getSettings() { + return settings; + } + + /** + * Returns the human-readable name (for example, {@code "Continuous"} or {@code "Profiling"}) for + * the configuration associated with this {@code ConfigurationInfo} + * + * @return the label, or {@code null} if doesn't exist + * + * @see Configuration#getLabel() + */ + public String getLabel() { + return label; + } + + /** + * Returns the name of the configuration associated with this + * {@code ConfigurationInfo} (for example, {@code "default"}). + * + * @return the name, or {@code null} if doesn't exist + * + * @see Configuration#getLabel() + */ + public String getName() { + return name; + } + + /** + * Returns a short sentence that describes the configuration associated with + * this {@code ConfigurationInfo} (for example, {@code "Low + * overhead configuration safe for continuous use in production + * environments"}. + * + * @return the description, or {@code null} if doesn't exist + */ + public String getDescription() { + return description; + } + + /** + * Returns a {@code ConfigurationInfo} object represented by the specified + * {@code CompositeData}. + *

    + * The following table shows the required attributes that the specified {@code CompositeData} must contain. + *

    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Required names and types for CompositeData
    NameType
    name{@code String}
    label{@code String}
    description{@code String}
    provider{@code String}
    contents{@code String}
    settings{@code javax.management.openmbean.TabularData} with a + * {@code TabularType} with the keys {@code "key"} and {@code "value"}, both + * of the {@code String} type
    + *
    + * + * @param cd {@code CompositeData} representing a {@code ConfigurationInfo} + * + * @throws IllegalArgumentException if {@code cd} does not represent a + * {@code ConfigurationInfo} with the required attributes + * + * @return a {@code ConfigurationInfo} object represented by {@code cd} if + * {@code cd} is not {@code null}, {@code null} otherwise + */ + public static ConfigurationInfo from(CompositeData cd) { + if (cd == null) { + return null; + } + return new ConfigurationInfo(cd); + } + + /** + * Returns a description of the configuration that is associated with this + * {@code ConfigurationInfo}. + * + * @return the description of the configuration, not {@code null} + */ + @Override + public String toString() { + Stringifier s = new Stringifier(); + s.add("name", name); + s.add("label", label); + s.add("description", description); + s.add("provider", provider); + return s.toString(); + } +} diff --git a/src/share/classes/jdk/management/jfr/EventTypeInfo.java b/src/share/classes/jdk/management/jfr/EventTypeInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..c8049af57ce575d951f9494c217ac0066e0d958b --- /dev/null +++ b/src/share/classes/jdk/management/jfr/EventTypeInfo.java @@ -0,0 +1,262 @@ +/* + * 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 + * 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.management.jfr; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.StringJoiner; + +import javax.management.openmbean.CompositeData; + +import jdk.jfr.Category; +import jdk.jfr.EventType; +import jdk.jfr.SettingDescriptor; + +/** + * Management representation of an {@code EventType}. + * + * @see EventType + * + * @since 8 + */ +public final class EventTypeInfo { + private final List settings; + private final long id; + private final String name; + private final String description; + private final String label; + private final List categoryNames; + + // package private + EventTypeInfo(EventType eventType) { + this.settings = creatingSettingDescriptorInfos(eventType); + this.id = eventType.getId(); + this.name = eventType.getName(); + this.label = eventType.getLabel(); + this.description = eventType.getDescription(); + this.categoryNames = eventType.getCategoryNames(); + } + + private EventTypeInfo(CompositeData cd) { + this.settings = createSettings(cd.get("settings")); + this.id = (long) cd.get("id"); + this.name = (String) cd.get("name"); + this.label = (String) cd.get("label"); + this.description = (String) cd.get("description"); + this.categoryNames = createCategoryNames((Object[]) cd.get("category")); + } + + private static List createCategoryNames(Object[] array) { + List list = new ArrayList<>(array.length); + for (int i = 0; i < array.length; i++) { + list.add((String) array[i]); + } + return Collections.unmodifiableList(list); + } + + private static List creatingSettingDescriptorInfos(EventType eventType) { + List settings = eventType.getSettingDescriptors(); + List settingDescriptorInfos = new ArrayList<>(settings.size()); + for (SettingDescriptor s : settings) { + settingDescriptorInfos.add(new SettingDescriptorInfo(s)); + } + return Collections.unmodifiableList(settingDescriptorInfos); + } + + private static List createSettings(Object settings) { + if (settings != null && settings.getClass().isArray()) { + Object[] settingsArray = (Object[]) settings; + List list = new ArrayList<>(settingsArray.length); + for (Object cd : settingsArray) { + if (cd instanceof CompositeData) { + list.add(SettingDescriptorInfo.from((CompositeData) cd)); + } + } + return Collections.unmodifiableList(list); + } + return Collections.emptyList(); + } + + /** + * Returns the label, a human-readable name, associated with the event type + * for this {@code EventTypeInfo} (for example, {@code "Garbage Collection"}). + * + * @return the label, or {@code null} if a label is not set + * + * @see EventType#getLabel() + */ + public String getLabel() { + return label; + } + + /** + * + * Returns the list of human-readable names that makes up the category for this + * {@code EventTypeInfo} (for example, {@code "Java Virtual Machine"} or {@code "Garbage Collector"}). + * + * @return an immutable list of category names, or a list with the name + * {@code "Uncategorized"} if no category has been set + * + * @see EventType#getCategoryNames() + * @see Category + */ + public List getCategoryNames() { + return categoryNames; + } + + /** + * Returns the unique ID for the event type associated with this + * {@code EventTypeInfo}, not guaranteed to be the same for different Java + * Virtual Machines (JVMs) instances. + * + * @return the ID + * + * @see EventType#getId() + */ + public long getId() { + return id; + } + + /** + * Returns the name for the event type associated with this + * {@code EventTypeInfo} (for example, {@code "jdk.GarbageCollection"}). + * + * @return the name, not {@code null} + * + * @see EventType#getName() + */ + public String getName() { + return name; + } + + /** + * Returns a short sentence or two describing the event type associated with + * this {@code EventTypeInfo}, for example + * {@code "Garbage collection performed by the JVM""}. + * + * @return the description, or {@code null} if no description exists + * + * @see EventType#getDescription() + */ + public String getDescription() { + return description; + } + + /** + * Returns settings for the event type associated with this + * {@code EventTypeInfo}. + * + * @return the settings, not {@code null} + * + * @see EventType#getSettingDescriptors() + */ + public List getSettingDescriptors() { + return settings; + } + + /** + * Returns a description of this {@code EventTypeInfo}. + * + * @return description, not {@code null} + */ + @Override + public String toString() { + Stringifier s = new Stringifier(); + s.add("id", id); + s.add("name", name); + s.add("label", label); + s.add("description", description); + StringJoiner sj = new StringJoiner(", ", "{", "}"); + for (String categoryName : categoryNames) { + sj.add(categoryName); + } + s.add("category", sj.toString()); + return s.toString(); + } + + /** + * Returns an {@code EventType} represented by the specified + * {@code CompositeData} + *

    + * The supplied {@code CompositeData} must have the following item names and + * item types to be valid.

    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    The name and type the specified CompositeData must contain
    NameType
    id{@code Long}
    name{@code String}
    label{@code String}
    description{@code String}
    categoryArrayType(1, SimpleType.STRING)
    settings{@code javax.management.openmbean.CompositeData[]} whose element type + * is the mapped type for {@link SettingDescriptorInfo} as specified in the + * {@link SettingDescriptorInfo#from} method.
    + *
    + * + * @param cd {@code CompositeData} representing the {@code EventTypeInfo} to + * return + * + * @throws IllegalArgumentException if {@code cd} does not represent a valid + * {@code EventTypeInfo} + * + * @return an {@code EventTypeInfo}, or {@code null} if {@code cd} is + * {@code null} + */ + public static EventTypeInfo from(CompositeData cd) { + if (cd == null) { + return null; + } + return new EventTypeInfo(cd); + } +} diff --git a/src/share/classes/jdk/management/jfr/FlightRecorderMXBean.java b/src/share/classes/jdk/management/jfr/FlightRecorderMXBean.java new file mode 100644 index 0000000000000000000000000000000000000000..df946d7bd99d760fd835cfc9f718aac9954a12f2 --- /dev/null +++ b/src/share/classes/jdk/management/jfr/FlightRecorderMXBean.java @@ -0,0 +1,639 @@ +/* + * 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 + * 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.management.jfr; + +import java.io.IOException; +import java.lang.management.PlatformManagedObject; +import java.time.Instant; +import java.util.List; +import java.util.Map; + +import jdk.jfr.Configuration; +import jdk.jfr.EventType; +import jdk.jfr.Recording; + +/** + * Management interface for controlling Flight Recorder. + *

    + * The object name for identifying the MXBean in the platform MBean + * server is:

    {@code jdk.management.jfr:type=FlightRecorder}
    + *

    + * Flight Recorder can be configured in the following ways: + *

      + *
    • Recording options
      + * Specify how long a recording should last, and where and when data + * should be dumped.
    • + *
    • Settings
      + * Specify which events should be enabled and what kind information each + * event should capture.
    • + *
    • Configurations
      + * Predefined sets of settings, typically derived from a settings file, + * that specify the configuration of multiple events simultaneously.
    • + *
    + *

    + * See the package {@code jdk.jfr} documentation for descriptions of the settings + * syntax and the {@link ConfigurationInfo} class documentation for configuration information. + * + *

    Recording options

    + *

    + * The following table shows the options names to use with {@link #setRecordingOptions(long, Map)} + * and {@link #getRecordingOptions(long)}. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Recording options
    NameDescripionDefault valueFormatExample values
    {@code name}Sets a human-readable recording nameString representation of the recording id{@code String}{@code "My Recording"},
    + * {@code "profiling"}
    {@code maxAge}Specify the length of time that the data is kept in the disk repository until the + * oldest data may be deleted. Only works if {@code disk=true}, otherwise + * this parameter is ignored.{@code "0"} (no limit){@code "0"} if no limit is imposed, otherwise a string + * representation of a positive {@code Long} value followed by an empty space + * and one of the following units,
    + *
    + * {@code "ns"} (nanoseconds)
    + * {@code "us"} (microseconds)
    + * {@code "ms"} (milliseconds)
    + * {@code "s"} (seconds)
    + * {@code "m"} (minutes)
    + * {@code "h"} (hours)
    + * {@code "d"} (days)
    + *
    {@code "2 h"},
    + * {@code "24 h"},
    + * {@code "2 d"},
    + * {@code "0"}
    {@code maxSize}Specifies the size, measured in bytes, at which data is kept in disk + * repository. Only works if + * {@code disk=true}, otherwise this parameter is ignored.{@code "0"} (no limit)String representation of a {@code Long} value, must be positive{@code "0"},
    + * {@code "1000000000"}
    {@code dumpOnExit}Dumps recording data to disk on Java Virtual Machine (JVM) exit{@code "false"}String representation of a {@code Boolean} value, {@code "true"} or + * {@code "false"}{@code "true"},
    + * {@code "false"}
    {@code destination}Specifies the path where recording data is written when the recording stops.{@code "false"}See {@code Paths#getPath} for format.
    + * If this method is invoked from another process, the data is written on the + * machine where the target JVM is running. If destination is a relative path, it + * is relative to the working directory where the target JVM was started.}
    {@code "c:\recording\recotding.jfr"},
    + * {@code "/recordings/recording.jfr"}, {@code "recording.jfr"}
    {@code disk}Stores recorded data as it is recorded"false"String representation of a {@code Boolean} value, {@code "true"} or + * {@code "false"}{@code "true"},
    + * {@code "false"}
    {@code duration}Sets how long the recording should be running{@code "0"} (no limit, continuous){@code "0"} if no limit should be imposed, otherwise a string + * representation of a positive {@code Long} followed by an empty space and one + * of the following units:
    + *
    + * {@code "ns"} (nanoseconds)
    + * {@code "us"} (microseconds)
    + * {@code "ms"} (milliseconds)
    + * {@code "s"} (seconds)
    + * {@code "m"} (minutes)
    + * {@code "h"} (hours)
    + * {@code "d"} (days)
    + *
    {@code "60 s"},
    + * {@code "10 m"},
    + * {@code "4 h"},
    + * {@code "0"}
    + * + * @since 8 + */ +public interface FlightRecorderMXBean extends PlatformManagedObject { + /** + * String representation of the {@code ObjectName} for the + * {@code FlightRecorderMXBean}. + */ + public static final String MXBEAN_NAME = "jdk.management.jfr:type=FlightRecorder"; + + /** + * Creates a recording, but doesn't start it. + * + * @return a unique ID that can be used to start, stop, close and + * configure the recording + * + * @throws IllegalStateException if Flight Recorder can't be created (for + * example, if the Java Virtual Machine (JVM) lacks Flight Recorder + * support, or if the file repository can't be created or accessed) + * + * @throws java.lang.SecurityException if a security manager exists and the + * caller does not have {@code ManagementPermission("control")} + * + * @see Recording + */ + long newRecording() throws IllegalStateException, SecurityException; + + /** + * Creates a snapshot recording of all available recorded data. + *

    + * A snapshot is a synthesized recording in a stopped state. If no data is + * available, a recording with size {@code 0} is returned. + *

    + * A snapshot provides stable access to data for later operations (for example, + * operations to change the time interval or to reduce the data size). + *

    + * The caller must close the recording when access to the data is no longer + * needed. + * + * @return a snapshot of all available recording data, not {@code null} + * + * @throws java.lang.SecurityException if a security manager exists and the + * caller does not have {@code ManagementPermission("control")} + * + * @return a unique ID that can be used for reading recording data. + * + * @see Recording + */ + public long takeSnapshot(); + + /** + * Creates a copy of an existing recording, useful for extracting parts of a + * recording. + *

    + * The cloned recording contains the same recording data as the + * original, but it has a new ID and a name prefixed with + * {@code "Clone of recording"}. If the original recording is running, then + * the clone is also running. + * + * @param recordingId the recording ID of the recording to create a clone + * from + * + * @param stop if the newly created clone is stopped before + * returning. + * + * @return a unique ID that can be used to start, stop, + * close and configure the recording + * + * @throws IllegalArgumentException if a recording with the specified ID + * doesn't exist + * + * @throws java.lang.SecurityException if a security manager exists and the + * caller does not have {@code ManagementPermission("control")} + * + * @see Recording + */ + long cloneRecording(long recordingId, boolean stop) throws IllegalArgumentException, SecurityException; + + /** + * Starts the recording with the specified ID. + *

    + * A recording that is stopped can't be restarted. + * + * @param recordingId ID of the recording to start + * + * @throws IllegalArgumentException if a recording with the specified ID + * doesn't exist + * + * @throws java.lang.SecurityException if a security manager exists and the + * caller does not have {@code ManagementPermission("control")} + * + * @see Recording + */ + void startRecording(long recordingId) throws IllegalStateException, SecurityException; + + /** + * Stops the running recording with the specified ID. + * + * @param recordingId the ID of the recording to stop + * + * @return {@code true} if the recording is stopped, {@code false} + * otherwise + * + * @throws IllegalArgumentException if a recording with the specified ID + * doesn't exist + * @throws IllegalStateException if the recording is not running + * @throws java.lang.SecurityException if a security manager exists and the + * caller does not have {@code ManagementPermission("control")} + * + * @see #newRecording() + */ + boolean stopRecording(long recordingId) throws IllegalArgumentException, IllegalStateException, SecurityException; + + /** + * Closes the recording with the specified ID and releases any system + * resources that are associated with the recording. + *

    + * If the recording is already closed, invoking this method has no effect. + * + * @param recordingId the ID of the recording to close + * + * @throws IllegalArgumentException if a recording with the specified ID + * doesn't exist + * @throws IOException if an I/O error occurs + * @throws java.lang.SecurityException if a security manager exists and the + * caller does not have {@code ManagementPermission("control")} + * + * @see #newRecording() + */ + void closeRecording(long recordingId) throws IOException; + + /** + * Opens a data stream for the recording with the specified ID, or {@code 0} + * to get data irrespective of recording. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Recording stream options
    NameDescripionDefault valueFormatExample values
    {@code startTime}Specifies the point in time to start a recording stream. Due to + * how data is stored, some events that start or end prior to the + * start time may be included.{@code Instant.MIN_VALUE.toString()}ISO-8601. See {@link Instant#toString}
    + * or milliseconds since epoch
    {@code "2015-11-03T00:00"},
    + * {@code "1446508800000"}
    {@code endTime}Specifies the point in time to end a recording stream. Due to how + * data is stored, some events that start or end after the end time may + * be included.{@code Instant.MAX_VALUE.toString()}ISO-8601. See {@link Instant#toString}
    + * or milliseconds since epoch
    {@code "2015-11-03T01:00"},
    + * {@code "1446512400000"}
    {@code blockSize}Specifies the maximum number of bytes to read with a call to {@code readStream} + * {@code "50000"}A positive {@code long} value.
    + *
    + * Setting {@code blockSize} to a very high value may result in + * {@link OutOfMemoryError} or an {@link IllegalArgumentException}, if the + * Java Virtual Machine (JVM) deems the value too large to handle.
    {@code "50000"},
    + * {@code "1000000"},
    + *
    + * If an option is omitted from the map the default value is used. + *

    + * The recording with the specified ID must be stopped before a stream can + * be opened. This restriction might be lifted in future releases. + * + * @param recordingId ID of the recording to open the stream for + * + * @param streamOptions a map that contains the options that controls the amount of data + * and how it is read, or {@code null} to get all data for the + * recording with the default block size + * + * @return a unique ID for the stream. + * + * @throws IllegalArgumentException if a recording with the iD doesn't + * exist, or if {@code options} contains invalid values + * + * @throws IOException if the recording is closed, an I/O error occurs, or + * no data is available for the specified recording or + * interval + * + * @throws java.lang.SecurityException if a security manager exists and the + * caller does not have {@code ManagementPermission("control")} + */ + long openStream(long recordingId, Map streamOptions) throws IOException; + + /** + * Closes the recording stream with the specified ID and releases any system + * resources that are associated with the stream. + *

    + * If the stream is already closed, invoking this method has no effect. + * + * @param streamId the ID of the stream + * + * @throws IllegalArgumentException if a stream with the specified ID doesn't + * exist + * @throws IOException if an I/O error occurs while trying to close the stream + * @throws java.lang.SecurityException if a security manager exists and the + * caller does not have {@code ManagementPermission("control")} + * + * @see #openStream(long, Map) + */ + void closeStream(long streamId) throws IOException; + + /** + * Reads a portion of data from the stream with the specified ID, or returns + * {@code null} if no more data is available. + *

    + * To read all data for a recording, invoke this method repeatedly until + * {@code null} is returned. + * + * @param streamId the ID of the stream + * + * @return byte array that contains recording data, or {@code null} when no more + * data is available + * @throws IOException if the stream is closed, or an I/O error occurred while + * trying to read the stream + * @throws IllegalArgumentException if no recording with the stream ID exists + * @throws java.lang.SecurityException if a security manager exists and the + * caller does not have {@code ManagementPermission("monitor")} + */ + byte[] readStream(long streamId) throws IOException; + + /** + * Returns a map that contains the options for the recording with the + * specified ID (for example, the destination file or time span to keep + * recorded data). + *

    + * See {@link FlightRecorderMXBean} for available option names. + * + * @param recordingId the ID of the recording to get options for + * + * @return a map describing the recording options, not {@code null} + * + * @throws IllegalArgumentException if no recording with the + * specified ID exists + * @throws java.lang.SecurityException if a security manager exists and the + * caller does not have {@code ManagementPermission("monitor")} + * + */ + Map getRecordingOptions(long recordingId) throws IllegalArgumentException; + + /** + * Returns a {@code Map} that contains the settings for the recording with the specified ID, + * (for example, the event thresholds) + *

    + * If multiple recordings are running at the same time, more data could be + * recorded than what is specified in the {@code Map} object. + *

    + * The name in the {@code Map} is the event name and the setting name separated by + * {@code "#"} (for example, {@code "jdk.VMInfo#period"}). The value + * is a textual representation of the settings value (for example, + * {@code "60 s"}). + * + * @param recordingId the ID of the recordings to get settings for + * + * @return a map that describes the recording settings, not {@code null} + * + * @throws IllegalArgumentException if no recording with the specified ID exists + * @throws java.lang.SecurityException if a security manager exists and the + * caller does not have {@code ManagementPermission("monitor")} + */ + Map getRecordingSettings(long recordingId) throws IllegalArgumentException; + + /** + * Sets a configuration as a string representation for the recording with the + * specified ID. + * + * @param recordingId ID of the recording + * @param contents a string representation of the configuration file to use, + * not {@code null} + * @throws IllegalArgumentException if no recording with the + * specified ID exists or if the configuration could not be parsed. + * @throws java.lang.SecurityException if a security manager exists and the + * caller does not have {@code ManagementPermission("control")} + * + * @see Configuration#getContents() + */ + void setConfiguration(long recordingId, String contents) throws IllegalArgumentException; + + /** + * Sets a predefined configuration for the recording with the specified ID. + * + * @param recordingId ID of the recording to set the configuration for + * @param configurationName the name of the configuration (for example, + * {@code "profile"} or {@code "default"}), not {@code null} + * @throws IllegalArgumentException if no recording with the + * specified ID exists + * @throws java.lang.SecurityException if a security manager exists and the + * caller does not have {@code ManagementPermission("control")} + * + * @see #getConfigurations() + */ + void setPredefinedConfiguration(long recordingId, String configurationName) throws IllegalArgumentException; + + /** + * Sets and replaces all previous settings for the specified recording. + *

    + * A setting consists of a name/value pair, where name specifies the + * event and setting to configure, and the value specifies what to set + * it to. + *

    + * The name can be formed in the following ways: + *

    + * {@code + * + "#" + + * } + *

    + * or + *

    + * {@code + * + "#" + + * } + *

    + * For example, to set the sample interval of the CPU Load event to once every + * second, use the name {@code "jdk.CPULoad#period"} and the value + * {@code "1 s"}. If multiple events use the same name, for example if an event + * class is loaded in multiple class loaders, and differentiation is needed + * between them, then the name is {@code "56#period"}. The ID for an event is + * obtained by invoking {@link jdk.jfr.EventType#getId()} method and is valid + * for the Java Virtual Machine (JVM) instance that the event is registered in. + *

    + * A list of available event names is retrieved by invoking + * {@link jdk.jfr.FlightRecorder#getEventTypes()} and + * {@link jdk.jfr.EventType#getName()}. A list of available settings for an + * event type is obtained by invoking + * {@link jdk.jfr.EventType#getSettingDescriptors()} and + * {@link jdk.jfr.ValueDescriptor#getName()}. + * + * @param recordingId ID of the recording + * + * @param settings name value map of the settings to set, not {@code null} + * + * @throws IllegalArgumentException if no recording with the specified ID exists + * @throws java.lang.SecurityException if a security manager exists and the + * caller does not have {@code ManagementPermission("control")} + * + * @see Recording#getId() + */ + void setRecordingSettings(long recordingId, Map settings) throws IllegalArgumentException; + + /** + * Configures the recording options (for example, destination file and time span + * to keep data). + *

    + * See {@link FlightRecorderMXBean} for a description of the options and values + * that can be used. Setting a value to {@code null} restores the value to the + * default value. + * + * @param recordingId the ID of the recording to set options for + * + * @param options name/value map of the settings to set, not {@code null} + * + * @throws IllegalArgumentException if no recording with the specified ID exists + * @throws java.lang.SecurityException if a security manager exists, and the + * caller does not have {@code ManagementPermission("control")} or an + * option contains a file that the caller does not have permission to + * operate on. + * @see Recording#getId() + */ + void setRecordingOptions(long recordingId, Map options) throws IllegalArgumentException; + + /** + * Returns the list of the available recordings, not necessarily running. + *

    + * MBeanServer access:
    + * The mapped type of {@code RecordingInfo} is {@code CompositeData} with + * attributes as specified in the {@link RecordingInfo#from + * RecordingInfo.from} method. + * + * @return list of recordings, not {@code null} + * + * @throws java.lang.SecurityException if a security manager exists and the + * caller does not have {@code ManagementPermission("monitor")} + * + * @see RecordingInfo + * @see Recording + */ + List getRecordings(); + + /** + * Returns the list of predefined configurations for this Java Virtual Machine (JVM). + *

    + * MBeanServer access:
    + * The mapped type of {@code ConfigurationInfo} is {@code CompositeData} + * with attributes as specified in the {@link ConfigurationInfo#from + * ConfigurationInfo.from} method. + * + * @return the list of predefined configurations, not {@code null} + * + * @throws java.lang.SecurityException if a security manager exists and the + * caller does not have {@code ManagementPermission("monitor")} + * + * @see ConfigurationInfo + * @see Configuration + */ + List getConfigurations(); + + /** + * Returns the list of currently registered event types. + *

    + * MBeanServer access:
    + * The mapped type of {@code EventTypeInfo} is {@code CompositeData} with + * attributes as specified in the {@link EventTypeInfo#from + * EventTypeInfo.from} method. + * + * @return the list of registered event types, not {@code null} + * + * @throws java.lang.SecurityException if a security manager exists and the + * caller does not have {@code ManagementPermission("monitor")} + * + * @see EventTypeInfo + * @see EventType + */ + List getEventTypes(); + + /** + * Writes recording data to the specified file. + *

    + * If this method is invoked remotely from another process, the data is written + * to a file named {@code outputFile} on the machine where the target Java + * Virtual Machine (JVM) is running. If the file location is a relative path, it + * is relative to the working directory where the target JVM was started. + * + * @param recordingId the ID of the recording to dump data for + * + * @param outputFile the system-dependent file name where data is written, not + * {@code null} + * + * @throws IOException if the recording can't be dumped due to an I/O error (for + * example, an invalid path) + * + * @throws IllegalArgumentException if a recording with the specified ID doesn't + * exist + * + * @throws IllegalStateException if the recording is not yet started or if it is + * already closed + * + * @throws SecurityException if a security manager exists and its + * {@code SecurityManager.checkWrite(java.lang.String)} method denies + * write access to the named file or the caller does not have + * {@code ManagmentPermission("control")} + * + * @see java.nio.file.Path#toString() + * @see Recording#dump(java.nio.file.Path) + */ + void copyTo(long recordingId, String outputFile) throws IOException, SecurityException; +} diff --git a/src/share/classes/jdk/management/jfr/FlightRecorderMXBeanImpl.java b/src/share/classes/jdk/management/jfr/FlightRecorderMXBeanImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..4a9206b777234a4461772879553e7bdc37be220d --- /dev/null +++ b/src/share/classes/jdk/management/jfr/FlightRecorderMXBeanImpl.java @@ -0,0 +1,440 @@ +/* + * 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. 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.management.jfr; + +import java.io.IOException; +import java.io.InputStream; +import java.io.StringReader; +import java.nio.file.Paths; +import java.security.AccessControlContext; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.text.ParseException; +import java.time.Instant; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.atomic.AtomicLong; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Predicate; + +import javax.management.AttributeChangeNotification; +import javax.management.AttributeNotFoundException; +import javax.management.ListenerNotFoundException; +import javax.management.MBeanException; +import javax.management.MBeanNotificationInfo; +import javax.management.Notification; +import javax.management.NotificationBroadcasterSupport; +import javax.management.NotificationEmitter; +import javax.management.NotificationFilter; +import javax.management.NotificationListener; +import javax.management.ObjectName; +import javax.management.ReflectionException; +import javax.management.StandardEmitterMBean; + +import jdk.jfr.Configuration; +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorder; +import jdk.jfr.FlightRecorderListener; +import jdk.jfr.FlightRecorderPermission; +import jdk.jfr.Recording; +import jdk.jfr.RecordingState; +import jdk.jfr.internal.management.ManagementSupport; + +// Instantiated by service provider +final class FlightRecorderMXBeanImpl extends StandardEmitterMBean implements FlightRecorderMXBean, NotificationEmitter { + + final class MXBeanListener implements FlightRecorderListener { + private final NotificationListener listener; + private final NotificationFilter filter; + private final Object handback; + private final AccessControlContext context; + + public MXBeanListener(NotificationListener listener, NotificationFilter filter, Object handback) { + this.context = AccessController.getContext(); + this.listener = listener; + this.filter = filter; + this.handback = handback; + } + + public void recordingStateChanged(Recording recording) { + AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Void run() { + sendNotification(createNotication(recording)); + return null; + } + }, context); + } + } + + private static final String ATTRIBUTE_RECORDINGS = "Recordings"; + private static final String OPTION_MAX_SIZE = "maxSize"; + private static final String OPTION_MAX_AGE = "maxAge"; + private static final String OPTION_NAME = "name"; + private static final String OPTION_DISK = "disk"; + private static final String OPTION_DUMP_ON_EXIT = "dumpOnExit"; + private static final String OPTION_DURATION = "duration"; + private static final List OPTIONS = Arrays.asList(new String[] { OPTION_DUMP_ON_EXIT, OPTION_DURATION, OPTION_NAME, OPTION_MAX_AGE, OPTION_MAX_SIZE, OPTION_DISK, }); + private final StreamManager streamHandler = new StreamManager(); + private final Map changes = new ConcurrentHashMap<>(); + private final AtomicLong sequenceNumber = new AtomicLong(); + private final List listeners = new CopyOnWriteArrayList<>(); + private FlightRecorder recorder; + + FlightRecorderMXBeanImpl() { + super(FlightRecorderMXBean.class, true, new NotificationBroadcasterSupport(createNotificationInfo())); + } + + @Override + public void startRecording(long id) { + MBeanUtils.checkControl(); + getExistingRecording(id).start(); + } + + @Override + public boolean stopRecording(long id) { + MBeanUtils.checkControl(); + return getExistingRecording(id).stop(); + } + + @Override + public void closeRecording(long id) { + MBeanUtils.checkControl(); + getExistingRecording(id).close(); + } + + @Override + public long openStream(long id, Map options) throws IOException { + MBeanUtils.checkControl(); + if (!FlightRecorder.isInitialized()) { + throw new IllegalArgumentException("No recording available with id " + id); + } + // Make local copy to prevent concurrent modification + Map s = options == null ? new HashMap<>() : new HashMap<>(options); + Instant starttime = MBeanUtils.parseTimestamp(s.get("startTime"), Instant.MIN); + Instant endtime = MBeanUtils.parseTimestamp(s.get("endTime"), Instant.MAX); + int blockSize = MBeanUtils.parseBlockSize(s.get("blockSize"), StreamManager.DEFAULT_BLOCK_SIZE); + InputStream is = getExistingRecording(id).getStream(starttime, endtime); + if (is == null) { + throw new IOException("No recording data available"); + } + return streamHandler.create(is, blockSize).getId(); + } + + @Override + public void closeStream(long streamIdentifier) throws IOException { + MBeanUtils.checkControl(); + streamHandler.getStream(streamIdentifier).close(); + } + + @Override + public byte[] readStream(long streamIdentifier) throws IOException { + MBeanUtils.checkMonitor(); + return streamHandler.getStream(streamIdentifier).read(); + } + + @Override + public List getRecordings() { + MBeanUtils.checkMonitor(); + if (!FlightRecorder.isInitialized()) { + return Collections.emptyList(); + } + return MBeanUtils.transformList(getRecorder().getRecordings(), RecordingInfo::new); + } + + @Override + public List getConfigurations() { + MBeanUtils.checkMonitor(); + return MBeanUtils.transformList(Configuration.getConfigurations(), ConfigurationInfo::new); + } + + @Override + public List getEventTypes() { + MBeanUtils.checkMonitor(); + List eventTypes = AccessController.doPrivileged(new PrivilegedAction>() { + @Override + public List run() { + return ManagementSupport.getEventTypes(); + } + }, null, new FlightRecorderPermission("accessFlightRecorder")); + + return MBeanUtils.transformList(eventTypes, EventTypeInfo::new); + } + + @Override + public Map getRecordingSettings(long recording) throws IllegalArgumentException { + MBeanUtils.checkMonitor(); + return getExistingRecording(recording).getSettings(); + } + + @Override + public void setRecordingSettings(long recording, Map values) throws IllegalArgumentException { + Objects.requireNonNull(values); + MBeanUtils.checkControl(); + getExistingRecording(recording).setSettings(values); + } + + @Override + public long newRecording() { + MBeanUtils.checkControl(); + getRecorder(); // ensure notification listener is setup + return AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Recording run() { + return new Recording(); + } + }, null, new FlightRecorderPermission("accessFlightRecorder")).getId(); + } + + @Override + public long takeSnapshot() { + MBeanUtils.checkControl(); + return getRecorder().takeSnapshot().getId(); + } + + @Override + public void setConfiguration(long recording, String configuration) throws IllegalArgumentException { + Objects.requireNonNull(configuration); + MBeanUtils.checkControl(); + try { + Configuration c = Configuration.create(new StringReader(configuration)); + getExistingRecording(recording).setSettings(c.getSettings()); + } catch (IOException | ParseException e) { + throw new IllegalArgumentException("Could not parse configuration", e); + } + } + + @Override + public void setPredefinedConfiguration(long recording, String configurationName) throws IllegalArgumentException { + Objects.requireNonNull(configurationName); + MBeanUtils.checkControl(); + Recording r = getExistingRecording(recording); + for (Configuration c : Configuration.getConfigurations()) { + if (c.getName().equals(configurationName)) { + r.setSettings(c.getSettings()); + return; + } + } + throw new IllegalArgumentException("Could not find configuration with name " + configurationName); + } + + @Override + public void copyTo(long recording, String path) throws IOException { + Objects.requireNonNull(path); + MBeanUtils.checkControl(); + getExistingRecording(recording).dump(Paths.get(path)); + } + + @Override + public void setRecordingOptions(long recording, Map options) throws IllegalArgumentException { + Objects.requireNonNull(options); + MBeanUtils.checkControl(); + // Make local copy to prevent concurrent modification + Map ops = new HashMap(options); + for (Map.Entry entry : ops.entrySet()) { + Object key = entry.getKey(); + Object value = entry.getValue(); + if (!(key instanceof String)) { + throw new IllegalArgumentException("Option key must not be null, or other type than " + String.class); + } + if (!OPTIONS.contains(key)) { + throw new IllegalArgumentException("Unknown recording option: " + key + ". Valid options are " + OPTIONS + "."); + } + if (value != null && !(value instanceof String)) { + throw new IllegalArgumentException("Incorrect value for option " + key + ". Values must be of type " + String.class + " ."); + } + } + + Recording r = getExistingRecording(recording); + validateOption(ops, OPTION_DUMP_ON_EXIT, MBeanUtils::booleanValue); + validateOption(ops, OPTION_DISK, MBeanUtils::booleanValue); + validateOption(ops, OPTION_NAME, Function.identity()); + validateOption(ops, OPTION_MAX_AGE, MBeanUtils::duration); + validateOption(ops, OPTION_MAX_SIZE, MBeanUtils::size); + validateOption(ops, OPTION_DURATION, MBeanUtils::duration); + + // All OK, now set them.atomically + setOption(ops, OPTION_DUMP_ON_EXIT, "false", MBeanUtils::booleanValue, x -> r.setDumpOnExit(x)); + setOption(ops, OPTION_DISK, "true", MBeanUtils::booleanValue, x -> r.setToDisk(x)); + setOption(ops, OPTION_NAME, String.valueOf(r.getId()), Function.identity(), x -> r.setName(x)); + setOption(ops, OPTION_MAX_AGE, null, MBeanUtils::duration, x -> r.setMaxAge(x)); + setOption(ops, OPTION_MAX_SIZE, "0", MBeanUtils::size, x -> r.setMaxSize(x)); + setOption(ops, OPTION_DURATION, null, MBeanUtils::duration, x -> r.setDuration(x)); + } + + @Override + public Map getRecordingOptions(long recording) throws IllegalArgumentException { + MBeanUtils.checkMonitor(); + Recording r = getExistingRecording(recording); + Map options = new HashMap<>(10); + options.put(OPTION_DUMP_ON_EXIT, String.valueOf(r.getDumpOnExit())); + options.put(OPTION_DISK, String.valueOf(r.isToDisk())); + options.put(OPTION_NAME, String.valueOf(r.getName())); + options.put(OPTION_MAX_AGE, ManagementSupport.formatTimespan(r.getMaxAge(), " ")); + Long maxSize = r.getMaxSize(); + options.put(OPTION_MAX_SIZE, String.valueOf(maxSize == null ? "0" : maxSize.toString())); + options.put(OPTION_DURATION, ManagementSupport.formatTimespan(r.getDuration(), " ")); + return options; + } + + @Override + public long cloneRecording(long id, boolean stop) throws IllegalStateException, SecurityException { + MBeanUtils.checkControl(); + return getRecording(id).copy(stop).getId(); + } + + @Override + public ObjectName getObjectName() { + return MBeanUtils.createObjectName(); + } + + private Recording getExistingRecording(long id) { + if (FlightRecorder.isInitialized()) { + Recording recording = getRecording(id); + if (recording != null) { + return recording; + } + } + throw new IllegalArgumentException("No recording available with id " + id); + } + + private Recording getRecording(long id) { + List recs = getRecorder().getRecordings(); + return recs.stream().filter(r -> r.getId() == id).findFirst().orElse(null); + } + + private static void setOption(Map options, String name, String defaultValue, Function converter, Consumer setter) { + if (!options.containsKey(name)) { + return; + } + String v = options.get(name); + if (v == null) { + v = defaultValue; + } + try { + setter.accept(converter.apply(v)); + } catch (IllegalArgumentException iae) { + throw new IllegalArgumentException("Not a valid value for option '" + name + "'. " + iae.getMessage()); + } + } + + private static void validateOption(Map options, String name, Function validator) { + try { + String v = options.get(name); + if (v == null) { + return; // OK, will set default + } + validator.apply(v); + } catch (IllegalArgumentException iae) { + throw new IllegalArgumentException("Not a valid value for option '" + name + "'. " + iae.getMessage()); + } + } + + private FlightRecorder getRecorder() throws SecurityException { + // Synchronize on some private object that is always available + synchronized (streamHandler) { + if (recorder == null) { + recorder = AccessController.doPrivileged(new PrivilegedAction() { + @Override + public FlightRecorder run() { + return FlightRecorder.getFlightRecorder(); + } + }, null, new FlightRecorderPermission("accessFlightRecorder")); + } + return recorder; + } + } + + private static MBeanNotificationInfo[] createNotificationInfo() { + String[] types = new String[] { AttributeChangeNotification.ATTRIBUTE_CHANGE }; + String name = AttributeChangeNotification.class.getName(); + String description = "Notifies if the RecordingState has changed for one of the recordings, for example if a recording starts or stops"; + MBeanNotificationInfo info = new MBeanNotificationInfo(types, name, description); + return new MBeanNotificationInfo[] { info }; + } + + @Override + public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) { + MXBeanListener mxbeanListener = new MXBeanListener(listener, filter, handback); + listeners.add(mxbeanListener); + AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Void run(){ + FlightRecorder.addListener(mxbeanListener); + return null; + } + }, null, new FlightRecorderPermission("accessFlightRecorder")); + super.addNotificationListener(listener, filter, handback); + } + + @Override + public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException { + removeListeners( x -> listener == x.listener); + super.removeNotificationListener(listener); + } + + @Override + public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException { + removeListeners( x -> listener == x.listener && filter == x.filter && handback == x.handback); + super.removeNotificationListener(listener, filter, handback); + } + + private void removeListeners(Predicate p) { + List toBeRemoved = new ArrayList<>(listeners.size()); + for (MXBeanListener l : listeners) { + if (p.test(l)) { + toBeRemoved.add(l); + FlightRecorder.removeListener(l); + } + } + listeners.removeAll(toBeRemoved); + } + + private Notification createNotication(Recording recording) { + try { + Long id = recording.getId(); + Object oldValue = changes.get(recording.getId()); + Object newValue = getAttribute(ATTRIBUTE_RECORDINGS); + if (recording.getState() != RecordingState.CLOSED) { + changes.put(id, newValue); + } else { + changes.remove(id); + } + return new AttributeChangeNotification(getObjectName(), sequenceNumber.incrementAndGet(), System.currentTimeMillis(), "Recording " + recording.getName() + " is " + + recording.getState(), ATTRIBUTE_RECORDINGS, newValue.getClass().getName(), oldValue, newValue); + } catch (AttributeNotFoundException | MBeanException | ReflectionException e) { + throw new RuntimeException("Could not create notifcation for FlightRecorderMXBean. " + e.getMessage(), e); + } + } +} diff --git a/src/share/classes/jdk/management/jfr/MBeanUtils.java b/src/share/classes/jdk/management/jfr/MBeanUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..8a69641e2a3ff87e9de0e2e7c8538bebb8717bc1 --- /dev/null +++ b/src/share/classes/jdk/management/jfr/MBeanUtils.java @@ -0,0 +1,130 @@ +/* + * 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. 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.management.jfr; + +import java.lang.management.ManagementPermission; +import java.security.Permission; +import java.time.DateTimeException; +import java.time.Duration; +import java.time.Instant; +import java.time.format.DateTimeParseException; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; + +import javax.management.MalformedObjectNameException; +import javax.management.ObjectName; + +import jdk.jfr.internal.management.ManagementSupport; + +final class MBeanUtils { + + private static final Permission monitor = new ManagementPermission("monitor"); + private static final Permission control = new ManagementPermission("control"); + + static ObjectName createObjectName() { + try { + return new ObjectName(FlightRecorderMXBean.MXBEAN_NAME); + } catch (MalformedObjectNameException mne) { + throw new Error("Can't happen", mne); + } + } + + static void checkControl() { + SecurityManager secManager = System.getSecurityManager(); + if (secManager != null) { + secManager.checkPermission(control); + } + } + + static void checkMonitor() { + SecurityManager secManager = System.getSecurityManager(); + if (secManager != null) { + secManager.checkPermission(monitor); + } + } + + static List transformList(List source, Function function) { + return source.stream().map(function).collect(Collectors.toList()); + } + + static boolean booleanValue(String s) { + if ("true".equals(s)) { + return true; + } + if ("false".equals(s)) { + return false; + } + throw new IllegalArgumentException("Value must be true or false."); + } + + static Duration duration(String s) throws NumberFormatException { + if (s == null) { + return null; + } + long l = ManagementSupport.parseTimespan(s); + if (l == 0) { + return null; + } + return Duration.ofNanos(l); + } + + public static Instant parseTimestamp(String s, Instant defaultValue) { + if (s == null) { + return defaultValue; + } + try { + return Instant.parse(s); + } catch(DateTimeParseException e ) { + // OK, try with milliseconds since epoch + // before giving up. + } + try { + return Instant.ofEpochMilli(Long.parseLong(s)); + } catch (NumberFormatException | DateTimeException nfr) { + throw new IllegalArgumentException("Not a valid timestamp " + s); + } + } + + static Long size(String s) throws NumberFormatException { + long size = Long.parseLong(s); + if (size < 0) { + throw new IllegalArgumentException("Negative size not allowed"); + } + return size; + } + + public static int parseBlockSize(String string, int defaultSize) { + if (string == null) { + return defaultSize; + } + int size = Integer.parseInt(string); + if (size <1) { + throw new IllegalArgumentException("Block size must be at least 1 byte"); + } + return size; + } +} + diff --git a/src/share/classes/jdk/management/jfr/RecordingInfo.java b/src/share/classes/jdk/management/jfr/RecordingInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..4c99e71dbe44853d54a33e1de7d4a375c9a7d8c8 --- /dev/null +++ b/src/share/classes/jdk/management/jfr/RecordingInfo.java @@ -0,0 +1,398 @@ +/* + * 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 + * 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.management.jfr; + +import java.nio.file.Path; +import java.time.Duration; +import java.time.Instant; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import javax.management.openmbean.CompositeData; +import javax.management.openmbean.TabularData; + +import jdk.jfr.Recording; +import jdk.jfr.RecordingState; + +/** + * Management representation of a {@code Recording}. + * + * @see Recording + * + * @since 8 + */ +public final class RecordingInfo { + private final long id; + private final String name; + private final String state; + private final boolean dumpOnExit; + private final long size; + private final boolean disk; + private final long maxAge; + private final long maxSize; + private final long startTime; + private final long stopTime; + private final String destination; + private final long durationInSeconds; + private final Map settings; + + // package private + RecordingInfo(Recording recording) { + id = recording.getId(); + name = recording.getName(); + state = recording.getState().toString(); + dumpOnExit = recording.getDumpOnExit(); + size = recording.getSize(); + disk = recording.isToDisk(); + + Duration d = recording.getMaxAge(); + if (d == null) { + maxAge = 0; + } else { + maxAge = d.getSeconds(); + } + maxSize = recording.getMaxSize(); + Instant s = recording.getStartTime(); + startTime = s == null ? 0L : s.toEpochMilli(); + Instant st = recording.getStopTime(); + stopTime = st == null ? 0L : st.toEpochMilli(); + Path p = recording.getDestination(); + destination = p == null ? null : p.toString(); + Duration duration = recording.getDuration(); + durationInSeconds = duration == null ? 0 : duration.getSeconds(); + settings = recording.getSettings(); + } + + private RecordingInfo(CompositeData cd) { + id = (int) cd.get("id"); + name = (String) cd.get("name"); + state = (String) cd.get("state"); + dumpOnExit = (boolean) cd.get("dumpOnExit"); + size = (long) cd.get("size"); + disk = (boolean) cd.get("disk"); + maxAge = (Long) cd.get("maxAge"); + maxSize = (Long) cd.get("maxSize"); + startTime = (Long) cd.get("startTime"); + stopTime = (Long) cd.get("stopTime"); + destination = (String) cd.get("destination"); + durationInSeconds = (long) cd.get("duration"); + settings = new LinkedHashMap<>(); + Object map = cd.get("settings"); + if (map instanceof TabularData) { + TabularData td = (TabularData) map; + List keyNames = td.getTabularType().getIndexNames(); + int size = keyNames.size(); + for (Object keys : td.keySet()) { + Object[] keyValues = ((List) keys).toArray(); + for (int i = 0; i < size; i++) { + String key = keyNames.get(i); + Object value = keyValues[i]; + if (value instanceof String) { + settings.put(key, (String) value); + } + } + } + } + } + + /** + * Returns the name of the recording associated with this + * {@code RecordingInfo}. + * + * @return the recording name, not {@code null} + * + * @see Recording#getName() + */ + public String getName() { + return name; + } + + /** + * Returns the unique ID for the recording associated with this + * {@code RecordingInfo}. + * + * @return the recording ID + * + * @see Recording#getId() + */ + public long getId() { + return id; + } + + /** + * Returns if the recording associated with this {@code RecordingInfo} + * should be dumped to file when the JVM exits. + * + * @return {@code true} if recording should be dumped on exit, {@code false} + * otherwise + * + * @see Recording#getDumpOnExit() + */ + public boolean getDumpOnExit() { + return dumpOnExit; + } + + /** + * Returns how many seconds data should be kept on disk, or {@code 0} if + * data is to be kept forever. + *

    + * In-memory recordings are not affected by maximum age. + * + * @see Recording#getMaxAge() + * @see Recording#setToDisk(boolean) + * @return how long data should be kept on disk, measured in seconds + * + */ + public long getMaxAge() { + return maxAge; + } + + /** + * Returns the amount of data, measured in bytes, the recording associated + * with this {@code RecordingInfo}, should be kept on disk, before it's + * rotated away, or {@code 0} if data is to be kept indefinitely. + *

    + * In-memory recordings are not affected by maximum size. + * + * @return the amount of data should be kept on disk, in bytes + * + * @see Recording#setToDisk(boolean) + * @see Recording#getMaxSize() + */ + public long getMaxSize() { + return maxSize; + } + + /** + * Returns a {@code String} representation of state of the recording + * associated with this {@code RecordingInfo}. + *

    + * Valid return values are {@code "NEW"}, {@code "DELAYED"}, {@code "STARTING"}, + * {@code "RUNNING"}, {@code "STOPPING"}, {@code "STOPPED"} and {@code "CLOSED"}. + * + * @return the recording state, not {@code null} + * + * @see RecordingState#toString() + * @see Recording#getState() + */ + public String getState() { + return state; + } + + /** + * Returns start time of the recording associated with this + * {@code RecordingInfo}, measured as ms since epoch, or {@code null} if the + * recording hasn't started. + * + * @return the start time of the recording, or {@code null} if the recording + * hasn't started + * + * @see Recording#getStartTime() + */ + public long getStartTime() { + return startTime; + } + + /** + * Returns the actual or expected stop time of the recording associated with + * this {@code RecordingInfo}, measured as ms since epoch, or {@code null} + * if the expected or actual stop time is not known, which can only happen + * if the recording has not yet been stopped. + * + * @return the stop time of recording, or {@code null} if recording hasn't + * been stopped. + * + * @see Recording#getStopTime() + */ + public long getStopTime() { + return stopTime; + } + + /** + * Returns the settings for the recording associated with this + * {@code RecordingInfo}. + * + * @return the recording settings, not {@code null} + * + * @see Recording#getSettings() + */ + public Map getSettings() { + return settings; + } + + /** + * Returns destination path where data, for the recording associated with + * this {@link RecordingInfo}, should be written when the recording stops, + * or {@code null} if the recording should not be written. + * + * @return the destination, or {@code null} if not set + * + * @see Recording#getDestination() + */ + public String getDestination() { + return destination; + } + + /** + * Returns a string description of the recording associated with this + * {@code RecordingInfo} + * + * @return description, not {@code null} + */ + @Override + public String toString() { + Stringifier s = new Stringifier(); + s.add("name", name); + s.add("id", id); + s.add("maxAge", maxAge); + s.add("maxSize", maxSize); + return s.toString(); + } + + /** + * Returns the amount data recorded by recording. associated with this + * {@link RecordingInfo}. + * + * @return the amount of recorded data, measured in bytes + */ + public long getSize() { + return size; + } + + /** + * Returns {@code true} if the recording associated with this + * {@code RecordingInfo} should be flushed to disk, when memory buffers are + * full, {@code false} otherwise. + * + * @return {@code true} if recording is to disk, {@code false} otherwise + */ + public boolean isToDisk() { + return disk; + } + + /** + * Returns the desired duration, measured in seconds, of the recording + * associated with this {@link RecordingInfo}, or {code 0} if no duration + * has been set. + * + * @return the desired duration, or {code 0} if no duration has been set + * + * @see Recording#getDuration() + */ + public long getDuration() { + return durationInSeconds; + } + + /** + * Returns a {@code RecordingInfo} represented by the specified + * {@code CompositeData} object. + *

    + * The specified {@code CompositeData} must have the following item names and + * item types to be valid.

    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Supported names and types in a specified {@code CompositeData} object
    NameType
    id{@code Long}
    name{@code String}
    state{@code String}
    dumpOnExit{@code Boolean}
    size{@code Long}
    disk{@code Boolean}
    maxAge{@code Long}
    maxSize{@code Long}
    startTime{@code Long}
    stopTime{@code Long}
    destination{@code String}
    duration{@code Long}
    settings{@code javax.management.openmbean.CompositeData[]} whose element type + * is the mapped type for {@link SettingDescriptorInfo} as specified in the + * {@link SettingDescriptorInfo#from} method.
    + *
    + * + * @param cd {@code CompositeData} representing the {@code RecordingInfo} to + * return + * + * @throws IllegalArgumentException if {@code cd} does not represent a valid + * {@code RecordingInfo} + * + * @return the {@code RecordingInfo} represented by {@code cd}, or + * {@code null} if {@code cd} is {@code null} + */ + public static RecordingInfo from(CompositeData cd) { + if (cd == null) { + return null; + } + return new RecordingInfo(cd); + } +} diff --git a/src/share/classes/jdk/management/jfr/SettingDescriptorInfo.java b/src/share/classes/jdk/management/jfr/SettingDescriptorInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..e944db65385f4e6728cdb7ca4ece4ed9ee11d7aa --- /dev/null +++ b/src/share/classes/jdk/management/jfr/SettingDescriptorInfo.java @@ -0,0 +1,232 @@ +/* + * 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 + * 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.management.jfr; + +import java.util.concurrent.Callable; + +import javax.management.openmbean.CompositeData; + +import jdk.jfr.EventType; +import jdk.jfr.SettingDescriptor; +import jdk.management.jfr.internal.FlightRecorderMXBeanProvider; + +/** + * Management class that describes a setting, for example name, description and + * default value. + * + * @see EventType#getSettingDescriptors() + * + * @since 8 + */ +public final class SettingDescriptorInfo { + + // Purpose of this static initializer is to allow + // FlightRecorderMXBeanProvider + // to be in an internal package and not visible, but at the same time allow + // it to instantiate FlightRecorderMXBeanImpl. + // + // The reason the mechanism is in this class is because it is light weight + // and can easily be triggered from FlightRecorderMXBeanProvider. + static { + FlightRecorderMXBeanProvider.setFlightRecorderMXBeanFactory(new Callable() { + @Override + public FlightRecorderMXBean call() throws Exception { + return new FlightRecorderMXBeanImpl(); + } + }); + } + + private final String name; + private final String label; + private final String description; + private final String typeName; + private final String contentType; + private final String defaultValue; + + // package private + SettingDescriptorInfo(SettingDescriptor settingDescriptor) { + this.name = settingDescriptor.getName(); + this.label = settingDescriptor.getLabel(); + this.description = settingDescriptor.getDescription(); + this.typeName = settingDescriptor.getTypeName(); + this.contentType = settingDescriptor.getContentType(); + this.defaultValue = settingDescriptor.getDefaultValue(); + } + + private SettingDescriptorInfo(CompositeData cd) { + this.name = (String) cd.get("name"); + this.label = (String) cd.get("label"); + this.description = (String) cd.get("description"); + this.typeName = (String) cd.get("typeName"); + this.defaultValue = (String) cd.get("defaultValue"); + this.contentType = (String) cd.get("contentType"); + } + + /** + * Returns the human-readable name of the setting associated with this + * {@code SettingDescriptorInfo} (for example, {@code "Threshold"}). + * + * @return the label for this setting, not {@code null} + */ + public String getLabel() { + return label; + } + + /** + * Returns the name of the setting associated with this + * {@code SettingDescriptorInfo} (for example, {@code "threshold"}). + * + * @return the name of this setting, not {@code null} + */ + public String getName() { + return name; + } + + /** + * Returns the description of the setting associated this + * {@code SettingDescriptorInfo} (for example, + * {@code "The duration an event must exceed to be be recorded"}). + * + * @return the description of this setting, not null + */ + public String getDescription() { + return description; + } + + /** + * Returns the type name of the setting associated this + * {@code SettingDescriptorInfo} (for example, + * {@code "jdk.settings.Threshold"}). + *

    + * The type can be used to identify what type of setting this is. + * + * @return the name of this settings type, not {@code null} + */ + public String getTypeName() { + return typeName; + } + + /** + * Returns the content type of the setting associated this + * {@code SettingDescriptorInfo} (for example, {@code "jdk.jfr.Timespan"}). + *

    + * The content type can be used to determine how the setting should be + * rendered in a graphical user interface. + * + * @return the name of this settings type, not {@code null} + */ + public String getContentType() { + return contentType; + } + + /** + * Returns the default value of the setting associated this + * {@code SettingDescriptorInfo} (for example, {@code "20 ms"}). + * + * @return default value for this setting, not {@code null} + * + * @see SettingDescriptor#getDefaultValue() + */ + public String getDefaultValue() { + return defaultValue; + } + + /** + * Returns an {@code SettingDescriptorInfo} represented by the specified + * {@code CompositeData} + *

    + * The supplied {@code CompositeData} must have the following item names and + * item types to be valid.

    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    The name and type the specified CompositeData must contain
    NameType
    name{@code String}
    label{@code String}
    description{@code String}
    typeName{@code String}
    contentType{@code String}
    defaultValue{@code String}
    + *
    + * + * @param cd {@code CompositeData} representing the {@code SettingDescriptorInfo} to + * return + * + * @throws IllegalArgumentException if {@code cd} does not represent a valid + * {@code EventTypeInfo} + * + * @return a {@code SettingDescriptorInfo}, or {@code null} if {@code cd} is + * {@code null} + */ + public static SettingDescriptorInfo from(CompositeData cd) { + if (cd == null) { + return null; + } + return new SettingDescriptorInfo(cd); + } + + /** + * Returns a {@code String} description of this {@code SettingDescriptorInfo}. + * + * @return a string describing this setting, not {@code null} + */ + @Override + public String toString() { + Stringifier s = new Stringifier(); + s.add("name", name); + s.add("label", label); + s.add("description", description); + s.add("typeName", typeName); + s.add("contentType", contentType); + s.add("defaultValue", defaultValue); + return s.toString(); + } +} diff --git a/src/share/classes/jdk/management/jfr/Stream.java b/src/share/classes/jdk/management/jfr/Stream.java new file mode 100644 index 0000000000000000000000000000000000000000..29df664e8d63b0bc15d674881a5fa173edc11c57 --- /dev/null +++ b/src/share/classes/jdk/management/jfr/Stream.java @@ -0,0 +1,81 @@ +/* + * 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. 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.management.jfr; + +import java.io.BufferedInputStream; +import java.io.Closeable; +import java.io.IOException; +import java.io.InputStream; + +final class Stream implements Closeable { + + private final long identifier; + private final BufferedInputStream inputStream; + private final byte[] buffer; + + private volatile long time; + + Stream(InputStream is, long identifier, int blockSize) { + this.inputStream = new BufferedInputStream(is, 50000); + this.identifier = identifier; + this.buffer = new byte[blockSize]; + } + + private void touch() { + time = System.currentTimeMillis(); + } + + public long getLastTouched() { + return time; + } + + public byte[] read() throws IOException { + // OK to reuse buffer since this + // is only used for serialization + touch(); + int read = inputStream.read(buffer); + if (read == -1) { + // null indicate no more data + return null; + } + if (read != buffer.length) { + byte[] smallerBuffer = new byte[read]; + System.arraycopy(buffer, 0, smallerBuffer, 0, read); + return smallerBuffer; + } + + return buffer; + } + + @Override + public void close() throws IOException { + inputStream.close(); + } + + public long getId() { + return identifier; + } +} diff --git a/src/share/classes/jdk/management/jfr/StreamCleanupTask.java b/src/share/classes/jdk/management/jfr/StreamCleanupTask.java new file mode 100644 index 0000000000000000000000000000000000000000..fe89e3c7bb0afc2a3ea02fcae1745442465725bb --- /dev/null +++ b/src/share/classes/jdk/management/jfr/StreamCleanupTask.java @@ -0,0 +1,50 @@ +/* + * 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. 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.management.jfr; + +import java.util.TimerTask; + +final class StreamCleanupTask extends TimerTask { + + private final Stream stream; + private final StreamManager manager; + + StreamCleanupTask(StreamManager streamManager, Stream stream) { + this.stream = stream; + this.manager = streamManager; + } + + @Override + public void run() { + long lastTouched = stream.getLastTouched(); + long now = System.currentTimeMillis(); + if (now - lastTouched >= StreamManager.TIME_OUT) { + manager.destroy(stream); + } else { + manager.scheduleAbort(stream, lastTouched + StreamManager.TIME_OUT); + } + } +} diff --git a/src/share/classes/jdk/management/jfr/StreamManager.java b/src/share/classes/jdk/management/jfr/StreamManager.java new file mode 100644 index 0000000000000000000000000000000000000000..b2cf93a2e2b90d3b0212fa6d5c0a722235358398 --- /dev/null +++ b/src/share/classes/jdk/management/jfr/StreamManager.java @@ -0,0 +1,82 @@ +/* + * 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. 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.management.jfr; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.Timer; +import java.util.concurrent.TimeUnit; + +final class StreamManager { + + public static final long TIME_OUT = TimeUnit.MINUTES.toMillis(2); + public static final int DEFAULT_BLOCK_SIZE = 50000; + + private static long idCounter = 0; + + private final Map streams = new HashMap<>(); + private Timer timer; + + public synchronized Stream getStream(long streamIdentifer) { + Stream stream = streams.get(streamIdentifer); + if (stream == null) { + throw new IllegalArgumentException("Unknown stream identifier " + streamIdentifer); + } + return stream; + } + + public synchronized Stream create(InputStream is, int blockSize) { + idCounter++; + Stream stream = new Stream(is, idCounter, blockSize); + streams.put(stream.getId(), stream); + + scheduleAbort(stream, System.currentTimeMillis() + TIME_OUT); + return stream; + } + + public synchronized void destroy(Stream stream) { + try { + stream.close(); + } catch (IOException e) { + // OK + } + streams.remove(stream.getId()); + if (streams.isEmpty()) { + timer.cancel(); + timer = null; + } + } + + public synchronized void scheduleAbort(Stream s, long when) { + if (timer == null) { + timer = new Timer(true); + } + timer.schedule(new StreamCleanupTask(this, s), new Date(when + TIME_OUT)); + } +} diff --git a/src/share/classes/jdk/management/jfr/Stringifier.java b/src/share/classes/jdk/management/jfr/Stringifier.java new file mode 100644 index 0000000000000000000000000000000000000000..fd290dfe51bd274876f183c8fba580e323cc1910 --- /dev/null +++ b/src/share/classes/jdk/management/jfr/Stringifier.java @@ -0,0 +1,60 @@ +/* + * 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. 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.management.jfr; +/** + * Helper class for generating toString() + * + */ +final class Stringifier { + private final StringBuilder sb = new StringBuilder(); + private boolean first = true; + + public void add(String name, Object value) { + if (first) { + first = false; + } else { + sb.append(" "); + } + boolean isString = value instanceof String; + sb.append(name).append("="); + if (value == null) { + sb.append("null"); + } else { + if (isString) { + sb.append("\""); + } + sb.append(value); + if (isString) { + sb.append("\""); + } + } + } + + @Override + public String toString() { + return sb.toString(); + } +} diff --git a/src/share/classes/jdk/management/jfr/internal/FlightRecorderMXBeanProvider.java b/src/share/classes/jdk/management/jfr/internal/FlightRecorderMXBeanProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..d526f856c90efaba44135fe35b7d384807623769 --- /dev/null +++ b/src/share/classes/jdk/management/jfr/internal/FlightRecorderMXBeanProvider.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. 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.management.jfr.internal; + +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.Callable; + +import jdk.jfr.internal.management.ManagementSupport; +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.management.jfr.SettingDescriptorInfo; +// XXX TODO +//import sun.management.spi.PlatformMBeanProvider; + +public final class FlightRecorderMXBeanProvider /*extends PlatformMBeanProvider */{ + + private final static class SingleMBeanComponent + /*implements PlatformComponent*/ { + private final String objectName; + private final Class mbeanInterface; + + public SingleMBeanComponent(String objectName, + Class mbeanInterface) { + this.objectName = objectName; + this.mbeanInterface = mbeanInterface; + } + +// @Override +// public Set mbeanInterfaceNames() { +// return Collections.singleton(mbeanInterface.getName()); +// } +// +// @Override +// public Map nameToMBeanMap() { +// FlightRecorderMXBean bean = getFlightRecorderMXBean(); +// if (bean != null) { +// return Collections.singletonMap(objectName, bean); +// } else { +// return Collections.emptyMap(); +// } +// } +// +// @Override +// public String getObjectNamePattern() { +// return objectName; +// } +// +// @Override +// public Set> mbeanInterfaces() { +// return Collections.singleton(mbeanInterface); +// } + } + + private static Callable flightRecorderMXBeanFactory; + + private static volatile FlightRecorderMXBean flightRecorderMXBean; + + public static FlightRecorderMXBean getFlightRecorderMXBean() { + FlightRecorderMXBean bean = flightRecorderMXBean; + if (bean == null) { + SettingDescriptorInfo.from(null); // Sets flightRecorderMXBeanFactory under lock + synchronized (flightRecorderMXBeanFactory) { + bean = flightRecorderMXBean; + if (bean != null) { + return bean; + } + try { + bean = flightRecorderMXBean = flightRecorderMXBeanFactory.call(); + } catch (Exception e) { + ManagementSupport.logError("Could not create Flight Recorder " + + "instance for MBeanServer. " + e.getMessage()); + } + } + } + return bean; + } + + public static void setFlightRecorderMXBeanFactory(Callable factory) { + flightRecorderMXBeanFactory = factory; + } + +// @Override +// public List> getPlatformComponentList() { +// String objectName = FlightRecorderMXBean.MXBEAN_NAME; +// Class mbeanInterface = FlightRecorderMXBean.class; +// return Collections.singletonList(new SingleMBeanComponent(objectName, mbeanInterface)); +// } +} diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheNodeSetData.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheNodeSetData.java index 7b0f23ed53043648570f9e0efa18f4ecfc92ac6b..8cbcaba56feb677566790b384e347aade3cdb385 100644 --- a/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheNodeSetData.java +++ b/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheNodeSetData.java @@ -21,7 +21,7 @@ * under the License. */ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. */ /* * $Id: ApacheNodeSetData.java 1203890 2011-11-18 22:47:56Z mullan $ @@ -47,7 +47,7 @@ public class ApacheNodeSetData implements ApacheData, NodeSetData { this.xi = xi; } - public Iterator iterator() { + public Iterator iterator() { // If nodefilters are set, must execute them first to create node-set if (xi.getNodeFilters() != null && !xi.getNodeFilters().isEmpty()) { return Collections.unmodifiableSet diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMCryptoBinary.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMCryptoBinary.java index b3b7c310bce07885278f117a80ce933b3674c1d2..c540648f4b101092a552b75c37e0e55016895937 100644 --- a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMCryptoBinary.java +++ b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMCryptoBinary.java @@ -41,12 +41,12 @@ import com.sun.org.apache.xml.internal.security.utils.Base64; * as defined in the W3C specification for XML-Signature Syntax and Processing. * The XML Schema Definition is defined as: * - * + * <pre>{@code * <simpleType name="CryptoBinary"> * <restriction base = "base64Binary"> * </restriction> * </simpleType> - * + * } * * @author Sean Mullan */ diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java index 61e511a8fc8b5abefd819f21724b98269c3168c1..eafbf6232931603d056a0b4bfd657577bf596a30 100644 --- a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java +++ b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java @@ -21,7 +21,7 @@ * under the License. */ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. */ /* * $Id: DOMKeyInfo.java 1333869 2012-05-04 10:42:44Z coheigea $ @@ -138,7 +138,7 @@ public final class DOMKeyInfo extends DOMStructure implements KeyInfo { return id; } - public List getContent() { + public List getContent() { return keyInfoTypes; } diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java index c241d68c2d75cdb99566d0c04c3b87680216a98a..356201762c06ec300d04bee5ab27ac98034cb03f 100644 --- a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java +++ b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java @@ -21,7 +21,7 @@ * under the License. */ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. */ /* * $Id: DOMKeyInfoFactory.java 1333869 2012-05-04 10:42:44Z coheigea $ @@ -48,11 +48,12 @@ public final class DOMKeyInfoFactory extends KeyInfoFactory { public DOMKeyInfoFactory() { } + @SuppressWarnings("rawtypes") public KeyInfo newKeyInfo(List content) { return newKeyInfo(content, null); } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) public KeyInfo newKeyInfo(List content, String id) { return new DOMKeyInfo(content, id); } @@ -78,12 +79,12 @@ public final class DOMKeyInfoFactory extends KeyInfoFactory { return newPGPData(keyId, null, null); } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) public PGPData newPGPData(byte[] keyId, byte[] keyPacket, List other) { return new DOMPGPData(keyId, keyPacket, other); } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) public PGPData newPGPData(byte[] keyPacket, List other) { return new DOMPGPData(keyPacket, other); } @@ -92,7 +93,7 @@ public final class DOMKeyInfoFactory extends KeyInfoFactory { return newRetrievalMethod(uri, null, null); } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) public RetrievalMethod newRetrievalMethod(String uri, String type, List transforms) { if (uri == null) { @@ -101,7 +102,7 @@ public final class DOMKeyInfoFactory extends KeyInfoFactory { return new DOMRetrievalMethod(uri, type, transforms); } - @SuppressWarnings("unchecked") + @SuppressWarnings("rawtypes") public X509Data newX509Data(List content) { return new DOMX509Data(content); } @@ -152,9 +153,15 @@ public final class DOMKeyInfoFactory extends KeyInfoFactory { "support DOM Level 2 and be namespace aware"); } if (tag.equals("KeyInfo")) { - return new DOMKeyInfo(element, new UnmarshalContext(), getProvider()); + try { + return new DOMKeyInfo(element, new UnmarshalContext(), getProvider()); + } catch (MarshalException me) { + throw me; + } catch (Exception e) { + throw new MarshalException(e); + } } else { - throw new MarshalException("invalid KeyInfo tag: " + tag); + throw new MarshalException("Invalid KeyInfo tag: " + tag); } } diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java index 0dfc5dbe7e27c42b78e1a151b48ad0c1277d8eac..63d514e588d1d459254235f5f7449881d7f7f2bf 100644 --- a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java +++ b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java @@ -21,7 +21,7 @@ * under the License. */ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. */ /* * $Id: DOMKeyValue.java 1333415 2012-05-03 12:03:51Z coheigea $ @@ -33,21 +33,19 @@ import javax.xml.crypto.dom.DOMCryptoContext; import javax.xml.crypto.dsig.*; import javax.xml.crypto.dsig.keyinfo.KeyValue; -// import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.security.AccessController; +import java.io.IOException; +import java.math.BigInteger; import java.security.KeyException; import java.security.KeyFactory; import java.security.NoSuchAlgorithmException; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; import java.security.PublicKey; import java.security.interfaces.DSAParams; import java.security.interfaces.DSAPublicKey; import java.security.interfaces.ECPublicKey; import java.security.interfaces.RSAPublicKey; import java.security.spec.DSAPublicKeySpec; +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; @@ -55,6 +53,7 @@ import java.security.spec.EllipticCurve; import java.security.spec.InvalidKeySpecException; import java.security.spec.KeySpec; import java.security.spec.RSAPublicKeySpec; +import java.util.Arrays; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -326,54 +325,155 @@ public abstract class DOMKeyValue extends DOMStructure implements KeyValue { private byte[] ecPublicKey; private KeyFactory eckf; private ECParameterSpec ecParams; - private Method encodePoint, decodePoint, getCurveName, - getECParameterSpec; + + /* 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); + } EC(PublicKey key) throws KeyException { super(key); ECPublicKey ecKey = (ECPublicKey)key; ECPoint ecPoint = ecKey.getW(); ecParams = ecKey.getParams(); - try { - AccessController.doPrivileged( - new PrivilegedExceptionAction() { - public Void run() throws - ClassNotFoundException, NoSuchMethodException - { - getMethods(); - return null; - } - } - ); - } catch (PrivilegedActionException pae) { - throw new KeyException("ECKeyValue not supported", - pae.getException()); - } - Object[] args = new Object[] { ecPoint, ecParams.getCurve() }; - try { - ecPublicKey = (byte[])encodePoint.invoke(null, args); - } catch (IllegalAccessException iae) { - throw new KeyException(iae); - } catch (InvocationTargetException ite) { - throw new KeyException(ite); - } + ecPublicKey = encodePoint(ecPoint, ecParams.getCurve()); } EC(Element dmElem) throws MarshalException { super(dmElem); } - void getMethods() throws ClassNotFoundException, NoSuchMethodException { - Class c = Class.forName("sun.security.ec.ECParameters"); - Class[] params = new Class[] { ECPoint.class, EllipticCurve.class }; - encodePoint = c.getMethod("encodePoint", params); - params = new Class[] { ECParameterSpec.class }; - getCurveName = c.getMethod("getCurveName", params); - params = new Class[] { byte[].class, EllipticCurve.class }; - decodePoint = c.getMethod("decodePoint", params); - c = Class.forName("sun.security.ec.NamedCurve"); - params = new Class[] { String.class }; - getECParameterSpec = c.getMethod("getECParameterSpec", params); + 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 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(); + if (curve.getCurve().getField().getFieldSize() == fieldSize + && curve.getCurve().equals(params.getCurve()) + && curve.getGenerator().equals(params.getGenerator()) + && curve.getOrder().equals(params.getOrder()) + && curve.getCofactor() == params.getCofactor()) { + return true; + } else { + return false; + } + } + + 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; + } } void marshalPublicKey(Node parent, Document doc, String dsPrefix, @@ -391,14 +491,11 @@ public abstract class DOMKeyValue extends DOMStructure implements KeyValue { XMLDSIG_11_XMLNS, prefix); Object[] args = new Object[] { ecParams }; - try { - String oid = (String) getCurveName.invoke(null, args); - DOMUtils.setAttribute(namedCurveElem, "URI", "urn:oid:" + oid); - } catch (IllegalAccessException iae) { - throw new MarshalException(iae); - } catch (InvocationTargetException ite) { - throw new MarshalException(ite); + String oid = getCurveOid(ecParams); + if (oid == null) { + throw new MarshalException("Invalid ECParameterSpec"); } + DOMUtils.setAttribute(namedCurveElem, "URI", "urn:oid:" + oid); String qname = (prefix == null || prefix.length() == 0) ? "xmlns" : "xmlns:" + prefix; namedCurveElem.setAttributeNS("http://www.w3.org/2000/xmlns/", @@ -422,21 +519,6 @@ public abstract class DOMKeyValue extends DOMStructure implements KeyValue { ("unable to create EC KeyFactory: " + e.getMessage()); } } - try { - AccessController.doPrivileged( - new PrivilegedExceptionAction() { - public Void run() throws - ClassNotFoundException, NoSuchMethodException - { - getMethods(); - return null; - } - } - ); - } catch (PrivilegedActionException pae) { - throw new MarshalException("ECKeyValue not supported", - pae.getException()); - } ECParameterSpec ecParams = null; Element curElem = DOMUtils.getFirstChildElement(kvtElem); if (curElem.getLocalName().equals("ECParameters")) { @@ -447,14 +529,9 @@ public abstract class DOMKeyValue extends DOMStructure implements KeyValue { // strip off "urn:oid" if (uri.startsWith("urn:oid:")) { String oid = uri.substring(8); - try { - Object[] args = new Object[] { oid }; - ecParams = (ECParameterSpec) - getECParameterSpec.invoke(null, args); - } catch (IllegalAccessException iae) { - throw new MarshalException(iae); - } catch (InvocationTargetException ite) { - throw new MarshalException(ite); + ecParams = getECParameterSpec(oid); + if (ecParams == null) { + throw new MarshalException("Invalid curve OID"); } } else { throw new MarshalException("Invalid NamedCurve URI"); @@ -464,24 +541,43 @@ public abstract class DOMKeyValue extends DOMStructure implements KeyValue { } curElem = DOMUtils.getNextSiblingElement(curElem, "PublicKey"); ECPoint ecPoint = null; + try { - Object[] args = new Object[] { Base64.decode(curElem), - ecParams.getCurve() }; - ecPoint = (ECPoint)decodePoint.invoke(null, args); + ecPoint = decodePoint(Base64.decode(curElem), + ecParams.getCurve()); } catch (Base64DecodingException bde) { throw new MarshalException("Invalid EC PublicKey", bde); - } catch (IllegalAccessException iae) { - throw new MarshalException(iae); - } catch (InvocationTargetException ite) { - throw new MarshalException(ite); + } catch (IOException ioe) { + throw new MarshalException("Invalid EC Point", ioe); } -/* - ecPoint = sun.security.ec.ECParameters.decodePoint( - Base64.decode(curElem), ecParams.getCurve()); -*/ + ECPublicKeySpec spec = new ECPublicKeySpec(ecPoint, ecParams); return generatePublicKey(eckf, spec); } + + 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); } static final class Unknown extends DOMKeyValue { diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java index d8fc21c34312e3ee45dadf9e3f2e34b1a857edc4..c3cf5d203b04577d2b8caa16c211cec75de06140 100644 --- a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java +++ b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java @@ -128,7 +128,12 @@ public final class DOMManifest extends DOMStructure implements Manifest { return id; } - public List getReferences() { + @SuppressWarnings("unchecked") + static List getManifestReferences(Manifest mf) { + return mf.getReferences(); + } + + public List getReferences() { return references; } diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMPGPData.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMPGPData.java index 85d52f4b4c46288e73a34823800fafb55b6eb6f6..07ee11b3bf0eade89996b4c32dc1ad3c86432821 100644 --- a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMPGPData.java +++ b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMPGPData.java @@ -21,7 +21,7 @@ * under the License. */ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. */ /* * $Id: DOMPGPData.java 1203846 2011-11-18 21:18:17Z mullan $ @@ -57,7 +57,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 - * RFC 2440. The + * RFC 2440. 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 @@ -95,10 +95,10 @@ public final class DOMPGPData extends DOMStructure implements PGPData { * optional key packet and list of external elements. * * @param keyId a PGP public key id as defined in section 11.2 of - * RFC 2440. The + * RFC 2440. The * array is cloned to prevent subsequent modification. * @param keyPacket a PGP Key Material Packet as defined in section 5.5 of - * RFC 2440 (may + * RFC 2440 (may * be null). The array is cloned to prevent subsequent * modification. * @param other a list of {@link XMLStructure}s representing elements from @@ -184,7 +184,7 @@ public final class DOMPGPData extends DOMStructure implements PGPData { return (keyPacket == null ? null : (byte[])keyPacket.clone()); } - public List getExternalElements() { + public List getExternalElements() { return externalElements; } diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java index dbb9be5e2e2be86784c45b94ee76c9e3d52f0abd..81f048310d95020c4d4c6e8b437024369cd6fc45 100644 --- a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java +++ b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java @@ -112,7 +112,6 @@ public final class DOMReference extends DOMStructure * is defensively copied to protect against subsequent modification. * May be null or empty. * @param id the reference ID (may be null) - * @return a Reference * @throws NullPointerException if dm is null * @throws ClassCastException if any of the transforms are * not of type Transform @@ -288,7 +287,7 @@ public final class DOMReference extends DOMStructure return type; } - public List getTransforms() { + public List getTransforms() { return Collections.unmodifiableList(allTransforms); } @@ -638,7 +637,7 @@ public final class DOMReference extends DOMStructure try { final Set s = xsi.getNodeSet(); return new NodeSetData() { - public Iterator iterator() { return s.iterator(); } + public Iterator iterator() { return s.iterator(); } }; } catch (Exception e) { // log a warning diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java index 73d801970b2d173bf0edcf7cae1792a1348315fe..e50a5f19debd504c7ea7a6fb012afcf1dd51fa2b 100644 --- a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java +++ b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java @@ -178,7 +178,7 @@ public final class DOMRetrievalMethod extends DOMStructure return type; } - public List getTransforms() { + public List getTransforms() { return transforms; } @@ -247,7 +247,7 @@ public final class DOMRetrievalMethod extends DOMStructure if ((data instanceof NodeSetData) && Utils.secureValidation(context) && Policy.restrictRetrievalMethodLoops()) { NodeSetData nsd = (NodeSetData)data; - Iterator i = nsd.iterator(); + Iterator i = nsd.iterator(); if (i.hasNext()) { Node root = (Node)i.next(); if ("RetrievalMethod".equals(root.getLocalName())) { diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java index c953cae200bf061c0f9fb23c17aaa0458ce57d3e..9eb40e00bbd25268133a4283d8652a9f5e6f3b4d 100644 --- a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java +++ b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java @@ -21,7 +21,7 @@ * under the License. */ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. */ /* * $Id: DOMSignatureProperties.java 1333415 2012-05-03 12:03:51Z coheigea $ @@ -58,7 +58,6 @@ public final class DOMSignatureProperties extends DOMStructure * @param properties a list of one or more {@link SignatureProperty}s. The * list is defensively copied to protect against subsequent modification. * @param id the Id (may be null) - * @return a DOMSignatureProperties * @throws ClassCastException if properties contains any * entries that are not of type {@link SignatureProperty} * @throws IllegalArgumentException if properties is empty @@ -125,7 +124,7 @@ public final class DOMSignatureProperties extends DOMStructure } } - public List getProperties() { + public List getProperties() { return properties; } diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java index b09b21c4a25c7c1d9051017702807f37aff63527..4fc688e43f1a08abfee278aa8e6de8954d6c6c9f 100644 --- a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java +++ b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java @@ -21,7 +21,7 @@ * under the License. */ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. */ /* * $Id: DOMSignatureProperty.java 1333415 2012-05-03 12:03:51Z coheigea $ @@ -59,7 +59,6 @@ public final class DOMSignatureProperty extends DOMStructure * is defensively copied to protect against subsequent modification. * @param target the target URI * @param id the Id (may be null) - * @return a SignatureProperty * @throws ClassCastException if content contains any * entries that are not of type {@link XMLStructure} * @throws IllegalArgumentException if content is empty @@ -123,7 +122,7 @@ public final class DOMSignatureProperty extends DOMStructure } } - public List getContent() { + public List getContent() { return content; } diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java index 3e2f799f86142ba4ebc712860ade9beba9b1c1f2..7fef580355631c8c54727e5a3568a531371be48e 100644 --- a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java +++ b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java @@ -193,7 +193,7 @@ public final class DOMSignedInfo extends DOMStructure implements SignedInfo { return id; } - public List getReferences() { + public List getReferences() { return references; } diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSubTreeData.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSubTreeData.java index 9119260c55c149bde31f68b8ea4aad0b96ba8e1c..c0ac945b893ee9756f57b16a39f0e7956451e6b2 100644 --- a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSubTreeData.java +++ b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSubTreeData.java @@ -21,7 +21,7 @@ * under the License. */ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. */ /* * $Id$ @@ -54,7 +54,7 @@ public class DOMSubTreeData implements NodeSetData { this.excludeComments = excludeComments; } - public Iterator iterator() { + public Iterator iterator() { return new DelayedNodeIterator(root, excludeComments); } diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMTransform.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMTransform.java index 74131a652b35a37c09d59cc5623a0d0851d4d089..77f2298e277ddd6764b00ceeed8d75eadd02c490 100644 --- a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMTransform.java +++ b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMTransform.java @@ -53,7 +53,7 @@ public class DOMTransform extends DOMStructure implements Transform { protected TransformService spi; /** - * Creates a DOMTransform. + * Creates a {@code DOMTransform}. * * @param spi the TransformService */ @@ -62,7 +62,7 @@ public class DOMTransform extends DOMStructure implements Transform { } /** - * Creates a DOMTransform from an element. This constructor + * Creates a {@code DOMTransform} from an element. This constructor * invokes the abstract {@link #unmarshalParams unmarshalParams} method to * unmarshal any algorithm-specific input parameters. * @@ -138,12 +138,12 @@ public class DOMTransform extends DOMStructure implements Transform { * Transforms the specified data using the underlying transform algorithm. * * @param data the data to be transformed - * @param sc the XMLCryptoContext containing - * additional context (may be null if not applicable) + * @param xc the {@code XMLCryptoContext} containing + * additional context (may be {@code null} if not applicable) * @return the transformed data - * @throws NullPointerException if data is null + * @throws NullPointerException if {@code data} is {@code null} * @throws XMLSignatureException if an unexpected error occurs while - * executing the transform + * executing the transform */ public Data transform(Data data, XMLCryptoContext xc) throws TransformException @@ -155,14 +155,14 @@ public class DOMTransform extends DOMStructure implements Transform { * Transforms the specified data using the underlying transform algorithm. * * @param data the data to be transformed - * @param sc the XMLCryptoContext containing - * additional context (may be null if not applicable) - * @param os the OutputStream that should be used to write - * the transformed data to + * @param xc the {@code XMLCryptoContext} containing + * additional context (may be {@code null} if not applicable) + * @param os the {@code OutputStream} that should be used to write + * the transformed data to * @return the transformed data - * @throws NullPointerException if data is null + * @throws NullPointerException if {@code data} is {@code null} * @throws XMLSignatureException if an unexpected error occurs while - * executing the transform + * executing the transform */ public Data transform(Data data, XMLCryptoContext xc, OutputStream os) throws TransformException @@ -201,16 +201,16 @@ public class DOMTransform extends DOMStructure implements Transform { /** * Transforms the specified data using the underlying transform algorithm. * This method invokes the {@link #marshal marshal} method and passes it - * the specified DOMSignContext before transforming the data. + * the specified {@code DOMSignContext} before transforming the data. * * @param data the data to be transformed - * @param sc the XMLCryptoContext containing - * additional context (may be null if not applicable) + * @param sc the {@code XMLCryptoContext} containing + * additional context (may be {@code null} if not applicable) * @param context the marshalling context * @return the transformed data * @throws MarshalException if an exception occurs while marshalling - * @throws NullPointerException if data or context - * is null + * @throws NullPointerException if {@code data} or {@code context} + * is {@code null} * @throws XMLSignatureException if an unexpected error occurs while * executing the transform */ diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509Data.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509Data.java index e701ff17e898b7c8e58d26fda238b56516c895ec..53555aa927ff96bd5d5580d3a940c49633fc3fdc 100644 --- a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509Data.java +++ b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509Data.java @@ -21,7 +21,7 @@ * under the License. */ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. */ /* * $Id: DOMX509Data.java 1333415 2012-05-03 12:03:51Z coheigea $ @@ -65,7 +65,6 @@ public final class DOMX509Data extends DOMStructure implements X509Data { * or {@link javax.xml.dsig.XMLStructure} ({@link X509IssuerSerial} * objects or elements from an external namespace). The list is * defensively copied to protect against subsequent modification. - * @return a X509Data * @throws NullPointerException if content is null * @throws IllegalArgumentException if content is empty * @throws ClassCastException if content contains any entries @@ -135,7 +134,7 @@ public final class DOMX509Data extends DOMStructure implements X509Data { this.content = Collections.unmodifiableList(content); } - public List getContent() { + public List getContent() { return content; } diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java index 4fa5f56b57d2e65a6373e8208ce5aca6313535fb..6d1ea83dfdc67dcbc09a447dd1eba17e12dc5579 100644 --- a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java +++ b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java @@ -21,7 +21,7 @@ * under the License. */ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. */ /* * $Id: DOMXMLObject.java 1333415 2012-05-03 12:03:51Z coheigea $ @@ -63,7 +63,6 @@ public final class DOMXMLObject extends DOMStructure implements XMLObject { * @param id the Id (may be null) * @param mimeType the mime type (may be null) * @param encoding the encoding (may be null) - * @return an XMLObject * @throws ClassCastException if content contains any * entries that are not of type {@link XMLStructure} */ @@ -139,7 +138,7 @@ public final class DOMXMLObject extends DOMStructure implements XMLObject { this.objectElem = objElem; } - public List getContent() { + public List getContent() { return content; } diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java index 0fbe0df162c1a132f5398e01e2544bc08816f0f6..95f5cc6455c7eb56e4d14c6a4c14cfeac95f6b14 100644 --- a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java +++ b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java @@ -21,7 +21,7 @@ * under the License. */ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. */ /* * =========================================================================== @@ -188,7 +188,7 @@ public final class DOMXMLSignature extends DOMStructure return si; } - public List getObjects() { + public List getObjects() { return objects; } @@ -471,7 +471,8 @@ public final class DOMXMLSignature extends DOMStructure digestReference((DOMReference)xs, signContext); } else if (xs instanceof Manifest) { Manifest man = (Manifest)xs; - List manRefs = man.getReferences(); + List manRefs = + DOMManifest.getManifestReferences(man); for (int i = 0, size = manRefs.size(); i < size; i++) { digestReference((DOMReference)manRefs.get(i), signContext); diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java index b2ca7ee7d48dff9c589a6072943f4e75cc5a7d38..85622e1cac3bf0e456811eca5e8d3f426cf3df3b 100644 --- a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java +++ b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java @@ -58,7 +58,7 @@ public final class DOMXMLSignatureFactory extends XMLSignatureFactory { return new DOMXMLSignature(si, ki, null, null, null); } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) public XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki, List objects, String id, String signatureValueId) { return new DOMXMLSignature(si, ki, objects, id, signatureValueId); @@ -68,13 +68,13 @@ public final class DOMXMLSignatureFactory extends XMLSignatureFactory { return newReference(uri, dm, null, null, null); } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) public Reference newReference(String uri, DigestMethod dm, List transforms, String type, String id) { return new DOMReference(uri, type, dm, transforms, id, getProvider()); } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) public Reference newReference(String uri, DigestMethod dm, List appliedTransforms, Data result, List transforms, String type, String id) { @@ -91,7 +91,7 @@ public final class DOMXMLSignatureFactory extends XMLSignatureFactory { (uri, type, dm, appliedTransforms, result, transforms, id, getProvider()); } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) public Reference newReference(String uri, DigestMethod dm, List transforms, String type, String id, byte[] digestValue) { if (digestValue == null) { @@ -101,41 +101,41 @@ public final class DOMXMLSignatureFactory extends XMLSignatureFactory { (uri, type, dm, null, null, transforms, id, digestValue, getProvider()); } - @SuppressWarnings("unchecked") + @SuppressWarnings("rawtypes") public SignedInfo newSignedInfo(CanonicalizationMethod cm, SignatureMethod sm, List references) { return newSignedInfo(cm, sm, references, null); } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) public SignedInfo newSignedInfo(CanonicalizationMethod cm, SignatureMethod sm, List references, String id) { return new DOMSignedInfo(cm, sm, references, id); } // Object factory methods - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) public XMLObject newXMLObject(List content, String id, String mimeType, String encoding) { return new DOMXMLObject(content, id, mimeType, encoding); } - @SuppressWarnings("unchecked") + @SuppressWarnings("rawtypes") public Manifest newManifest(List references) { return newManifest(references, null); } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) public Manifest newManifest(List references, String id) { return new DOMManifest(references, id); } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) public SignatureProperties newSignatureProperties(List props, String id) { return new DOMSignatureProperties(props, id); } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) public SignatureProperty newSignatureProperty (List info, String target, String id) { return new DOMSignatureProperty(info, target, id); @@ -190,9 +190,15 @@ public final class DOMXMLSignatureFactory extends XMLSignatureFactory { "support DOM Level 2 and be namespace aware"); } if (tag.equals("Signature")) { - return new DOMXMLSignature(element, context, getProvider()); + try { + return new DOMXMLSignature(element, context, getProvider()); + } catch (MarshalException me) { + throw me; + } catch (Exception e) { + throw new MarshalException(e); + } } else { - throw new MarshalException("invalid Signature tag: " + tag); + throw new MarshalException("Invalid Signature tag: " + tag); } } diff --git a/src/share/classes/sun/font/FileFontStrike.java b/src/share/classes/sun/font/FileFontStrike.java index c66bcaf7411fed0c3dbab7b08b74a93c8fe09824..d423feb3258a3a114eb0f7dbe9a20e062647a29f 100644 --- a/src/share/classes/sun/font/FileFontStrike.java +++ b/src/share/classes/sun/font/FileFontStrike.java @@ -328,7 +328,8 @@ public class FileFontStrike extends PhysicalStrike { int style, int size, int glyphCode, - boolean fracMetrics); + boolean fracMetrics, + int fontDataSize); long getGlyphImageFromWindows(int glyphCode) { String family = fileFont.getFamilyName(null); @@ -337,7 +338,8 @@ public class FileFontStrike extends PhysicalStrike { int size = intPtSize; long ptr = _getGlyphImageFromWindows (family, style, size, glyphCode, - desc.fmHint == INTVAL_FRACTIONALMETRICS_ON); + desc.fmHint == INTVAL_FRACTIONALMETRICS_ON, + ((TrueTypeFont)fileFont).fontDataSize); if (ptr != 0) { /* Get the advance from the JDK rasterizer. This is mostly * necessary for the fractional metrics case, but there are @@ -351,6 +353,12 @@ public class FileFontStrike extends PhysicalStrike { advance); return ptr; } else { + if (FontUtilities.isLogging()) { + FontUtilities.getLogger().warning( + "Failed to render glyph using GDI: code=" + glyphCode + + ", fontFamily=" + family + ", style=" + style + + ", size=" + size); + } return fileFont.getGlyphImage(pScalerContext, glyphCode); } } diff --git a/src/share/classes/sun/font/TrueTypeFont.java b/src/share/classes/sun/font/TrueTypeFont.java index 8724c161b970ef69985893aa7ebb7303d9fd6194..5ee84d93201056a4e0720354885f4b18ee56ec8c 100644 --- a/src/share/classes/sun/font/TrueTypeFont.java +++ b/src/share/classes/sun/font/TrueTypeFont.java @@ -172,6 +172,15 @@ public class TrueTypeFont extends FileFont { private String localeFamilyName; private String localeFullName; + /* + * Used on Windows to validate the font selected by GDI for (sub-pixel + * antialiased) rendering. For 'standalone' fonts it's equal to the font + * file size, for collection (TTC, OTC) members it's the number of bytes in + * the collection file from the start of this font's offset table till the + * end of the file. + */ + int fontDataSize; + public TrueTypeFont(String platname, Object nativeNames, int fIndex, boolean javaRasterizer) throws FontFormatException @@ -529,11 +538,13 @@ public class TrueTypeFont extends FileFont { fontIndex = fIndex; buffer = readBlock(TTCHEADERSIZE+4*fIndex, 4); headerOffset = buffer.getInt(); + fontDataSize = Math.max(0, fileSize - headerOffset); break; case v1ttTag: case trueTag: case ottoTag: + fontDataSize = fileSize; break; default: @@ -559,8 +570,8 @@ public class TrueTypeFont extends FileFont { tableDirectory[i] = table = new DirectoryEntry(); table.tag = ibuffer.get(); /* checksum */ ibuffer.get(); - table.offset = ibuffer.get(); - table.length = ibuffer.get(); + table.offset = ibuffer.get() & 0x7FFFFFFF; + table.length = ibuffer.get() & 0x7FFFFFFF; if (table.offset + table.length > fileSize) { throw new FontFormatException("bad table, tag="+table.tag); } diff --git a/src/share/classes/sun/java2d/ReentrantContext.java b/src/share/classes/sun/java2d/ReentrantContext.java new file mode 100644 index 0000000000000000000000000000000000000000..fc067b0070da62efcb51405685271f5de079bc15 --- /dev/null +++ b/src/share/classes/sun/java2d/ReentrantContext.java @@ -0,0 +1,43 @@ +/* + * 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. 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.java2d; + +import java.lang.ref.Reference; + +/** + * ReentrantContext is a base class to hold thread-local data supporting + * reentrancy in either a ThreadLocal or a ConcurrentLinkedQueue + * + * @see ReentrantContextProvider + */ +public class ReentrantContext { + // usage stored as a byte + byte usage = ReentrantContextProvider.USAGE_TL_INACTIVE; + /* + * Reference to this instance (hard, soft or weak). + * @see ReentrantContextProvider#refType + */ + Reference reference = null; +} diff --git a/src/share/classes/sun/java2d/ReentrantContextProvider.java b/src/share/classes/sun/java2d/ReentrantContextProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..92132aabcc455b3d2eef2a5083fac3f7ee5aaeef --- /dev/null +++ b/src/share/classes/sun/java2d/ReentrantContextProvider.java @@ -0,0 +1,169 @@ +/* + * 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. 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.java2d; + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; + +/** + * This abstract ReentrantContextProvider helper class manages the creation, + * storage, and retrieval of concrete ReentrantContext instances which can be + * subclassed to hold cached contextual data. + * + * It supports reentrancy as every call to acquire() provides a new unique context + * instance that must later be returned for reuse by a call to release(ctx) + * (typically in a try/finally block). + * + * It has a couple of abstract implementations which store references in a queue + * and/or thread-local storage. + * The Providers can be configured to hold ReentrantContext instances in memory + * using hard, soft or weak references. + * + * The acquire() and release() methods are used to retrieve and return the contexts. + * + * The {@code newContext()} method remains abstract in all implementations and + * must be provided by the module to create a new subclass of ReentrantContext + * with the appropriate contextual data in it. + * + * Sample Usage: + * - create a subclass ReentrantContextImpl to hold the thread state: + * + * static final class ReentrantContextImpl extends ReentrantContext { + * // specific cached data + * } + * + * - create the appropriate ReentrantContextProvider: + * + * private static final ReentrantContextProvider contextProvider = + * new ReentrantContextProviderTL(ReentrantContextProvider.REF_WEAK) + * { + * @Override + * protected ReentrantContextImpl newContext() { + * return new ReentrantContextImpl(); + * } + * }; + * ... + * void someMethod() { + * ReentrantContextImpl ctx = contextProvider.acquire(); + * try { + * // use the context + * } finally { + * contextProvider.release(ctx); + * } + * } + * + * @param ReentrantContext subclass + * + * @see ReentrantContext + */ +public abstract class ReentrantContextProvider +{ + // thread-local storage: inactive + static final byte USAGE_TL_INACTIVE = 0; + // thread-local storage: in use + static final byte USAGE_TL_IN_USE = 1; + // CLQ storage + static final byte USAGE_CLQ = 2; + + // hard reference + public static final int REF_HARD = 0; + // soft reference + public static final int REF_SOFT = 1; + // weak reference + public static final int REF_WEAK = 2; + + /* members */ + // internal reference type + private final int refType; + + /** + * Create a new ReentrantContext provider using the given reference type + * among hard, soft or weak + * + * @param refType reference type + */ + protected ReentrantContextProvider(final int refType) { + this.refType = refType; + } + + /** + * Create a new ReentrantContext instance + * + * @return new ReentrantContext instance + */ + protected abstract K newContext(); + + /** + * Give a ReentrantContext instance for the current thread + * + * @return ReentrantContext instance + */ + public abstract K acquire(); + + /** + * Restore the given ReentrantContext instance for reuse + * + * @param ctx ReentrantContext instance + */ + public abstract void release(K ctx); + + @SuppressWarnings("unchecked") + protected final Reference getOrCreateReference(final K ctx) { + if (ctx.reference == null) { + // Create the reference: + switch (refType) { + case REF_HARD: + ctx.reference = new HardReference(ctx); + break; + case REF_SOFT: + ctx.reference = new SoftReference(ctx); + break; + default: + case REF_WEAK: + ctx.reference = new WeakReference(ctx); + break; + } + } + return (Reference) ctx.reference; + } + + /* Missing HardReference implementation */ + static final class HardReference extends WeakReference { + // kept strong reference: + private final V strongRef; + + HardReference(final V referent) { + // no referent needed for the parent WeakReference: + super(null); + this.strongRef = referent; + } + + @Override + public V get() { + return strongRef; + } + } +} diff --git a/src/share/classes/sun/java2d/ReentrantContextProviderCLQ.java b/src/share/classes/sun/java2d/ReentrantContextProviderCLQ.java new file mode 100644 index 0000000000000000000000000000000000000000..22978cef88829ebd2f8f29e806143924813a6841 --- /dev/null +++ b/src/share/classes/sun/java2d/ReentrantContextProviderCLQ.java @@ -0,0 +1,89 @@ +/* + * 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. 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.java2d; + +import java.lang.ref.Reference; +import java.util.concurrent.ConcurrentLinkedQueue; + +/** + * This ReentrantContextProvider implementation uses one ConcurrentLinkedQueue + * to store all ReentrantContext instances (thread and its child contexts) + * + * Note: this implementation keeps less contexts in memory depending on the + * concurrent active threads in contrary to a ThreadLocal provider. However, + * it is slower in highly concurrent workloads. + * + * @param ReentrantContext subclass + */ +public abstract class ReentrantContextProviderCLQ + extends ReentrantContextProvider +{ + // ReentrantContext queue to store all contexts + private final ConcurrentLinkedQueue> ctxQueue + = new ConcurrentLinkedQueue>(); + + /** + * Create a new ReentrantContext provider using the given reference type + * among hard, soft or weak based using a ConcurrentLinkedQueue storage + * + * @param refType reference type + */ + public ReentrantContextProviderCLQ(final int refType) { + super(refType); + } + + /** + * Give a ReentrantContext instance for the current thread + * + * @return ReentrantContext instance + */ + @Override + public final K acquire() { + K ctx = null; + // Drain queue if all referent are null: + Reference ref = null; + while ((ctx == null) && ((ref = ctxQueue.poll()) != null)) { + ctx = ref.get(); + } + if (ctx == null) { + // create a new ReentrantContext if none is available + ctx = newContext(); + ctx.usage = USAGE_CLQ; + } + return ctx; + } + + /** + * Restore the given ReentrantContext instance for reuse + * + * @param ctx ReentrantContext instance + */ + @Override + public final void release(final K ctx) { + if (ctx.usage == USAGE_CLQ) { + ctxQueue.offer(getOrCreateReference(ctx)); + } + } +} diff --git a/src/share/classes/sun/java2d/ReentrantContextProviderTL.java b/src/share/classes/sun/java2d/ReentrantContextProviderTL.java new file mode 100644 index 0000000000000000000000000000000000000000..14dcb84d6d5e67da297956c4ae957def00e83d8d --- /dev/null +++ b/src/share/classes/sun/java2d/ReentrantContextProviderTL.java @@ -0,0 +1,123 @@ +/* + * 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. 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.java2d; + +import java.lang.ref.Reference; + +/** +* This ReentrantContextProvider implementation uses a ThreadLocal to hold + * the first ReentrantContext per thread and a ReentrantContextProviderCLQ to + * store child ReentrantContext instances needed during recursion. + * + * Note: this implementation may keep up to one context in memory per thread. + * Child contexts for recursive uses are stored in the queue using a WEAK + * reference by default unless specified in the 2 argument constructor. + * + * @param ReentrantContext subclass + */ +public abstract class ReentrantContextProviderTL + extends ReentrantContextProvider +{ + // Thread-local storage: + private final ThreadLocal> ctxTL + = new ThreadLocal>(); + + // ReentrantContext CLQ provider for child contexts: + private final ReentrantContextProviderCLQ ctxProviderCLQ; + + /** + * Create a new ReentrantContext provider using the given reference type + * among hard, soft or weak. + * It uses weak reference for the child contexts. + * + * @param refType reference type + */ + public ReentrantContextProviderTL(final int refType) { + this(refType, REF_WEAK); + } + + /** + * Create a new ReentrantContext provider using the given reference types + * among hard, soft or weak + * + * @param refTypeTL reference type used by ThreadLocal + * @param refTypeCLQ reference type used by ReentrantContextProviderCLQ + */ + public ReentrantContextProviderTL(final int refTypeTL, final int refTypeCLQ) + { + super(refTypeTL); + + final ReentrantContextProviderTL parent = this; + + this.ctxProviderCLQ = new ReentrantContextProviderCLQ(refTypeCLQ) { + @Override + protected K newContext() { + return parent.newContext(); + } + }; + } + + /** + * Give a ReentrantContext instance for the current thread + * + * @return ReentrantContext instance + */ + @Override + public final K acquire() { + K ctx = null; + final Reference ref = ctxTL.get(); + if (ref != null) { + ctx = ref.get(); + } + if (ctx == null) { + // create a new ReentrantContext if none is available + ctx = newContext(); + // update thread local reference: + ctxTL.set(getOrCreateReference(ctx)); + } + // Check reentrance: + if (ctx.usage == USAGE_TL_INACTIVE) { + ctx.usage = USAGE_TL_IN_USE; + } else { + // get or create another ReentrantContext from CLQ provider: + ctx = ctxProviderCLQ.acquire(); + } + return ctx; + } + + /** + * Restore the given ReentrantContext instance for reuse + * + * @param ctx ReentrantContext instance + */ + @Override + public final void release(final K ctx) { + if (ctx.usage == USAGE_TL_IN_USE) { + ctx.usage = USAGE_TL_INACTIVE; + } else { + ctxProviderCLQ.release(ctx); + } + } +} diff --git a/src/share/classes/sun/java2d/marlin/ArrayCache.java b/src/share/classes/sun/java2d/marlin/ArrayCache.java new file mode 100644 index 0000000000000000000000000000000000000000..e518c4d226174f4e59658c8304a68932a1fe24d0 --- /dev/null +++ b/src/share/classes/sun/java2d/marlin/ArrayCache.java @@ -0,0 +1,232 @@ +/* + * 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. 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.java2d.marlin; + +import java.util.Arrays; +import static sun.java2d.marlin.MarlinUtils.logInfo; + +public final class ArrayCache implements MarlinConst { + + static final int BUCKETS = 4; + static final int MIN_ARRAY_SIZE = 4096; + static final int MAX_ARRAY_SIZE; + static final int MASK_CLR_1 = ~1; + // threshold to grow arrays only by (3/2) instead of 2 + static final int THRESHOLD_ARRAY_SIZE; + static final int[] ARRAY_SIZES = new int[BUCKETS]; + // dirty byte array sizes + static final int MIN_DIRTY_BYTE_ARRAY_SIZE = 32 * 2048; // 32px x 2048px + static final int MAX_DIRTY_BYTE_ARRAY_SIZE; + static final int[] DIRTY_BYTE_ARRAY_SIZES = new int[BUCKETS]; + // large array thresholds: + static final long THRESHOLD_LARGE_ARRAY_SIZE; + static final long THRESHOLD_HUGE_ARRAY_SIZE; + // stats + private static int resizeInt = 0; + private static int resizeDirtyInt = 0; + private static int resizeDirtyFloat = 0; + private static int resizeDirtyByte = 0; + private static int oversize = 0; + + static { + // initialize buckets for int/float arrays + int arraySize = MIN_ARRAY_SIZE; + + for (int i = 0; i < BUCKETS; i++, arraySize <<= 2) { + ARRAY_SIZES[i] = arraySize; + + if (doTrace) { + logInfo("arraySize[" + i + "]: " + arraySize); + } + } + MAX_ARRAY_SIZE = arraySize >> 2; + + /* initialize buckets for dirty byte arrays + (large AA chunk = 32 x 2048 pixels) */ + arraySize = MIN_DIRTY_BYTE_ARRAY_SIZE; + + for (int i = 0; i < BUCKETS; i++, arraySize <<= 1) { + DIRTY_BYTE_ARRAY_SIZES[i] = arraySize; + + if (doTrace) { + logInfo("dirty arraySize[" + i + "]: " + arraySize); + } + } + MAX_DIRTY_BYTE_ARRAY_SIZE = arraySize >> 1; + + // threshold to grow arrays only by (3/2) instead of 2 + THRESHOLD_ARRAY_SIZE = Math.max(2 * 1024 * 1024, MAX_ARRAY_SIZE); // 2M + + THRESHOLD_LARGE_ARRAY_SIZE = 8L * THRESHOLD_ARRAY_SIZE; // 16M + THRESHOLD_HUGE_ARRAY_SIZE = 8L * THRESHOLD_LARGE_ARRAY_SIZE; // 128M + + if (doStats || doMonitors) { + logInfo("ArrayCache.BUCKETS = " + BUCKETS); + logInfo("ArrayCache.MIN_ARRAY_SIZE = " + MIN_ARRAY_SIZE); + logInfo("ArrayCache.MAX_ARRAY_SIZE = " + MAX_ARRAY_SIZE); + logInfo("ArrayCache.ARRAY_SIZES = " + + Arrays.toString(ARRAY_SIZES)); + logInfo("ArrayCache.MIN_DIRTY_BYTE_ARRAY_SIZE = " + + MIN_DIRTY_BYTE_ARRAY_SIZE); + logInfo("ArrayCache.MAX_DIRTY_BYTE_ARRAY_SIZE = " + + MAX_DIRTY_BYTE_ARRAY_SIZE); + logInfo("ArrayCache.ARRAY_SIZES = " + + Arrays.toString(DIRTY_BYTE_ARRAY_SIZES)); + logInfo("ArrayCache.THRESHOLD_ARRAY_SIZE = " + + THRESHOLD_ARRAY_SIZE); + logInfo("ArrayCache.THRESHOLD_LARGE_ARRAY_SIZE = " + + THRESHOLD_LARGE_ARRAY_SIZE); + logInfo("ArrayCache.THRESHOLD_HUGE_ARRAY_SIZE = " + + THRESHOLD_HUGE_ARRAY_SIZE); + } + } + + private ArrayCache() { + // Utility class + } + + static synchronized void incResizeInt() { + resizeInt++; + } + + static synchronized void incResizeDirtyInt() { + resizeDirtyInt++; + } + + static synchronized void incResizeDirtyFloat() { + resizeDirtyFloat++; + } + + static synchronized void incResizeDirtyByte() { + resizeDirtyByte++; + } + + static synchronized void incOversize() { + oversize++; + } + + static void dumpStats() { + if (resizeInt != 0 || resizeDirtyInt != 0 || resizeDirtyFloat != 0 + || resizeDirtyByte != 0 || oversize != 0) { + logInfo("ArrayCache: int resize: " + resizeInt + + " - dirty int resize: " + resizeDirtyInt + + " - dirty float resize: " + resizeDirtyFloat + + " - dirty byte resize: " + resizeDirtyByte + + " - oversize: " + oversize); + } + } + + // small methods used a lot (to be inlined / optimized by hotspot) + + static int getBucket(final int length) { + for (int i = 0; i < ARRAY_SIZES.length; i++) { + if (length <= ARRAY_SIZES[i]) { + return i; + } + } + return -1; + } + + static int getBucketDirtyBytes(final int length) { + for (int i = 0; i < DIRTY_BYTE_ARRAY_SIZES.length; i++) { + if (length <= DIRTY_BYTE_ARRAY_SIZES[i]) { + return i; + } + } + return -1; + } + + /** + * Return the new array size (~ x2) + * @param curSize current used size + * @param needSize needed size + * @return new array size + */ + public static int getNewSize(final int curSize, final int needSize) { + // check if needSize is negative or integer overflow: + if (needSize < 0) { + // hard overflow failure - we can't even accommodate + // new items without overflowing + throw new ArrayIndexOutOfBoundsException( + "array exceeds maximum capacity !"); + } + assert curSize >= 0; + final int initial = (curSize & MASK_CLR_1); + int size; + if (initial > THRESHOLD_ARRAY_SIZE) { + size = initial + (initial >> 1); // x(3/2) + } else { + size = (initial << 1); // x2 + } + // ensure the new size is >= needed size: + if (size < needSize) { + // align to 4096 (may overflow): + size = ((needSize >> 12) + 1) << 12; + } + // check integer overflow: + if (size < 0) { + // resize to maximum capacity: + size = Integer.MAX_VALUE; + } + return size; + } + + /** + * Return the new array size (~ x2) + * @param curSize current used size + * @param needSize needed size + * @return new array size + */ + public static long getNewLargeSize(final long curSize, final long needSize) { + // check if needSize is negative or integer overflow: + if ((needSize >> 31L) != 0L) { + // hard overflow failure - we can't even accommodate + // new items without overflowing + throw new ArrayIndexOutOfBoundsException( + "array exceeds maximum capacity !"); + } + assert curSize >= 0L; + long size; + if (curSize > THRESHOLD_HUGE_ARRAY_SIZE) { + size = curSize + (curSize >> 2L); // x(5/4) + } else if (curSize > THRESHOLD_LARGE_ARRAY_SIZE) { + size = curSize + (curSize >> 1L); // x(3/2) + } else { + size = (curSize << 1L); // x2 + } + // ensure the new size is >= needed size: + if (size < needSize) { + // align to 4096: + size = ((needSize >> 12L) + 1L) << 12L; + } + // check integer overflow: + if (size > Integer.MAX_VALUE) { + // resize to maximum capacity: + size = Integer.MAX_VALUE; + } + return size; + } +} diff --git a/src/share/classes/sun/java2d/marlin/ByteArrayCache.java b/src/share/classes/sun/java2d/marlin/ByteArrayCache.java new file mode 100644 index 0000000000000000000000000000000000000000..6e8da24453e3737d199e3a22e63ff7b6f72fde9a --- /dev/null +++ b/src/share/classes/sun/java2d/marlin/ByteArrayCache.java @@ -0,0 +1,152 @@ +/* + * 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. 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.java2d.marlin; + +import java.util.ArrayDeque; +import java.util.Arrays; +import static sun.java2d.marlin.MarlinUtils.logException; +import static sun.java2d.marlin.MarlinUtils.logInfo; + +final class ByteArrayCache implements MarlinConst { + + private final int arraySize; + private final ArrayDeque byteArrays; + // stats + private int getOp = 0; + private int createOp = 0; + private int returnOp = 0; + + void dumpStats() { + if (getOp > 0) { + logInfo("ByteArrayCache[" + arraySize + "]: get: " + getOp + + " created: " + createOp + " - returned: " + returnOp + + " :: cache size: " + byteArrays.size()); + } + } + + ByteArrayCache(final int arraySize) { + this.arraySize = arraySize; + // small but enough: almost 1 cache line + this.byteArrays = new ArrayDeque(6); + } + + byte[] getArray() { + if (doStats) { + getOp++; + } + + // use cache: + final byte[] array = byteArrays.pollLast(); + if (array != null) { + return array; + } + + if (doStats) { + createOp++; + } + + return new byte[arraySize]; + } + + void putDirtyArray(final byte[] array, final int length) { + if (length != arraySize) { + if (doChecks) { + MarlinUtils.logInfo("ArrayCache: bad length = " + length); + } + return; + } + if (doStats) { + returnOp++; + } + + // NO clean-up of array data = DIRTY ARRAY + + if (doCleanDirty) { + // Force zero-fill dirty arrays: + Arrays.fill(array, 0, array.length, BYTE_0); + } + + // fill cache: + byteArrays.addLast(array); + } + + void putArray(final byte[] array, final int length, + final int fromIndex, final int toIndex) + { + if (length != arraySize) { + if (doChecks) { + MarlinUtils.logInfo("ArrayCache: bad length = " + length); + } + return; + } + if (doStats) { + returnOp++; + } + + // clean-up array of dirty part[fromIndex; toIndex[ + fill(array, fromIndex, toIndex, BYTE_0); + + // fill cache: + byteArrays.addLast(array); + } + + static void fill(final byte[] array, final int fromIndex, + final int toIndex, final byte value) + { + // clear array data: + /* + * Arrays.fill is faster than System.arraycopy(empty array) + * or Unsafe.setMemory(byte 0) + */ + if (toIndex != 0) { + Arrays.fill(array, fromIndex, toIndex, value); + } + + if (doChecks) { + check(array, fromIndex, toIndex, value); + } + } + + static void check(final byte[] array, final int fromIndex, + final int toIndex, final byte value) + { + if (doChecks) { + // check zero on full array: + for (int i = 0; i < array.length; i++) { + if (array[i] != value) { + logException("Invalid value at: " + i + " = " + array[i] + + " from: " + fromIndex + " to: " + toIndex + "\n" + + Arrays.toString(array), new Throwable()); + + // ensure array is correctly filled: + Arrays.fill(array, value); + + return; + } + } + } + } +} diff --git a/src/share/classes/sun/java2d/marlin/CollinearSimplifier.java b/src/share/classes/sun/java2d/marlin/CollinearSimplifier.java new file mode 100644 index 0000000000000000000000000000000000000000..dbe9c2cc8ab37fdbf9d0116ab5d52515679921ad --- /dev/null +++ b/src/share/classes/sun/java2d/marlin/CollinearSimplifier.java @@ -0,0 +1,155 @@ +/* + * 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. 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.java2d.marlin; + +import sun.awt.geom.PathConsumer2D; + +final class CollinearSimplifier implements PathConsumer2D { + + enum SimplifierState { + + Empty, PreviousPoint, PreviousLine + }; + // slope precision threshold + static final float EPS = 1e-4f; // aaime proposed 1e-3f + + PathConsumer2D delegate; + SimplifierState state; + float px1, py1, px2, py2; + float pslope; + + CollinearSimplifier() { + } + + public CollinearSimplifier init(PathConsumer2D delegate) { + this.delegate = delegate; + this.state = SimplifierState.Empty; + + return this; // fluent API + } + + @Override + public void pathDone() { + emitStashedLine(); + state = SimplifierState.Empty; + delegate.pathDone(); + } + + @Override + public void closePath() { + emitStashedLine(); + state = SimplifierState.Empty; + delegate.closePath(); + } + + @Override + public long getNativeConsumer() { + return 0; + } + + @Override + public void quadTo(float x1, float y1, float x2, float y2) { + emitStashedLine(); + delegate.quadTo(x1, y1, x2, y2); + // final end point: + state = SimplifierState.PreviousPoint; + px1 = x2; + py1 = y2; + } + + @Override + public void curveTo(float x1, float y1, float x2, float y2, + float x3, float y3) { + emitStashedLine(); + delegate.curveTo(x1, y1, x2, y2, x3, y3); + // final end point: + state = SimplifierState.PreviousPoint; + px1 = x3; + py1 = y3; + } + + @Override + public void moveTo(float x, float y) { + emitStashedLine(); + delegate.moveTo(x, y); + state = SimplifierState.PreviousPoint; + px1 = x; + py1 = y; + } + + @Override + public void lineTo(final float x, final float y) { + switch (state) { + case Empty: + delegate.lineTo(x, y); + state = SimplifierState.PreviousPoint; + px1 = x; + py1 = y; + return; + + case PreviousPoint: + state = SimplifierState.PreviousLine; + px2 = x; + py2 = y; + pslope = getSlope(px1, py1, x, y); + return; + + case PreviousLine: + final float slope = getSlope(px2, py2, x, y); + // test for collinearity + if ((slope == pslope) || (Math.abs(pslope - slope) < EPS)) { + // merge segments + px2 = x; + py2 = y; + return; + } + // emit previous segment + delegate.lineTo(px2, py2); + px1 = px2; + py1 = py2; + px2 = x; + py2 = y; + pslope = slope; + return; + default: + } + } + + private void emitStashedLine() { + if (state == SimplifierState.PreviousLine) { + delegate.lineTo(px2, py2); + } + } + + private static float getSlope(float x1, float y1, float x2, float y2) { + float dy = y2 - y1; + if (dy == 0f) { + return (x2 > x1) ? Float.POSITIVE_INFINITY + : Float.NEGATIVE_INFINITY; + } + return (x2 - x1) / dy; + } +} diff --git a/src/share/classes/sun/java2d/marlin/Curve.java b/src/share/classes/sun/java2d/marlin/Curve.java new file mode 100644 index 0000000000000000000000000000000000000000..2d61d9157f61c8ed543aa2f27ab8a1660381caf3 --- /dev/null +++ b/src/share/classes/sun/java2d/marlin/Curve.java @@ -0,0 +1,306 @@ +/* + * Copyright (c) 2007, 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. 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.java2d.marlin; + +import java.util.Iterator; + +final class Curve { + + float ax, ay, bx, by, cx, cy, dx, dy; + float dax, day, dbx, dby; + // shared iterator instance + private final BreakPtrIterator iterator = new BreakPtrIterator(); + + Curve() { + } + + void set(float[] points, int type) { + switch(type) { + case 8: + set(points[0], points[1], + points[2], points[3], + points[4], points[5], + points[6], points[7]); + return; + case 6: + set(points[0], points[1], + points[2], points[3], + points[4], points[5]); + return; + default: + throw new InternalError("Curves can only be cubic or quadratic"); + } + } + + void set(float x1, float y1, + float x2, float y2, + float x3, float y3, + float x4, float y4) + { + ax = 3f * (x2 - x3) + x4 - x1; + ay = 3f * (y2 - y3) + y4 - y1; + bx = 3f * (x1 - 2f * x2 + x3); + by = 3f * (y1 - 2f * y2 + y3); + cx = 3f * (x2 - x1); + cy = 3f * (y2 - y1); + dx = x1; + dy = y1; + dax = 3f * ax; day = 3f * ay; + dbx = 2f * bx; dby = 2f * by; + } + + void set(float x1, float y1, + float x2, float y2, + float x3, float y3) + { + ax = 0f; ay = 0f; + bx = x1 - 2f * x2 + x3; + by = y1 - 2f * y2 + y3; + cx = 2f * (x2 - x1); + cy = 2f * (y2 - y1); + dx = x1; + dy = y1; + dax = 0f; day = 0f; + dbx = 2f * bx; dby = 2f * by; + } + + float xat(float t) { + return t * (t * (t * ax + bx) + cx) + dx; + } + float yat(float t) { + return t * (t * (t * ay + by) + cy) + dy; + } + + float dxat(float t) { + return t * (t * dax + dbx) + cx; + } + + float dyat(float t) { + return t * (t * day + dby) + cy; + } + + int dxRoots(float[] roots, int off) { + return Helpers.quadraticRoots(dax, dbx, cx, roots, off); + } + + int dyRoots(float[] roots, int off) { + return Helpers.quadraticRoots(day, dby, cy, roots, off); + } + + int infPoints(float[] pts, int off) { + // inflection point at t if -f'(t)x*f''(t)y + f'(t)y*f''(t)x == 0 + // Fortunately, this turns out to be quadratic, so there are at + // most 2 inflection points. + final float a = dax * dby - dbx * day; + final float b = 2f * (cy * dax - day * cx); + final float c = cy * dbx - cx * dby; + + return Helpers.quadraticRoots(a, b, c, pts, off); + } + + // finds points where the first and second derivative are + // perpendicular. This happens when g(t) = f'(t)*f''(t) == 0 (where + // * is a dot product). Unfortunately, we have to solve a cubic. + private int perpendiculardfddf(float[] pts, int off) { + assert pts.length >= off + 4; + + // these are the coefficients of some multiple of g(t) (not g(t), + // because the roots of a polynomial are not changed after multiplication + // by a constant, and this way we save a few multiplications). + final float a = 2f * (dax*dax + day*day); + final float b = 3f * (dax*dbx + day*dby); + final float c = 2f * (dax*cx + day*cy) + dbx*dbx + dby*dby; + final float d = dbx*cx + dby*cy; + return Helpers.cubicRootsInAB(a, b, c, d, pts, off, 0f, 1f); + } + + // Tries to find the roots of the function ROC(t)-w in [0, 1). It uses + // a variant of the false position algorithm to find the roots. False + // position requires that 2 initial values x0,x1 be given, and that the + // function must have opposite signs at those values. To find such + // values, we need the local extrema of the ROC function, for which we + // need the roots of its derivative; however, it's harder to find the + // roots of the derivative in this case than it is to find the roots + // of the original function. So, we find all points where this curve's + // first and second derivative are perpendicular, and we pretend these + // are our local extrema. There are at most 3 of these, so we will check + // at most 4 sub-intervals of (0,1). ROC has asymptotes at inflection + // points, so roc-w can have at least 6 roots. This shouldn't be a + // problem for what we're trying to do (draw a nice looking curve). + int rootsOfROCMinusW(float[] roots, int off, final float w, final float err) { + // no OOB exception, because by now off<=6, and roots.length >= 10 + assert off <= 6 && roots.length >= 10; + int ret = off; + int numPerpdfddf = perpendiculardfddf(roots, off); + float t0 = 0, ft0 = ROCsq(t0) - w*w; + roots[off + numPerpdfddf] = 1f; // always check interval end points + numPerpdfddf++; + for (int i = off; i < off + numPerpdfddf; i++) { + float t1 = roots[i], ft1 = ROCsq(t1) - w*w; + if (ft0 == 0f) { + roots[ret++] = t0; + } else if (ft1 * ft0 < 0f) { // have opposite signs + // (ROC(t)^2 == w^2) == (ROC(t) == w) is true because + // ROC(t) >= 0 for all t. + roots[ret++] = falsePositionROCsqMinusX(t0, t1, w*w, err); + } + t0 = t1; + ft0 = ft1; + } + + return ret - off; + } + + private static float eliminateInf(float x) { + return (x == Float.POSITIVE_INFINITY ? Float.MAX_VALUE : + (x == Float.NEGATIVE_INFINITY ? Float.MIN_VALUE : x)); + } + + // A slight modification of the false position algorithm on wikipedia. + // This only works for the ROCsq-x functions. It might be nice to have + // the function as an argument, but that would be awkward in java6. + // TODO: It is something to consider for java8 (or whenever lambda + // expressions make it into the language), depending on how closures + // and turn out. Same goes for the newton's method + // algorithm in Helpers.java + private float falsePositionROCsqMinusX(float x0, float x1, + final float x, final float err) + { + final int iterLimit = 100; + int side = 0; + float t = x1, ft = eliminateInf(ROCsq(t) - x); + float s = x0, fs = eliminateInf(ROCsq(s) - x); + float r = s, fr; + for (int i = 0; i < iterLimit && Math.abs(t - s) > err * Math.abs(t + s); i++) { + r = (fs * t - ft * s) / (fs - ft); + fr = ROCsq(r) - x; + if (sameSign(fr, ft)) { + ft = fr; t = r; + if (side < 0) { + fs /= (1 << (-side)); + side--; + } else { + side = -1; + } + } else if (fr * fs > 0) { + fs = fr; s = r; + if (side > 0) { + ft /= (1 << side); + side++; + } else { + side = 1; + } + } else { + break; + } + } + return r; + } + + private static boolean sameSign(float x, float y) { + // another way is to test if x*y > 0. This is bad for small x, y. + return (x < 0f && y < 0f) || (x > 0f && y > 0f); + } + + // returns the radius of curvature squared at t of this curve + // see http://en.wikipedia.org/wiki/Radius_of_curvature_(applications) + private float ROCsq(final float t) { + // dx=xat(t) and dy=yat(t). These calls have been inlined for efficiency + final float dx = t * (t * dax + dbx) + cx; + final float dy = t * (t * day + dby) + cy; + final float ddx = 2f * dax * t + dbx; + final float ddy = 2f * day * t + dby; + final float dx2dy2 = dx*dx + dy*dy; + final float ddx2ddy2 = ddx*ddx + ddy*ddy; + final float ddxdxddydy = ddx*dx + ddy*dy; + return dx2dy2*((dx2dy2*dx2dy2) / (dx2dy2 * ddx2ddy2 - ddxdxddydy*ddxdxddydy)); + } + + // curve to be broken should be in pts + // this will change the contents of pts but not Ts + // TODO: There's no reason for Ts to be an array. All we need is a sequence + // of t values at which to subdivide. An array statisfies this condition, + // but is unnecessarily restrictive. Ts should be an Iterator instead. + // Doing this will also make dashing easier, since we could easily make + // LengthIterator an Iterator and feed it to this function to simplify + // the loop in Dasher.somethingTo. + BreakPtrIterator breakPtsAtTs(final float[] pts, final int type, + final float[] Ts, final int numTs) + { + assert pts.length >= 2*type && numTs <= Ts.length; + + // initialize shared iterator: + iterator.init(pts, type, Ts, numTs); + + return iterator; + } + + static final class BreakPtrIterator { + private int nextCurveIdx; + private int curCurveOff; + private float prevT; + private float[] pts; + private int type; + private float[] ts; + private int numTs; + + void init(final float[] pts, final int type, + final float[] ts, final int numTs) { + this.pts = pts; + this.type = type; + this.ts = ts; + this.numTs = numTs; + + nextCurveIdx = 0; + curCurveOff = 0; + prevT = 0f; + } + + public boolean hasNext() { + return nextCurveIdx <= numTs; + } + + public int next() { + int ret; + if (nextCurveIdx < numTs) { + float curT = ts[nextCurveIdx]; + float splitT = (curT - prevT) / (1f - prevT); + Helpers.subdivideAt(splitT, + pts, curCurveOff, + pts, 0, + pts, type, type); + prevT = curT; + ret = 0; + curCurveOff = type; + } else { + ret = curCurveOff; + } + nextCurveIdx++; + return ret; + } + } +} + diff --git a/src/share/classes/sun/java2d/marlin/Dasher.java b/src/share/classes/sun/java2d/marlin/Dasher.java new file mode 100644 index 0000000000000000000000000000000000000000..a7da2102287d27944df03f878473fe615c82b1cf --- /dev/null +++ b/src/share/classes/sun/java2d/marlin/Dasher.java @@ -0,0 +1,702 @@ +/* + * Copyright (c) 2007, 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. 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.java2d.marlin; + +import java.util.Arrays; +import sun.awt.geom.PathConsumer2D; + +/** + * The Dasher class takes a series of linear commands + * (moveTo, lineTo, close and + * end) and breaks them into smaller segments according to a + * dash pattern array and a starting dash phase. + * + *

    Issues: in J2Se, a zero length dash segment as drawn as a very + * short dash, whereas Pisces does not draw anything. The PostScript + * semantics are unclear. + * + */ +final class Dasher implements sun.awt.geom.PathConsumer2D, MarlinConst { + + static final int recLimit = 4; + static final float ERR = 0.01f; + static final float minTincrement = 1f / (1 << recLimit); + + private PathConsumer2D out; + private float[] dash; + private int dashLen; + private float startPhase; + private boolean startDashOn; + private int startIdx; + + private boolean starting; + private boolean needsMoveTo; + + private int idx; + private boolean dashOn; + private float phase; + + private float sx, sy; + private float x0, y0; + + // temporary storage for the current curve + private final float[] curCurvepts; + + // per-thread renderer context + final RendererContext rdrCtx; + + // dashes array (dirty) + final float[] dashes_initial = new float[INITIAL_ARRAY]; + + // flag to recycle dash array copy + boolean recycleDashes; + + // per-thread initial arrays (large enough to satisfy most usages + // +1 to avoid recycling in Helpers.widenArray() + private final float[] firstSegmentsBuffer_initial = new float[INITIAL_ARRAY + 1]; + + /** + * Constructs a Dasher. + * @param rdrCtx per-thread renderer context + */ + Dasher(final RendererContext rdrCtx) { + this.rdrCtx = rdrCtx; + + firstSegmentsBuffer = firstSegmentsBuffer_initial; + + // we need curCurvepts to be able to contain 2 curves because when + // dashing curves, we need to subdivide it + curCurvepts = new float[8 * 2]; + } + + /** + * Initialize the Dasher. + * + * @param out an output PathConsumer2D. + * @param dash an array of floats containing the dash pattern + * @param dashLen length of the given dash array + * @param phase a float containing the dash phase + * @param recycleDashes true to indicate to recycle the given dash array + * @return this instance + */ + Dasher init(final PathConsumer2D out, float[] dash, int dashLen, + float phase, boolean recycleDashes) + { + if (phase < 0f) { + throw new IllegalArgumentException("phase < 0 !"); + } + this.out = out; + + // Normalize so 0 <= phase < dash[0] + int idx = 0; + dashOn = true; + float d; + while (phase >= (d = dash[idx])) { + phase -= d; + idx = (idx + 1) % dashLen; + dashOn = !dashOn; + } + + this.dash = dash; + this.dashLen = dashLen; + this.startPhase = this.phase = phase; + this.startDashOn = dashOn; + this.startIdx = idx; + this.starting = true; + needsMoveTo = false; + firstSegidx = 0; + + this.recycleDashes = recycleDashes; + + return this; // fluent API + } + + /** + * Disposes this dasher: + * clean up before reusing this instance + */ + void dispose() { + if (doCleanDirty) { + // Force zero-fill dirty arrays: + Arrays.fill(curCurvepts, 0f); + Arrays.fill(firstSegmentsBuffer, 0f); + } + // Return arrays: + if (recycleDashes && dash != dashes_initial) { + rdrCtx.putDirtyFloatArray(dash); + dash = null; + } + + if (firstSegmentsBuffer != firstSegmentsBuffer_initial) { + rdrCtx.putDirtyFloatArray(firstSegmentsBuffer); + firstSegmentsBuffer = firstSegmentsBuffer_initial; + } + } + + @Override + public void moveTo(float x0, float y0) { + if (firstSegidx > 0) { + out.moveTo(sx, sy); + emitFirstSegments(); + } + needsMoveTo = true; + this.idx = startIdx; + this.dashOn = this.startDashOn; + this.phase = this.startPhase; + this.sx = this.x0 = x0; + this.sy = this.y0 = y0; + this.starting = true; + } + + private void emitSeg(float[] buf, int off, int type) { + switch (type) { + case 8: + out.curveTo(buf[off+0], buf[off+1], + buf[off+2], buf[off+3], + buf[off+4], buf[off+5]); + return; + case 6: + out.quadTo(buf[off+0], buf[off+1], + buf[off+2], buf[off+3]); + return; + case 4: + out.lineTo(buf[off], buf[off+1]); + return; + default: + } + } + + private void emitFirstSegments() { + final float[] fSegBuf = firstSegmentsBuffer; + + for (int i = 0; i < firstSegidx; ) { + int type = (int)fSegBuf[i]; + emitSeg(fSegBuf, i + 1, type); + i += (type - 1); + } + firstSegidx = 0; + } + // We don't emit the first dash right away. If we did, caps would be + // drawn on it, but we need joins to be drawn if there's a closePath() + // So, we store the path elements that make up the first dash in the + // buffer below. + private float[] firstSegmentsBuffer; // dynamic array + private int firstSegidx; + + // precondition: pts must be in relative coordinates (relative to x0,y0) + // fullCurve is true iff the curve in pts has not been split. + private void goTo(float[] pts, int off, final int type) { + float x = pts[off + type - 4]; + float y = pts[off + type - 3]; + if (dashOn) { + if (starting) { + int len = type - 2 + 1; + int segIdx = firstSegidx; + float[] buf = firstSegmentsBuffer; + if (segIdx + len > buf.length) { + if (doStats) { + RendererContext.stats.stat_array_dasher_firstSegmentsBuffer + .add(segIdx + len); + } + firstSegmentsBuffer = buf + = rdrCtx.widenDirtyFloatArray(buf, segIdx, segIdx + len); + } + buf[segIdx++] = type; + len--; + // small arraycopy (2, 4 or 6) but with offset: + System.arraycopy(pts, off, buf, segIdx, len); + segIdx += len; + firstSegidx = segIdx; + } else { + if (needsMoveTo) { + out.moveTo(x0, y0); + needsMoveTo = false; + } + emitSeg(pts, off, type); + } + } else { + starting = false; + needsMoveTo = true; + } + this.x0 = x; + this.y0 = y; + } + + @Override + public void lineTo(float x1, float y1) { + float dx = x1 - x0; + float dy = y1 - y0; + + float len = dx*dx + dy*dy; + if (len == 0f) { + return; + } + len = (float) Math.sqrt(len); + + // The scaling factors needed to get the dx and dy of the + // transformed dash segments. + final float cx = dx / len; + final float cy = dy / len; + + final float[] _curCurvepts = curCurvepts; + final float[] _dash = dash; + + float leftInThisDashSegment; + float dashdx, dashdy, p; + + while (true) { + leftInThisDashSegment = _dash[idx] - phase; + + if (len <= leftInThisDashSegment) { + _curCurvepts[0] = x1; + _curCurvepts[1] = y1; + goTo(_curCurvepts, 0, 4); + + // Advance phase within current dash segment + phase += len; + // TODO: compare float values using epsilon: + if (len == leftInThisDashSegment) { + phase = 0f; + idx = (idx + 1) % dashLen; + dashOn = !dashOn; + } + return; + } + + dashdx = _dash[idx] * cx; + dashdy = _dash[idx] * cy; + + if (phase == 0f) { + _curCurvepts[0] = x0 + dashdx; + _curCurvepts[1] = y0 + dashdy; + } else { + p = leftInThisDashSegment / _dash[idx]; + _curCurvepts[0] = x0 + p * dashdx; + _curCurvepts[1] = y0 + p * dashdy; + } + + goTo(_curCurvepts, 0, 4); + + len -= leftInThisDashSegment; + // Advance to next dash segment + idx = (idx + 1) % dashLen; + dashOn = !dashOn; + phase = 0f; + } + } + + // shared instance in Dasher + private final LengthIterator li = new LengthIterator(); + + // preconditions: curCurvepts must be an array of length at least 2 * type, + // that contains the curve we want to dash in the first type elements + private void somethingTo(int type) { + if (pointCurve(curCurvepts, type)) { + return; + } + li.initializeIterationOnCurve(curCurvepts, type); + + // initially the current curve is at curCurvepts[0...type] + int curCurveoff = 0; + float lastSplitT = 0f; + float t; + float leftInThisDashSegment = dash[idx] - phase; + + while ((t = li.next(leftInThisDashSegment)) < 1f) { + if (t != 0f) { + Helpers.subdivideAt((t - lastSplitT) / (1f - lastSplitT), + curCurvepts, curCurveoff, + curCurvepts, 0, + curCurvepts, type, type); + lastSplitT = t; + goTo(curCurvepts, 2, type); + curCurveoff = type; + } + // Advance to next dash segment + idx = (idx + 1) % dashLen; + dashOn = !dashOn; + phase = 0f; + leftInThisDashSegment = dash[idx]; + } + goTo(curCurvepts, curCurveoff+2, type); + phase += li.lastSegLen(); + if (phase >= dash[idx]) { + phase = 0f; + idx = (idx + 1) % dashLen; + dashOn = !dashOn; + } + // reset LengthIterator: + li.reset(); + } + + private static boolean pointCurve(float[] curve, int type) { + for (int i = 2; i < type; i++) { + if (curve[i] != curve[i-2]) { + return false; + } + } + return true; + } + + // Objects of this class are used to iterate through curves. They return + // t values where the left side of the curve has a specified length. + // It does this by subdividing the input curve until a certain error + // condition has been met. A recursive subdivision procedure would + // return as many as 1<= 0; i--) { + Arrays.fill(recCurveStack[i], 0f); + } + Arrays.fill(sides, Side.LEFT); + Arrays.fill(curLeafCtrlPolyLengths, 0f); + Arrays.fill(nextRoots, 0f); + Arrays.fill(flatLeafCoefCache, 0f); + flatLeafCoefCache[2] = -1f; + } + } + + void initializeIterationOnCurve(float[] pts, int type) { + // optimize arraycopy (8 values faster than 6 = type): + System.arraycopy(pts, 0, recCurveStack[0], 0, 8); + this.curveType = type; + this.recLevel = 0; + this.lastT = 0f; + this.lenAtLastT = 0f; + this.nextT = 0f; + this.lenAtNextT = 0f; + goLeft(); // initializes nextT and lenAtNextT properly + this.lenAtLastSplit = 0f; + if (recLevel > 0) { + this.sides[0] = Side.LEFT; + this.done = false; + } else { + // the root of the tree is a leaf so we're done. + this.sides[0] = Side.RIGHT; + this.done = true; + } + this.lastSegLen = 0f; + } + + // 0 == false, 1 == true, -1 == invalid cached value. + private int cachedHaveLowAcceleration = -1; + + private boolean haveLowAcceleration(float err) { + if (cachedHaveLowAcceleration == -1) { + final float len1 = curLeafCtrlPolyLengths[0]; + final float len2 = curLeafCtrlPolyLengths[1]; + // the test below is equivalent to !within(len1/len2, 1, err). + // It is using a multiplication instead of a division, so it + // should be a bit faster. + if (!Helpers.within(len1, len2, err*len2)) { + cachedHaveLowAcceleration = 0; + return false; + } + if (curveType == 8) { + final float len3 = curLeafCtrlPolyLengths[2]; + // if len1 is close to 2 and 2 is close to 3, that probably + // means 1 is close to 3 so the second part of this test might + // not be needed, but it doesn't hurt to include it. + final float errLen3 = err * len3; + if (!(Helpers.within(len2, len3, errLen3) && + Helpers.within(len1, len3, errLen3))) { + cachedHaveLowAcceleration = 0; + return false; + } + } + cachedHaveLowAcceleration = 1; + return true; + } + + return (cachedHaveLowAcceleration == 1); + } + + // we want to avoid allocations/gc so we keep this array so we + // can put roots in it, + private final float[] nextRoots = new float[4]; + + // caches the coefficients of the current leaf in its flattened + // form (see inside next() for what that means). The cache is + // invalid when it's third element is negative, since in any + // valid flattened curve, this would be >= 0. + private final float[] flatLeafCoefCache = new float[]{0f, 0f, -1f, 0f}; + + // returns the t value where the remaining curve should be split in + // order for the left subdivided curve to have length len. If len + // is >= than the length of the uniterated curve, it returns 1. + float next(final float len) { + final float targetLength = lenAtLastSplit + len; + while (lenAtNextT < targetLength) { + if (done) { + lastSegLen = lenAtNextT - lenAtLastSplit; + return 1f; + } + goToNextLeaf(); + } + lenAtLastSplit = targetLength; + final float leaflen = lenAtNextT - lenAtLastT; + float t = (targetLength - lenAtLastT) / leaflen; + + // cubicRootsInAB is a fairly expensive call, so we just don't do it + // if the acceleration in this section of the curve is small enough. + if (!haveLowAcceleration(0.05f)) { + // We flatten the current leaf along the x axis, so that we're + // left with a, b, c which define a 1D Bezier curve. We then + // solve this to get the parameter of the original leaf that + // gives us the desired length. + final float[] _flatLeafCoefCache = flatLeafCoefCache; + + if (_flatLeafCoefCache[2] < 0) { + float x = 0f + curLeafCtrlPolyLengths[0], + y = x + curLeafCtrlPolyLengths[1]; + if (curveType == 8) { + float z = y + curLeafCtrlPolyLengths[2]; + _flatLeafCoefCache[0] = 3f * (x - y) + z; + _flatLeafCoefCache[1] = 3f * (y - 2f * x); + _flatLeafCoefCache[2] = 3f * x; + _flatLeafCoefCache[3] = -z; + } else if (curveType == 6) { + _flatLeafCoefCache[0] = 0f; + _flatLeafCoefCache[1] = y - 2f * x; + _flatLeafCoefCache[2] = 2f * x; + _flatLeafCoefCache[3] = -y; + } + } + float a = _flatLeafCoefCache[0]; + float b = _flatLeafCoefCache[1]; + float c = _flatLeafCoefCache[2]; + float d = t * _flatLeafCoefCache[3]; + + // we use cubicRootsInAB here, because we want only roots in 0, 1, + // and our quadratic root finder doesn't filter, so it's just a + // matter of convenience. + int n = Helpers.cubicRootsInAB(a, b, c, d, nextRoots, 0, 0, 1); + if (n == 1 && !Float.isNaN(nextRoots[0])) { + t = nextRoots[0]; + } + } + // t is relative to the current leaf, so we must make it a valid parameter + // of the original curve. + t = t * (nextT - lastT) + lastT; + if (t >= 1f) { + t = 1f; + done = true; + } + // even if done = true, if we're here, that means targetLength + // is equal to, or very, very close to the total length of the + // curve, so lastSegLen won't be too high. In cases where len + // overshoots the curve, this method will exit in the while + // loop, and lastSegLen will still be set to the right value. + lastSegLen = len; + return t; + } + + float lastSegLen() { + return lastSegLen; + } + + // go to the next leaf (in an inorder traversal) in the recursion tree + // preconditions: must be on a leaf, and that leaf must not be the root. + private void goToNextLeaf() { + // We must go to the first ancestor node that has an unvisited + // right child. + int _recLevel = recLevel; + final Side[] _sides = sides; + + _recLevel--; + while(_sides[_recLevel] == Side.RIGHT) { + if (_recLevel == 0) { + recLevel = 0; + done = true; + return; + } + _recLevel--; + } + + _sides[_recLevel] = Side.RIGHT; + // optimize arraycopy (8 values faster than 6 = type): + System.arraycopy(recCurveStack[_recLevel], 0, + recCurveStack[_recLevel+1], 0, 8); + _recLevel++; + + recLevel = _recLevel; + goLeft(); + } + + // go to the leftmost node from the current node. Return its length. + private void goLeft() { + float len = onLeaf(); + if (len >= 0f) { + lastT = nextT; + lenAtLastT = lenAtNextT; + nextT += (1 << (recLimit - recLevel)) * minTincrement; + lenAtNextT += len; + // invalidate caches + flatLeafCoefCache[2] = -1f; + cachedHaveLowAcceleration = -1; + } else { + Helpers.subdivide(recCurveStack[recLevel], 0, + recCurveStack[recLevel+1], 0, + recCurveStack[recLevel], 0, curveType); + sides[recLevel] = Side.LEFT; + recLevel++; + goLeft(); + } + } + + // this is a bit of a hack. It returns -1 if we're not on a leaf, and + // the length of the leaf if we are on a leaf. + private float onLeaf() { + float[] curve = recCurveStack[recLevel]; + float polyLen = 0f; + + float x0 = curve[0], y0 = curve[1]; + for (int i = 2; i < curveType; i += 2) { + final float x1 = curve[i], y1 = curve[i+1]; + final float len = Helpers.linelen(x0, y0, x1, y1); + polyLen += len; + curLeafCtrlPolyLengths[i/2 - 1] = len; + x0 = x1; + y0 = y1; + } + + final float lineLen = Helpers.linelen(curve[0], curve[1], + curve[curveType-2], + curve[curveType-1]); + if ((polyLen - lineLen) < ERR || recLevel == recLimit) { + return (polyLen + lineLen) / 2f; + } + return -1f; + } + } + + @Override + public void curveTo(float x1, float y1, + float x2, float y2, + float x3, float y3) + { + final float[] _curCurvepts = curCurvepts; + _curCurvepts[0] = x0; _curCurvepts[1] = y0; + _curCurvepts[2] = x1; _curCurvepts[3] = y1; + _curCurvepts[4] = x2; _curCurvepts[5] = y2; + _curCurvepts[6] = x3; _curCurvepts[7] = y3; + somethingTo(8); + } + + @Override + public void quadTo(float x1, float y1, float x2, float y2) { + final float[] _curCurvepts = curCurvepts; + _curCurvepts[0] = x0; _curCurvepts[1] = y0; + _curCurvepts[2] = x1; _curCurvepts[3] = y1; + _curCurvepts[4] = x2; _curCurvepts[5] = y2; + somethingTo(6); + } + + @Override + public void closePath() { + lineTo(sx, sy); + if (firstSegidx > 0) { + if (!dashOn || needsMoveTo) { + out.moveTo(sx, sy); + } + emitFirstSegments(); + } + moveTo(sx, sy); + } + + @Override + public void pathDone() { + if (firstSegidx > 0) { + out.moveTo(sx, sy); + emitFirstSegments(); + } + out.pathDone(); + + // Dispose this instance: + dispose(); + } + + @Override + public long getNativeConsumer() { + throw new InternalError("Dasher does not use a native consumer"); + } +} + diff --git a/src/share/classes/sun/java2d/marlin/FloatArrayCache.java b/src/share/classes/sun/java2d/marlin/FloatArrayCache.java new file mode 100644 index 0000000000000000000000000000000000000000..681c75d4ceb0e9530c277bf5b0b8ee22eea9eb23 --- /dev/null +++ b/src/share/classes/sun/java2d/marlin/FloatArrayCache.java @@ -0,0 +1,153 @@ +/* + * 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. 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.java2d.marlin; + +import java.util.ArrayDeque; +import java.util.Arrays; +import static sun.java2d.marlin.MarlinUtils.logException; +import static sun.java2d.marlin.MarlinUtils.logInfo; + +final class FloatArrayCache implements MarlinConst { + + private final int arraySize; + private final ArrayDeque floatArrays; + // stats + private int getOp = 0; + private int createOp = 0; + private int returnOp = 0; + + void dumpStats() { + if (getOp > 0) { + logInfo("FloatArrayCache[" + arraySize + "]: get: " + getOp + + " created: " + createOp + " - returned: " + returnOp + + " :: cache size: " + floatArrays.size()); + } + } + + FloatArrayCache(final int arraySize) { + this.arraySize = arraySize; + // small but enough: almost 1 cache line + this.floatArrays = new ArrayDeque(6); + } + + float[] getArray() { + if (doStats) { + getOp++; + } + + // use cache + final float[] array = floatArrays.pollLast(); + + if (array != null) { + return array; + } + + if (doStats) { + createOp++; + } + + return new float[arraySize]; + } + + void putDirtyArray(final float[] array, final int length) { + if (length != arraySize) { + if (doChecks) { + MarlinUtils.logInfo("ArrayCache: bad length = " + length); + } + return; + } + if (doStats) { + returnOp++; + } + + // NO clean-up of array data = DIRTY ARRAY + + if (doCleanDirty) { + // Force zero-fill dirty arrays: + Arrays.fill(array, 0, array.length, 0f); + } + + // fill cache: + floatArrays.addLast(array); + } + + void putArray(final float[] array, final int length, + final int fromIndex, final int toIndex) + { + if (length != arraySize) { + if (doChecks) { + MarlinUtils.logInfo("ArrayCache: bad length = " + length); + } + return; + } + if (doStats) { + returnOp++; + } + + // clean-up array of dirty part[fromIndex; toIndex[ + fill(array, fromIndex, toIndex, 0f); + + // fill cache: + floatArrays.addLast(array); + } + + static void fill(final float[] array, final int fromIndex, + final int toIndex, final float value) + { + // clear array data: + /* + * Arrays.fill is faster than System.arraycopy(empty array) + * or Unsafe.setMemory(byte 0) + */ + if (toIndex != 0) { + Arrays.fill(array, fromIndex, toIndex, value); + } + + if (doChecks) { + check(array, fromIndex, toIndex, value); + } + } + + static void check(final float[] array, final int fromIndex, + final int toIndex, final float value) + { + if (doChecks) { + // check zero on full array: + for (int i = 0; i < array.length; i++) { + if (array[i] != value) { + logException("Invalid value at: " + i + " = " + array[i] + + " from: " + fromIndex + " to: " + toIndex + "\n" + + Arrays.toString(array), new Throwable()); + + // ensure array is correctly filled: + Arrays.fill(array, value); + + return; + } + } + } + } +} diff --git a/src/share/classes/sun/java2d/marlin/FloatMath.java b/src/share/classes/sun/java2d/marlin/FloatMath.java new file mode 100644 index 0000000000000000000000000000000000000000..922796e75cc205d07fe8a025bbd0f450473706f4 --- /dev/null +++ b/src/share/classes/sun/java2d/marlin/FloatMath.java @@ -0,0 +1,213 @@ +/* + * 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. 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.java2d.marlin; + +import sun.misc.DoubleConsts; +import sun.misc.FloatConsts; + +/** + * Faster Math ceil / floor routines derived from StrictMath + */ +public final class FloatMath implements MarlinConst { + + // overflow / NaN handling enabled: + static final boolean CHECK_OVERFLOW = true; + static final boolean CHECK_NAN = true; + + private FloatMath() { + // utility class + } + + // faster inlined min/max functions in the branch prediction is high + static float max(final float a, final float b) { + // no NaN handling + return (a >= b) ? a : b; + } + + static int max(final int a, final int b) { + return (a >= b) ? a : b; + } + + static int min(final int a, final int b) { + return (a <= b) ? a : b; + } + + /** + * Returns the smallest (closest to negative infinity) {@code float} value + * that is greater than or equal to the argument and is equal to a + * mathematical integer. Special cases: + *

    • If the argument value is already equal to a mathematical integer, + * then the result is the same as the argument.
    • If the argument is NaN + * or an infinity or positive zero or negative zero, then the result is the + * same as the argument.
    • If the argument value is less than zero but + * greater than -1.0, then the result is negative zero.
    Note that the + * value of {@code StrictMath.ceil(x)} is exactly the value of + * {@code -StrictMath.floor(-x)}. + * + * @param a a value. + * @return the smallest (closest to negative infinity) floating-point value + * that is greater than or equal to the argument and is equal to a + * mathematical integer. + */ + public static float ceil_f(final float a) { + // Derived from StrictMath.ceil(double): + + // Inline call to Math.getExponent(a) to + // compute only once Float.floatToRawIntBits(a) + final int doppel = Float.floatToRawIntBits(a); + + final int exponent = ((doppel & FloatConsts.EXP_BIT_MASK) + >> (FloatConsts.SIGNIFICAND_WIDTH - 1)) + - FloatConsts.EXP_BIAS; + + if (exponent < 0) { + /* + * Absolute value of argument is less than 1. + * floorOrceil(-0.0) => -0.0 + * floorOrceil(+0.0) => +0.0 + */ + return ((a == 0) ? a : + ( (a < 0f) ? -0f : 1f) ); + } + if (CHECK_OVERFLOW && (exponent >= 23)) { // 52 for double + /* + * Infinity, NaN, or a value so large it must be integral. + */ + return a; + } + // Else the argument is either an integral value already XOR it + // has to be rounded to one. + assert exponent >= 0 && exponent <= 22; // 51 for double + + final int intpart = doppel + & (~(FloatConsts.SIGNIF_BIT_MASK >> exponent)); + + if (intpart == doppel) { + return a; // integral value (including 0) + } + + // 0 handled above as an integer + // sign: 1 for negative, 0 for positive numbers + // add : 0 for negative and 1 for positive numbers + return Float.intBitsToFloat(intpart) + ((~intpart) >>> 31); + } + + /** + * Returns the largest (closest to positive infinity) {@code float} value + * that is less than or equal to the argument and is equal to a mathematical + * integer. Special cases: + *
    • If the argument value is already equal to a mathematical integer, + * then the result is the same as the argument.
    • If the argument is NaN + * or an infinity or positive zero or negative zero, then the result is the + * same as the argument.
    + * + * @param a a value. + * @return the largest (closest to positive infinity) floating-point value + * that less than or equal to the argument and is equal to a mathematical + * integer. + */ + public static float floor_f(final float a) { + // Derived from StrictMath.floor(double): + + // Inline call to Math.getExponent(a) to + // compute only once Float.floatToRawIntBits(a) + final int doppel = Float.floatToRawIntBits(a); + + final int exponent = ((doppel & FloatConsts.EXP_BIT_MASK) + >> (FloatConsts.SIGNIFICAND_WIDTH - 1)) + - FloatConsts.EXP_BIAS; + + if (exponent < 0) { + /* + * Absolute value of argument is less than 1. + * floorOrceil(-0.0) => -0.0 + * floorOrceil(+0.0) => +0.0 + */ + return ((a == 0) ? a : + ( (a < 0f) ? -1f : 0f) ); + } + if (CHECK_OVERFLOW && (exponent >= 23)) { // 52 for double + /* + * Infinity, NaN, or a value so large it must be integral. + */ + return a; + } + // Else the argument is either an integral value already XOR it + // has to be rounded to one. + assert exponent >= 0 && exponent <= 22; // 51 for double + + final int intpart = doppel + & (~(FloatConsts.SIGNIF_BIT_MASK >> exponent)); + + if (intpart == doppel) { + return a; // integral value (including 0) + } + + // 0 handled above as an integer + // sign: 1 for negative, 0 for positive numbers + // add : -1 for negative and 0 for positive numbers + return Float.intBitsToFloat(intpart) + (intpart >> 31); + } + + /** + * Faster alternative to ceil(float) optimized for the integer domain + * and supporting NaN and +/-Infinity. + * + * @param a a value. + * @return the largest (closest to positive infinity) integer value + * that less than or equal to the argument and is equal to a mathematical + * integer. + */ + public static int ceil_int(final float a) { + final int intpart = (int) a; + + if (a <= intpart + || (CHECK_OVERFLOW && intpart == Integer.MAX_VALUE) + || CHECK_NAN && Float.isNaN(a)) { + return intpart; + } + return intpart + 1; + } + + /** + * Faster alternative to floor(float) optimized for the integer domain + * and supporting NaN and +/-Infinity. + * + * @param a a value. + * @return the largest (closest to positive infinity) floating-point value + * that less than or equal to the argument and is equal to a mathematical + * integer. + */ + public static int floor_int(final float a) { + final int intpart = (int) a; + + if (a >= intpart + || (CHECK_OVERFLOW && intpart == Integer.MIN_VALUE) + || CHECK_NAN && Float.isNaN(a)) { + return intpart; + } + return intpart - 1; + } +} diff --git a/src/share/classes/sun/java2d/marlin/Helpers.java b/src/share/classes/sun/java2d/marlin/Helpers.java new file mode 100644 index 0000000000000000000000000000000000000000..40599f1142a8c1769b5a4c145650b41eb530f932 --- /dev/null +++ b/src/share/classes/sun/java2d/marlin/Helpers.java @@ -0,0 +1,441 @@ +/* + * Copyright (c) 2007, 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. 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.java2d.marlin; + +import static java.lang.Math.PI; +import static java.lang.Math.cos; +import static java.lang.Math.sqrt; +import static java.lang.Math.cbrt; +import static java.lang.Math.acos; + +final class Helpers implements MarlinConst { + + private Helpers() { + throw new Error("This is a non instantiable class"); + } + + static boolean within(final float x, final float y, final float err) { + final float d = y - x; + return (d <= err && d >= -err); + } + + static boolean within(final double x, final double y, final double err) { + final double d = y - x; + return (d <= err && d >= -err); + } + + static int quadraticRoots(final float a, final float b, + final float c, float[] zeroes, final int off) + { + int ret = off; + float t; + if (a != 0f) { + final float dis = b*b - 4*a*c; + if (dis > 0f) { + final float sqrtDis = (float)Math.sqrt(dis); + // depending on the sign of b we use a slightly different + // algorithm than the traditional one to find one of the roots + // so we can avoid adding numbers of different signs (which + // might result in loss of precision). + if (b >= 0f) { + zeroes[ret++] = (2f * c) / (-b - sqrtDis); + zeroes[ret++] = (-b - sqrtDis) / (2f * a); + } else { + zeroes[ret++] = (-b + sqrtDis) / (2f * a); + zeroes[ret++] = (2f * c) / (-b + sqrtDis); + } + } else if (dis == 0f) { + t = (-b) / (2f * a); + zeroes[ret++] = t; + } + } else { + if (b != 0f) { + t = (-c) / b; + zeroes[ret++] = t; + } + } + return ret - off; + } + + // find the roots of g(t) = d*t^3 + a*t^2 + b*t + c in [A,B) + static int cubicRootsInAB(float d, float a, float b, float c, + float[] pts, final int off, + final float A, final float B) + { + if (d == 0f) { + int num = quadraticRoots(a, b, c, pts, off); + return filterOutNotInAB(pts, off, num, A, B) - off; + } + // From Graphics Gems: + // http://tog.acm.org/resources/GraphicsGems/gems/Roots3And4.c + // (also from awt.geom.CubicCurve2D. But here we don't need as + // much accuracy and we don't want to create arrays so we use + // our own customized version). + + // normal form: x^3 + ax^2 + bx + c = 0 + a /= d; + b /= d; + c /= d; + + // substitute x = y - A/3 to eliminate quadratic term: + // x^3 +Px + Q = 0 + // + // Since we actually need P/3 and Q/2 for all of the + // calculations that follow, we will calculate + // p = P/3 + // q = Q/2 + // instead and use those values for simplicity of the code. + double sq_A = a * a; + double p = (1.0/3.0) * ((-1.0/3.0) * sq_A + b); + double q = (1.0/2.0) * ((2.0/27.0) * a * sq_A - (1.0/3.0) * a * b + c); + + // use Cardano's formula + + double cb_p = p * p * p; + double D = q * q + cb_p; + + int num; + if (D < 0.0) { + // see: http://en.wikipedia.org/wiki/Cubic_function#Trigonometric_.28and_hyperbolic.29_method + final double phi = (1.0/3.0) * acos(-q / sqrt(-cb_p)); + final double t = 2.0 * sqrt(-p); + + pts[ off+0 ] = (float)( t * cos(phi)); + pts[ off+1 ] = (float)(-t * cos(phi + (PI / 3.0))); + pts[ off+2 ] = (float)(-t * cos(phi - (PI / 3.0))); + num = 3; + } else { + final double sqrt_D = sqrt(D); + final double u = cbrt(sqrt_D - q); + final double v = - cbrt(sqrt_D + q); + + pts[ off ] = (float)(u + v); + num = 1; + + if (within(D, 0.0, 1e-8)) { + pts[off+1] = -(pts[off] / 2f); + num = 2; + } + } + + final float sub = (1f/3f) * a; + + for (int i = 0; i < num; ++i) { + pts[ off+i ] -= sub; + } + + return filterOutNotInAB(pts, off, num, A, B) - off; + } + + static float evalCubic(final float a, final float b, + final float c, final float d, + final float t) + { + return t * (t * (t * a + b) + c) + d; + } + + static float evalQuad(final float a, final float b, + final float c, final float t) + { + return t * (t * a + b) + c; + } + + // returns the index 1 past the last valid element remaining after filtering + static int filterOutNotInAB(float[] nums, final int off, final int len, + final float a, final float b) + { + int ret = off; + for (int i = off, end = off + len; i < end; i++) { + if (nums[i] >= a && nums[i] < b) { + nums[ret++] = nums[i]; + } + } + return ret; + } + + static float polyLineLength(float[] poly, final int off, final int nCoords) { + assert nCoords % 2 == 0 && poly.length >= off + nCoords : ""; + float acc = 0; + for (int i = off + 2; i < off + nCoords; i += 2) { + acc += linelen(poly[i], poly[i+1], poly[i-2], poly[i-1]); + } + return acc; + } + + static float linelen(float x1, float y1, float x2, float y2) { + final float dx = x2 - x1; + final float dy = y2 - y1; + return (float)Math.sqrt(dx*dx + dy*dy); + } + + static void subdivide(float[] src, int srcoff, float[] left, int leftoff, + float[] right, int rightoff, int type) + { + switch(type) { + case 6: + Helpers.subdivideQuad(src, srcoff, left, leftoff, right, rightoff); + return; + case 8: + Helpers.subdivideCubic(src, srcoff, left, leftoff, right, rightoff); + return; + default: + throw new InternalError("Unsupported curve type"); + } + } + + static void isort(float[] a, int off, int len) { + for (int i = off + 1, end = off + len; i < end; i++) { + float ai = a[i]; + int j = i - 1; + for (; j >= off && a[j] > ai; j--) { + a[j+1] = a[j]; + } + a[j+1] = ai; + } + } + + // Most of these are copied from classes in java.awt.geom because we need + // float versions of these functions, and Line2D, CubicCurve2D, + // QuadCurve2D don't provide them. + /** + * Subdivides the cubic curve specified by the coordinates + * stored in the src array at indices srcoff + * through (srcoff + 7) and stores the + * resulting two subdivided curves into the two result arrays at the + * corresponding indices. + * Either or both of the left and right + * arrays may be null or a reference to the same array + * as the src array. + * Note that the last point in the first subdivided curve is the + * same as the first point in the second subdivided curve. Thus, + * it is possible to pass the same array for left + * and right and to use offsets, such as rightoff + * equals (leftoff + 6), in order + * to avoid allocating extra storage for this common point. + * @param src the array holding the coordinates for the source curve + * @param srcoff the offset into the array of the beginning of the + * the 6 source coordinates + * @param left the array for storing the coordinates for the first + * half of the subdivided curve + * @param leftoff the offset into the array of the beginning of the + * the 6 left coordinates + * @param right the array for storing the coordinates for the second + * half of the subdivided curve + * @param rightoff the offset into the array of the beginning of the + * the 6 right coordinates + * @since 1.7 + */ + static void subdivideCubic(float src[], int srcoff, + float left[], int leftoff, + float right[], int rightoff) + { + float x1 = src[srcoff + 0]; + float y1 = src[srcoff + 1]; + float ctrlx1 = src[srcoff + 2]; + float ctrly1 = src[srcoff + 3]; + float ctrlx2 = src[srcoff + 4]; + float ctrly2 = src[srcoff + 5]; + float x2 = src[srcoff + 6]; + float y2 = src[srcoff + 7]; + if (left != null) { + left[leftoff + 0] = x1; + left[leftoff + 1] = y1; + } + if (right != null) { + right[rightoff + 6] = x2; + right[rightoff + 7] = y2; + } + x1 = (x1 + ctrlx1) / 2f; + y1 = (y1 + ctrly1) / 2f; + x2 = (x2 + ctrlx2) / 2f; + y2 = (y2 + ctrly2) / 2f; + float centerx = (ctrlx1 + ctrlx2) / 2f; + float centery = (ctrly1 + ctrly2) / 2f; + ctrlx1 = (x1 + centerx) / 2f; + ctrly1 = (y1 + centery) / 2f; + ctrlx2 = (x2 + centerx) / 2f; + ctrly2 = (y2 + centery) / 2f; + centerx = (ctrlx1 + ctrlx2) / 2f; + centery = (ctrly1 + ctrly2) / 2f; + if (left != null) { + left[leftoff + 2] = x1; + left[leftoff + 3] = y1; + left[leftoff + 4] = ctrlx1; + left[leftoff + 5] = ctrly1; + left[leftoff + 6] = centerx; + left[leftoff + 7] = centery; + } + if (right != null) { + right[rightoff + 0] = centerx; + right[rightoff + 1] = centery; + right[rightoff + 2] = ctrlx2; + right[rightoff + 3] = ctrly2; + right[rightoff + 4] = x2; + right[rightoff + 5] = y2; + } + } + + + static void subdivideCubicAt(float t, float src[], int srcoff, + float left[], int leftoff, + float right[], int rightoff) + { + float x1 = src[srcoff + 0]; + float y1 = src[srcoff + 1]; + float ctrlx1 = src[srcoff + 2]; + float ctrly1 = src[srcoff + 3]; + float ctrlx2 = src[srcoff + 4]; + float ctrly2 = src[srcoff + 5]; + float x2 = src[srcoff + 6]; + float y2 = src[srcoff + 7]; + if (left != null) { + left[leftoff + 0] = x1; + left[leftoff + 1] = y1; + } + if (right != null) { + right[rightoff + 6] = x2; + right[rightoff + 7] = y2; + } + x1 = x1 + t * (ctrlx1 - x1); + y1 = y1 + t * (ctrly1 - y1); + x2 = ctrlx2 + t * (x2 - ctrlx2); + y2 = ctrly2 + t * (y2 - ctrly2); + float centerx = ctrlx1 + t * (ctrlx2 - ctrlx1); + float centery = ctrly1 + t * (ctrly2 - ctrly1); + ctrlx1 = x1 + t * (centerx - x1); + ctrly1 = y1 + t * (centery - y1); + ctrlx2 = centerx + t * (x2 - centerx); + ctrly2 = centery + t * (y2 - centery); + centerx = ctrlx1 + t * (ctrlx2 - ctrlx1); + centery = ctrly1 + t * (ctrly2 - ctrly1); + if (left != null) { + left[leftoff + 2] = x1; + left[leftoff + 3] = y1; + left[leftoff + 4] = ctrlx1; + left[leftoff + 5] = ctrly1; + left[leftoff + 6] = centerx; + left[leftoff + 7] = centery; + } + if (right != null) { + right[rightoff + 0] = centerx; + right[rightoff + 1] = centery; + right[rightoff + 2] = ctrlx2; + right[rightoff + 3] = ctrly2; + right[rightoff + 4] = x2; + right[rightoff + 5] = y2; + } + } + + static void subdivideQuad(float src[], int srcoff, + float left[], int leftoff, + float right[], int rightoff) + { + float x1 = src[srcoff + 0]; + float y1 = src[srcoff + 1]; + float ctrlx = src[srcoff + 2]; + float ctrly = src[srcoff + 3]; + float x2 = src[srcoff + 4]; + float y2 = src[srcoff + 5]; + if (left != null) { + left[leftoff + 0] = x1; + left[leftoff + 1] = y1; + } + if (right != null) { + right[rightoff + 4] = x2; + right[rightoff + 5] = y2; + } + x1 = (x1 + ctrlx) / 2f; + y1 = (y1 + ctrly) / 2f; + x2 = (x2 + ctrlx) / 2f; + y2 = (y2 + ctrly) / 2f; + ctrlx = (x1 + x2) / 2f; + ctrly = (y1 + y2) / 2f; + if (left != null) { + left[leftoff + 2] = x1; + left[leftoff + 3] = y1; + left[leftoff + 4] = ctrlx; + left[leftoff + 5] = ctrly; + } + if (right != null) { + right[rightoff + 0] = ctrlx; + right[rightoff + 1] = ctrly; + right[rightoff + 2] = x2; + right[rightoff + 3] = y2; + } + } + + static void subdivideQuadAt(float t, float src[], int srcoff, + float left[], int leftoff, + float right[], int rightoff) + { + float x1 = src[srcoff + 0]; + float y1 = src[srcoff + 1]; + float ctrlx = src[srcoff + 2]; + float ctrly = src[srcoff + 3]; + float x2 = src[srcoff + 4]; + float y2 = src[srcoff + 5]; + if (left != null) { + left[leftoff + 0] = x1; + left[leftoff + 1] = y1; + } + if (right != null) { + right[rightoff + 4] = x2; + right[rightoff + 5] = y2; + } + x1 = x1 + t * (ctrlx - x1); + y1 = y1 + t * (ctrly - y1); + x2 = ctrlx + t * (x2 - ctrlx); + y2 = ctrly + t * (y2 - ctrly); + ctrlx = x1 + t * (x2 - x1); + ctrly = y1 + t * (y2 - y1); + if (left != null) { + left[leftoff + 2] = x1; + left[leftoff + 3] = y1; + left[leftoff + 4] = ctrlx; + left[leftoff + 5] = ctrly; + } + if (right != null) { + right[rightoff + 0] = ctrlx; + right[rightoff + 1] = ctrly; + right[rightoff + 2] = x2; + right[rightoff + 3] = y2; + } + } + + static void subdivideAt(float t, float src[], int srcoff, + float left[], int leftoff, + float right[], int rightoff, int size) + { + switch(size) { + case 8: + subdivideCubicAt(t, src, srcoff, left, leftoff, right, rightoff); + return; + case 6: + subdivideQuadAt(t, src, srcoff, left, leftoff, right, rightoff); + return; + } + } +} diff --git a/src/share/classes/sun/java2d/marlin/IntArrayCache.java b/src/share/classes/sun/java2d/marlin/IntArrayCache.java new file mode 100644 index 0000000000000000000000000000000000000000..af4d0b69529e605bdb21dffc021f986ce461d7ee --- /dev/null +++ b/src/share/classes/sun/java2d/marlin/IntArrayCache.java @@ -0,0 +1,152 @@ +/* + * 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. 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.java2d.marlin; + +import java.util.ArrayDeque; +import java.util.Arrays; +import static sun.java2d.marlin.MarlinUtils.logException; +import static sun.java2d.marlin.MarlinUtils.logInfo; + +final class IntArrayCache implements MarlinConst { + + private final int arraySize; + private final ArrayDeque intArrays; + // stats + private int getOp = 0; + private int createOp = 0; + private int returnOp = 0; + + void dumpStats() { + if (getOp > 0) { + logInfo("IntArrayCache[" + arraySize + "]: get: " + getOp + + " created: " + createOp + " - returned: " + returnOp + + " :: cache size: " + intArrays.size()); + } + } + + IntArrayCache(final int arraySize) { + this.arraySize = arraySize; + // small but enough: almost 1 cache line + this.intArrays = new ArrayDeque(6); + } + + int[] getArray() { + if (doStats) { + getOp++; + } + + // use cache: + final int[] array = intArrays.pollLast(); + if (array != null) { + return array; + } + + if (doStats) { + createOp++; + } + + return new int[arraySize]; + } + + void putDirtyArray(final int[] array, final int length) { + if (length != arraySize) { + if (doChecks) { + MarlinUtils.logInfo("ArrayCache: bad length = " + length); + } + return; + } + if (doStats) { + returnOp++; + } + + // NO clean-up of array data = DIRTY ARRAY + + if (doCleanDirty) { + // Force zero-fill dirty arrays: + Arrays.fill(array, 0, array.length, 0); + } + + // fill cache: + intArrays.addLast(array); + } + + void putArray(final int[] array, final int length, + final int fromIndex, final int toIndex) + { + if (length != arraySize) { + if (doChecks) { + MarlinUtils.logInfo("ArrayCache: bad length = " + length); + } + return; + } + if (doStats) { + returnOp++; + } + + // clean-up array of dirty part[fromIndex; toIndex[ + fill(array, fromIndex, toIndex, 0); + + // fill cache: + intArrays.addLast(array); + } + + static void fill(final int[] array, final int fromIndex, + final int toIndex, final int value) + { + // clear array data: + /* + * Arrays.fill is faster than System.arraycopy(empty array) + * or Unsafe.setMemory(byte 0) + */ + if (toIndex != 0) { + Arrays.fill(array, fromIndex, toIndex, value); + } + + if (doChecks) { + check(array, fromIndex, toIndex, value); + } + } + + static void check(final int[] array, final int fromIndex, + final int toIndex, final int value) + { + if (doChecks) { + // check zero on full array: + for (int i = 0; i < array.length; i++) { + if (array[i] != value) { + logException("Invalid value at: " + i + " = " + array[i] + + " from: " + fromIndex + " to: " + toIndex + "\n" + + Arrays.toString(array), new Throwable()); + + // ensure array is correctly filled: + Arrays.fill(array, value); + + return; + } + } + } + } +} diff --git a/src/share/classes/sun/java2d/marlin/MarlinCache.java b/src/share/classes/sun/java2d/marlin/MarlinCache.java new file mode 100644 index 0000000000000000000000000000000000000000..c85f96b0e011fb9a0a40cb2329f29235eb28c99a --- /dev/null +++ b/src/share/classes/sun/java2d/marlin/MarlinCache.java @@ -0,0 +1,689 @@ +/* + * Copyright (c) 2007, 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. + */ + +package sun.java2d.marlin; + +import sun.misc.Unsafe; + +/** + * An object used to cache pre-rendered complex paths. + * + * @see Renderer + */ +public final class MarlinCache implements MarlinConst { + + static final boolean FORCE_RLE = MarlinProperties.isForceRLE(); + static final boolean FORCE_NO_RLE = MarlinProperties.isForceNoRLE(); + // minimum width to try using RLE encoding: + static final int RLE_MIN_WIDTH + = Math.max(BLOCK_SIZE, MarlinProperties.getRLEMinWidth()); + // maximum width for RLE encoding: + // values are stored as int [x|alpha] where alpha is 8 bits + static final int RLE_MAX_WIDTH = 1 << (24 - 1); + + // 2048 (pixelSize) alpha values (width) x 32 rows (tile) = 64K bytes + // x1 instead of 4 bytes (RLE) ie 1/4 capacity or average good RLE compression + static final long INITIAL_CHUNK_ARRAY = TILE_SIZE * INITIAL_PIXEL_DIM; // 64K + + // The alpha map used by this object (taken out of our map cache) to convert + // pixel coverage counts gotten from MarlinCache (which are in the range + // [0, maxalpha]) into alpha values, which are in [0,256). + static final byte[] ALPHA_MAP; + + static final OffHeapArray ALPHA_MAP_UNSAFE; + + static { + final byte[] _ALPHA_MAP = buildAlphaMap(MAX_AA_ALPHA); + + ALPHA_MAP_UNSAFE = new OffHeapArray(_ALPHA_MAP, _ALPHA_MAP.length); // 1K + ALPHA_MAP =_ALPHA_MAP; + + final Unsafe _unsafe = OffHeapArray.unsafe; + final long addr = ALPHA_MAP_UNSAFE.address; + + for (int i = 0; i < _ALPHA_MAP.length; i++) { + _unsafe.putByte(addr + i, _ALPHA_MAP[i]); + } + } + + int bboxX0, bboxY0, bboxX1, bboxY1; + + // 1D dirty arrays + // row index in rowAAChunk[] + final long[] rowAAChunkIndex = new long[TILE_SIZE]; + // first pixel (inclusive) for each row + final int[] rowAAx0 = new int[TILE_SIZE]; + // last pixel (exclusive) for each row + final int[] rowAAx1 = new int[TILE_SIZE]; + // encoding mode (0=raw, 1=RLE encoding) for each row + final int[] rowAAEnc = new int[TILE_SIZE]; + // coded length (RLE encoding) for each row + final long[] rowAALen = new long[TILE_SIZE]; + // last position in RLE decoding for each row (getAlpha): + final long[] rowAAPos = new long[TILE_SIZE]; + + // dirty off-heap array containing pixel coverages for (32) rows (packed) + // if encoding=raw, it contains alpha coverage values (val) as integer + // if encoding=RLE, it contains tuples (val, last x-coordinate exclusive) + // use rowAAx0/rowAAx1 to get row indices within this chunk + final OffHeapArray rowAAChunk; + + // current position in rowAAChunk array + long rowAAChunkPos; + + // touchedTile[i] is the sum of all the alphas in the tile with + // x=j*TILE_SIZE+bboxX0. + int[] touchedTile; + + // per-thread renderer context + final RendererContext rdrCtx; + + // large cached touchedTile (dirty) + final int[] touchedTile_initial = new int[INITIAL_ARRAY]; // 1 tile line + + int tileMin, tileMax; + + boolean useRLE = false; + + MarlinCache(final RendererContext rdrCtx) { + this.rdrCtx = rdrCtx; + + rowAAChunk = new OffHeapArray(rdrCtx, INITIAL_CHUNK_ARRAY); + + touchedTile = touchedTile_initial; + + // tile used marks: + tileMin = Integer.MAX_VALUE; + tileMax = Integer.MIN_VALUE; + } + + void init(int minx, int miny, int maxx, int maxy, int edgeSumDeltaY) + { + // assert maxy >= miny && maxx >= minx; + bboxX0 = minx; + bboxY0 = miny; + bboxX1 = maxx; + bboxY1 = maxy; + + final int width = (maxx - minx); + + if (FORCE_NO_RLE) { + useRLE = false; + } else if (FORCE_RLE) { + useRLE = true; + } else { + // heuristics: use both bbox area and complexity + // ie number of primitives: + + // fast check min and max width (maxx < 23bits): + if (width <= RLE_MIN_WIDTH || width >= RLE_MAX_WIDTH) { + useRLE = false; + } else { + // perimeter approach: how fit the total length into given height: + + // if stroking: meanCrossings /= 2 => divide edgeSumDeltaY by 2 + final int heightSubPixel + = (((maxy - miny) << SUBPIXEL_LG_POSITIONS_Y) << rdrCtx.stroking); + + // check meanDist > block size: + // check width / (meanCrossings - 1) >= RLE_THRESHOLD + + // fast case: (meanCrossingPerPixel <= 2) means 1 span only + useRLE = (edgeSumDeltaY <= (heightSubPixel << 1)) + // note: already checked (meanCrossingPerPixel <= 2) + // rewritten to avoid division: + || (width * heightSubPixel) > + ((edgeSumDeltaY - heightSubPixel) << BLOCK_SIZE_LG); + + if (doTrace && !useRLE) { + final float meanCrossings + = ((float) edgeSumDeltaY) / heightSubPixel; + final float meanDist = width / (meanCrossings - 1); + + System.out.println("High complexity: " + + " for bbox[width = " + width + + " height = " + (maxy - miny) + + "] edgeSumDeltaY = " + edgeSumDeltaY + + " heightSubPixel = " + heightSubPixel + + " meanCrossings = "+ meanCrossings + + " meanDist = " + meanDist + + " width = " + (width * heightSubPixel) + + " <= criteria: " + ((edgeSumDeltaY - heightSubPixel) << BLOCK_SIZE_LG) + ); + } + } + } + + // the ceiling of (maxy - miny + 1) / TILE_SIZE; + final int nxTiles = (width + TILE_SIZE) >> TILE_SIZE_LG; + + if (nxTiles > INITIAL_ARRAY) { + if (doStats) { + RendererContext.stats.stat_array_marlincache_touchedTile + .add(nxTiles); + } + touchedTile = rdrCtx.getIntArray(nxTiles); + } + } + + /** + * Disposes this cache: + * clean up before reusing this instance + */ + void dispose() { + // Reset touchedTile if needed: + resetTileLine(0); + + // Return arrays: + if (touchedTile != touchedTile_initial) { + rdrCtx.putIntArray(touchedTile, 0, 0); // already zero filled + touchedTile = touchedTile_initial; + } + // At last: resize back off-heap rowAA to initial size + if (rowAAChunk.length != INITIAL_CHUNK_ARRAY) { + // note: may throw OOME: + rowAAChunk.resize(INITIAL_CHUNK_ARRAY); + } + if (doCleanDirty) { + // Force zero-fill dirty arrays: + rowAAChunk.fill(BYTE_0); + } + } + + void resetTileLine(final int pminY) { + // update bboxY0 to process a complete tile line [0 - 32] + bboxY0 = pminY; + + // reset current pos + if (doStats) { + RendererContext.stats.stat_cache_rowAAChunk.add(rowAAChunkPos); + } + rowAAChunkPos = 0L; + + // Reset touchedTile: + if (tileMin != Integer.MAX_VALUE) { + if (doStats) { + RendererContext.stats.stat_cache_tiles.add(tileMax - tileMin); + } + // clean only dirty touchedTile: + if (tileMax == 1) { + touchedTile[0] = 0; + } else { + IntArrayCache.fill(touchedTile, tileMin, tileMax, 0); + } + // reset tile used marks: + tileMin = Integer.MAX_VALUE; + tileMax = Integer.MIN_VALUE; + } + + if (doCleanDirty) { + // Force zero-fill dirty arrays: + rowAAChunk.fill(BYTE_0); + } + } + + void clearAARow(final int y) { + // process tile line [0 - 32] + final int row = y - bboxY0; + + // update pixel range: + rowAAx0[row] = 0; // first pixel inclusive + rowAAx1[row] = 0; // last pixel exclusive + rowAAEnc[row] = 0; // raw encoding + + // note: leave rowAAChunkIndex[row] undefined + // and rowAALen[row] & rowAAPos[row] (RLE) + } + + /** + * Copy the given alpha data into the rowAA cache + * @param alphaRow alpha data to copy from + * @param y y pixel coordinate + * @param px0 first pixel inclusive x0 + * @param px1 last pixel exclusive x1 + */ + void copyAARowNoRLE(final int[] alphaRow, final int y, + final int px0, final int px1) + { + if (doMonitors) { + RendererContext.stats.mon_rdr_copyAARow.start(); + } + + // skip useless pixels above boundary + final int px_bbox1 = FloatMath.min(px1, bboxX1); + + if (doLogBounds) { + MarlinUtils.logInfo("row = [" + px0 + " ... " + px_bbox1 + + " (" + px1 + ") [ for y=" + y); + } + + final int row = y - bboxY0; + + // update pixel range: + rowAAx0[row] = px0; // first pixel inclusive + rowAAx1[row] = px_bbox1; // last pixel exclusive + rowAAEnc[row] = 0; // raw encoding + + // get current position (bytes): + final long pos = rowAAChunkPos; + // update row index to current position: + rowAAChunkIndex[row] = pos; + + // determine need array size: + // for RLE encoding, position must be aligned to 4 bytes (int): + // align - 1 = 3 so add +3 and round-off by mask ~3 = -4 + final long needSize = pos + ((px_bbox1 - px0 + 3) & -4); + + // update next position (bytes): + rowAAChunkPos = needSize; + + // update row data: + final OffHeapArray _rowAAChunk = rowAAChunk; + // ensure rowAAChunk capacity: + if (_rowAAChunk.length < needSize) { + expandRowAAChunk(needSize); + } + if (doStats) { + RendererContext.stats.stat_cache_rowAA.add(px_bbox1 - px0); + } + + // rowAA contains only alpha values for range[x0; x1[ + final int[] _touchedTile = touchedTile; + final int _TILE_SIZE_LG = TILE_SIZE_LG; + + final int from = px0 - bboxX0; // first pixel inclusive + final int to = px_bbox1 - bboxX0; // last pixel exclusive + + final Unsafe _unsafe = OffHeapArray.unsafe; + final long SIZE_BYTE = 1L; + final long addr_alpha = ALPHA_MAP_UNSAFE.address; + long addr_off = _rowAAChunk.address + pos; + + // compute alpha sum into rowAA: + for (int x = from, val = 0; x < to; x++) { + // alphaRow is in [0; MAX_COVERAGE] + val += alphaRow[x]; // [from; to[ + + // ensure values are in [0; MAX_AA_ALPHA] range + if (DO_AA_RANGE_CHECK) { + if (val < 0) { + System.out.println("Invalid coverage = " + val); + val = 0; + } + if (val > MAX_AA_ALPHA) { + System.out.println("Invalid coverage = " + val); + val = MAX_AA_ALPHA; + } + } + + // store alpha sum (as byte): + if (val == 0) { + _unsafe.putByte(addr_off, (byte)0); // [0..255] + } else { + _unsafe.putByte(addr_off, _unsafe.getByte(addr_alpha + val)); // [0..255] + + // update touchedTile + _touchedTile[x >> _TILE_SIZE_LG] += val; + } + addr_off += SIZE_BYTE; + } + + // update tile used marks: + int tx = from >> _TILE_SIZE_LG; // inclusive + if (tx < tileMin) { + tileMin = tx; + } + + tx = ((to - 1) >> _TILE_SIZE_LG) + 1; // exclusive (+1 to be sure) + if (tx > tileMax) { + tileMax = tx; + } + + if (doLogBounds) { + MarlinUtils.logInfo("clear = [" + from + " ... " + to + "["); + } + + // Clear alpha row for reuse: + IntArrayCache.fill(alphaRow, from, px1 - bboxX0, 0); + + if (doMonitors) { + RendererContext.stats.mon_rdr_copyAARow.stop(); + } + } + + void copyAARowRLE_WithBlockFlags(final int[] blkFlags, final int[] alphaRow, + final int y, final int px0, final int px1) + { + if (doMonitors) { + RendererContext.stats.mon_rdr_copyAARow.start(); + } + + // Copy rowAA data into the piscesCache if one is present + final int _bboxX0 = bboxX0; + + // process tile line [0 - 32] + final int row = y - bboxY0; + final int from = px0 - _bboxX0; // first pixel inclusive + + // skip useless pixels above boundary + final int px_bbox1 = FloatMath.min(px1, bboxX1); + final int to = px_bbox1 - _bboxX0; // last pixel exclusive + + if (doLogBounds) { + MarlinUtils.logInfo("row = [" + px0 + " ... " + px_bbox1 + + " (" + px1 + ") [ for y=" + y); + } + + // get current position: + final long initialPos = startRLERow(row, px0, px_bbox1); + + // determine need array size: + // pessimistic: max needed size = deltaX x 4 (1 int) + final long needSize = initialPos + ((to - from) << 2); + + // update row data: + OffHeapArray _rowAAChunk = rowAAChunk; + // ensure rowAAChunk capacity: + if (_rowAAChunk.length < needSize) { + expandRowAAChunk(needSize); + } + + final Unsafe _unsafe = OffHeapArray.unsafe; + final long SIZE_INT = 4L; + final long addr_alpha = ALPHA_MAP_UNSAFE.address; + long addr_off = _rowAAChunk.address + initialPos; + + final int[] _touchedTile = touchedTile; + final int _TILE_SIZE_LG = TILE_SIZE_LG; + final int _BLK_SIZE_LG = BLOCK_SIZE_LG; + + // traverse flagged blocks: + final int blkW = (from >> _BLK_SIZE_LG); + final int blkE = (to >> _BLK_SIZE_LG) + 1; + + // Perform run-length encoding and store results in the piscesCache + int val = 0; + int cx0 = from; + int runLen; + + final int _MAX_VALUE = Integer.MAX_VALUE; + int last_t0 = _MAX_VALUE; + + int skip = 0; + + for (int t = blkW, blk_x0, blk_x1, cx, delta; t <= blkE; t++) { + if (blkFlags[t] != 0) { + blkFlags[t] = 0; + + if (last_t0 == _MAX_VALUE) { + last_t0 = t; + } + continue; + } + if (last_t0 != _MAX_VALUE) { + // emit blocks: + blk_x0 = FloatMath.max(last_t0 << _BLK_SIZE_LG, from); + last_t0 = _MAX_VALUE; + + // (last block pixel+1) inclusive => +1 + blk_x1 = FloatMath.min((t << _BLK_SIZE_LG) + 1, to); + + for (cx = blk_x0; cx < blk_x1; cx++) { + if ((delta = alphaRow[cx]) != 0) { + alphaRow[cx] = 0; + + // not first rle entry: + if (cx != cx0) { + runLen = cx - cx0; + + // store alpha coverage (ensure within bounds): + // as [absX|val] where: + // absX is the absolute x-coordinate: + // note: last pixel exclusive (>= 0) + // note: it should check X is smaller than 23bits (overflow)! + + // check address alignment to 4 bytes: + if (doCheckUnsafe) { + if ((addr_off & 3) != 0) { + MarlinUtils.logInfo("Misaligned Unsafe address: " + addr_off); + } + } + + // special case to encode entries into a single int: + if (val == 0) { + _unsafe.putInt(addr_off, + ((_bboxX0 + cx) << 8) + ); + } else { + _unsafe.putInt(addr_off, + ((_bboxX0 + cx) << 8) + | (((int) _unsafe.getByte(addr_alpha + val)) & 0xFF) // [0..255] + ); + + if (runLen == 1) { + _touchedTile[cx0 >> _TILE_SIZE_LG] += val; + } else { + touchTile(cx0, val, cx, runLen, _touchedTile); + } + } + addr_off += SIZE_INT; + + if (doStats) { + RendererContext.stats.hist_tile_generator_encoding_runLen + .add(runLen); + } + cx0 = cx; + } + + // alpha value = running sum of coverage delta: + val += delta; + + // ensure values are in [0; MAX_AA_ALPHA] range + if (DO_AA_RANGE_CHECK) { + if (val < 0) { + System.out.println("Invalid coverage = " + val); + val = 0; + } + if (val > MAX_AA_ALPHA) { + System.out.println("Invalid coverage = " + val); + val = MAX_AA_ALPHA; + } + } + } + } + } else if (doStats) { + skip++; + } + } + + // Process remaining RLE run: + runLen = to - cx0; + + // store alpha coverage (ensure within bounds): + // as (int)[absX|val] where: + // absX is the absolute x-coordinate in bits 31 to 8 and val in bits 0..7 + // note: last pixel exclusive (>= 0) + // note: it should check X is smaller than 23bits (overflow)! + + // check address alignment to 4 bytes: + if (doCheckUnsafe) { + if ((addr_off & 3) != 0) { + MarlinUtils.logInfo("Misaligned Unsafe address: " + addr_off); + } + } + + // special case to encode entries into a single int: + if (val == 0) { + _unsafe.putInt(addr_off, + ((_bboxX0 + to) << 8) + ); + } else { + _unsafe.putInt(addr_off, + ((_bboxX0 + to) << 8) + | (((int) _unsafe.getByte(addr_alpha + val)) & 0xFF) // [0..255] + ); + + if (runLen == 1) { + _touchedTile[cx0 >> _TILE_SIZE_LG] += val; + } else { + touchTile(cx0, val, to, runLen, _touchedTile); + } + } + addr_off += SIZE_INT; + + if (doStats) { + RendererContext.stats.hist_tile_generator_encoding_runLen + .add(runLen); + } + + long len = (addr_off - _rowAAChunk.address); + + // update coded length as bytes: + rowAALen[row] = (len - initialPos); + + // update current position: + rowAAChunkPos = len; + + if (doStats) { + RendererContext.stats.stat_cache_rowAA.add(rowAALen[row]); + RendererContext.stats.hist_tile_generator_encoding_ratio.add( + (100 * skip) / (blkE - blkW) + ); + } + + // update tile used marks: + int tx = from >> _TILE_SIZE_LG; // inclusive + if (tx < tileMin) { + tileMin = tx; + } + + tx = ((to - 1) >> _TILE_SIZE_LG) + 1; // exclusive (+1 to be sure) + if (tx > tileMax) { + tileMax = tx; + } + + // Clear alpha row for reuse: + if (px1 > bboxX1) { + alphaRow[to ] = 0; + alphaRow[to + 1] = 0; + } + if (doChecks) { + IntArrayCache.check(blkFlags, blkW, blkE, 0); + IntArrayCache.check(alphaRow, from, px1 - bboxX0, 0); + } + + if (doMonitors) { + RendererContext.stats.mon_rdr_copyAARow.stop(); + } + } + + long startRLERow(final int row, final int x0, final int x1) { + // rows are supposed to be added by increasing y. + rowAAx0[row] = x0; // first pixel inclusive + rowAAx1[row] = x1; // last pixel exclusive + rowAAEnc[row] = 1; // RLE encoding + rowAAPos[row] = 0L; // position = 0 + + // update row index to current position: + return (rowAAChunkIndex[row] = rowAAChunkPos); + } + + private void expandRowAAChunk(final long needSize) { + if (doStats) { + RendererContext.stats.stat_array_marlincache_rowAAChunk + .add(needSize); + } + + // note: throw IOOB if neededSize > 2Gb: + final long newSize = ArrayCache.getNewLargeSize(rowAAChunk.length, needSize); + + rowAAChunk.resize(newSize); + } + + private void touchTile(final int x0, final int val, final int x1, + final int runLen, + final int[] _touchedTile) + { + // the x and y of the current row, minus bboxX0, bboxY0 + // process tile line [0 - 32] + final int _TILE_SIZE_LG = TILE_SIZE_LG; + + // update touchedTile + int tx = (x0 >> _TILE_SIZE_LG); + + // handle trivial case: same tile (x0, x0+runLen) + if (tx == (x1 >> _TILE_SIZE_LG)) { + // same tile: + _touchedTile[tx] += val * runLen; + return; + } + + final int tx1 = (x1 - 1) >> _TILE_SIZE_LG; + + if (tx <= tx1) { + final int nextTileXCoord = (tx + 1) << _TILE_SIZE_LG; + _touchedTile[tx++] += val * (nextTileXCoord - x0); + } + if (tx < tx1) { + // don't go all the way to tx1 - we need to handle the last + // tile as a special case (just like we did with the first + final int tileVal = (val << _TILE_SIZE_LG); + for (; tx < tx1; tx++) { + _touchedTile[tx] += tileVal; + } + } + // they will be equal unless x0 >> TILE_SIZE_LG == tx1 + if (tx == tx1) { + final int txXCoord = tx << _TILE_SIZE_LG; + final int nextTileXCoord = (tx + 1) << _TILE_SIZE_LG; + + final int lastXCoord = (nextTileXCoord <= x1) ? nextTileXCoord : x1; + _touchedTile[tx] += val * (lastXCoord - txXCoord); + } + } + + int alphaSumInTile(final int x) { + return touchedTile[(x - bboxX0) >> TILE_SIZE_LG]; + } + + @Override + public String toString() { + return "bbox = [" + + bboxX0 + ", " + bboxY0 + " => " + + bboxX1 + ", " + bboxY1 + "]\n"; + } + + private static byte[] buildAlphaMap(final int maxalpha) { + // double size ! + final byte[] alMap = new byte[maxalpha << 1]; + final int halfmaxalpha = maxalpha >> 2; + for (int i = 0; i <= maxalpha; i++) { + alMap[i] = (byte) ((i * 255 + halfmaxalpha) / maxalpha); +// System.out.println("alphaMap[" + i + "] = " +// + Byte.toUnsignedInt(alMap[i])); + } + return alMap; + } +} diff --git a/src/share/classes/sun/java2d/marlin/MarlinConst.java b/src/share/classes/sun/java2d/marlin/MarlinConst.java new file mode 100644 index 0000000000000000000000000000000000000000..72993ebfd7c070cb7a46adbae299209f0078e489 --- /dev/null +++ b/src/share/classes/sun/java2d/marlin/MarlinConst.java @@ -0,0 +1,124 @@ +/* + * 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. 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.java2d.marlin; + +/** + * Marlin constant holder using System properties + */ +interface MarlinConst { + // enable Logs (logger or stdout) + static final boolean enableLogs = MarlinProperties.isLoggingEnabled(); + // use Logger instead of stdout + static final boolean useLogger = enableLogs && MarlinProperties.isUseLogger(); + + // log new RendererContext + static final boolean logCreateContext = enableLogs + && MarlinProperties.isLogCreateContext(); + // log misc.Unsafe alloc/realloc/free + static final boolean logUnsafeMalloc = enableLogs + && MarlinProperties.isLogUnsafeMalloc(); + // do check unsafe alignment: + static final boolean doCheckUnsafe = false; + + // do statistics + static final boolean doStats = enableLogs && MarlinProperties.isDoStats(); + // do monitors + // disabled to reduce byte-code size a bit... + static final boolean doMonitors = false; +// static final boolean doMonitors = enableLogs && MarlinProperties.isDoMonitors(); + // do checks + static final boolean doChecks = enableLogs && MarlinProperties.isDoChecks(); + + // do AA range checks: disable when algorithm / code is stable + static final boolean DO_AA_RANGE_CHECK = false; + + // enable logs + static final boolean doLogWidenArray = enableLogs && false; + // enable oversize logs + static final boolean doLogOverSize = enableLogs && false; + // enable traces + static final boolean doTrace = enableLogs && false; + // do flush monitors + static final boolean doFlushMonitors = true; + // use one polling thread to dump statistics/monitors + static final boolean useDumpThread = false; + // thread dump interval (ms) + static final long statDump = 5000L; + + // do clean dirty array + static final boolean doCleanDirty = false; + + // flag to use line simplifier + static final boolean useSimplifier = MarlinProperties.isUseSimplifier(); + + // flag to enable logs related bounds checks + static final boolean doLogBounds = enableLogs && false; + + // Initial Array sizing (initial context capacity) ~ 512K + + // 2048 pixel (width x height) for initial capacity + static final int INITIAL_PIXEL_DIM + = MarlinProperties.getInitialImageSize(); + + // typical array sizes: only odd numbers allowed below + static final int INITIAL_ARRAY = 256; + static final int INITIAL_SMALL_ARRAY = 1024; + static final int INITIAL_MEDIUM_ARRAY = 4096; + static final int INITIAL_LARGE_ARRAY = 8192; + static final int INITIAL_ARRAY_16K = 16384; + static final int INITIAL_ARRAY_32K = 32768; + // alpha row dimension + static final int INITIAL_AA_ARRAY = INITIAL_PIXEL_DIM; + + // initial edges (24 bytes) = 24K [ints] = 96K + static final int INITIAL_EDGES_CAPACITY = 4096 * 24; // 6 ints per edges + + // zero value as byte + static final byte BYTE_0 = (byte) 0; + + // subpixels expressed as log2 + public static final int SUBPIXEL_LG_POSITIONS_X + = MarlinProperties.getSubPixel_Log2_X(); + public static final int SUBPIXEL_LG_POSITIONS_Y + = MarlinProperties.getSubPixel_Log2_Y(); + + // number of subpixels + public static final int SUBPIXEL_POSITIONS_X = 1 << (SUBPIXEL_LG_POSITIONS_X); + public static final int SUBPIXEL_POSITIONS_Y = 1 << (SUBPIXEL_LG_POSITIONS_Y); + + public static final float NORM_SUBPIXELS + = (float)Math.sqrt(( SUBPIXEL_POSITIONS_X * SUBPIXEL_POSITIONS_X + + SUBPIXEL_POSITIONS_Y * SUBPIXEL_POSITIONS_Y)/2.0); + + public static final int MAX_AA_ALPHA + = SUBPIXEL_POSITIONS_X * SUBPIXEL_POSITIONS_Y; + + public static final int TILE_SIZE_LG = MarlinProperties.getTileSize_Log2(); + public static final int TILE_SIZE = 1 << TILE_SIZE_LG; // 32 by default + + public static final int BLOCK_SIZE_LG = MarlinProperties.getBlockSize_Log2(); + public static final int BLOCK_SIZE = 1 << BLOCK_SIZE_LG; +} diff --git a/src/share/classes/sun/java2d/marlin/MarlinProperties.java b/src/share/classes/sun/java2d/marlin/MarlinProperties.java new file mode 100644 index 0000000000000000000000000000000000000000..bbee15a13fb455282e72f2e17f31fb92863f64a1 --- /dev/null +++ b/src/share/classes/sun/java2d/marlin/MarlinProperties.java @@ -0,0 +1,185 @@ +/* + * Copyright (c) 2007, 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. 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.java2d.marlin; + +import java.security.AccessController; +import static sun.java2d.marlin.MarlinUtils.logInfo; +import sun.security.action.GetPropertyAction; + +public final class MarlinProperties { + + private MarlinProperties() { + // no-op + } + + // marlin system properties + + public static boolean isUseThreadLocal() { + return getBoolean("sun.java2d.renderer.useThreadLocal", "true"); + } + + /** + * Return the initial pixel size used to define initial arrays + * (tile AA chunk, alpha line, buckets) + * + * @return 64 < initial pixel size < 32768 (2048 by default) + */ + public static int getInitialImageSize() { + return getInteger("sun.java2d.renderer.pixelsize", 2048, 64, 32 * 1024); + } + + /** + * Return the log(2) corresponding to subpixel on x-axis ( + * + * @return 1 (2 subpixels) < initial pixel size < 4 (256 subpixels) + * (3 by default ie 8 subpixels) + */ + public static int getSubPixel_Log2_X() { + return getInteger("sun.java2d.renderer.subPixel_log2_X", 3, 1, 8); + } + + /** + * Return the log(2) corresponding to subpixel on y-axis ( + * + * @return 1 (2 subpixels) < initial pixel size < 8 (256 subpixels) + * (3 by default ie 8 subpixels) + */ + public static int getSubPixel_Log2_Y() { + return getInteger("sun.java2d.renderer.subPixel_log2_Y", 3, 1, 8); + } + + /** + * Return the log(2) corresponding to the square tile size in pixels + * + * @return 3 (8x8 pixels) < tile size < 8 (256x256 pixels) + * (5 by default ie 32x32 pixels) + */ + public static int getTileSize_Log2() { + return getInteger("sun.java2d.renderer.tileSize_log2", 5, 3, 8); + } + + /** + * Return the log(2) corresponding to the block size in pixels + * + * @return 3 (8 pixels) < block size < 8 (256 pixels) + * (5 by default ie 32 pixels) + */ + public static int getBlockSize_Log2() { + return getInteger("sun.java2d.renderer.blockSize_log2", 5, 3, 8); + } + + // RLE / blockFlags settings + + public static boolean isForceRLE() { + return getBoolean("sun.java2d.renderer.forceRLE", "false"); + } + + public static boolean isForceNoRLE() { + return getBoolean("sun.java2d.renderer.forceNoRLE", "false"); + } + + public static boolean isUseTileFlags() { + return getBoolean("sun.java2d.renderer.useTileFlags", "true"); + } + + public static boolean isUseTileFlagsWithHeuristics() { + return isUseTileFlags() + && getBoolean("sun.java2d.renderer.useTileFlags.useHeuristics", "true"); + } + + public static int getRLEMinWidth() { + return getInteger("sun.java2d.renderer.rleMinWidth", 64, 0, Integer.MAX_VALUE); + } + + // optimisation parameters + + public static boolean isUseSimplifier() { + return getBoolean("sun.java2d.renderer.useSimplifier", "false"); + } + + // debugging parameters + + public static boolean isDoStats() { + return getBoolean("sun.java2d.renderer.doStats", "false"); + } + + public static boolean isDoMonitors() { + return getBoolean("sun.java2d.renderer.doMonitors", "false"); + } + + public static boolean isDoChecks() { + return getBoolean("sun.java2d.renderer.doChecks", "false"); + } + + // logging parameters + + public static boolean isLoggingEnabled() { + return getBoolean("sun.java2d.renderer.log", "false"); + } + + public static boolean isUseLogger() { + return getBoolean("sun.java2d.renderer.useLogger", "false"); + } + + public static boolean isLogCreateContext() { + return getBoolean("sun.java2d.renderer.logCreateContext", "false"); + } + + public static boolean isLogUnsafeMalloc() { + return getBoolean("sun.java2d.renderer.logUnsafeMalloc", "false"); + } + + // system property utilities + static boolean getBoolean(final String key, final String def) { + return Boolean.valueOf(AccessController.doPrivileged( + new GetPropertyAction(key, def))); + } + + static int getInteger(final String key, final int def, + final int min, final int max) + { + final String property = AccessController.doPrivileged( + new GetPropertyAction(key)); + + int value = def; + if (property != null) { + try { + value = Integer.decode(property); + } catch (NumberFormatException e) { + logInfo("Invalid integer value for " + key + " = " + property); + } + } + + // check for invalid values + if ((value < min) || (value > max)) { + logInfo("Invalid value for " + key + " = " + value + + "; expected value in range[" + min + ", " + max + "] !"); + value = def; + } + return value; + } + +} diff --git a/src/share/classes/sun/java2d/marlin/MarlinRenderingEngine.java b/src/share/classes/sun/java2d/marlin/MarlinRenderingEngine.java new file mode 100644 index 0000000000000000000000000000000000000000..e01a5e77f9cf252758d66c4678131f240294cba1 --- /dev/null +++ b/src/share/classes/sun/java2d/marlin/MarlinRenderingEngine.java @@ -0,0 +1,1052 @@ +/* + * Copyright (c) 2007, 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. + */ + +package sun.java2d.marlin; + +import java.awt.BasicStroke; +import java.awt.Shape; +import java.awt.geom.AffineTransform; +import java.awt.geom.Path2D; +import java.awt.geom.PathIterator; +import java.security.AccessController; +import static sun.java2d.marlin.MarlinUtils.logInfo; +import sun.awt.geom.PathConsumer2D; +import sun.java2d.ReentrantContextProvider; +import sun.java2d.ReentrantContextProviderCLQ; +import sun.java2d.ReentrantContextProviderTL; +import sun.java2d.pipe.AATileGenerator; +import sun.java2d.pipe.Region; +import sun.java2d.pipe.RenderingEngine; +import sun.security.action.GetPropertyAction; + +/** + * Marlin RendererEngine implementation (derived from Pisces) + */ +public class MarlinRenderingEngine extends RenderingEngine + implements MarlinConst +{ + private static enum NormMode {ON_WITH_AA, ON_NO_AA, OFF} + + private static final float MIN_PEN_SIZE = 1f / NORM_SUBPIXELS; + + /** + * Public constructor + */ + public MarlinRenderingEngine() { + super(); + logSettings(MarlinRenderingEngine.class.getName()); + } + + /** + * Create a widened path as specified by the parameters. + *

    + * The specified {@code src} {@link Shape} is widened according + * to the specified attribute parameters as per the + * {@link BasicStroke} specification. + * + * @param src the source path to be widened + * @param width the width of the widened path as per {@code BasicStroke} + * @param caps the end cap decorations as per {@code BasicStroke} + * @param join the segment join decorations as per {@code BasicStroke} + * @param miterlimit the miter limit as per {@code BasicStroke} + * @param dashes the dash length array as per {@code BasicStroke} + * @param dashphase the initial dash phase as per {@code BasicStroke} + * @return the widened path stored in a new {@code Shape} object + * @since 1.7 + */ + @Override + public Shape createStrokedShape(Shape src, + float width, + int caps, + int join, + float miterlimit, + float dashes[], + float dashphase) + { + final RendererContext rdrCtx = getRendererContext(); + try { + // initialize a large copyable Path2D to avoid a lot of array growing: + final Path2D.Float p2d = + (rdrCtx.p2d == null) ? + (rdrCtx.p2d = new Path2D.Float(Path2D.WIND_NON_ZERO, + INITIAL_MEDIUM_ARRAY)) + : rdrCtx.p2d; + // reset + p2d.reset(); + + strokeTo(rdrCtx, + src, + null, + width, + NormMode.OFF, + caps, + join, + miterlimit, + dashes, + dashphase, + rdrCtx.transformerPC2D.wrapPath2d(p2d) + ); + + // Use Path2D copy constructor (trim) + return new Path2D.Float(p2d); + + } finally { + // recycle the RendererContext instance + returnRendererContext(rdrCtx); + } + } + + /** + * Sends the geometry for a widened path as specified by the parameters + * to the specified consumer. + *

    + * The specified {@code src} {@link Shape} is widened according + * to the parameters specified by the {@link BasicStroke} object. + * Adjustments are made to the path as appropriate for the + * {@link VALUE_STROKE_NORMALIZE} hint if the {@code normalize} + * boolean parameter is true. + * Adjustments are made to the path as appropriate for the + * {@link VALUE_ANTIALIAS_ON} hint if the {@code antialias} + * boolean parameter is true. + *

    + * The geometry of the widened path is forwarded to the indicated + * {@link PathConsumer2D} object as it is calculated. + * + * @param src the source path to be widened + * @param bs the {@code BasicSroke} object specifying the + * decorations to be applied to the widened path + * @param normalize indicates whether stroke normalization should + * be applied + * @param antialias indicates whether or not adjustments appropriate + * to antialiased rendering should be applied + * @param consumer the {@code PathConsumer2D} instance to forward + * the widened geometry to + * @since 1.7 + */ + @Override + public void strokeTo(Shape src, + AffineTransform at, + BasicStroke bs, + boolean thin, + boolean normalize, + boolean antialias, + final PathConsumer2D consumer) + { + final NormMode norm = (normalize) ? + ((antialias) ? NormMode.ON_WITH_AA : NormMode.ON_NO_AA) + : NormMode.OFF; + + final RendererContext rdrCtx = getRendererContext(); + try { + strokeTo(rdrCtx, src, at, bs, thin, norm, antialias, consumer); + } finally { + // recycle the RendererContext instance + returnRendererContext(rdrCtx); + } + } + + final void strokeTo(final RendererContext rdrCtx, + Shape src, + AffineTransform at, + BasicStroke bs, + boolean thin, + NormMode normalize, + boolean antialias, + PathConsumer2D pc2d) + { + float lw; + if (thin) { + if (antialias) { + lw = userSpaceLineWidth(at, MIN_PEN_SIZE); + } else { + lw = userSpaceLineWidth(at, 1.0f); + } + } else { + lw = bs.getLineWidth(); + } + strokeTo(rdrCtx, + src, + at, + lw, + normalize, + bs.getEndCap(), + bs.getLineJoin(), + bs.getMiterLimit(), + bs.getDashArray(), + bs.getDashPhase(), + pc2d); + } + + private final float userSpaceLineWidth(AffineTransform at, float lw) { + + float widthScale; + + if (at == null) { + widthScale = 1.0f; + } else if ((at.getType() & (AffineTransform.TYPE_GENERAL_TRANSFORM | + AffineTransform.TYPE_GENERAL_SCALE)) != 0) { + widthScale = (float)Math.sqrt(at.getDeterminant()); + } else { + // First calculate the "maximum scale" of this transform. + double A = at.getScaleX(); // m00 + double C = at.getShearX(); // m01 + double B = at.getShearY(); // m10 + double D = at.getScaleY(); // m11 + + /* + * Given a 2 x 2 affine matrix [ A B ] such that + * [ C D ] + * v' = [x' y'] = [Ax + Cy, Bx + Dy], we want to + * find the maximum magnitude (norm) of the vector v' + * with the constraint (x^2 + y^2 = 1). + * The equation to maximize is + * |v'| = sqrt((Ax+Cy)^2+(Bx+Dy)^2) + * or |v'| = sqrt((AA+BB)x^2 + 2(AC+BD)xy + (CC+DD)y^2). + * Since sqrt is monotonic we can maximize |v'|^2 + * instead and plug in the substitution y = sqrt(1 - x^2). + * Trigonometric equalities can then be used to get + * rid of most of the sqrt terms. + */ + + double EA = A*A + B*B; // x^2 coefficient + double EB = 2.0*(A*C + B*D); // xy coefficient + double EC = C*C + D*D; // y^2 coefficient + + /* + * There is a lot of calculus omitted here. + * + * Conceptually, in the interests of understanding the + * terms that the calculus produced we can consider + * that EA and EC end up providing the lengths along + * the major axes and the hypot term ends up being an + * adjustment for the additional length along the off-axis + * angle of rotated or sheared ellipses as well as an + * adjustment for the fact that the equation below + * averages the two major axis lengths. (Notice that + * the hypot term contains a part which resolves to the + * difference of these two axis lengths in the absence + * of rotation.) + * + * In the calculus, the ratio of the EB and (EA-EC) terms + * ends up being the tangent of 2*theta where theta is + * the angle that the long axis of the ellipse makes + * with the horizontal axis. Thus, this equation is + * calculating the length of the hypotenuse of a triangle + * along that axis. + */ + + double hypot = Math.sqrt(EB*EB + (EA-EC)*(EA-EC)); + // sqrt omitted, compare to squared limits below. + double widthsquared = ((EA + EC + hypot)/2.0); + + widthScale = (float)Math.sqrt(widthsquared); + } + + return (lw / widthScale); + } + + final void strokeTo(final RendererContext rdrCtx, + Shape src, + AffineTransform at, + float width, + NormMode normalize, + int caps, + int join, + float miterlimit, + float dashes[], + float dashphase, + PathConsumer2D pc2d) + { + // We use strokerat and outat so that in Stroker and Dasher we can work only + // with the pre-transformation coordinates. This will repeat a lot of + // computations done in the path iterator, but the alternative is to + // work with transformed paths and compute untransformed coordinates + // as needed. This would be faster but I do not think the complexity + // of working with both untransformed and transformed coordinates in + // the same code is worth it. + // However, if a path's width is constant after a transformation, + // we can skip all this untransforming. + + // If normalization is off we save some transformations by not + // transforming the input to pisces. Instead, we apply the + // transformation after the path processing has been done. + // We can't do this if normalization is on, because it isn't a good + // idea to normalize before the transformation is applied. + AffineTransform strokerat = null; + AffineTransform outat = null; + + PathIterator pi; + int dashLen = -1; + boolean recycleDashes = false; + + if (at != null && !at.isIdentity()) { + final double a = at.getScaleX(); + final double b = at.getShearX(); + final double c = at.getShearY(); + final double d = at.getScaleY(); + final double det = a * d - c * b; + + if (Math.abs(det) <= (2f * Float.MIN_VALUE)) { + // this rendering engine takes one dimensional curves and turns + // them into 2D shapes by giving them width. + // However, if everything is to be passed through a singular + // transformation, these 2D shapes will be squashed down to 1D + // again so, nothing can be drawn. + + // Every path needs an initial moveTo and a pathDone. If these + // are not there this causes a SIGSEGV in libawt.so (at the time + // of writing of this comment (September 16, 2010)). Actually, + // I am not sure if the moveTo is necessary to avoid the SIGSEGV + // but the pathDone is definitely needed. + pc2d.moveTo(0f, 0f); + pc2d.pathDone(); + return; + } + + // If the transform is a constant multiple of an orthogonal transformation + // then every length is just multiplied by a constant, so we just + // need to transform input paths to stroker and tell stroker + // the scaled width. This condition is satisfied if + // a*b == -c*d && a*a+c*c == b*b+d*d. In the actual check below, we + // leave a bit of room for error. + if (nearZero(a*b + c*d) && nearZero(a*a + c*c - (b*b + d*d))) { + final float scale = (float) Math.sqrt(a*a + c*c); + if (dashes != null) { + recycleDashes = true; + dashLen = dashes.length; + final float[] newDashes; + if (dashLen <= INITIAL_ARRAY) { + newDashes = rdrCtx.dasher.dashes_initial; + } else { + if (doStats) { + RendererContext.stats.stat_array_dasher_dasher + .add(dashLen); + } + newDashes = rdrCtx.getDirtyFloatArray(dashLen); + } + System.arraycopy(dashes, 0, newDashes, 0, dashLen); + dashes = newDashes; + for (int i = 0; i < dashLen; i++) { + dashes[i] = scale * dashes[i]; + } + dashphase = scale * dashphase; + } + width = scale * width; + pi = getNormalizingPathIterator(rdrCtx, normalize, + src.getPathIterator(at)); + + // by now strokerat == null && outat == null. Input paths to + // stroker (and maybe dasher) will have the full transform at + // applied to them and nothing will happen to the output paths. + } else { + if (normalize != NormMode.OFF) { + strokerat = at; + pi = getNormalizingPathIterator(rdrCtx, normalize, + src.getPathIterator(at)); + + // by now strokerat == at && outat == null. Input paths to + // stroker (and maybe dasher) will have the full transform at + // applied to them, then they will be normalized, and then + // the inverse of *only the non translation part of at* will + // be applied to the normalized paths. This won't cause problems + // in stroker, because, suppose at = T*A, where T is just the + // translation part of at, and A is the rest. T*A has already + // been applied to Stroker/Dasher's input. Then Ainv will be + // applied. Ainv*T*A is not equal to T, but it is a translation, + // which means that none of stroker's assumptions about its + // input will be violated. After all this, A will be applied + // to stroker's output. + } else { + outat = at; + pi = src.getPathIterator(null); + // outat == at && strokerat == null. This is because if no + // normalization is done, we can just apply all our + // transformations to stroker's output. + } + } + } else { + // either at is null or it's the identity. In either case + // we don't transform the path. + pi = getNormalizingPathIterator(rdrCtx, normalize, + src.getPathIterator(null)); + } + + if (useSimplifier) { + // Use simplifier after stroker before Renderer + // to remove collinear segments (notably due to cap square) + pc2d = rdrCtx.simplifier.init(pc2d); + } + + // by now, at least one of outat and strokerat will be null. Unless at is not + // a constant multiple of an orthogonal transformation, they will both be + // null. In other cases, outat == at if normalization is off, and if + // normalization is on, strokerat == at. + final TransformingPathConsumer2D transformerPC2D = rdrCtx.transformerPC2D; + pc2d = transformerPC2D.transformConsumer(pc2d, outat); + pc2d = transformerPC2D.deltaTransformConsumer(pc2d, strokerat); + + pc2d = rdrCtx.stroker.init(pc2d, width, caps, join, miterlimit); + + if (dashes != null) { + if (!recycleDashes) { + dashLen = dashes.length; + } + pc2d = rdrCtx.dasher.init(pc2d, dashes, dashLen, dashphase, + recycleDashes); + } + pc2d = transformerPC2D.inverseDeltaTransformConsumer(pc2d, strokerat); + pathTo(rdrCtx, pi, pc2d); + + /* + * Pipeline seems to be: + * shape.getPathIterator + * -> NormalizingPathIterator + * -> inverseDeltaTransformConsumer + * -> Dasher + * -> Stroker + * -> deltaTransformConsumer OR transformConsumer + * + * -> CollinearSimplifier to remove redundant segments + * + * -> pc2d = Renderer (bounding box) + */ + } + + private static boolean nearZero(final double num) { + return Math.abs(num) < 2.0 * Math.ulp(num); + } + + PathIterator getNormalizingPathIterator(final RendererContext rdrCtx, + final NormMode mode, + final PathIterator src) + { + switch (mode) { + case ON_WITH_AA: + // NormalizingPathIterator NearestPixelCenter: + return rdrCtx.nPCPathIterator.init(src); + case ON_NO_AA: + // NearestPixel NormalizingPathIterator: + return rdrCtx.nPQPathIterator.init(src); + case OFF: + // return original path iterator if normalization is disabled: + return src; + default: + throw new InternalError("Unrecognized normalization mode"); + } + } + + abstract static class NormalizingPathIterator implements PathIterator { + + private PathIterator src; + + // the adjustment applied to the current position. + private float curx_adjust, cury_adjust; + // the adjustment applied to the last moveTo position. + private float movx_adjust, movy_adjust; + + private final float[] tmp; + + NormalizingPathIterator(final float[] tmp) { + this.tmp = tmp; + } + + final NormalizingPathIterator init(final PathIterator src) { + this.src = src; + return this; // fluent API + } + + /** + * Disposes this path iterator: + * clean up before reusing this instance + */ + final void dispose() { + // free source PathIterator: + this.src = null; + } + + @Override + public final int currentSegment(final float[] coords) { + if (doMonitors) { + RendererContext.stats.mon_npi_currentSegment.start(); + } + int lastCoord; + final int type = src.currentSegment(coords); + + switch(type) { + case PathIterator.SEG_MOVETO: + case PathIterator.SEG_LINETO: + lastCoord = 0; + break; + case PathIterator.SEG_QUADTO: + lastCoord = 2; + break; + case PathIterator.SEG_CUBICTO: + lastCoord = 4; + break; + case PathIterator.SEG_CLOSE: + // we don't want to deal with this case later. We just exit now + curx_adjust = movx_adjust; + cury_adjust = movy_adjust; + + if (doMonitors) { + RendererContext.stats.mon_npi_currentSegment.stop(); + } + return type; + default: + throw new InternalError("Unrecognized curve type"); + } + + // TODO: handle NaN, Inf and overflow + + // normalize endpoint + float coord, x_adjust, y_adjust; + + coord = coords[lastCoord]; + x_adjust = normCoord(coord); // new coord + coords[lastCoord] = x_adjust; + x_adjust -= coord; + + coord = coords[lastCoord + 1]; + y_adjust = normCoord(coord); // new coord + coords[lastCoord + 1] = y_adjust; + y_adjust -= coord; + + // now that the end points are done, normalize the control points + switch(type) { + case PathIterator.SEG_MOVETO: + movx_adjust = x_adjust; + movy_adjust = y_adjust; + break; + case PathIterator.SEG_LINETO: + break; + case PathIterator.SEG_QUADTO: + coords[0] += (curx_adjust + x_adjust) / 2f; + coords[1] += (cury_adjust + y_adjust) / 2f; + break; + case PathIterator.SEG_CUBICTO: + coords[0] += curx_adjust; + coords[1] += cury_adjust; + coords[2] += x_adjust; + coords[3] += y_adjust; + break; + case PathIterator.SEG_CLOSE: + // handled earlier + default: + } + curx_adjust = x_adjust; + cury_adjust = y_adjust; + + if (doMonitors) { + RendererContext.stats.mon_npi_currentSegment.stop(); + } + return type; + } + + abstract float normCoord(final float coord); + + @Override + public final int currentSegment(final double[] coords) { + final float[] _tmp = tmp; // dirty + int type = this.currentSegment(_tmp); + for (int i = 0; i < 6; i++) { + coords[i] = _tmp[i]; + } + return type; + } + + @Override + public final int getWindingRule() { + return src.getWindingRule(); + } + + @Override + public final boolean isDone() { + if (src.isDone()) { + // Dispose this instance: + dispose(); + return true; + } + return false; + } + + @Override + public final void next() { + src.next(); + } + + static final class NearestPixelCenter + extends NormalizingPathIterator + { + NearestPixelCenter(final float[] tmp) { + super(tmp); + } + + @Override + float normCoord(final float coord) { + // round to nearest pixel center + return FloatMath.floor_f(coord) + 0.5f; + } + } + + static final class NearestPixelQuarter + extends NormalizingPathIterator + { + NearestPixelQuarter(final float[] tmp) { + super(tmp); + } + + @Override + float normCoord(final float coord) { + // round to nearest (0.25, 0.25) pixel quarter + return FloatMath.floor_f(coord + 0.25f) + 0.25f; + } + } + } + + private static void pathTo(final RendererContext rdrCtx, final PathIterator pi, + final PathConsumer2D pc2d) + { + // mark context as DIRTY: + rdrCtx.dirty = true; + + final float[] coords = rdrCtx.float6; + + pathToLoop(coords, pi, pc2d); + + // mark context as CLEAN: + rdrCtx.dirty = false; + } + + private static void pathToLoop(final float[] coords, final PathIterator pi, + final PathConsumer2D pc2d) + { + for (; !pi.isDone(); pi.next()) { + switch (pi.currentSegment(coords)) { + case PathIterator.SEG_MOVETO: + pc2d.moveTo(coords[0], coords[1]); + continue; + case PathIterator.SEG_LINETO: + pc2d.lineTo(coords[0], coords[1]); + continue; + case PathIterator.SEG_QUADTO: + pc2d.quadTo(coords[0], coords[1], + coords[2], coords[3]); + continue; + case PathIterator.SEG_CUBICTO: + pc2d.curveTo(coords[0], coords[1], + coords[2], coords[3], + coords[4], coords[5]); + continue; + case PathIterator.SEG_CLOSE: + pc2d.closePath(); + continue; + default: + } + } + pc2d.pathDone(); + } + + /** + * Construct an antialiased tile generator for the given shape with + * the given rendering attributes and store the bounds of the tile + * iteration in the bbox parameter. + * The {@code at} parameter specifies a transform that should affect + * both the shape and the {@code BasicStroke} attributes. + * The {@code clip} parameter specifies the current clip in effect + * in device coordinates and can be used to prune the data for the + * operation, but the renderer is not required to perform any + * clipping. + * If the {@code BasicStroke} parameter is null then the shape + * should be filled as is, otherwise the attributes of the + * {@code BasicStroke} should be used to specify a draw operation. + * The {@code thin} parameter indicates whether or not the + * transformed {@code BasicStroke} represents coordinates smaller + * than the minimum resolution of the antialiasing rasterizer as + * specified by the {@code getMinimumAAPenWidth()} method. + *

    + * Upon returning, this method will fill the {@code bbox} parameter + * with 4 values indicating the bounds of the iteration of the + * tile generator. + * The iteration order of the tiles will be as specified by the + * pseudo-code: + *

    +     *     for (y = bbox[1]; y < bbox[3]; y += tileheight) {
    +     *         for (x = bbox[0]; x < bbox[2]; x += tilewidth) {
    +     *         }
    +     *     }
    +     * 
    + * If there is no output to be rendered, this method may return + * null. + * + * @param s the shape to be rendered (fill or draw) + * @param at the transform to be applied to the shape and the + * stroke attributes + * @param clip the current clip in effect in device coordinates + * @param bs if non-null, a {@code BasicStroke} whose attributes + * should be applied to this operation + * @param thin true if the transformed stroke attributes are smaller + * than the minimum dropout pen width + * @param normalize true if the {@code VALUE_STROKE_NORMALIZE} + * {@code RenderingHint} is in effect + * @param bbox returns the bounds of the iteration + * @return the {@code AATileGenerator} instance to be consulted + * for tile coverages, or null if there is no output to render + * @since 1.7 + */ + @Override + public AATileGenerator getAATileGenerator(Shape s, + AffineTransform at, + Region clip, + BasicStroke bs, + boolean thin, + boolean normalize, + int bbox[]) + { + MarlinTileGenerator ptg = null; + Renderer r = null; + + final RendererContext rdrCtx = getRendererContext(); + try { + // Test if at is identity: + final AffineTransform _at = (at != null && !at.isIdentity()) ? at + : null; + + final NormMode norm = (normalize) ? NormMode.ON_WITH_AA : NormMode.OFF; + + if (bs == null) { + // fill shape: + final PathIterator pi = getNormalizingPathIterator(rdrCtx, norm, + s.getPathIterator(_at)); + + r = rdrCtx.renderer.init(clip.getLoX(), clip.getLoY(), + clip.getWidth(), clip.getHeight(), + pi.getWindingRule()); + + // TODO: subdivide quad/cubic curves into monotonic curves ? + pathTo(rdrCtx, pi, r); + } else { + // draw shape with given stroke: + r = rdrCtx.renderer.init(clip.getLoX(), clip.getLoY(), + clip.getWidth(), clip.getHeight(), + PathIterator.WIND_NON_ZERO); + + strokeTo(rdrCtx, s, _at, bs, thin, norm, true, r); + } + if (r.endRendering()) { + ptg = rdrCtx.ptg.init(); + ptg.getBbox(bbox); + // note: do not returnRendererContext(rdrCtx) + // as it will be called later by MarlinTileGenerator.dispose() + r = null; + } + } finally { + if (r != null) { + // dispose renderer: + r.dispose(); + // recycle the RendererContext instance + MarlinRenderingEngine.returnRendererContext(rdrCtx); + } + } + + // Return null to cancel AA tile generation (nothing to render) + return ptg; + } + + @Override + public final AATileGenerator getAATileGenerator(double x, double y, + double dx1, double dy1, + double dx2, double dy2, + double lw1, double lw2, + Region clip, + int bbox[]) + { + // REMIND: Deal with large coordinates! + double ldx1, ldy1, ldx2, ldy2; + boolean innerpgram = (lw1 > 0.0 && lw2 > 0.0); + + if (innerpgram) { + ldx1 = dx1 * lw1; + ldy1 = dy1 * lw1; + ldx2 = dx2 * lw2; + ldy2 = dy2 * lw2; + x -= (ldx1 + ldx2) / 2.0; + y -= (ldy1 + ldy2) / 2.0; + dx1 += ldx1; + dy1 += ldy1; + dx2 += ldx2; + dy2 += ldy2; + if (lw1 > 1.0 && lw2 > 1.0) { + // Inner parallelogram was entirely consumed by stroke... + innerpgram = false; + } + } else { + ldx1 = ldy1 = ldx2 = ldy2 = 0.0; + } + + MarlinTileGenerator ptg = null; + Renderer r = null; + + final RendererContext rdrCtx = getRendererContext(); + try { + r = rdrCtx.renderer.init(clip.getLoX(), clip.getLoY(), + clip.getWidth(), clip.getHeight(), + Renderer.WIND_EVEN_ODD); + + r.moveTo((float) x, (float) y); + r.lineTo((float) (x+dx1), (float) (y+dy1)); + r.lineTo((float) (x+dx1+dx2), (float) (y+dy1+dy2)); + r.lineTo((float) (x+dx2), (float) (y+dy2)); + r.closePath(); + + if (innerpgram) { + x += ldx1 + ldx2; + y += ldy1 + ldy2; + dx1 -= 2.0 * ldx1; + dy1 -= 2.0 * ldy1; + dx2 -= 2.0 * ldx2; + dy2 -= 2.0 * ldy2; + r.moveTo((float) x, (float) y); + r.lineTo((float) (x+dx1), (float) (y+dy1)); + r.lineTo((float) (x+dx1+dx2), (float) (y+dy1+dy2)); + r.lineTo((float) (x+dx2), (float) (y+dy2)); + r.closePath(); + } + r.pathDone(); + + if (r.endRendering()) { + ptg = rdrCtx.ptg.init(); + ptg.getBbox(bbox); + // note: do not returnRendererContext(rdrCtx) + // as it will be called later by MarlinTileGenerator.dispose() + r = null; + } + } finally { + if (r != null) { + // dispose renderer: + r.dispose(); + // recycle the RendererContext instance + MarlinRenderingEngine.returnRendererContext(rdrCtx); + } + } + + // Return null to cancel AA tile generation (nothing to render) + return ptg; + } + + /** + * Returns the minimum pen width that the antialiasing rasterizer + * can represent without dropouts occuring. + * @since 1.7 + */ + @Override + public float getMinimumAAPenSize() { + return MIN_PEN_SIZE; + } + + static { + if (PathIterator.WIND_NON_ZERO != Renderer.WIND_NON_ZERO || + PathIterator.WIND_EVEN_ODD != Renderer.WIND_EVEN_ODD || + BasicStroke.JOIN_MITER != Stroker.JOIN_MITER || + BasicStroke.JOIN_ROUND != Stroker.JOIN_ROUND || + BasicStroke.JOIN_BEVEL != Stroker.JOIN_BEVEL || + BasicStroke.CAP_BUTT != Stroker.CAP_BUTT || + BasicStroke.CAP_ROUND != Stroker.CAP_ROUND || + BasicStroke.CAP_SQUARE != Stroker.CAP_SQUARE) + { + throw new InternalError("mismatched renderer constants"); + } + } + + // --- RendererContext handling --- + // use ThreadLocal or ConcurrentLinkedQueue to get one RendererContext + private static final boolean useThreadLocal; + + // reference type stored in either TL or CLQ + static final int REF_TYPE; + + // Per-thread RendererContext + private static final ReentrantContextProvider rdrCtxProvider; + + // Static initializer to use TL or CLQ mode + static { + useThreadLocal = MarlinProperties.isUseThreadLocal(); + + // Soft reference by default: + final String refType = AccessController.doPrivileged( + new GetPropertyAction("sun.java2d.renderer.useRef", + "soft")); + switch (refType) { + default: + case "soft": + REF_TYPE = ReentrantContextProvider.REF_SOFT; + break; + case "weak": + REF_TYPE = ReentrantContextProvider.REF_WEAK; + break; + case "hard": + REF_TYPE = ReentrantContextProvider.REF_HARD; + break; + } + + if (useThreadLocal) { + rdrCtxProvider = new ReentrantContextProviderTL(REF_TYPE) + { + @Override + protected RendererContext newContext() { + return RendererContext.createContext(); + } + }; + } else { + rdrCtxProvider = new ReentrantContextProviderCLQ(REF_TYPE) + { + @Override + protected RendererContext newContext() { + return RendererContext.createContext(); + } + }; + } + } + + private static boolean settingsLogged = !enableLogs; + + private static void logSettings(final String reClass) { + // log information at startup + if (settingsLogged) { + return; + } + settingsLogged = true; + + String refType; + switch (REF_TYPE) { + default: + case ReentrantContextProvider.REF_HARD: + refType = "hard"; + break; + case ReentrantContextProvider.REF_SOFT: + refType = "soft"; + break; + case ReentrantContextProvider.REF_WEAK: + refType = "weak"; + break; + } + + logInfo("==========================================================" + + "====================="); + + logInfo("Marlin software rasterizer = ENABLED"); + logInfo("Version = [" + + Version.getVersion() + "]"); + logInfo("sun.java2d.renderer = " + + reClass); + logInfo("sun.java2d.renderer.useThreadLocal = " + + useThreadLocal); + logInfo("sun.java2d.renderer.useRef = " + + refType); + + logInfo("sun.java2d.renderer.pixelsize = " + + MarlinConst.INITIAL_PIXEL_DIM); + logInfo("sun.java2d.renderer.subPixel_log2_X = " + + MarlinConst.SUBPIXEL_LG_POSITIONS_X); + logInfo("sun.java2d.renderer.subPixel_log2_Y = " + + MarlinConst.SUBPIXEL_LG_POSITIONS_Y); + logInfo("sun.java2d.renderer.tileSize_log2 = " + + MarlinConst.TILE_SIZE_LG); + + logInfo("sun.java2d.renderer.blockSize_log2 = " + + MarlinConst.BLOCK_SIZE_LG); + + logInfo("sun.java2d.renderer.blockSize_log2 = " + + MarlinConst.BLOCK_SIZE_LG); + + // RLE / blockFlags settings + + logInfo("sun.java2d.renderer.forceRLE = " + + MarlinProperties.isForceRLE()); + logInfo("sun.java2d.renderer.forceNoRLE = " + + MarlinProperties.isForceNoRLE()); + logInfo("sun.java2d.renderer.useTileFlags = " + + MarlinProperties.isUseTileFlags()); + logInfo("sun.java2d.renderer.useTileFlags.useHeuristics = " + + MarlinProperties.isUseTileFlagsWithHeuristics()); + logInfo("sun.java2d.renderer.rleMinWidth = " + + MarlinCache.RLE_MIN_WIDTH); + + // optimisation parameters + logInfo("sun.java2d.renderer.useSimplifier = " + + MarlinConst.useSimplifier); + + // debugging parameters + logInfo("sun.java2d.renderer.doStats = " + + MarlinConst.doStats); + logInfo("sun.java2d.renderer.doMonitors = " + + MarlinConst.doMonitors); + logInfo("sun.java2d.renderer.doChecks = " + + MarlinConst.doChecks); + + // logging parameters + logInfo("sun.java2d.renderer.useLogger = " + + MarlinConst.useLogger); + logInfo("sun.java2d.renderer.logCreateContext = " + + MarlinConst.logCreateContext); + logInfo("sun.java2d.renderer.logUnsafeMalloc = " + + MarlinConst.logUnsafeMalloc); + + // quality settings + logInfo("Renderer settings:"); + logInfo("CUB_COUNT_LG = " + Renderer.CUB_COUNT_LG); + logInfo("CUB_DEC_BND = " + Renderer.CUB_DEC_BND); + logInfo("CUB_INC_BND = " + Renderer.CUB_INC_BND); + logInfo("QUAD_DEC_BND = " + Renderer.QUAD_DEC_BND); + + logInfo("==========================================================" + + "====================="); + } + + /** + * Get the RendererContext instance dedicated to the current thread + * @return RendererContext instance + */ + @SuppressWarnings({"unchecked"}) + static RendererContext getRendererContext() { + final RendererContext rdrCtx = rdrCtxProvider.acquire(); + if (doMonitors) { + RendererContext.stats.mon_pre_getAATileGenerator.start(); + } + return rdrCtx; + } + + /** + * Reset and return the given RendererContext instance for reuse + * @param rdrCtx RendererContext instance + */ + static void returnRendererContext(final RendererContext rdrCtx) { + rdrCtx.dispose(); + + if (doMonitors) { + RendererContext.stats.mon_pre_getAATileGenerator.stop(); + } + rdrCtxProvider.release(rdrCtx); + } +} diff --git a/src/share/classes/sun/java2d/marlin/MarlinTileGenerator.java b/src/share/classes/sun/java2d/marlin/MarlinTileGenerator.java new file mode 100644 index 0000000000000000000000000000000000000000..31ba7b9c49315bdc2419c434b1650d162e595224 --- /dev/null +++ b/src/share/classes/sun/java2d/marlin/MarlinTileGenerator.java @@ -0,0 +1,465 @@ +/* + * Copyright (c) 2007, 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. 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.java2d.marlin; + +import sun.java2d.pipe.AATileGenerator; +import sun.misc.Unsafe; + +final class MarlinTileGenerator implements AATileGenerator, MarlinConst { + + private static final int MAX_TILE_ALPHA_SUM = TILE_SIZE * TILE_SIZE + * MAX_AA_ALPHA; + + private final Renderer rdr; + private final MarlinCache cache; + private int x, y; + + MarlinTileGenerator(Renderer r) { + this.rdr = r; + this.cache = r.cache; + } + + MarlinTileGenerator init() { + this.x = cache.bboxX0; + this.y = cache.bboxY0; + + return this; // fluent API + } + + /** + * Disposes this tile generator: + * clean up before reusing this instance + */ + @Override + public void dispose() { + if (doMonitors) { + // called from AAShapePipe.renderTiles() (render tiles end): + RendererContext.stats.mon_pipe_renderTiles.stop(); + } + // dispose cache: + cache.dispose(); + // dispose renderer: + rdr.dispose(); + // recycle the RendererContext instance + MarlinRenderingEngine.returnRendererContext(rdr.rdrCtx); + } + + void getBbox(int bbox[]) { + bbox[0] = cache.bboxX0; + bbox[1] = cache.bboxY0; + bbox[2] = cache.bboxX1; + bbox[3] = cache.bboxY1; + } + + /** + * Gets the width of the tiles that the generator batches output into. + * @return the width of the standard alpha tile + */ + @Override + public int getTileWidth() { + if (doMonitors) { + // called from AAShapePipe.renderTiles() (render tiles start): + RendererContext.stats.mon_pipe_renderTiles.start(); + } + return TILE_SIZE; + } + + /** + * Gets the height of the tiles that the generator batches output into. + * @return the height of the standard alpha tile + */ + @Override + public int getTileHeight() { + return TILE_SIZE; + } + + /** + * Gets the typical alpha value that will characterize the current + * tile. + * The answer may be 0x00 to indicate that the current tile has + * no coverage in any of its pixels, or it may be 0xff to indicate + * that the current tile is completely covered by the path, or any + * other value to indicate non-trivial coverage cases. + * @return 0x00 for no coverage, 0xff for total coverage, or any other + * value for partial coverage of the tile + */ + @Override + public int getTypicalAlpha() { + int al = cache.alphaSumInTile(x); + // Note: if we have a filled rectangle that doesn't end on a tile + // border, we could still return 0xff, even though al!=maxTileAlphaSum + // This is because if we return 0xff, our users will fill a rectangle + // starting at x,y that has width = Math.min(TILE_SIZE, bboxX1-x), + // and height min(TILE_SIZE,bboxY1-y), which is what should happen. + // However, to support this, we would have to use 2 Math.min's + // and 2 multiplications per tile, instead of just 2 multiplications + // to compute maxTileAlphaSum. The savings offered would probably + // not be worth it, considering how rare this case is. + // Note: I have not tested this, so in the future if it is determined + // that it is worth it, it should be implemented. Perhaps this method's + // interface should be changed to take arguments the width and height + // of the current tile. This would eliminate the 2 Math.min calls that + // would be needed here, since our caller needs to compute these 2 + // values anyway. + final int alpha = (al == 0x00 ? 0x00 + : (al == MAX_TILE_ALPHA_SUM ? 0xff : 0x80)); + if (doStats) { + RendererContext.stats.hist_tile_generator_alpha.add(alpha); + } + return alpha; + } + + /** + * Skips the current tile and moves on to the next tile. + * Either this method, or the getAlpha() method should be called + * once per tile, but not both. + */ + @Override + public void nextTile() { + if ((x += TILE_SIZE) >= cache.bboxX1) { + x = cache.bboxX0; + y += TILE_SIZE; + + if (y < cache.bboxY1) { + // compute for the tile line + // [ y; max(y + TILE_SIZE, bboxY1) ] + this.rdr.endRendering(y); + } + } + } + + /** + * Gets the alpha coverage values for the current tile. + * Either this method, or the nextTile() method should be called + * once per tile, but not both. + */ + @Override + public void getAlpha(final byte tile[], final int offset, + final int rowstride) + { + if (cache.useRLE) { + getAlphaRLE(tile, offset, rowstride); + } else { + getAlphaNoRLE(tile, offset, rowstride); + } + } + + /** + * Gets the alpha coverage values for the current tile. + * Either this method, or the nextTile() method should be called + * once per tile, but not both. + */ + private void getAlphaNoRLE(final byte tile[], final int offset, + final int rowstride) + { + if (doMonitors) { + RendererContext.stats.mon_ptg_getAlpha.start(); + } + + // local vars for performance: + final MarlinCache _cache = this.cache; + final long[] rowAAChunkIndex = _cache.rowAAChunkIndex; + final int[] rowAAx0 = _cache.rowAAx0; + final int[] rowAAx1 = _cache.rowAAx1; + + final int x0 = this.x; + final int x1 = FloatMath.min(x0 + TILE_SIZE, _cache.bboxX1); + + // note: process tile line [0 - 32[ + final int y0 = 0; + final int y1 = FloatMath.min(this.y + TILE_SIZE, _cache.bboxY1) - this.y; + + if (doLogBounds) { + MarlinUtils.logInfo("getAlpha = [" + x0 + " ... " + x1 + + "[ [" + y0 + " ... " + y1 + "["); + } + + final Unsafe _unsafe = OffHeapArray.unsafe; + final long SIZE = 1L; + final long addr_rowAA = _cache.rowAAChunk.address; + long addr; + + final int skipRowPixels = (rowstride - (x1 - x0)); + + int aax0, aax1, end; + int idx = offset; + + for (int cy = y0, cx; cy < y1; cy++) { + // empty line (default) + cx = x0; + + aax1 = rowAAx1[cy]; // exclusive + + // quick check if there is AA data + // corresponding to this tile [x0; x1[ + if (aax1 > x0) { + aax0 = rowAAx0[cy]; // inclusive + + if (aax0 < x1) { + // note: cx is the cursor pointer in the tile array + // (left to right) + cx = aax0; + + // ensure cx >= x0 + if (cx <= x0) { + cx = x0; + } else { + // fill line start until first AA pixel rowAA exclusive: + for (end = x0; end < cx; end++) { + tile[idx++] = 0; + } + } + + // now: cx >= x0 but cx < aax0 (x1 < aax0) + + // Copy AA data (sum alpha data): + addr = addr_rowAA + rowAAChunkIndex[cy] + (cx - aax0); + + for (end = (aax1 <= x1) ? aax1 : x1; cx < end; cx++) { + // cx inside tile[x0; x1[ : + tile[idx++] = _unsafe.getByte(addr); // [0..255] + addr += SIZE; + } + } + } + + // fill line end + while (cx < x1) { + tile[idx++] = 0; + cx++; + } + + if (doTrace) { + for (int i = idx - (x1 - x0); i < idx; i++) { + System.out.print(hex(tile[i], 2)); + } + System.out.println(); + } + + idx += skipRowPixels; + } + + nextTile(); + + if (doMonitors) { + RendererContext.stats.mon_ptg_getAlpha.stop(); + } + } + + /** + * Gets the alpha coverage values for the current tile. + * Either this method, or the nextTile() method should be called + * once per tile, but not both. + */ + private void getAlphaRLE(final byte tile[], final int offset, + final int rowstride) + { + if (doMonitors) { + RendererContext.stats.mon_ptg_getAlpha.start(); + } + + // Decode run-length encoded alpha mask data + // The data for row j begins at cache.rowOffsetsRLE[j] + // and is encoded as a set of 2-byte pairs (val, runLen) + // terminated by a (0, 0) pair. + + // local vars for performance: + final MarlinCache _cache = this.cache; + final long[] rowAAChunkIndex = _cache.rowAAChunkIndex; + final int[] rowAAx0 = _cache.rowAAx0; + final int[] rowAAx1 = _cache.rowAAx1; + final int[] rowAAEnc = _cache.rowAAEnc; + final long[] rowAALen = _cache.rowAALen; + final long[] rowAAPos = _cache.rowAAPos; + + final int x0 = this.x; + final int x1 = FloatMath.min(x0 + TILE_SIZE, _cache.bboxX1); + + // note: process tile line [0 - 32[ + final int y0 = 0; + final int y1 = FloatMath.min(this.y + TILE_SIZE, _cache.bboxY1) - this.y; + + if (doLogBounds) { + MarlinUtils.logInfo("getAlpha = [" + x0 + " ... " + x1 + + "[ [" + y0 + " ... " + y1 + "["); + } + + final Unsafe _unsafe = OffHeapArray.unsafe; + final long SIZE_BYTE = 1L; + final long SIZE_INT = 4L; + final long addr_rowAA = _cache.rowAAChunk.address; + long addr, addr_row, last_addr, addr_end; + + final int skipRowPixels = (rowstride - (x1 - x0)); + + int cx, cy, cx1; + int rx0, rx1, runLen, end; + int packed; + byte val; + int idx = offset; + + for (cy = y0; cy < y1; cy++) { + // empty line (default) + cx = x0; + + if (rowAAEnc[cy] == 0) { + // Raw encoding: + + final int aax1 = rowAAx1[cy]; // exclusive + + // quick check if there is AA data + // corresponding to this tile [x0; x1[ + if (aax1 > x0) { + final int aax0 = rowAAx0[cy]; // inclusive + + if (aax0 < x1) { + // note: cx is the cursor pointer in the tile array + // (left to right) + cx = aax0; + + // ensure cx >= x0 + if (cx <= x0) { + cx = x0; + } else { + // fill line start until first AA pixel rowAA exclusive: + for (end = x0; end < cx; end++) { + tile[idx++] = 0; + } + } + + // now: cx >= x0 but cx < aax0 (x1 < aax0) + + // Copy AA data (sum alpha data): + addr = addr_rowAA + rowAAChunkIndex[cy] + (cx - aax0); + + for (end = (aax1 <= x1) ? aax1 : x1; cx < end; cx++) { + tile[idx++] = _unsafe.getByte(addr); // [0..255] + addr += SIZE_BYTE; + } + } + } + } else { + // RLE encoding: + + // quick check if there is AA data + // corresponding to this tile [x0; x1[ + if (rowAAx1[cy] > x0) { // last pixel exclusive + + cx = rowAAx0[cy]; // inclusive + if (cx > x1) { + cx = x1; + } + + // fill line start until first AA pixel rowAA exclusive: + for (int i = x0; i < cx; i++) { + tile[idx++] = 0; + } + + // get row address: + addr_row = addr_rowAA + rowAAChunkIndex[cy]; + // get row end address: + addr_end = addr_row + rowAALen[cy]; // coded length + + // reuse previous iteration position: + addr = addr_row + rowAAPos[cy]; + + last_addr = 0L; + + while ((cx < x1) && (addr < addr_end)) { + // keep current position: + last_addr = addr; + + // packed value: + packed = _unsafe.getInt(addr); + + // last exclusive pixel x-coordinate: + cx1 = (packed >> 8); + // as bytes: + addr += SIZE_INT; + + rx0 = cx; + if (rx0 < x0) { + rx0 = x0; + } + rx1 = cx = cx1; + if (rx1 > x1) { + rx1 = x1; + cx = x1; // fix last x + } + // adjust runLen: + runLen = rx1 - rx0; + + // ensure rx1 > rx0: + if (runLen > 0) { + val = (byte)(packed & 0xFF); // [0..255] + + do { + tile[idx++] = val; + } while (--runLen > 0); + } + } + + // Update last position in RLE entries: + if (last_addr != 0L) { + // Fix x0: + rowAAx0[cy] = cx; // inclusive + // Fix position: + rowAAPos[cy] = (last_addr - addr_row); + } + } + } + + // fill line end + while (cx < x1) { + tile[idx++] = 0; + cx++; + } + + if (doTrace) { + for (int i = idx - (x1 - x0); i < idx; i++) { + System.out.print(hex(tile[i], 2)); + } + System.out.println(); + } + + idx += skipRowPixels; + } + + nextTile(); + + if (doMonitors) { + RendererContext.stats.mon_ptg_getAlpha.stop(); + } + } + + static String hex(int v, int d) { + String s = Integer.toHexString(v); + while (s.length() < d) { + s = "0" + s; + } + return s.substring(0, d); + } +} diff --git a/src/share/classes/sun/java2d/marlin/MarlinUtils.java b/src/share/classes/sun/java2d/marlin/MarlinUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..aeeacca57bd3c0de8f636a9b86c2c79dafb3fced --- /dev/null +++ b/src/share/classes/sun/java2d/marlin/MarlinUtils.java @@ -0,0 +1,63 @@ +/* + * 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. 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.java2d.marlin; + + +public final class MarlinUtils { + // Marlin logger + private static final sun.util.logging.PlatformLogger log; + + static { + if (MarlinConst.useLogger) { + log = sun.util.logging.PlatformLogger.getLogger("sun.java2d.marlin"); + } else { + log = null; + } + } + + private MarlinUtils() { + // no-op + } + + public static void logInfo(final String msg) { + if (MarlinConst.useLogger) { + log.info(msg); + } else if (MarlinConst.enableLogs) { + System.out.print("INFO: "); + System.out.println(msg); + } + } + + public static void logException(final String msg, final Throwable th) { + if (MarlinConst.useLogger) { + log.warning(msg, th); + } else if (MarlinConst.enableLogs) { + System.out.print("WARNING: "); + System.out.println(msg); + th.printStackTrace(System.err); + } + } +} diff --git a/src/share/classes/sun/java2d/marlin/MergeSort.java b/src/share/classes/sun/java2d/marlin/MergeSort.java new file mode 100644 index 0000000000000000000000000000000000000000..52e1f6302eea98fcd6e6975b3c3ebdf5339ee4df --- /dev/null +++ b/src/share/classes/sun/java2d/marlin/MergeSort.java @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2009, 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. 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.java2d.marlin; + +/** + * MergeSort adapted from (OpenJDK 8) java.util.Array.legacyMergeSort(Object[]) + * to swap two arrays at the same time (x & y) + * and use external auxiliary storage for temporary arrays + */ +final class MergeSort { + + // insertion sort threshold + public static final int INSERTION_SORT_THRESHOLD = 14; + + /** + * Modified merge sort: + * Input arrays are in both auxX/auxY (sorted: 0 to insertionSortIndex) + * and x/y (unsorted: insertionSortIndex to toIndex) + * Outputs are stored in x/y arrays + */ + static void mergeSortNoCopy(final int[] x, final int[] y, + final int[] auxX, final int[] auxY, + final int toIndex, + final int insertionSortIndex) + { + if ((toIndex > x.length) || (toIndex > y.length) + || (toIndex > auxX.length) || (toIndex > auxY.length)) { + // explicit check to avoid bound checks within hot loops (below): + throw new ArrayIndexOutOfBoundsException("bad arguments: toIndex=" + + toIndex); + } + + // sort second part only using merge / insertion sort + // in auxiliary storage (auxX/auxY) + mergeSort(x, y, x, auxX, y, auxY, insertionSortIndex, toIndex); + + // final pass to merge both + // Merge sorted parts (auxX/auxY) into x/y arrays + if ((insertionSortIndex == 0) + || (auxX[insertionSortIndex - 1] <= auxX[insertionSortIndex])) { +// System.out.println("mergeSortNoCopy: ordered"); + // 34 occurences + // no initial left part or both sublists (auxX, auxY) are sorted: + // copy back data into (x, y): + System.arraycopy(auxX, 0, x, 0, toIndex); + System.arraycopy(auxY, 0, y, 0, toIndex); + return; + } + + for (int i = 0, p = 0, q = insertionSortIndex; i < toIndex; i++) { + if ((q >= toIndex) || ((p < insertionSortIndex) + && (auxX[p] <= auxX[q]))) { + x[i] = auxX[p]; + y[i] = auxY[p]; + p++; + } else { + x[i] = auxX[q]; + y[i] = auxY[q]; + q++; + } + } + } + + /** + * Src is the source array that starts at index 0 + * Dest is the (possibly larger) array destination with a possible offset + * low is the index in dest to start sorting + * high is the end index in dest to end sorting + */ + private static void mergeSort(final int[] refX, final int[] refY, + final int[] srcX, final int[] dstX, + final int[] srcY, final int[] dstY, + final int low, final int high) + { + final int length = high - low; + + /* + * Tuning parameter: list size at or below which insertion sort + * will be used in preference to mergesort. + */ + if (length <= INSERTION_SORT_THRESHOLD) { + // Insertion sort on smallest arrays + dstX[low] = refX[low]; + dstY[low] = refY[low]; + + for (int i = low + 1, j = low, x, y; i < high; j = i++) { + x = refX[i]; + y = refY[i]; + + while (dstX[j] > x) { + // swap element + dstX[j + 1] = dstX[j]; + dstY[j + 1] = dstY[j]; + if (j-- == low) { + break; + } + } + dstX[j + 1] = x; + dstY[j + 1] = y; + } + return; + } + + // Recursively sort halves of dest into src + + // note: use signed shift (not >>>) for performance + // as indices are small enough to exceed Integer.MAX_VALUE + final int mid = (low + high) >> 1; + + mergeSort(refX, refY, dstX, srcX, dstY, srcY, low, mid); + mergeSort(refX, refY, dstX, srcX, dstY, srcY, mid, high); + + // If arrays are inverted ie all(A) > all(B) do swap A and B to dst + if (srcX[high - 1] <= srcX[low]) { +// System.out.println("mergeSort: inverse ordered"); + // 1561 occurences + final int left = mid - low; + final int right = high - mid; + final int off = (left != right) ? 1 : 0; + // swap parts: + System.arraycopy(srcX, low, dstX, mid + off, left); + System.arraycopy(srcX, mid, dstX, low, right); + System.arraycopy(srcY, low, dstY, mid + off, left); + System.arraycopy(srcY, mid, dstY, low, right); + return; + } + + // If arrays are already sorted, just copy from src to dest. This is an + // optimization that results in faster sorts for nearly ordered lists. + if (srcX[mid - 1] <= srcX[mid]) { +// System.out.println("mergeSort: ordered"); + // 14 occurences + System.arraycopy(srcX, low, dstX, low, length); + System.arraycopy(srcY, low, dstY, low, length); + return; + } + + // Merge sorted halves (now in src) into dest + for (int i = low, p = low, q = mid; i < high; i++) { + if ((q >= high) || ((p < mid) && (srcX[p] <= srcX[q]))) { + dstX[i] = srcX[p]; + dstY[i] = srcY[p]; + p++; + } else { + dstX[i] = srcX[q]; + dstY[i] = srcY[q]; + q++; + } + } + } + + private MergeSort() { + } +} diff --git a/src/share/classes/sun/java2d/marlin/OffHeapArray.java b/src/share/classes/sun/java2d/marlin/OffHeapArray.java new file mode 100644 index 0000000000000000000000000000000000000000..f0a0999b9e238d366c66a1e2c32cb0f36b6b7a81 --- /dev/null +++ b/src/share/classes/sun/java2d/marlin/OffHeapArray.java @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2007, 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. 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.java2d.marlin; + +import java.lang.ref.PhantomReference; +import java.lang.ref.ReferenceQueue; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.Vector; +import static sun.java2d.marlin.MarlinConst.logUnsafeMalloc; +import sun.misc.ThreadGroupUtils; +import sun.misc.Unsafe; + +/** + * + * @author bourgesl + */ +final class OffHeapArray { + + // unsafe reference + static final Unsafe unsafe; + // size of int / float + static final int SIZE_INT; + + // RendererContext reference queue + private static final ReferenceQueue rdrQueue + = new ReferenceQueue(); + // reference list + private static final Vector refList + = new Vector(32); + + static { + unsafe = Unsafe.getUnsafe(); + SIZE_INT = Unsafe.ARRAY_INT_INDEX_SCALE; + + // Mimics Java2D Disposer: + AccessController.doPrivileged( + (PrivilegedAction) () -> { + /* + * The thread must be a member of a thread group + * which will not get GCed before VM exit. + * Make its parent the top-level thread group. + */ + final ThreadGroup rootTG + = ThreadGroupUtils.getRootThreadGroup(); + final Thread t = new Thread(rootTG, new OffHeapDisposer(), + "MarlinRenderer Disposer"); + t.setContextClassLoader(null); + t.setDaemon(true); + t.setPriority(Thread.MAX_PRIORITY); + t.start(); + return null; + } + ); + } + + /* members */ + long address; + long length; + int used; + + OffHeapArray(final Object parent, final long len) { + // note: may throw OOME: + this.address = unsafe.allocateMemory(len); + this.length = len; + this.used = 0; + if (logUnsafeMalloc) { + MarlinUtils.logInfo(System.currentTimeMillis() + + ": OffHeapArray.allocateMemory = " + + len + " to addr = " + this.address); + } + + // Create the phantom reference to ensure freeing off-heap memory: + refList.add(new OffHeapReference(parent, this)); + } + + /* + * As realloc may change the address, updating address is MANDATORY + * @param len new array length + * @throws OutOfMemoryError if the allocation is refused by the system + */ + void resize(final long len) { + // note: may throw OOME: + this.address = unsafe.reallocateMemory(address, len); + this.length = len; + if (logUnsafeMalloc) { + MarlinUtils.logInfo(System.currentTimeMillis() + + ": OffHeapArray.reallocateMemory = " + + len + " to addr = " + this.address); + } + } + + void free() { + unsafe.freeMemory(this.address); + if (logUnsafeMalloc) { + MarlinUtils.logInfo(System.currentTimeMillis() + + ": OffHeapEdgeArray.free = " + + this.length + + " at addr = " + this.address); + } + } + + void fill(final byte val) { + unsafe.setMemory(this.address, this.length, val); + } + + static final class OffHeapReference extends PhantomReference { + + private final OffHeapArray array; + + OffHeapReference(final Object parent, final OffHeapArray edges) { + super(parent, rdrQueue); + this.array = edges; + } + + void dispose() { + // free off-heap blocks + this.array.free(); + } + } + + static final class OffHeapDisposer implements Runnable { + @Override + public void run() { + final Thread currentThread = Thread.currentThread(); + OffHeapReference ref; + + // check interrupted: + for (; !currentThread.isInterrupted();) { + try { + ref = (OffHeapReference)rdrQueue.remove(); + ref.dispose(); + + refList.remove(ref); + + } catch (InterruptedException ie) { + MarlinUtils.logException("OffHeapDisposer interrupted:", + ie); + } + } + } + } +} diff --git a/src/share/classes/sun/java2d/marlin/Renderer.java b/src/share/classes/sun/java2d/marlin/Renderer.java new file mode 100644 index 0000000000000000000000000000000000000000..c63b14bedc7cb25140f52bdeabe1d9b623df5d07 --- /dev/null +++ b/src/share/classes/sun/java2d/marlin/Renderer.java @@ -0,0 +1,1558 @@ +/* + * Copyright (c) 2007, 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. 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.java2d.marlin; + +import java.util.Arrays; +import sun.awt.geom.PathConsumer2D; +import static sun.java2d.marlin.OffHeapArray.SIZE_INT; +import sun.misc.Unsafe; + +final class Renderer implements PathConsumer2D, MarlinConst { + + static final boolean DISABLE_RENDER = false; + + static final boolean ENABLE_BLOCK_FLAGS = MarlinProperties.isUseTileFlags(); + static final boolean ENABLE_BLOCK_FLAGS_HEURISTICS = MarlinProperties.isUseTileFlagsWithHeuristics(); + + private static final int ALL_BUT_LSB = 0xfffffffe; + private static final int ERR_STEP_MAX = 0x7fffffff; // = 2^31 - 1 + + private static final double POWER_2_TO_32 = 0x1.0p32; + + // use float to make tosubpix methods faster (no int to float conversion) + public static final float f_SUBPIXEL_POSITIONS_X + = (float) SUBPIXEL_POSITIONS_X; + public static final float f_SUBPIXEL_POSITIONS_Y + = (float) SUBPIXEL_POSITIONS_Y; + public static final int SUBPIXEL_MASK_X = SUBPIXEL_POSITIONS_X - 1; + public static final int SUBPIXEL_MASK_Y = SUBPIXEL_POSITIONS_Y - 1; + + // number of subpixels corresponding to a tile line + private static final int SUBPIXEL_TILE + = TILE_SIZE << SUBPIXEL_LG_POSITIONS_Y; + + // 2048 (pixelSize) pixels (height) x 8 subpixels = 64K + static final int INITIAL_BUCKET_ARRAY + = INITIAL_PIXEL_DIM * SUBPIXEL_POSITIONS_Y; + + public static final int WIND_EVEN_ODD = 0; + public static final int WIND_NON_ZERO = 1; + + // common to all types of input path segments. + // OFFSET as bytes + // only integer values: + public static final long OFF_CURX_OR = 0; + public static final long OFF_ERROR = OFF_CURX_OR + SIZE_INT; + public static final long OFF_BUMP_X = OFF_ERROR + SIZE_INT; + public static final long OFF_BUMP_ERR = OFF_BUMP_X + SIZE_INT; + public static final long OFF_NEXT = OFF_BUMP_ERR + SIZE_INT; + public static final long OFF_YMAX = OFF_NEXT + SIZE_INT; + + // size of one edge in bytes + public static final int SIZEOF_EDGE_BYTES = (int)(OFF_YMAX + SIZE_INT); + + // curve break into lines + // cubic error in subpixels to decrement step + private static final float CUB_DEC_ERR_SUBPIX + = 2.5f * (NORM_SUBPIXELS / 8f); // 2.5 subpixel for typical 8x8 subpixels + // cubic error in subpixels to increment step + private static final float CUB_INC_ERR_SUBPIX + = 1f * (NORM_SUBPIXELS / 8f); // 1 subpixel for typical 8x8 subpixels + + // cubic bind length to decrement step = 8 * error in subpixels + // pisces: 20 / 8 + // openjfx pisces: 8 / 3.2 + // multiply by 8 = error scale factor: + public static final float CUB_DEC_BND + = 8f * CUB_DEC_ERR_SUBPIX; // 20f means 2.5 subpixel error + // cubic bind length to increment step = 8 * error in subpixels + public static final float CUB_INC_BND + = 8f * CUB_INC_ERR_SUBPIX; // 8f means 1 subpixel error + + // cubic countlg + public static final int CUB_COUNT_LG = 2; + // cubic count = 2^countlg + private static final int CUB_COUNT = 1 << CUB_COUNT_LG; + // cubic count^2 = 4^countlg + private static final int CUB_COUNT_2 = 1 << (2 * CUB_COUNT_LG); + // cubic count^3 = 8^countlg + private static final int CUB_COUNT_3 = 1 << (3 * CUB_COUNT_LG); + // cubic dt = 1 / count + private static final float CUB_INV_COUNT = 1f / CUB_COUNT; + // cubic dt^2 = 1 / count^2 = 1 / 4^countlg + private static final float CUB_INV_COUNT_2 = 1f / CUB_COUNT_2; + // cubic dt^3 = 1 / count^3 = 1 / 8^countlg + private static final float CUB_INV_COUNT_3 = 1f / CUB_COUNT_3; + + // quad break into lines + // quadratic error in subpixels + private static final float QUAD_DEC_ERR_SUBPIX + = 1f * (NORM_SUBPIXELS / 8f); // 1 subpixel for typical 8x8 subpixels + + // quadratic bind length to decrement step = 8 * error in subpixels + // pisces and openjfx pisces: 32 + public static final float QUAD_DEC_BND + = 8f * QUAD_DEC_ERR_SUBPIX; // 8f means 1 subpixel error + +////////////////////////////////////////////////////////////////////////////// +// SCAN LINE +////////////////////////////////////////////////////////////////////////////// + // crossings ie subpixel edge x coordinates + private int[] crossings; + // auxiliary storage for crossings (merge sort) + private int[] aux_crossings; + + // indices into the segment pointer lists. They indicate the "active" + // sublist in the segment lists (the portion of the list that contains + // all the segments that cross the next scan line). + private int edgeCount; + private int[] edgePtrs; + // auxiliary storage for edge pointers (merge sort) + private int[] aux_edgePtrs; + + // max used for both edgePtrs and crossings (stats only) + private int activeEdgeMaxUsed; + + // per-thread initial arrays (large enough to satisfy most usages) (1024) + private final int[] crossings_initial = new int[INITIAL_SMALL_ARRAY]; // 4K + // +1 to avoid recycling in Helpers.widenArray() + private final int[] edgePtrs_initial = new int[INITIAL_SMALL_ARRAY + 1]; // 4K + // merge sort initial arrays (large enough to satisfy most usages) (1024) + private final int[] aux_crossings_initial = new int[INITIAL_SMALL_ARRAY]; // 4K + // +1 to avoid recycling in Helpers.widenArray() + private final int[] aux_edgePtrs_initial = new int[INITIAL_SMALL_ARRAY + 1]; // 4K + +////////////////////////////////////////////////////////////////////////////// +// EDGE LIST +////////////////////////////////////////////////////////////////////////////// + private int edgeMinY = Integer.MAX_VALUE; + private int edgeMaxY = Integer.MIN_VALUE; + private float edgeMinX = Float.POSITIVE_INFINITY; + private float edgeMaxX = Float.NEGATIVE_INFINITY; + + // edges [floats|ints] stored in off-heap memory + private final OffHeapArray edges; + + private int[] edgeBuckets; + private int[] edgeBucketCounts; // 2*newedges + (1 if pruning needed) + // used range for edgeBuckets / edgeBucketCounts + private int buckets_minY; + private int buckets_maxY; + // sum of each edge delta Y (subpixels) + private int edgeSumDeltaY; + + // +1 to avoid recycling in Helpers.widenArray() + private final int[] edgeBuckets_initial + = new int[INITIAL_BUCKET_ARRAY + 1]; // 64K + private final int[] edgeBucketCounts_initial + = new int[INITIAL_BUCKET_ARRAY + 1]; // 64K + + // Flattens using adaptive forward differencing. This only carries out + // one iteration of the AFD loop. All it does is update AFD variables (i.e. + // X0, Y0, D*[X|Y], COUNT; not variables used for computing scanline crossings). + private void quadBreakIntoLinesAndAdd(float x0, float y0, + final Curve c, + final float x2, final float y2) + { + int count = 1; // dt = 1 / count + + // maximum(ddX|Y) = norm(dbx, dby) * dt^2 (= 1) + float maxDD = FloatMath.max(Math.abs(c.dbx), Math.abs(c.dby)); + + final float _DEC_BND = QUAD_DEC_BND; + + while (maxDD >= _DEC_BND) { + // divide step by half: + maxDD /= 4f; // error divided by 2^2 = 4 + + count <<= 1; + if (doStats) { + RendererContext.stats.stat_rdr_quadBreak_dec.add(count); + } + } + + int nL = 0; // line count + if (count > 1) { + final float icount = 1f / count; // dt + final float icount2 = icount * icount; // dt^2 + + final float ddx = c.dbx * icount2; + final float ddy = c.dby * icount2; + float dx = c.bx * icount2 + c.cx * icount; + float dy = c.by * icount2 + c.cy * icount; + + float x1, y1; + + while (--count > 0) { + x1 = x0 + dx; + dx += ddx; + y1 = y0 + dy; + dy += ddy; + + addLine(x0, y0, x1, y1); + + if (doStats) { nL++; } + x0 = x1; + y0 = y1; + } + } + addLine(x0, y0, x2, y2); + + if (doStats) { + RendererContext.stats.stat_rdr_quadBreak.add(nL + 1); + } + } + + // x0, y0 and x3,y3 are the endpoints of the curve. We could compute these + // using c.xat(0),c.yat(0) and c.xat(1),c.yat(1), but this might introduce + // numerical errors, and our callers already have the exact values. + // Another alternative would be to pass all the control points, and call + // c.set here, but then too many numbers are passed around. + private void curveBreakIntoLinesAndAdd(float x0, float y0, + final Curve c, + final float x3, final float y3) + { + int count = CUB_COUNT; + final float icount = CUB_INV_COUNT; // dt + final float icount2 = CUB_INV_COUNT_2; // dt^2 + final float icount3 = CUB_INV_COUNT_3; // dt^3 + + // the dx and dy refer to forward differencing variables, not the last + // coefficients of the "points" polynomial + float dddx, dddy, ddx, ddy, dx, dy; + dddx = 2f * c.dax * icount3; + dddy = 2f * c.day * icount3; + ddx = dddx + c.dbx * icount2; + ddy = dddy + c.dby * icount2; + dx = c.ax * icount3 + c.bx * icount2 + c.cx * icount; + dy = c.ay * icount3 + c.by * icount2 + c.cy * icount; + + // we use x0, y0 to walk the line + float x1 = x0, y1 = y0; + int nL = 0; // line count + + final float _DEC_BND = CUB_DEC_BND; + final float _INC_BND = CUB_INC_BND; + + while (count > 0) { + // divide step by half: + while (Math.abs(ddx) >= _DEC_BND || Math.abs(ddy) >= _DEC_BND) { + dddx /= 8f; + dddy /= 8f; + ddx = ddx/4f - dddx; + ddy = ddy/4f - dddy; + dx = (dx - ddx) / 2f; + dy = (dy - ddy) / 2f; + + count <<= 1; + if (doStats) { + RendererContext.stats.stat_rdr_curveBreak_dec.add(count); + } + } + + // double step: + // TODO: why use first derivative dX|Y instead of second ddX|Y ? + // both scale changes should use speed or acceleration to have the same metric. + + // can only do this on even "count" values, because we must divide count by 2 + while (count % 2 == 0 + && Math.abs(dx) <= _INC_BND && Math.abs(dy) <= _INC_BND) + { + dx = 2f * dx + ddx; + dy = 2f * dy + ddy; + ddx = 4f * (ddx + dddx); + ddy = 4f * (ddy + dddy); + dddx *= 8f; + dddy *= 8f; + + count >>= 1; + if (doStats) { + RendererContext.stats.stat_rdr_curveBreak_inc.add(count); + } + } + if (--count > 0) { + x1 += dx; + dx += ddx; + ddx += dddx; + y1 += dy; + dy += ddy; + ddy += dddy; + } else { + x1 = x3; + y1 = y3; + } + + addLine(x0, y0, x1, y1); + + if (doStats) { nL++; } + x0 = x1; + y0 = y1; + } + if (doStats) { + RendererContext.stats.stat_rdr_curveBreak.add(nL); + } + } + + private void addLine(float x1, float y1, float x2, float y2) { + if (doMonitors) { + RendererContext.stats.mon_rdr_addLine.start(); + } + if (doStats) { + RendererContext.stats.stat_rdr_addLine.add(1); + } + int or = 1; // orientation of the line. 1 if y increases, 0 otherwise. + if (y2 < y1) { + or = 0; + float tmp = y2; + y2 = y1; + y1 = tmp; + tmp = x2; + x2 = x1; + x1 = tmp; + } + + // convert subpixel coordinates (float) into pixel positions (int) + + // The index of the pixel that holds the next HPC is at ceil(trueY - 0.5) + // Since y1 and y2 are biased by -0.5 in tosubpixy(), this is simply + // ceil(y1) or ceil(y2) + // upper integer (inclusive) + final int firstCrossing = FloatMath.max(FloatMath.ceil_int(y1), boundsMinY); + + // note: use boundsMaxY (last Y exclusive) to compute correct coverage + // upper integer (exclusive) + final int lastCrossing = FloatMath.min(FloatMath.ceil_int(y2), boundsMaxY); + + /* skip horizontal lines in pixel space and clip edges + out of y range [boundsMinY; boundsMaxY] */ + if (firstCrossing >= lastCrossing) { + if (doMonitors) { + RendererContext.stats.mon_rdr_addLine.stop(); + } + if (doStats) { + RendererContext.stats.stat_rdr_addLine_skip.add(1); + } + return; + } + + // edge min/max X/Y are in subpixel space (inclusive) within bounds: + // note: Use integer crossings to ensure consistent range within + // edgeBuckets / edgeBucketCounts arrays in case of NaN values (int = 0) + if (firstCrossing < edgeMinY) { + edgeMinY = firstCrossing; + } + if (lastCrossing > edgeMaxY) { + edgeMaxY = lastCrossing; + } + + // Use double-precision for improved accuracy: + final double x1d = x1; + final double y1d = y1; + final double slope = (x1d - x2) / (y1d - y2); + + if (slope >= 0.0) { // <==> x1 < x2 + if (x1 < edgeMinX) { + edgeMinX = x1; + } + if (x2 > edgeMaxX) { + edgeMaxX = x2; + } + } else { + if (x2 < edgeMinX) { + edgeMinX = x2; + } + if (x1 > edgeMaxX) { + edgeMaxX = x1; + } + } + + // local variables for performance: + final int _SIZEOF_EDGE_BYTES = SIZEOF_EDGE_BYTES; + + final OffHeapArray _edges = edges; + + // get free pointer (ie length in bytes) + final int edgePtr = _edges.used; + + // use substraction to avoid integer overflow: + if (_edges.length - edgePtr < _SIZEOF_EDGE_BYTES) { + // suppose _edges.length > _SIZEOF_EDGE_BYTES + // so doubling size is enough to add needed bytes + // note: throw IOOB if neededSize > 2Gb: + final long edgeNewSize = ArrayCache.getNewLargeSize(_edges.length, + edgePtr + _SIZEOF_EDGE_BYTES); + + if (doStats) { + RendererContext.stats.stat_rdr_edges_resizes.add(edgeNewSize); + } + _edges.resize(edgeNewSize); + } + + + final Unsafe _unsafe = OffHeapArray.unsafe; + final long SIZE_INT = 4L; + long addr = _edges.address + edgePtr; + + // The x value must be bumped up to its position at the next HPC we will evaluate. + // "firstcrossing" is the (sub)pixel number where the next crossing occurs + // thus, the actual coordinate of the next HPC is "firstcrossing + 0.5" + // so the Y distance we cover is "firstcrossing + 0.5 - trueY". + // Note that since y1 (and y2) are already biased by -0.5 in tosubpixy(), we have + // y1 = trueY - 0.5 + // trueY = y1 + 0.5 + // firstcrossing + 0.5 - trueY = firstcrossing + 0.5 - (y1 + 0.5) + // = firstcrossing - y1 + // The x coordinate at that HPC is then: + // x1_intercept = x1 + (firstcrossing - y1) * slope + // The next VPC is then given by: + // VPC index = ceil(x1_intercept - 0.5), or alternately + // VPC index = floor(x1_intercept - 0.5 + 1 - epsilon) + // epsilon is hard to pin down in floating point, but easy in fixed point, so if + // we convert to fixed point then these operations get easier: + // long x1_fixed = x1_intercept * 2^32; (fixed point 32.32 format) + // curx = next VPC = fixed_floor(x1_fixed - 2^31 + 2^32 - 1) + // = fixed_floor(x1_fixed + 2^31 - 1) + // = fixed_floor(x1_fixed + 0x7fffffff) + // and error = fixed_fract(x1_fixed + 0x7fffffff) + final double x1_intercept = x1d + (firstCrossing - y1d) * slope; + + // inlined scalb(x1_intercept, 32): + final long x1_fixed_biased = ((long) (POWER_2_TO_32 * x1_intercept)) + + 0x7fffffffL; + // curx: + // last bit corresponds to the orientation + _unsafe.putInt(addr, (((int) (x1_fixed_biased >> 31L)) & ALL_BUT_LSB) | or); + addr += SIZE_INT; + _unsafe.putInt(addr, ((int) x1_fixed_biased) >>> 1); + addr += SIZE_INT; + + // inlined scalb(slope, 32): + final long slope_fixed = (long) (POWER_2_TO_32 * slope); + + // last bit set to 0 to keep orientation: + _unsafe.putInt(addr, (((int) (slope_fixed >> 31L)) & ALL_BUT_LSB)); + addr += SIZE_INT; + _unsafe.putInt(addr, ((int) slope_fixed) >>> 1); + addr += SIZE_INT; + + final int[] _edgeBuckets = edgeBuckets; + final int[] _edgeBucketCounts = edgeBucketCounts; + + final int _boundsMinY = boundsMinY; + + // each bucket is a linked list. this method adds ptr to the + // start of the "bucket"th linked list. + final int bucketIdx = firstCrossing - _boundsMinY; + + // pointer from bucket + _unsafe.putInt(addr, _edgeBuckets[bucketIdx]); + addr += SIZE_INT; + // y max (inclusive) + _unsafe.putInt(addr, lastCrossing); + + // Update buckets: + // directly the edge struct "pointer" + _edgeBuckets[bucketIdx] = edgePtr; + _edgeBucketCounts[bucketIdx] += 2; // 1 << 1 + // last bit means edge end + _edgeBucketCounts[lastCrossing - _boundsMinY] |= 0x1; + + // update sum of delta Y (subpixels): + edgeSumDeltaY += (lastCrossing - firstCrossing); + + // update free pointer (ie length in bytes) + _edges.used += _SIZEOF_EDGE_BYTES; + + if (doMonitors) { + RendererContext.stats.mon_rdr_addLine.stop(); + } + } + +// END EDGE LIST +////////////////////////////////////////////////////////////////////////////// + + // Cache to store RLE-encoded coverage mask of the current primitive + final MarlinCache cache; + + // Bounds of the drawing region, at subpixel precision. + private int boundsMinX, boundsMinY, boundsMaxX, boundsMaxY; + + // Current winding rule + private int windingRule; + + // Current drawing position, i.e., final point of last segment + private float x0, y0; + + // Position of most recent 'moveTo' command + private float sx0, sy0; + + // per-thread renderer context + final RendererContext rdrCtx; + // dirty curve + private final Curve curve; + + Renderer(final RendererContext rdrCtx) { + this.rdrCtx = rdrCtx; + + this.edges = new OffHeapArray(rdrCtx, INITIAL_EDGES_CAPACITY); // 96K + + this.curve = rdrCtx.curve; + + edgeBuckets = edgeBuckets_initial; + edgeBucketCounts = edgeBucketCounts_initial; + + alphaLine = alphaLine_initial; + + this.cache = rdrCtx.cache; + + // ScanLine: + crossings = crossings_initial; + aux_crossings = aux_crossings_initial; + edgePtrs = edgePtrs_initial; + aux_edgePtrs = aux_edgePtrs_initial; + + edgeCount = 0; + activeEdgeMaxUsed = 0; + } + + Renderer init(final int pix_boundsX, final int pix_boundsY, + final int pix_boundsWidth, final int pix_boundsHeight, + final int windingRule) { + + this.windingRule = windingRule; + + // bounds as half-open intervals: minX <= x < maxX and minY <= y < maxY + this.boundsMinX = pix_boundsX << SUBPIXEL_LG_POSITIONS_X; + this.boundsMaxX = + (pix_boundsX + pix_boundsWidth) << SUBPIXEL_LG_POSITIONS_X; + this.boundsMinY = pix_boundsY << SUBPIXEL_LG_POSITIONS_Y; + this.boundsMaxY = + (pix_boundsY + pix_boundsHeight) << SUBPIXEL_LG_POSITIONS_Y; + + if (doLogBounds) { + MarlinUtils.logInfo("boundsXY = [" + boundsMinX + " ... " + + boundsMaxX + "[ [" + boundsMinY + " ... " + + boundsMaxY + "["); + } + + // see addLine: ceil(boundsMaxY) => boundsMaxY + 1 + // +1 for edgeBucketCounts + final int edgeBucketsLength = (boundsMaxY - boundsMinY) + 1; + + if (edgeBucketsLength > INITIAL_BUCKET_ARRAY) { + if (doStats) { + RendererContext.stats.stat_array_renderer_edgeBuckets + .add(edgeBucketsLength); + RendererContext.stats.stat_array_renderer_edgeBucketCounts + .add(edgeBucketsLength); + } + edgeBuckets = rdrCtx.getIntArray(edgeBucketsLength); + edgeBucketCounts = rdrCtx.getIntArray(edgeBucketsLength); + } + + edgeMinY = Integer.MAX_VALUE; + edgeMaxY = Integer.MIN_VALUE; + edgeMinX = Float.POSITIVE_INFINITY; + edgeMaxX = Float.NEGATIVE_INFINITY; + + // reset used mark: + edgeCount = 0; + activeEdgeMaxUsed = 0; + edges.used = 0; + + edgeSumDeltaY = 0; + + return this; // fluent API + } + + /** + * Disposes this renderer and recycle it clean up before reusing this instance + */ + void dispose() { + if (doStats) { + RendererContext.stats.stat_rdr_activeEdges.add(activeEdgeMaxUsed); + RendererContext.stats.stat_rdr_edges.add(edges.used); + RendererContext.stats.stat_rdr_edges_count + .add(edges.used / SIZEOF_EDGE_BYTES); + } + if (doCleanDirty) { + // Force zero-fill dirty arrays: + Arrays.fill(crossings, 0); + Arrays.fill(aux_crossings, 0); + Arrays.fill(edgePtrs, 0); + Arrays.fill(aux_edgePtrs, 0); + } + // Return arrays: + if (crossings != crossings_initial) { + rdrCtx.putDirtyIntArray(crossings); + crossings = crossings_initial; + if (aux_crossings != aux_crossings_initial) { + rdrCtx.putDirtyIntArray(aux_crossings); + aux_crossings = aux_crossings_initial; + } + } + if (edgePtrs != edgePtrs_initial) { + rdrCtx.putDirtyIntArray(edgePtrs); + edgePtrs = edgePtrs_initial; + if (aux_edgePtrs != aux_edgePtrs_initial) { + rdrCtx.putDirtyIntArray(aux_edgePtrs); + aux_edgePtrs = aux_edgePtrs_initial; + } + } + if (alphaLine != alphaLine_initial) { + rdrCtx.putIntArray(alphaLine, 0, 0); // already zero filled + alphaLine = alphaLine_initial; + } + if (blkFlags != blkFlags_initial) { + rdrCtx.putIntArray(blkFlags, 0, 0); // already zero filled + blkFlags = blkFlags_initial; + } + + if (edgeMinY != Integer.MAX_VALUE) { + // if context is maked as DIRTY: + if (rdrCtx.dirty) { + // may happen if an exception if thrown in the pipeline processing: + // clear completely buckets arrays: + buckets_minY = 0; + buckets_maxY = boundsMaxY - boundsMinY; + } + // clear used part + if (edgeBuckets == edgeBuckets_initial) { + // fill only used part + IntArrayCache.fill(edgeBuckets, buckets_minY, + buckets_maxY, 0); + IntArrayCache.fill(edgeBucketCounts, buckets_minY, + buckets_maxY + 1, 0); + } else { + // clear only used part + rdrCtx.putIntArray(edgeBuckets, buckets_minY, + buckets_maxY); + edgeBuckets = edgeBuckets_initial; + + rdrCtx.putIntArray(edgeBucketCounts, buckets_minY, + buckets_maxY + 1); + edgeBucketCounts = edgeBucketCounts_initial; + } + } else if (edgeBuckets != edgeBuckets_initial) { + // unused arrays + rdrCtx.putIntArray(edgeBuckets, 0, 0); + edgeBuckets = edgeBuckets_initial; + + rdrCtx.putIntArray(edgeBucketCounts, 0, 0); + edgeBucketCounts = edgeBucketCounts_initial; + } + + // At last: resize back off-heap edges to initial size + if (edges.length != INITIAL_EDGES_CAPACITY) { + // note: may throw OOME: + edges.resize(INITIAL_EDGES_CAPACITY); + } + if (doCleanDirty) { + // Force zero-fill dirty arrays: + edges.fill(BYTE_0); + } + if (doMonitors) { + RendererContext.stats.mon_rdr_endRendering.stop(); + } + } + + private static float tosubpixx(final float pix_x) { + return f_SUBPIXEL_POSITIONS_X * pix_x; + } + + private static float tosubpixy(final float pix_y) { + // shift y by -0.5 for fast ceil(y - 0.5): + return f_SUBPIXEL_POSITIONS_Y * pix_y - 0.5f; + } + + @Override + public void moveTo(float pix_x0, float pix_y0) { + closePath(); + final float sx = tosubpixx(pix_x0); + final float sy = tosubpixy(pix_y0); + this.sx0 = sx; + this.sy0 = sy; + this.x0 = sx; + this.y0 = sy; + } + + @Override + public void lineTo(float pix_x1, float pix_y1) { + final float x1 = tosubpixx(pix_x1); + final float y1 = tosubpixy(pix_y1); + addLine(x0, y0, x1, y1); + x0 = x1; + y0 = y1; + } + + @Override + public void curveTo(float x1, float y1, + float x2, float y2, + float x3, float y3) + { + final float xe = tosubpixx(x3); + final float ye = tosubpixy(y3); + curve.set(x0, y0, tosubpixx(x1), tosubpixy(y1), + tosubpixx(x2), tosubpixy(y2), xe, ye); + curveBreakIntoLinesAndAdd(x0, y0, curve, xe, ye); + x0 = xe; + y0 = ye; + } + + @Override + public void quadTo(float x1, float y1, float x2, float y2) { + final float xe = tosubpixx(x2); + final float ye = tosubpixy(y2); + curve.set(x0, y0, tosubpixx(x1), tosubpixy(y1), xe, ye); + quadBreakIntoLinesAndAdd(x0, y0, curve, xe, ye); + x0 = xe; + y0 = ye; + } + + @Override + public void closePath() { + addLine(x0, y0, sx0, sy0); + x0 = sx0; + y0 = sy0; + } + + @Override + public void pathDone() { + closePath(); + } + + @Override + public long getNativeConsumer() { + throw new InternalError("Renderer does not use a native consumer."); + } + + // clean alpha array (zero filled) + private int[] alphaLine; + // 2048 (pixelsize) pixel large + private final int[] alphaLine_initial = new int[INITIAL_AA_ARRAY]; // 8K + + private void _endRendering(final int ymin, final int ymax) { + if (DISABLE_RENDER) { + return; + } + + // Get X bounds as true pixel boundaries to compute correct pixel coverage: + final int bboxx0 = bbox_spminX; + final int bboxx1 = bbox_spmaxX; + + final boolean windingRuleEvenOdd = (windingRule == WIND_EVEN_ODD); + + // Useful when processing tile line by tile line + final int[] _alpha = alphaLine; + + // local vars (performance): + final MarlinCache _cache = cache; + final OffHeapArray _edges = edges; + final int[] _edgeBuckets = edgeBuckets; + final int[] _edgeBucketCounts = edgeBucketCounts; + + int[] _crossings = this.crossings; + int[] _edgePtrs = this.edgePtrs; + + // merge sort auxiliary storage: + int[] _aux_crossings = this.aux_crossings; + int[] _aux_edgePtrs = this.aux_edgePtrs; + + // copy constants: + final long _OFF_ERROR = OFF_ERROR; + final long _OFF_BUMP_X = OFF_BUMP_X; + final long _OFF_BUMP_ERR = OFF_BUMP_ERR; + + final long _OFF_NEXT = OFF_NEXT; + final long _OFF_YMAX = OFF_YMAX; + + final int _ALL_BUT_LSB = ALL_BUT_LSB; + final int _ERR_STEP_MAX = ERR_STEP_MAX; + + // unsafe I/O: + final Unsafe _unsafe = OffHeapArray.unsafe; + final long addr0 = _edges.address; + long addr; + final int _SUBPIXEL_LG_POSITIONS_X = SUBPIXEL_LG_POSITIONS_X; + final int _SUBPIXEL_LG_POSITIONS_Y = SUBPIXEL_LG_POSITIONS_Y; + final int _SUBPIXEL_MASK_X = SUBPIXEL_MASK_X; + final int _SUBPIXEL_MASK_Y = SUBPIXEL_MASK_Y; + final int _SUBPIXEL_POSITIONS_X = SUBPIXEL_POSITIONS_X; + + final int _MIN_VALUE = Integer.MIN_VALUE; + final int _MAX_VALUE = Integer.MAX_VALUE; + + // Now we iterate through the scanlines. We must tell emitRow the coord + // of the first non-transparent pixel, so we must keep accumulators for + // the first and last pixels of the section of the current pixel row + // that we will emit. + // We also need to accumulate pix_bbox, but the iterator does it + // for us. We will just get the values from it once this loop is done + int minX = _MAX_VALUE; + int maxX = _MIN_VALUE; + + int y = ymin; + int bucket = y - boundsMinY; + + int numCrossings = this.edgeCount; + int edgePtrsLen = _edgePtrs.length; + int crossingsLen = _crossings.length; + int _arrayMaxUsed = activeEdgeMaxUsed; + int ptrLen = 0, newCount, ptrEnd; + + int bucketcount, i, j, ecur; + int cross, lastCross; + int x0, x1, tmp, sum, prev, curx, curxo, crorientation, err; + int pix_x, pix_xmaxm1, pix_xmax; + + int low, high, mid, prevNumCrossings; + boolean useBinarySearch; + + final int[] _blkFlags = blkFlags; + final int _BLK_SIZE_LG = BLOCK_SIZE_LG; + final int _BLK_SIZE = BLOCK_SIZE; + + final boolean _enableBlkFlagsHeuristics = ENABLE_BLOCK_FLAGS_HEURISTICS && this.enableBlkFlags; + + // Use block flags if large pixel span and few crossings: + // ie mean(distance between crossings) is high + boolean useBlkFlags = this.prevUseBlkFlags; + + final int stroking = rdrCtx.stroking; + + int lastY = -1; // last emited row + + + // Iteration on scanlines + for (; y < ymax; y++, bucket++) { + // --- from former ScanLineIterator.next() + bucketcount = _edgeBucketCounts[bucket]; + + // marker on previously sorted edges: + prevNumCrossings = numCrossings; + + // bucketCount indicates new edge / edge end: + if (bucketcount != 0) { + if (doStats) { + RendererContext.stats.stat_rdr_activeEdges_updates + .add(numCrossings); + } + + // last bit set to 1 means that edges ends + if ((bucketcount & 0x1) != 0) { + // eviction in active edge list + // cache edges[] address + offset + addr = addr0 + _OFF_YMAX; + + for (i = 0, newCount = 0; i < numCrossings; i++) { + // get the pointer to the edge + ecur = _edgePtrs[i]; + // random access so use unsafe: + if (_unsafe.getInt(addr + ecur) > y) { + _edgePtrs[newCount++] = ecur; + } + } + // update marker on sorted edges minus removed edges: + prevNumCrossings = numCrossings = newCount; + } + + ptrLen = bucketcount >> 1; // number of new edge + + if (ptrLen != 0) { + if (doStats) { + RendererContext.stats.stat_rdr_activeEdges_adds + .add(ptrLen); + if (ptrLen > 10) { + RendererContext.stats.stat_rdr_activeEdges_adds_high + .add(ptrLen); + } + } + ptrEnd = numCrossings + ptrLen; + + if (edgePtrsLen < ptrEnd) { + if (doStats) { + RendererContext.stats.stat_array_renderer_edgePtrs + .add(ptrEnd); + } + this.edgePtrs = _edgePtrs + = rdrCtx.widenDirtyIntArray(_edgePtrs, numCrossings, + ptrEnd); + + edgePtrsLen = _edgePtrs.length; + // Get larger auxiliary storage: + if (_aux_edgePtrs != aux_edgePtrs_initial) { + rdrCtx.putDirtyIntArray(_aux_edgePtrs); + } + // use ArrayCache.getNewSize() to use the same growing + // factor than widenDirtyIntArray(): + if (doStats) { + RendererContext.stats.stat_array_renderer_aux_edgePtrs + .add(ptrEnd); + } + this.aux_edgePtrs = _aux_edgePtrs + = rdrCtx.getDirtyIntArray( + ArrayCache.getNewSize(numCrossings, ptrEnd) + ); + } + + // cache edges[] address + offset + addr = addr0 + _OFF_NEXT; + + // add new edges to active edge list: + for (ecur = _edgeBuckets[bucket]; + numCrossings < ptrEnd; numCrossings++) + { + // store the pointer to the edge + _edgePtrs[numCrossings] = ecur; + // random access so use unsafe: + ecur = _unsafe.getInt(addr + ecur); + } + + if (crossingsLen < numCrossings) { + // Get larger array: + if (_crossings != crossings_initial) { + rdrCtx.putDirtyIntArray(_crossings); + } + if (doStats) { + RendererContext.stats.stat_array_renderer_crossings + .add(numCrossings); + } + this.crossings = _crossings + = rdrCtx.getDirtyIntArray(numCrossings); + + // Get larger auxiliary storage: + if (_aux_crossings != aux_crossings_initial) { + rdrCtx.putDirtyIntArray(_aux_crossings); + } + if (doStats) { + RendererContext.stats.stat_array_renderer_aux_crossings + .add(numCrossings); + } + this.aux_crossings = _aux_crossings + = rdrCtx.getDirtyIntArray(numCrossings); + + crossingsLen = _crossings.length; + } + if (doStats) { + // update max used mark + if (numCrossings > _arrayMaxUsed) { + _arrayMaxUsed = numCrossings; + } + } + } // ptrLen != 0 + } // bucketCount != 0 + + + if (numCrossings != 0) { + /* + * thresholds to switch to optimized merge sort + * for newly added edges + final merge pass. + */ + if ((ptrLen < 10) || (numCrossings < 40)) { + if (doStats) { + RendererContext.stats.hist_rdr_crossings + .add(numCrossings); + RendererContext.stats.hist_rdr_crossings_adds + .add(ptrLen); + } + + /* + * threshold to use binary insertion sort instead of + * straight insertion sort (to reduce minimize comparisons). + */ + useBinarySearch = (numCrossings >= 20); + + // if small enough: + lastCross = _MIN_VALUE; + + for (i = 0; i < numCrossings; i++) { + // get the pointer to the edge + ecur = _edgePtrs[i]; + + /* convert subpixel coordinates (float) into pixel + positions (int) for coming scanline */ + /* note: it is faster to always update edges even + if it is removed from AEL for coming or last scanline */ + + // random access so use unsafe: + addr = addr0 + ecur; // ecur + OFF_F_CURX + + // get current crossing: + curx = _unsafe.getInt(addr); + + // update crossing with orientation at last bit: + cross = curx; + + // Increment x using DDA (fixed point): + curx += _unsafe.getInt(addr + _OFF_BUMP_X); + + // Increment error: + err = _unsafe.getInt(addr + _OFF_ERROR) + + _unsafe.getInt(addr + _OFF_BUMP_ERR); + + // Manual carry handling: + // keep sign and carry bit only and ignore last bit (preserve orientation): + _unsafe.putInt(addr, curx - ((err >> 30) & _ALL_BUT_LSB)); + _unsafe.putInt(addr + _OFF_ERROR, (err & _ERR_STEP_MAX)); + + if (doStats) { + RendererContext.stats.stat_rdr_crossings_updates + .add(numCrossings); + } + + // insertion sort of crossings: + if (cross < lastCross) { + if (doStats) { + RendererContext.stats.stat_rdr_crossings_sorts + .add(i); + } + + /* use binary search for newly added edges + in crossings if arrays are large enough */ + if (useBinarySearch && (i >= prevNumCrossings)) { + if (doStats) { + RendererContext.stats. + stat_rdr_crossings_bsearch.add(i); + } + low = 0; + high = i - 1; + + do { + // note: use signed shift (not >>>) for performance + // as indices are small enough to exceed Integer.MAX_VALUE + mid = (low + high) >> 1; + + if (_crossings[mid] < cross) { + low = mid + 1; + } else { + high = mid - 1; + } + } while (low <= high); + + for (j = i - 1; j >= low; j--) { + _crossings[j + 1] = _crossings[j]; + _edgePtrs [j + 1] = _edgePtrs[j]; + } + _crossings[low] = cross; + _edgePtrs [low] = ecur; + + } else { + j = i - 1; + _crossings[i] = _crossings[j]; + _edgePtrs[i] = _edgePtrs[j]; + + while ((--j >= 0) && (_crossings[j] > cross)) { + _crossings[j + 1] = _crossings[j]; + _edgePtrs [j + 1] = _edgePtrs[j]; + } + _crossings[j + 1] = cross; + _edgePtrs [j + 1] = ecur; + } + + } else { + _crossings[i] = lastCross = cross; + } + } + } else { + if (doStats) { + RendererContext.stats.stat_rdr_crossings_msorts + .add(numCrossings); + RendererContext.stats.hist_rdr_crossings_ratio + .add((1000 * ptrLen) / numCrossings); + RendererContext.stats.hist_rdr_crossings_msorts + .add(numCrossings); + RendererContext.stats.hist_rdr_crossings_msorts_adds + .add(ptrLen); + } + + // Copy sorted data in auxiliary arrays + // and perform insertion sort on almost sorted data + // (ie i < prevNumCrossings): + + lastCross = _MIN_VALUE; + + for (i = 0; i < numCrossings; i++) { + // get the pointer to the edge + ecur = _edgePtrs[i]; + + /* convert subpixel coordinates (float) into pixel + positions (int) for coming scanline */ + /* note: it is faster to always update edges even + if it is removed from AEL for coming or last scanline */ + + // random access so use unsafe: + addr = addr0 + ecur; // ecur + OFF_F_CURX + + // get current crossing: + curx = _unsafe.getInt(addr); + + // update crossing with orientation at last bit: + cross = curx; + + // Increment x using DDA (fixed point): + curx += _unsafe.getInt(addr + _OFF_BUMP_X); + + // Increment error: + err = _unsafe.getInt(addr + _OFF_ERROR) + + _unsafe.getInt(addr + _OFF_BUMP_ERR); + + // Manual carry handling: + // keep sign and carry bit only and ignore last bit (preserve orientation): + _unsafe.putInt(addr, curx - ((err >> 30) & _ALL_BUT_LSB)); + _unsafe.putInt(addr + _OFF_ERROR, (err & _ERR_STEP_MAX)); + + if (doStats) { + RendererContext.stats.stat_rdr_crossings_updates + .add(numCrossings); + } + + if (i >= prevNumCrossings) { + // simply store crossing as edgePtrs is in-place: + // will be copied and sorted efficiently by mergesort later: + _crossings[i] = cross; + + } else if (cross < lastCross) { + if (doStats) { + RendererContext.stats.stat_rdr_crossings_sorts + .add(i); + } + + // (straight) insertion sort of crossings: + j = i - 1; + _aux_crossings[i] = _aux_crossings[j]; + _aux_edgePtrs[i] = _aux_edgePtrs[j]; + + while ((--j >= 0) && (_aux_crossings[j] > cross)) { + _aux_crossings[j + 1] = _aux_crossings[j]; + _aux_edgePtrs [j + 1] = _aux_edgePtrs[j]; + } + _aux_crossings[j + 1] = cross; + _aux_edgePtrs [j + 1] = ecur; + + } else { + // auxiliary storage: + _aux_crossings[i] = lastCross = cross; + _aux_edgePtrs [i] = ecur; + } + } + + // use Mergesort using auxiliary arrays (sort only right part) + MergeSort.mergeSortNoCopy(_crossings, _edgePtrs, + _aux_crossings, _aux_edgePtrs, + numCrossings, prevNumCrossings); + } + + // reset ptrLen + ptrLen = 0; + // --- from former ScanLineIterator.next() + + + /* note: bboxx0 and bboxx1 must be pixel boundaries + to have correct coverage computation */ + + // right shift on crossings to get the x-coordinate: + curxo = _crossings[0]; + x0 = curxo >> 1; + if (x0 < minX) { + minX = x0; // subpixel coordinate + } + + x1 = _crossings[numCrossings - 1] >> 1; + if (x1 > maxX) { + maxX = x1; // subpixel coordinate + } + + + // compute pixel coverages + prev = curx = x0; + // to turn {0, 1} into {-1, 1}, multiply by 2 and subtract 1. + // last bit contains orientation (0 or 1) + crorientation = ((curxo & 0x1) << 1) - 1; + + if (windingRuleEvenOdd) { + sum = crorientation; + + // Even Odd winding rule: take care of mask ie sum(orientations) + for (i = 1; i < numCrossings; i++) { + curxo = _crossings[i]; + curx = curxo >> 1; + // to turn {0, 1} into {-1, 1}, multiply by 2 and subtract 1. + // last bit contains orientation (0 or 1) + crorientation = ((curxo & 0x1) << 1) - 1; + + if ((sum & 0x1) != 0) { + // TODO: perform line clipping on left-right sides + // to avoid such bound checks: + x0 = (prev > bboxx0) ? prev : bboxx0; + x1 = (curx < bboxx1) ? curx : bboxx1; + + if (x0 < x1) { + x0 -= bboxx0; // turn x0, x1 from coords to indices + x1 -= bboxx0; // in the alpha array. + + pix_x = x0 >> _SUBPIXEL_LG_POSITIONS_X; + pix_xmaxm1 = (x1 - 1) >> _SUBPIXEL_LG_POSITIONS_X; + + if (pix_x == pix_xmaxm1) { + // Start and end in same pixel + tmp = (x1 - x0); // number of subpixels + _alpha[pix_x ] += tmp; + _alpha[pix_x + 1] -= tmp; + + if (useBlkFlags) { + // flag used blocks: + _blkFlags[pix_x >> _BLK_SIZE_LG] = 1; + } + } else { + tmp = (x0 & _SUBPIXEL_MASK_X); + _alpha[pix_x ] + += (_SUBPIXEL_POSITIONS_X - tmp); + _alpha[pix_x + 1] + += tmp; + + pix_xmax = x1 >> _SUBPIXEL_LG_POSITIONS_X; + + tmp = (x1 & _SUBPIXEL_MASK_X); + _alpha[pix_xmax ] + -= (_SUBPIXEL_POSITIONS_X - tmp); + _alpha[pix_xmax + 1] + -= tmp; + + if (useBlkFlags) { + // flag used blocks: + _blkFlags[pix_x >> _BLK_SIZE_LG] = 1; + _blkFlags[pix_xmax >> _BLK_SIZE_LG] = 1; + } + } + } + } + + sum += crorientation; + prev = curx; + } + } else { + // Non-zero winding rule: optimize that case (default) + // and avoid processing intermediate crossings + for (i = 1, sum = 0;; i++) { + sum += crorientation; + + if (sum != 0) { + // prev = min(curx) + if (prev > curx) { + prev = curx; + } + } else { + // TODO: perform line clipping on left-right sides + // to avoid such bound checks: + x0 = (prev > bboxx0) ? prev : bboxx0; + x1 = (curx < bboxx1) ? curx : bboxx1; + + if (x0 < x1) { + x0 -= bboxx0; // turn x0, x1 from coords to indices + x1 -= bboxx0; // in the alpha array. + + pix_x = x0 >> _SUBPIXEL_LG_POSITIONS_X; + pix_xmaxm1 = (x1 - 1) >> _SUBPIXEL_LG_POSITIONS_X; + + if (pix_x == pix_xmaxm1) { + // Start and end in same pixel + tmp = (x1 - x0); // number of subpixels + _alpha[pix_x ] += tmp; + _alpha[pix_x + 1] -= tmp; + + if (useBlkFlags) { + // flag used blocks: + _blkFlags[pix_x >> _BLK_SIZE_LG] = 1; + } + } else { + tmp = (x0 & _SUBPIXEL_MASK_X); + _alpha[pix_x ] + += (_SUBPIXEL_POSITIONS_X - tmp); + _alpha[pix_x + 1] + += tmp; + + pix_xmax = x1 >> _SUBPIXEL_LG_POSITIONS_X; + + tmp = (x1 & _SUBPIXEL_MASK_X); + _alpha[pix_xmax ] + -= (_SUBPIXEL_POSITIONS_X - tmp); + _alpha[pix_xmax + 1] + -= tmp; + + if (useBlkFlags) { + // flag used blocks: + _blkFlags[pix_x >> _BLK_SIZE_LG] = 1; + _blkFlags[pix_xmax >> _BLK_SIZE_LG] = 1; + } + } + } + prev = _MAX_VALUE; + } + + if (i == numCrossings) { + break; + } + + curxo = _crossings[i]; + curx = curxo >> 1; + // to turn {0, 1} into {-1, 1}, multiply by 2 and subtract 1. + // last bit contains orientation (0 or 1) + crorientation = ((curxo & 0x1) << 1) - 1; + } + } + } // numCrossings > 0 + + // even if this last row had no crossings, alpha will be zeroed + // from the last emitRow call. But this doesn't matter because + // maxX < minX, so no row will be emitted to the MarlinCache. + if ((y & _SUBPIXEL_MASK_Y) == _SUBPIXEL_MASK_Y) { + lastY = y >> _SUBPIXEL_LG_POSITIONS_Y; + + // convert subpixel to pixel coordinate within boundaries: + minX = FloatMath.max(minX, bboxx0) >> _SUBPIXEL_LG_POSITIONS_X; + maxX = FloatMath.min(maxX, bboxx1) >> _SUBPIXEL_LG_POSITIONS_X; + + if (maxX >= minX) { + // note: alpha array will be zeroed by copyAARow() + // +2 because alpha [pix_minX; pix_maxX+1] + // fix range [x0; x1[ + copyAARow(_alpha, lastY, minX, maxX + 2, useBlkFlags); + + // speculative for next pixel row (scanline coherence): + if (_enableBlkFlagsHeuristics) { + // Use block flags if large pixel span and few crossings: + // ie mean(distance between crossings) is larger than + // 1 block size; + + // fast check width: + maxX -= minX; + + // if stroking: numCrossings /= 2 + // => shift numCrossings by 1 + // condition = (width / (numCrossings - 1)) > blockSize + useBlkFlags = (maxX > _BLK_SIZE) && (maxX > + (((numCrossings >> stroking) - 1) << _BLK_SIZE_LG)); + + if (doStats) { + tmp = FloatMath.max(1, + ((numCrossings >> stroking) - 1)); + RendererContext.stats.hist_tile_generator_encoding_dist + .add(maxX / tmp); + } + } + } else { + _cache.clearAARow(lastY); + } + minX = _MAX_VALUE; + maxX = _MIN_VALUE; + } + } // scan line iterator + + // Emit final row + y--; + y >>= _SUBPIXEL_LG_POSITIONS_Y; + + // convert subpixel to pixel coordinate within boundaries: + minX = FloatMath.max(minX, bboxx0) >> _SUBPIXEL_LG_POSITIONS_X; + maxX = FloatMath.min(maxX, bboxx1) >> _SUBPIXEL_LG_POSITIONS_X; + + if (maxX >= minX) { + // note: alpha array will be zeroed by copyAARow() + // +2 because alpha [pix_minX; pix_maxX+1] + // fix range [x0; x1[ + copyAARow(_alpha, y, minX, maxX + 2, useBlkFlags); + } else if (y != lastY) { + _cache.clearAARow(y); + } + + // update member: + edgeCount = numCrossings; + prevUseBlkFlags = useBlkFlags; + + if (doStats) { + // update max used mark + activeEdgeMaxUsed = _arrayMaxUsed; + } + } + + boolean endRendering() { + if (doMonitors) { + RendererContext.stats.mon_rdr_endRendering.start(); + } + if (edgeMinY == Integer.MAX_VALUE) { + return false; // undefined edges bounds + } + + final int _boundsMinY = boundsMinY; + final int _boundsMaxY = boundsMaxY; + + // bounds as inclusive intervals + final int spminX = FloatMath.max(FloatMath.ceil_int(edgeMinX - 0.5f), boundsMinX); + final int spmaxX = FloatMath.min(FloatMath.ceil_int(edgeMaxX - 0.5f), boundsMaxX - 1); + + // edge Min/Max Y are already rounded to subpixels within bounds: + final int spminY = edgeMinY; + final int spmaxY; + int maxY = edgeMaxY; + + if (maxY <= _boundsMaxY - 1) { + spmaxY = maxY; + } else { + spmaxY = _boundsMaxY - 1; + maxY = _boundsMaxY; + } + buckets_minY = spminY - _boundsMinY; + buckets_maxY = maxY - _boundsMinY; + + if (doLogBounds) { + MarlinUtils.logInfo("edgesXY = [" + edgeMinX + " ... " + edgeMaxX + + "][" + edgeMinY + " ... " + edgeMaxY + "]"); + MarlinUtils.logInfo("spXY = [" + spminX + " ... " + spmaxX + + "][" + spminY + " ... " + spmaxY + "]"); + } + + // test clipping for shapes out of bounds + if ((spminX > spmaxX) || (spminY > spmaxY)) { + return false; + } + + // half open intervals + // inclusive: + final int pminX = spminX >> SUBPIXEL_LG_POSITIONS_X; + // exclusive: + final int pmaxX = (spmaxX + SUBPIXEL_MASK_X) >> SUBPIXEL_LG_POSITIONS_X; + // inclusive: + final int pminY = spminY >> SUBPIXEL_LG_POSITIONS_Y; + // exclusive: + final int pmaxY = (spmaxY + SUBPIXEL_MASK_Y) >> SUBPIXEL_LG_POSITIONS_Y; + + // store BBox to answer ptg.getBBox(): + this.cache.init(pminX, pminY, pmaxX, pmaxY, edgeSumDeltaY); + + // Heuristics for using block flags: + if (ENABLE_BLOCK_FLAGS) { + enableBlkFlags = this.cache.useRLE; + prevUseBlkFlags = enableBlkFlags && !ENABLE_BLOCK_FLAGS_HEURISTICS; + + if (enableBlkFlags) { + // ensure blockFlags array is large enough: + // note: +2 to ensure enough space left at end + final int nxTiles = ((pmaxX - pminX) >> TILE_SIZE_LG) + 2; + if (nxTiles > INITIAL_ARRAY) { + blkFlags = rdrCtx.getIntArray(nxTiles); + } + } + } + + // memorize the rendering bounding box: + /* note: bbox_spminX and bbox_spmaxX must be pixel boundaries + to have correct coverage computation */ + // inclusive: + bbox_spminX = pminX << SUBPIXEL_LG_POSITIONS_X; + // exclusive: + bbox_spmaxX = pmaxX << SUBPIXEL_LG_POSITIONS_X; + // inclusive: + bbox_spminY = spminY; + // exclusive: + bbox_spmaxY = FloatMath.min(spmaxY + 1, pmaxY << SUBPIXEL_LG_POSITIONS_Y); + + if (doLogBounds) { + MarlinUtils.logInfo("pXY = [" + pminX + " ... " + pmaxX + + "[ [" + pminY + " ... " + pmaxY + "["); + MarlinUtils.logInfo("bbox_spXY = [" + bbox_spminX + " ... " + + bbox_spmaxX + "[ [" + bbox_spminY + " ... " + + bbox_spmaxY + "["); + } + + // Prepare alpha line: + // add 2 to better deal with the last pixel in a pixel row. + final int width = (pmaxX - pminX) + 2; + + // Useful when processing tile line by tile line + if (width > INITIAL_AA_ARRAY) { + if (doStats) { + RendererContext.stats.stat_array_renderer_alphaline + .add(width); + } + alphaLine = rdrCtx.getIntArray(width); + } + + // process first tile line: + endRendering(pminY); + + return true; + } + + private int bbox_spminX, bbox_spmaxX, bbox_spminY, bbox_spmaxY; + + void endRendering(final int pminY) { + if (doMonitors) { + RendererContext.stats.mon_rdr_endRendering_Y.start(); + } + + final int spminY = pminY << SUBPIXEL_LG_POSITIONS_Y; + final int fixed_spminY = FloatMath.max(bbox_spminY, spminY); + + // avoid rendering for last call to nextTile() + if (fixed_spminY < bbox_spmaxY) { + // process a complete tile line ie scanlines for 32 rows + final int spmaxY = FloatMath.min(bbox_spmaxY, spminY + SUBPIXEL_TILE); + + // process tile line [0 - 32] + cache.resetTileLine(pminY); + + // Process only one tile line: + _endRendering(fixed_spminY, spmaxY); + } + if (doMonitors) { + RendererContext.stats.mon_rdr_endRendering_Y.stop(); + } + } + + private boolean enableBlkFlags = false; + private boolean prevUseBlkFlags = false; + + private final int[] blkFlags_initial = new int[INITIAL_ARRAY]; // 1 tile line + /* block flags (0|1) */ + private int[] blkFlags = blkFlags_initial; + + void copyAARow(final int[] alphaRow, + final int pix_y, final int pix_from, final int pix_to, + final boolean useBlockFlags) + { + if (useBlockFlags) { + if (doStats) { + RendererContext.stats.hist_tile_generator_encoding.add(1); + } + cache.copyAARowRLE_WithBlockFlags(blkFlags, alphaRow, pix_y, pix_from, pix_to); + } else { + if (doStats) { + RendererContext.stats.hist_tile_generator_encoding.add(0); + } + cache.copyAARowNoRLE(alphaRow, pix_y, pix_from, pix_to); + } + } +} diff --git a/src/share/classes/sun/java2d/marlin/RendererContext.java b/src/share/classes/sun/java2d/marlin/RendererContext.java new file mode 100644 index 0000000000000000000000000000000000000000..461cc0870c284dc693bd327893cd2d6e84c0a0cd --- /dev/null +++ b/src/share/classes/sun/java2d/marlin/RendererContext.java @@ -0,0 +1,448 @@ +/* + * 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. 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.java2d.marlin; + +import java.awt.geom.Path2D; +import java.lang.ref.WeakReference; +import java.util.concurrent.atomic.AtomicInteger; +import sun.java2d.ReentrantContext; +import sun.java2d.ReentrantContextProvider; +import static sun.java2d.marlin.ArrayCache.*; +import sun.java2d.marlin.MarlinRenderingEngine.NormalizingPathIterator; +import static sun.java2d.marlin.MarlinUtils.logInfo; + +/** + * This class is a renderer context dedicated to a single thread + */ +final class RendererContext extends ReentrantContext implements MarlinConst { + + // RendererContext creation counter + private static final AtomicInteger contextCount = new AtomicInteger(1); + // RendererContext statistics + static final RendererStats stats = (doStats || doMonitors) + ? RendererStats.getInstance(): null; + + private static final boolean USE_CACHE_HARD_REF = doStats + || (MarlinRenderingEngine.REF_TYPE == ReentrantContextProvider.REF_WEAK); + + /** + * Create a new renderer context + * + * @return new RendererContext instance + */ + static RendererContext createContext() { + final RendererContext newCtx = new RendererContext("ctx" + + Integer.toString(contextCount.getAndIncrement())); + + if (RendererContext.stats != null) { + RendererContext.stats.allContexts.add(newCtx); + } + return newCtx; + } + + // context name (debugging purposes) + final String name; + // dirty flag indicating an exception occured during pipeline in pathTo() + boolean dirty = false; + // dynamic array caches kept using weak reference (low memory footprint) + WeakReference refArrayCaches = null; + // hard reference to array caches (for statistics) + ArrayCachesHolder hardRefArrayCaches = null; + // shared data + final float[] float6 = new float[6]; + // shared curve (dirty) (Renderer / Stroker) + final Curve curve = new Curve(); + // MarlinRenderingEngine NormalizingPathIterator NearestPixelCenter: + final NormalizingPathIterator nPCPathIterator; + // MarlinRenderingEngine NearestPixelQuarter NormalizingPathIterator: + final NormalizingPathIterator nPQPathIterator; + // MarlinRenderingEngine.TransformingPathConsumer2D + final TransformingPathConsumer2D transformerPC2D; + // recycled Path2D instance + Path2D.Float p2d = null; + final Renderer renderer; + final Stroker stroker; + // Simplifies out collinear lines + final CollinearSimplifier simplifier = new CollinearSimplifier(); + final Dasher dasher; + final MarlinTileGenerator ptg; + final MarlinCache cache; + // flag indicating the shape is stroked (1) or filled (0) + int stroking = 0; + + /** + * Constructor + * + * @param name context name (debugging) + */ + RendererContext(final String name) { + if (logCreateContext) { + MarlinUtils.logInfo("new RendererContext = " + name); + } + + this.name = name; + + // NormalizingPathIterator instances: + nPCPathIterator = new NormalizingPathIterator.NearestPixelCenter(float6); + nPQPathIterator = new NormalizingPathIterator.NearestPixelQuarter(float6); + + // MarlinRenderingEngine.TransformingPathConsumer2D + transformerPC2D = new TransformingPathConsumer2D(); + + // Renderer: + cache = new MarlinCache(this); + renderer = new Renderer(this); // needs MarlinCache from rdrCtx.cache + ptg = new MarlinTileGenerator(renderer); + + stroker = new Stroker(this); + dasher = new Dasher(this); + } + + /** + * Disposes this renderer context: + * clean up before reusing this context + */ + void dispose() { + stroking = 0; + // reset hard reference to array caches if needed: + if (!USE_CACHE_HARD_REF) { + hardRefArrayCaches = null; + } + // if context is maked as DIRTY: + if (dirty) { + // may happen if an exception if thrown in the pipeline processing: + // force cleanup of all possible pipelined blocks (except Renderer): + + // NormalizingPathIterator instances: + this.nPCPathIterator.dispose(); + this.nPQPathIterator.dispose(); + // Dasher: + this.dasher.dispose(); + // Stroker: + this.stroker.dispose(); + + // mark context as CLEAN: + dirty = false; + } + } + + // Array caches + ArrayCachesHolder getArrayCachesHolder() { + // Use hard reference first (cached resolved weak reference): + ArrayCachesHolder holder = hardRefArrayCaches; + if (holder == null) { + // resolve reference: + holder = (refArrayCaches != null) + ? refArrayCaches.get() + : null; + // create a new ArrayCachesHolder if none is available + if (holder == null) { + if (logCreateContext) { + MarlinUtils.logInfo("new ArrayCachesHolder for " + + "RendererContext = " + name); + } + + holder = new ArrayCachesHolder(); + + if (USE_CACHE_HARD_REF) { + // update hard reference: + hardRefArrayCaches = holder; + } + + // update weak reference: + refArrayCaches = new WeakReference(holder); + } + } + return holder; + } + + // dirty byte array cache + ByteArrayCache getDirtyByteArrayCache(final int length) { + final int bucket = ArrayCache.getBucketDirtyBytes(length); + return getArrayCachesHolder().dirtyByteArrayCaches[bucket]; + } + + byte[] getDirtyByteArray(final int length) { + if (length <= MAX_DIRTY_BYTE_ARRAY_SIZE) { + return getDirtyByteArrayCache(length).getArray(); + } + + if (doStats) { + incOversize(); + } + + if (doLogOverSize) { + logInfo("getDirtyByteArray[oversize]: length=\t" + length); + } + + return new byte[length]; + } + + void putDirtyByteArray(final byte[] array) { + final int length = array.length; + // odd sized array are non-cached arrays (initial arrays) + // ensure to never store initial arrays in cache: + if (((length & 0x1) == 0) && (length <= MAX_DIRTY_BYTE_ARRAY_SIZE)) { + getDirtyByteArrayCache(length).putDirtyArray(array, length); + } + } + + byte[] widenDirtyByteArray(final byte[] in, + final int usedSize, final int needSize) + { + final int length = in.length; + if (doChecks && length >= needSize) { + return in; + } + if (doStats) { + incResizeDirtyByte(); + } + + // maybe change bucket: + // ensure getNewSize() > newSize: + final byte[] res = getDirtyByteArray(getNewSize(usedSize, needSize)); + + System.arraycopy(in, 0, res, 0, usedSize); // copy only used elements + + // maybe return current array: + // NO clean-up of array data = DIRTY ARRAY + putDirtyByteArray(in); + + if (doLogWidenArray) { + logInfo("widenDirtyByteArray[" + res.length + "]: usedSize=\t" + + usedSize + "\tlength=\t" + length + "\tneeded length=\t" + + needSize); + } + return res; + } + + // int array cache + IntArrayCache getIntArrayCache(final int length) { + final int bucket = ArrayCache.getBucket(length); + return getArrayCachesHolder().intArrayCaches[bucket]; + } + + int[] getIntArray(final int length) { + if (length <= MAX_ARRAY_SIZE) { + return getIntArrayCache(length).getArray(); + } + + if (doStats) { + incOversize(); + } + + if (doLogOverSize) { + logInfo("getIntArray[oversize]: length=\t" + length); + } + + return new int[length]; + } + + // unused + int[] widenIntArray(final int[] in, final int usedSize, + final int needSize, final int clearTo) + { + final int length = in.length; + if (doChecks && length >= needSize) { + return in; + } + if (doStats) { + incResizeInt(); + } + + // maybe change bucket: + // ensure getNewSize() > newSize: + final int[] res = getIntArray(getNewSize(usedSize, needSize)); + + System.arraycopy(in, 0, res, 0, usedSize); // copy only used elements + + // maybe return current array: + putIntArray(in, 0, clearTo); // ensure all array is cleared (grow-reduce algo) + + if (doLogWidenArray) { + logInfo("widenIntArray[" + res.length + "]: usedSize=\t" + + usedSize + "\tlength=\t" + length + "\tneeded length=\t" + + needSize); + } + return res; + } + + void putIntArray(final int[] array, final int fromIndex, + final int toIndex) + { + final int length = array.length; + // odd sized array are non-cached arrays (initial arrays) + // ensure to never store initial arrays in cache: + if (((length & 0x1) == 0) && (length <= MAX_ARRAY_SIZE)) { + getIntArrayCache(length).putArray(array, length, fromIndex, toIndex); + } + } + + // dirty int array cache + IntArrayCache getDirtyIntArrayCache(final int length) { + final int bucket = ArrayCache.getBucket(length); + return getArrayCachesHolder().dirtyIntArrayCaches[bucket]; + } + + int[] getDirtyIntArray(final int length) { + if (length <= MAX_ARRAY_SIZE) { + return getDirtyIntArrayCache(length).getArray(); + } + + if (doStats) { + incOversize(); + } + + if (doLogOverSize) { + logInfo("getDirtyIntArray[oversize]: length=\t" + length); + } + + return new int[length]; + } + + int[] widenDirtyIntArray(final int[] in, + final int usedSize, final int needSize) + { + final int length = in.length; + if (doChecks && length >= needSize) { + return in; + } + if (doStats) { + incResizeDirtyInt(); + } + + // maybe change bucket: + // ensure getNewSize() > newSize: + final int[] res = getDirtyIntArray(getNewSize(usedSize, needSize)); + + System.arraycopy(in, 0, res, 0, usedSize); // copy only used elements + + // maybe return current array: + // NO clean-up of array data = DIRTY ARRAY + putDirtyIntArray(in); + + if (doLogWidenArray) { + logInfo("widenDirtyIntArray[" + res.length + "]: usedSize=\t" + + usedSize + "\tlength=\t" + length + "\tneeded length=\t" + + needSize); + } + return res; + } + + void putDirtyIntArray(final int[] array) { + final int length = array.length; + // odd sized array are non-cached arrays (initial arrays) + // ensure to never store initial arrays in cache: + if (((length & 0x1) == 0) && (length <= MAX_ARRAY_SIZE)) { + getDirtyIntArrayCache(length).putDirtyArray(array, length); + } + } + + // dirty float array cache + FloatArrayCache getDirtyFloatArrayCache(final int length) { + final int bucket = ArrayCache.getBucket(length); + return getArrayCachesHolder().dirtyFloatArrayCaches[bucket]; + } + + float[] getDirtyFloatArray(final int length) { + if (length <= MAX_ARRAY_SIZE) { + return getDirtyFloatArrayCache(length).getArray(); + } + + if (doStats) { + incOversize(); + } + + if (doLogOverSize) { + logInfo("getDirtyFloatArray[oversize]: length=\t" + length); + } + + return new float[length]; + } + + float[] widenDirtyFloatArray(final float[] in, + final int usedSize, final int needSize) + { + final int length = in.length; + if (doChecks && length >= needSize) { + return in; + } + if (doStats) { + incResizeDirtyFloat(); + } + + // maybe change bucket: + // ensure getNewSize() > newSize: + final float[] res = getDirtyFloatArray(getNewSize(usedSize, needSize)); + + System.arraycopy(in, 0, res, 0, usedSize); // copy only used elements + + // maybe return current array: + // NO clean-up of array data = DIRTY ARRAY + putDirtyFloatArray(in); + + if (doLogWidenArray) { + logInfo("widenDirtyFloatArray[" + res.length + "]: usedSize=\t" + + usedSize + "\tlength=\t" + length + "\tneeded length=\t" + + needSize); + } + return res; + } + + void putDirtyFloatArray(final float[] array) { + final int length = array.length; + // odd sized array are non-cached arrays (initial arrays) + // ensure to never store initial arrays in cache: + if (((length & 0x1) == 0) && (length <= MAX_ARRAY_SIZE)) { + getDirtyFloatArrayCache(length).putDirtyArray(array, length); + } + } + + /* class holding all array cache instances */ + static final class ArrayCachesHolder { + // zero-filled int array cache: + final IntArrayCache[] intArrayCaches; + // dirty array caches: + final IntArrayCache[] dirtyIntArrayCaches; + final FloatArrayCache[] dirtyFloatArrayCaches; + final ByteArrayCache[] dirtyByteArrayCaches; + + ArrayCachesHolder() { + intArrayCaches = new IntArrayCache[BUCKETS]; + dirtyIntArrayCaches = new IntArrayCache[BUCKETS]; + dirtyFloatArrayCaches = new FloatArrayCache[BUCKETS]; + dirtyByteArrayCaches = new ByteArrayCache[BUCKETS]; + + for (int i = 0; i < BUCKETS; i++) { + intArrayCaches[i] = new IntArrayCache(ARRAY_SIZES[i]); + // dirty array caches: + dirtyIntArrayCaches[i] = new IntArrayCache(ARRAY_SIZES[i]); + dirtyFloatArrayCaches[i] = new FloatArrayCache(ARRAY_SIZES[i]); + dirtyByteArrayCaches[i] = new ByteArrayCache(DIRTY_BYTE_ARRAY_SIZES[i]); + } + } + } +} diff --git a/src/share/classes/sun/java2d/marlin/RendererStats.java b/src/share/classes/sun/java2d/marlin/RendererStats.java new file mode 100644 index 0000000000000000000000000000000000000000..11520d77facd53f24bd2150de1b61ee6ecc2ecf9 --- /dev/null +++ b/src/share/classes/sun/java2d/marlin/RendererStats.java @@ -0,0 +1,333 @@ +/* + * 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. 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.java2d.marlin; + +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.ConcurrentLinkedQueue; +import static sun.java2d.marlin.MarlinUtils.logInfo; +import sun.java2d.marlin.stats.Histogram; +import sun.java2d.marlin.stats.Monitor; +import sun.java2d.marlin.stats.StatLong; +import sun.misc.ThreadGroupUtils; + +/** + * This class gathers global rendering statistics for debugging purposes only + */ +public final class RendererStats implements MarlinConst { + + // singleton + private static volatile RendererStats singleton = null; + + static RendererStats getInstance() { + if (singleton == null) { + singleton = new RendererStats(); + } + return singleton; + } + + public static void dumpStats() { + if (singleton != null) { + singleton.dump(); + } + } + + /* RendererContext collection as hard references + (only used for debugging purposes) */ + final ConcurrentLinkedQueue allContexts + = new ConcurrentLinkedQueue(); + // stats + final StatLong stat_cache_rowAA + = new StatLong("cache.rowAA"); + final StatLong stat_cache_rowAAChunk + = new StatLong("cache.rowAAChunk"); + final StatLong stat_cache_tiles + = new StatLong("cache.tiles"); + final StatLong stat_rdr_poly_stack_curves + = new StatLong("renderer.poly.stack.curves"); + final StatLong stat_rdr_poly_stack_types + = new StatLong("renderer.poly.stack.types"); + final StatLong stat_rdr_addLine + = new StatLong("renderer.addLine"); + final StatLong stat_rdr_addLine_skip + = new StatLong("renderer.addLine.skip"); + final StatLong stat_rdr_curveBreak + = new StatLong("renderer.curveBreakIntoLinesAndAdd"); + final StatLong stat_rdr_curveBreak_dec + = new StatLong("renderer.curveBreakIntoLinesAndAdd.dec"); + final StatLong stat_rdr_curveBreak_inc + = new StatLong("renderer.curveBreakIntoLinesAndAdd.inc"); + final StatLong stat_rdr_quadBreak + = new StatLong("renderer.quadBreakIntoLinesAndAdd"); + final StatLong stat_rdr_quadBreak_dec + = new StatLong("renderer.quadBreakIntoLinesAndAdd.dec"); + final StatLong stat_rdr_edges + = new StatLong("renderer.edges"); + final StatLong stat_rdr_edges_count + = new StatLong("renderer.edges.count"); + final StatLong stat_rdr_edges_resizes + = new StatLong("renderer.edges.resize"); + final StatLong stat_rdr_activeEdges + = new StatLong("renderer.activeEdges"); + final StatLong stat_rdr_activeEdges_updates + = new StatLong("renderer.activeEdges.updates"); + final StatLong stat_rdr_activeEdges_adds + = new StatLong("renderer.activeEdges.adds"); + final StatLong stat_rdr_activeEdges_adds_high + = new StatLong("renderer.activeEdges.adds_high"); + final StatLong stat_rdr_crossings_updates + = new StatLong("renderer.crossings.updates"); + final StatLong stat_rdr_crossings_sorts + = new StatLong("renderer.crossings.sorts"); + final StatLong stat_rdr_crossings_bsearch + = new StatLong("renderer.crossings.bsearch"); + final StatLong stat_rdr_crossings_msorts + = new StatLong("renderer.crossings.msorts"); + // growable arrays + final StatLong stat_array_dasher_dasher + = new StatLong("array.dasher.dasher.d_float"); + final StatLong stat_array_dasher_firstSegmentsBuffer + = new StatLong("array.dasher.firstSegmentsBuffer.d_float"); + final StatLong stat_array_stroker_polystack_curves + = new StatLong("array.stroker.polystack.curves.d_float"); + final StatLong stat_array_stroker_polystack_curveTypes + = new StatLong("array.stroker.polystack.curveTypes.d_byte"); + final StatLong stat_array_marlincache_rowAAChunk + = new StatLong("array.marlincache.rowAAChunk.d_byte"); + final StatLong stat_array_marlincache_touchedTile + = new StatLong("array.marlincache.touchedTile.int"); + final StatLong stat_array_renderer_alphaline + = new StatLong("array.renderer.alphaline.int"); + final StatLong stat_array_renderer_crossings + = new StatLong("array.renderer.crossings.int"); + final StatLong stat_array_renderer_aux_crossings + = new StatLong("array.renderer.aux_crossings.int"); + final StatLong stat_array_renderer_edgeBuckets + = new StatLong("array.renderer.edgeBuckets.int"); + final StatLong stat_array_renderer_edgeBucketCounts + = new StatLong("array.renderer.edgeBucketCounts.int"); + final StatLong stat_array_renderer_edgePtrs + = new StatLong("array.renderer.edgePtrs.int"); + final StatLong stat_array_renderer_aux_edgePtrs + = new StatLong("array.renderer.aux_edgePtrs.int"); + // histograms + final Histogram hist_rdr_crossings + = new Histogram("renderer.crossings"); + final Histogram hist_rdr_crossings_ratio + = new Histogram("renderer.crossings.ratio"); + final Histogram hist_rdr_crossings_adds + = new Histogram("renderer.crossings.adds"); + final Histogram hist_rdr_crossings_msorts + = new Histogram("renderer.crossings.msorts"); + final Histogram hist_rdr_crossings_msorts_adds + = new Histogram("renderer.crossings.msorts.adds"); + final Histogram hist_tile_generator_alpha + = new Histogram("tile_generator.alpha"); + final Histogram hist_tile_generator_encoding + = new Histogram("tile_generator.encoding"); + final Histogram hist_tile_generator_encoding_dist + = new Histogram("tile_generator.encoding.dist"); + final Histogram hist_tile_generator_encoding_ratio + = new Histogram("tile_generator.encoding.ratio"); + final Histogram hist_tile_generator_encoding_runLen + = new Histogram("tile_generator.encoding.runLen"); + // all stats + final StatLong[] statistics = new StatLong[]{ + stat_cache_rowAA, + stat_cache_rowAAChunk, + stat_cache_tiles, + stat_rdr_poly_stack_types, + stat_rdr_poly_stack_curves, + stat_rdr_addLine, + stat_rdr_addLine_skip, + stat_rdr_curveBreak, + stat_rdr_curveBreak_dec, + stat_rdr_curveBreak_inc, + stat_rdr_quadBreak, + stat_rdr_quadBreak_dec, + stat_rdr_edges, + stat_rdr_edges_count, + stat_rdr_edges_resizes, + stat_rdr_activeEdges, + stat_rdr_activeEdges_updates, + stat_rdr_activeEdges_adds, + stat_rdr_activeEdges_adds_high, + stat_rdr_crossings_updates, + stat_rdr_crossings_sorts, + stat_rdr_crossings_bsearch, + stat_rdr_crossings_msorts, + hist_rdr_crossings, + hist_rdr_crossings_ratio, + hist_rdr_crossings_adds, + hist_rdr_crossings_msorts, + hist_rdr_crossings_msorts_adds, + hist_tile_generator_alpha, + hist_tile_generator_encoding, + hist_tile_generator_encoding_dist, + hist_tile_generator_encoding_ratio, + hist_tile_generator_encoding_runLen, + stat_array_dasher_dasher, + stat_array_dasher_firstSegmentsBuffer, + stat_array_stroker_polystack_curves, + stat_array_stroker_polystack_curveTypes, + stat_array_marlincache_rowAAChunk, + stat_array_marlincache_touchedTile, + stat_array_renderer_alphaline, + stat_array_renderer_crossings, + stat_array_renderer_aux_crossings, + stat_array_renderer_edgeBuckets, + stat_array_renderer_edgeBucketCounts, + stat_array_renderer_edgePtrs, + stat_array_renderer_aux_edgePtrs + }; + // monitors + final Monitor mon_pre_getAATileGenerator + = new Monitor("MarlinRenderingEngine.getAATileGenerator()"); + final Monitor mon_npi_currentSegment + = new Monitor("NormalizingPathIterator.currentSegment()"); + final Monitor mon_rdr_addLine + = new Monitor("Renderer.addLine()"); + final Monitor mon_rdr_endRendering + = new Monitor("Renderer.endRendering()"); + final Monitor mon_rdr_endRendering_Y + = new Monitor("Renderer._endRendering(Y)"); + final Monitor mon_rdr_copyAARow + = new Monitor("Renderer.copyAARow()"); + final Monitor mon_pipe_renderTiles + = new Monitor("AAShapePipe.renderTiles()"); + final Monitor mon_ptg_getAlpha + = new Monitor("MarlinTileGenerator.getAlpha()"); + final Monitor mon_debug + = new Monitor("DEBUG()"); + // all monitors + final Monitor[] monitors = new Monitor[]{ + mon_pre_getAATileGenerator, + mon_npi_currentSegment, + mon_rdr_addLine, + mon_rdr_endRendering, + mon_rdr_endRendering_Y, + mon_rdr_copyAARow, + mon_pipe_renderTiles, + mon_ptg_getAlpha, + mon_debug + }; + + private RendererStats() { + super(); + + AccessController.doPrivileged( + (PrivilegedAction) () -> { + final Thread hook = new Thread( + ThreadGroupUtils.getRootThreadGroup(), + new Runnable() { + @Override + public void run() { + dump(); + } + }, + "MarlinStatsHook" + ); + hook.setContextClassLoader(null); + Runtime.getRuntime().addShutdownHook(hook); + + if (useDumpThread) { + final Timer statTimer = new Timer("RendererStats"); + statTimer.scheduleAtFixedRate(new TimerTask() { + @Override + public void run() { + dump(); + } + }, statDump, statDump); + } + return null; + } + ); + } + + void dump() { + if (doStats) { + ArrayCache.dumpStats(); + } + final RendererContext[] all = allContexts.toArray( + new RendererContext[allContexts.size()]); + for (RendererContext rdrCtx : all) { + logInfo("RendererContext: " + rdrCtx.name); + + if (doMonitors) { + for (Monitor monitor : monitors) { + if (monitor.count != 0) { + logInfo(monitor.toString()); + } + } + // As getAATileGenerator percents: + final long total = mon_pre_getAATileGenerator.sum; + if (total != 0L) { + for (Monitor monitor : monitors) { + logInfo(monitor.name + " : " + + ((100d * monitor.sum) / total) + " %"); + } + } + if (doFlushMonitors) { + for (Monitor m : monitors) { + m.reset(); + } + } + } + + if (doStats) { + for (StatLong stat : statistics) { + if (stat.count != 0) { + logInfo(stat.toString()); + stat.reset(); + } + } + // IntArrayCaches stats: + final RendererContext.ArrayCachesHolder holder + = rdrCtx.getArrayCachesHolder(); + + logInfo("Array caches for thread: " + rdrCtx.name); + + for (IntArrayCache cache : holder.intArrayCaches) { + cache.dumpStats(); + } + + logInfo("Dirty Array caches for thread: " + rdrCtx.name); + + for (IntArrayCache cache : holder.dirtyIntArrayCaches) { + cache.dumpStats(); + } + for (FloatArrayCache cache : holder.dirtyFloatArrayCaches) { + cache.dumpStats(); + } + for (ByteArrayCache cache : holder.dirtyByteArrayCaches) { + cache.dumpStats(); + } + } + } + } +} diff --git a/src/share/classes/sun/java2d/marlin/Stroker.java b/src/share/classes/sun/java2d/marlin/Stroker.java new file mode 100644 index 0000000000000000000000000000000000000000..2946eda28f064a2cc02241a5baff3efe928d4705 --- /dev/null +++ b/src/share/classes/sun/java2d/marlin/Stroker.java @@ -0,0 +1,1399 @@ +/* + * Copyright (c) 2007, 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. 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.java2d.marlin; + +import java.util.Arrays; +import static java.lang.Math.ulp; +import static java.lang.Math.sqrt; + +import sun.awt.geom.PathConsumer2D; +import sun.java2d.marlin.Curve.BreakPtrIterator; + + +// TODO: some of the arithmetic here is too verbose and prone to hard to +// debug typos. We should consider making a small Point/Vector class that +// has methods like plus(Point), minus(Point), dot(Point), cross(Point)and such +final class Stroker implements PathConsumer2D, MarlinConst { + + private static final int MOVE_TO = 0; + private static final int DRAWING_OP_TO = 1; // ie. curve, line, or quad + private static final int CLOSE = 2; + + /** + * Constant value for join style. + */ + public static final int JOIN_MITER = 0; + + /** + * Constant value for join style. + */ + public static final int JOIN_ROUND = 1; + + /** + * Constant value for join style. + */ + public static final int JOIN_BEVEL = 2; + + /** + * Constant value for end cap style. + */ + public static final int CAP_BUTT = 0; + + /** + * Constant value for end cap style. + */ + public static final int CAP_ROUND = 1; + + /** + * Constant value for end cap style. + */ + public static final int CAP_SQUARE = 2; + + // pisces used to use fixed point arithmetic with 16 decimal digits. I + // didn't want to change the values of the constant below when I converted + // it to floating point, so that's why the divisions by 2^16 are there. + private static final float ROUND_JOIN_THRESHOLD = 1000/65536f; + + private static final float C = 0.5522847498307933f; + + private static final int MAX_N_CURVES = 11; + + private PathConsumer2D out; + + private int capStyle; + private int joinStyle; + + private float lineWidth2; + private float invHalfLineWidth2Sq; + + private final float[] offset0 = new float[2]; + private final float[] offset1 = new float[2]; + private final float[] offset2 = new float[2]; + private final float[] miter = new float[2]; + private float miterLimitSq; + + private int prev; + + // The starting point of the path, and the slope there. + private float sx0, sy0, sdx, sdy; + // the current point and the slope there. + private float cx0, cy0, cdx, cdy; // c stands for current + // vectors that when added to (sx0,sy0) and (cx0,cy0) respectively yield the + // first and last points on the left parallel path. Since this path is + // parallel, it's slope at any point is parallel to the slope of the + // original path (thought they may have different directions), so these + // could be computed from sdx,sdy and cdx,cdy (and vice versa), but that + // would be error prone and hard to read, so we keep these anyway. + private float smx, smy, cmx, cmy; + + private final PolyStack reverse; + + // This is where the curve to be processed is put. We give it + // enough room to store 2 curves: one for the current subdivision, the + // other for the rest of the curve. + private final float[] middle = new float[2 * 8]; + private final float[] lp = new float[8]; + private final float[] rp = new float[8]; + private final float[] subdivTs = new float[MAX_N_CURVES - 1]; + + // per-thread renderer context + final RendererContext rdrCtx; + + // dirty curve + final Curve curve; + + /** + * Constructs a Stroker. + * @param rdrCtx per-thread renderer context + */ + Stroker(final RendererContext rdrCtx) { + this.rdrCtx = rdrCtx; + + this.reverse = new PolyStack(rdrCtx); + this.curve = rdrCtx.curve; + } + + /** + * Inits the Stroker. + * + * @param pc2d an output PathConsumer2D. + * @param lineWidth the desired line width in pixels + * @param capStyle the desired end cap style, one of + * CAP_BUTT, CAP_ROUND or + * CAP_SQUARE. + * @param joinStyle the desired line join style, one of + * JOIN_MITER, JOIN_ROUND or + * JOIN_BEVEL. + * @param miterLimit the desired miter limit + * @return this instance + */ + Stroker init(PathConsumer2D pc2d, + float lineWidth, + int capStyle, + int joinStyle, + float miterLimit) + { + this.out = pc2d; + + this.lineWidth2 = lineWidth / 2f; + this.invHalfLineWidth2Sq = 1f / (2f * lineWidth2 * lineWidth2); + this.capStyle = capStyle; + this.joinStyle = joinStyle; + + float limit = miterLimit * lineWidth2; + this.miterLimitSq = limit * limit; + + this.prev = CLOSE; + + rdrCtx.stroking = 1; + + return this; // fluent API + } + + /** + * Disposes this stroker: + * clean up before reusing this instance + */ + void dispose() { + reverse.dispose(); + + if (doCleanDirty) { + // Force zero-fill dirty arrays: + Arrays.fill(offset0, 0f); + Arrays.fill(offset1, 0f); + Arrays.fill(offset2, 0f); + Arrays.fill(miter, 0f); + Arrays.fill(middle, 0f); + Arrays.fill(lp, 0f); + Arrays.fill(rp, 0f); + Arrays.fill(subdivTs, 0f); + } + } + + private static void computeOffset(final float lx, final float ly, + final float w, final float[] m) + { + float len = lx*lx + ly*ly; + if (len == 0f) { + m[0] = 0f; + m[1] = 0f; + } else { + len = (float) sqrt(len); + m[0] = (ly * w) / len; + m[1] = -(lx * w) / len; + } + } + + // Returns true if the vectors (dx1, dy1) and (dx2, dy2) are + // clockwise (if dx1,dy1 needs to be rotated clockwise to close + // the smallest angle between it and dx2,dy2). + // This is equivalent to detecting whether a point q is on the right side + // of a line passing through points p1, p2 where p2 = p1+(dx1,dy1) and + // q = p2+(dx2,dy2), which is the same as saying p1, p2, q are in a + // clockwise order. + // NOTE: "clockwise" here assumes coordinates with 0,0 at the bottom left. + private static boolean isCW(final float dx1, final float dy1, + final float dx2, final float dy2) + { + return dx1 * dy2 <= dy1 * dx2; + } + + private void drawRoundJoin(float x, float y, + float omx, float omy, float mx, float my, + boolean rev, + float threshold) + { + if ((omx == 0 && omy == 0) || (mx == 0 && my == 0)) { + return; + } + + float domx = omx - mx; + float domy = omy - my; + float len = domx*domx + domy*domy; + if (len < threshold) { + return; + } + + if (rev) { + omx = -omx; + omy = -omy; + mx = -mx; + my = -my; + } + drawRoundJoin(x, y, omx, omy, mx, my, rev); + } + + private void drawRoundJoin(float cx, float cy, + float omx, float omy, + float mx, float my, + boolean rev) + { + // The sign of the dot product of mx,my and omx,omy is equal to the + // the sign of the cosine of ext + // (ext is the angle between omx,omy and mx,my). + final float cosext = omx * mx + omy * my; + // If it is >=0, we know that abs(ext) is <= 90 degrees, so we only + // need 1 curve to approximate the circle section that joins omx,omy + // and mx,my. + final int numCurves = (cosext >= 0f) ? 1 : 2; + + switch (numCurves) { + case 1: + drawBezApproxForArc(cx, cy, omx, omy, mx, my, rev); + break; + case 2: + // we need to split the arc into 2 arcs spanning the same angle. + // The point we want will be one of the 2 intersections of the + // perpendicular bisector of the chord (omx,omy)->(mx,my) and the + // circle. We could find this by scaling the vector + // (omx+mx, omy+my)/2 so that it has length=lineWidth2 (and thus lies + // on the circle), but that can have numerical problems when the angle + // between omx,omy and mx,my is close to 180 degrees. So we compute a + // normal of (omx,omy)-(mx,my). This will be the direction of the + // perpendicular bisector. To get one of the intersections, we just scale + // this vector that its length is lineWidth2 (this works because the + // perpendicular bisector goes through the origin). This scaling doesn't + // have numerical problems because we know that lineWidth2 divided by + // this normal's length is at least 0.5 and at most sqrt(2)/2 (because + // we know the angle of the arc is > 90 degrees). + float nx = my - omy, ny = omx - mx; + float nlen = (float) sqrt(nx*nx + ny*ny); + float scale = lineWidth2/nlen; + float mmx = nx * scale, mmy = ny * scale; + + // if (isCW(omx, omy, mx, my) != isCW(mmx, mmy, mx, my)) then we've + // computed the wrong intersection so we get the other one. + // The test above is equivalent to if (rev). + if (rev) { + mmx = -mmx; + mmy = -mmy; + } + drawBezApproxForArc(cx, cy, omx, omy, mmx, mmy, rev); + drawBezApproxForArc(cx, cy, mmx, mmy, mx, my, rev); + break; + default: + } + } + + // the input arc defined by omx,omy and mx,my must span <= 90 degrees. + private void drawBezApproxForArc(final float cx, final float cy, + final float omx, final float omy, + final float mx, final float my, + boolean rev) + { + final float cosext2 = (omx * mx + omy * my) * invHalfLineWidth2Sq; + + // check round off errors producing cos(ext) > 1 and a NaN below + // cos(ext) == 1 implies colinear segments and an empty join anyway + if (cosext2 >= 0.5f) { + // just return to avoid generating a flat curve: + return; + } + + // cv is the length of P1-P0 and P2-P3 divided by the radius of the arc + // (so, cv assumes the arc has radius 1). P0, P1, P2, P3 are the points that + // define the bezier curve we're computing. + // It is computed using the constraints that P1-P0 and P3-P2 are parallel + // to the arc tangents at the endpoints, and that |P1-P0|=|P3-P2|. + float cv = (float) ((4.0 / 3.0) * sqrt(0.5 - cosext2) / + (1.0 + sqrt(cosext2 + 0.5))); + // if clockwise, we need to negate cv. + if (rev) { // rev is equivalent to isCW(omx, omy, mx, my) + cv = -cv; + } + final float x1 = cx + omx; + final float y1 = cy + omy; + final float x2 = x1 - cv * omy; + final float y2 = y1 + cv * omx; + + final float x4 = cx + mx; + final float y4 = cy + my; + final float x3 = x4 + cv * my; + final float y3 = y4 - cv * mx; + + emitCurveTo(x1, y1, x2, y2, x3, y3, x4, y4, rev); + } + + private void drawRoundCap(float cx, float cy, float mx, float my) { + // the first and second arguments of the following two calls + // are really will be ignored by emitCurveTo (because of the false), + // but we put them in anyway, as opposed to just giving it 4 zeroes, + // because it's just 4 additions and it's not good to rely on this + // sort of assumption (right now it's true, but that may change). + emitCurveTo(cx+mx-C*my, cy+my+C*mx, + cx-my+C*mx, cy+mx+C*my, + cx-my, cy+mx); + emitCurveTo(cx-my-C*mx, cy+mx-C*my, + cx-mx-C*my, cy-my+C*mx, + cx-mx, cy-my); + } + + // Put the intersection point of the lines (x0, y0) -> (x1, y1) + // and (x0p, y0p) -> (x1p, y1p) in m[off] and m[off+1]. + // If the lines are parallel, it will put a non finite number in m. + private static void computeIntersection(final float x0, final float y0, + final float x1, final float y1, + final float x0p, final float y0p, + final float x1p, final float y1p, + final float[] m, int off) + { + float x10 = x1 - x0; + float y10 = y1 - y0; + float x10p = x1p - x0p; + float y10p = y1p - y0p; + + float den = x10*y10p - x10p*y10; + float t = x10p*(y0-y0p) - y10p*(x0-x0p); + t /= den; + m[off++] = x0 + t*x10; + m[off] = y0 + t*y10; + } + + private void drawMiter(final float pdx, final float pdy, + final float x0, final float y0, + final float dx, final float dy, + float omx, float omy, float mx, float my, + boolean rev) + { + if ((mx == omx && my == omy) || + (pdx == 0f && pdy == 0f) || + (dx == 0f && dy == 0f)) + { + return; + } + + if (rev) { + omx = -omx; + omy = -omy; + mx = -mx; + my = -my; + } + + computeIntersection((x0 - pdx) + omx, (y0 - pdy) + omy, x0 + omx, y0 + omy, + (dx + x0) + mx, (dy + y0) + my, x0 + mx, y0 + my, + miter, 0); + + final float miterX = miter[0]; + final float miterY = miter[1]; + float lenSq = (miterX-x0)*(miterX-x0) + (miterY-y0)*(miterY-y0); + + // If the lines are parallel, lenSq will be either NaN or +inf + // (actually, I'm not sure if the latter is possible. The important + // thing is that -inf is not possible, because lenSq is a square). + // For both of those values, the comparison below will fail and + // no miter will be drawn, which is correct. + if (lenSq < miterLimitSq) { + emitLineTo(miterX, miterY, rev); + } + } + + @Override + public void moveTo(float x0, float y0) { + if (prev == DRAWING_OP_TO) { + finish(); + } + this.sx0 = this.cx0 = x0; + this.sy0 = this.cy0 = y0; + this.cdx = this.sdx = 1; + this.cdy = this.sdy = 0; + this.prev = MOVE_TO; + } + + @Override + public void lineTo(float x1, float y1) { + float dx = x1 - cx0; + float dy = y1 - cy0; + if (dx == 0f && dy == 0f) { + dx = 1f; + } + computeOffset(dx, dy, lineWidth2, offset0); + final float mx = offset0[0]; + final float my = offset0[1]; + + drawJoin(cdx, cdy, cx0, cy0, dx, dy, cmx, cmy, mx, my); + + emitLineTo(cx0 + mx, cy0 + my); + emitLineTo( x1 + mx, y1 + my); + + emitLineToRev(cx0 - mx, cy0 - my); + emitLineToRev( x1 - mx, y1 - my); + + this.cmx = mx; + this.cmy = my; + this.cdx = dx; + this.cdy = dy; + this.cx0 = x1; + this.cy0 = y1; + this.prev = DRAWING_OP_TO; + } + + @Override + public void closePath() { + if (prev != DRAWING_OP_TO) { + if (prev == CLOSE) { + return; + } + emitMoveTo(cx0, cy0 - lineWidth2); + this.cmx = this.smx = 0; + this.cmy = this.smy = -lineWidth2; + this.cdx = this.sdx = 1; + this.cdy = this.sdy = 0; + finish(); + return; + } + + if (cx0 != sx0 || cy0 != sy0) { + lineTo(sx0, sy0); + } + + drawJoin(cdx, cdy, cx0, cy0, sdx, sdy, cmx, cmy, smx, smy); + + emitLineTo(sx0 + smx, sy0 + smy); + + emitMoveTo(sx0 - smx, sy0 - smy); + emitReverse(); + + this.prev = CLOSE; + emitClose(); + } + + private void emitReverse() { + reverse.popAll(out); + } + + @Override + public void pathDone() { + if (prev == DRAWING_OP_TO) { + finish(); + } + + out.pathDone(); + + // this shouldn't matter since this object won't be used + // after the call to this method. + this.prev = CLOSE; + + // Dispose this instance: + dispose(); + } + + private void finish() { + if (capStyle == CAP_ROUND) { + drawRoundCap(cx0, cy0, cmx, cmy); + } else if (capStyle == CAP_SQUARE) { + emitLineTo(cx0 - cmy + cmx, cy0 + cmx + cmy); + emitLineTo(cx0 - cmy - cmx, cy0 + cmx - cmy); + } + + emitReverse(); + + if (capStyle == CAP_ROUND) { + drawRoundCap(sx0, sy0, -smx, -smy); + } else if (capStyle == CAP_SQUARE) { + emitLineTo(sx0 + smy - smx, sy0 - smx - smy); + emitLineTo(sx0 + smy + smx, sy0 - smx + smy); + } + + emitClose(); + } + + private void emitMoveTo(final float x0, final float y0) { + out.moveTo(x0, y0); + } + + private void emitLineTo(final float x1, final float y1) { + out.lineTo(x1, y1); + } + + private void emitLineToRev(final float x1, final float y1) { + reverse.pushLine(x1, y1); + } + + private void emitLineTo(final float x1, final float y1, + final boolean rev) + { + if (rev) { + emitLineToRev(x1, y1); + } else { + emitLineTo(x1, y1); + } + } + + private void emitQuadTo(final float x1, final float y1, + final float x2, final float y2) + { + out.quadTo(x1, y1, x2, y2); + } + + private void emitQuadToRev(final float x0, final float y0, + final float x1, final float y1) + { + reverse.pushQuad(x0, y0, x1, y1); + } + + private void emitCurveTo(final float x1, final float y1, + final float x2, final float y2, + final float x3, final float y3) + { + out.curveTo(x1, y1, x2, y2, x3, y3); + } + + private void emitCurveToRev(final float x0, final float y0, + final float x1, final float y1, + final float x2, final float y2) + { + reverse.pushCubic(x0, y0, x1, y1, x2, y2); + } + + private void emitCurveTo(final float x0, final float y0, + final float x1, final float y1, + final float x2, final float y2, + final float x3, final float y3, final boolean rev) + { + if (rev) { + reverse.pushCubic(x0, y0, x1, y1, x2, y2); + } else { + out.curveTo(x1, y1, x2, y2, x3, y3); + } + } + + private void emitClose() { + out.closePath(); + } + + private void drawJoin(float pdx, float pdy, + float x0, float y0, + float dx, float dy, + float omx, float omy, + float mx, float my) + { + if (prev != DRAWING_OP_TO) { + emitMoveTo(x0 + mx, y0 + my); + this.sdx = dx; + this.sdy = dy; + this.smx = mx; + this.smy = my; + } else { + boolean cw = isCW(pdx, pdy, dx, dy); + if (joinStyle == JOIN_MITER) { + drawMiter(pdx, pdy, x0, y0, dx, dy, omx, omy, mx, my, cw); + } else if (joinStyle == JOIN_ROUND) { + drawRoundJoin(x0, y0, + omx, omy, + mx, my, cw, + ROUND_JOIN_THRESHOLD); + } + emitLineTo(x0, y0, !cw); + } + prev = DRAWING_OP_TO; + } + + private static boolean within(final float x1, final float y1, + final float x2, final float y2, + final float ERR) + { + assert ERR > 0 : ""; + // compare taxicab distance. ERR will always be small, so using + // true distance won't give much benefit + return (Helpers.within(x1, x2, ERR) && // we want to avoid calling Math.abs + Helpers.within(y1, y2, ERR)); // this is just as good. + } + + private void getLineOffsets(float x1, float y1, + float x2, float y2, + float[] left, float[] right) { + computeOffset(x2 - x1, y2 - y1, lineWidth2, offset0); + final float mx = offset0[0]; + final float my = offset0[1]; + left[0] = x1 + mx; + left[1] = y1 + my; + left[2] = x2 + mx; + left[3] = y2 + my; + right[0] = x1 - mx; + right[1] = y1 - my; + right[2] = x2 - mx; + right[3] = y2 - my; + } + + private int computeOffsetCubic(float[] pts, final int off, + float[] leftOff, float[] rightOff) + { + // if p1=p2 or p3=p4 it means that the derivative at the endpoint + // vanishes, which creates problems with computeOffset. Usually + // this happens when this stroker object is trying to winden + // a curve with a cusp. What happens is that curveTo splits + // the input curve at the cusp, and passes it to this function. + // because of inaccuracies in the splitting, we consider points + // equal if they're very close to each other. + final float x1 = pts[off + 0], y1 = pts[off + 1]; + final float x2 = pts[off + 2], y2 = pts[off + 3]; + final float x3 = pts[off + 4], y3 = pts[off + 5]; + final float x4 = pts[off + 6], y4 = pts[off + 7]; + + float dx4 = x4 - x3; + float dy4 = y4 - y3; + float dx1 = x2 - x1; + float dy1 = y2 - y1; + + // if p1 == p2 && p3 == p4: draw line from p1->p4, unless p1 == p4, + // in which case ignore if p1 == p2 + final boolean p1eqp2 = within(x1,y1,x2,y2, 6f * ulp(y2)); + final boolean p3eqp4 = within(x3,y3,x4,y4, 6f * ulp(y4)); + if (p1eqp2 && p3eqp4) { + getLineOffsets(x1, y1, x4, y4, leftOff, rightOff); + return 4; + } else if (p1eqp2) { + dx1 = x3 - x1; + dy1 = y3 - y1; + } else if (p3eqp4) { + dx4 = x4 - x2; + dy4 = y4 - y2; + } + + // if p2-p1 and p4-p3 are parallel, that must mean this curve is a line + float dotsq = (dx1 * dx4 + dy1 * dy4); + dotsq *= dotsq; + float l1sq = dx1 * dx1 + dy1 * dy1, l4sq = dx4 * dx4 + dy4 * dy4; + if (Helpers.within(dotsq, l1sq * l4sq, 4f * ulp(dotsq))) { + getLineOffsets(x1, y1, x4, y4, leftOff, rightOff); + return 4; + } + +// What we're trying to do in this function is to approximate an ideal +// offset curve (call it I) of the input curve B using a bezier curve Bp. +// The constraints I use to get the equations are: +// +// 1. The computed curve Bp should go through I(0) and I(1). These are +// x1p, y1p, x4p, y4p, which are p1p and p4p. We still need to find +// 4 variables: the x and y components of p2p and p3p (i.e. x2p, y2p, x3p, y3p). +// +// 2. Bp should have slope equal in absolute value to I at the endpoints. So, +// (by the way, the operator || in the comments below means "aligned with". +// It is defined on vectors, so when we say I'(0) || Bp'(0) we mean that +// vectors I'(0) and Bp'(0) are aligned, which is the same as saying +// that the tangent lines of I and Bp at 0 are parallel. Mathematically +// this means (I'(t) || Bp'(t)) <==> (I'(t) = c * Bp'(t)) where c is some +// nonzero constant.) +// I'(0) || Bp'(0) and I'(1) || Bp'(1). Obviously, I'(0) || B'(0) and +// I'(1) || B'(1); therefore, Bp'(0) || B'(0) and Bp'(1) || B'(1). +// We know that Bp'(0) || (p2p-p1p) and Bp'(1) || (p4p-p3p) and the same +// is true for any bezier curve; therefore, we get the equations +// (1) p2p = c1 * (p2-p1) + p1p +// (2) p3p = c2 * (p4-p3) + p4p +// We know p1p, p4p, p2, p1, p3, and p4; therefore, this reduces the number +// of unknowns from 4 to 2 (i.e. just c1 and c2). +// To eliminate these 2 unknowns we use the following constraint: +// +// 3. Bp(0.5) == I(0.5). Bp(0.5)=(x,y) and I(0.5)=(xi,yi), and I should note +// that I(0.5) is *the only* reason for computing dxm,dym. This gives us +// (3) Bp(0.5) = (p1p + 3 * (p2p + p3p) + p4p)/8, which is equivalent to +// (4) p2p + p3p = (Bp(0.5)*8 - p1p - p4p) / 3 +// We can substitute (1) and (2) from above into (4) and we get: +// (5) c1*(p2-p1) + c2*(p4-p3) = (Bp(0.5)*8 - p1p - p4p)/3 - p1p - p4p +// which is equivalent to +// (6) c1*(p2-p1) + c2*(p4-p3) = (4/3) * (Bp(0.5) * 2 - p1p - p4p) +// +// The right side of this is a 2D vector, and we know I(0.5), which gives us +// Bp(0.5), which gives us the value of the right side. +// The left side is just a matrix vector multiplication in disguise. It is +// +// [x2-x1, x4-x3][c1] +// [y2-y1, y4-y3][c2] +// which, is equal to +// [dx1, dx4][c1] +// [dy1, dy4][c2] +// At this point we are left with a simple linear system and we solve it by +// getting the inverse of the matrix above. Then we use [c1,c2] to compute +// p2p and p3p. + + float x = (x1 + 3f * (x2 + x3) + x4) / 8f; + float y = (y1 + 3f * (y2 + y3) + y4) / 8f; + // (dxm,dym) is some tangent of B at t=0.5. This means it's equal to + // c*B'(0.5) for some constant c. + float dxm = x3 + x4 - x1 - x2, dym = y3 + y4 - y1 - y2; + + // this computes the offsets at t=0, 0.5, 1, using the property that + // for any bezier curve the vectors p2-p1 and p4-p3 are parallel to + // the (dx/dt, dy/dt) vectors at the endpoints. + computeOffset(dx1, dy1, lineWidth2, offset0); + computeOffset(dxm, dym, lineWidth2, offset1); + computeOffset(dx4, dy4, lineWidth2, offset2); + float x1p = x1 + offset0[0]; // start + float y1p = y1 + offset0[1]; // point + float xi = x + offset1[0]; // interpolation + float yi = y + offset1[1]; // point + float x4p = x4 + offset2[0]; // end + float y4p = y4 + offset2[1]; // point + + float invdet43 = 4f / (3f * (dx1 * dy4 - dy1 * dx4)); + + float two_pi_m_p1_m_p4x = 2f * xi - x1p - x4p; + float two_pi_m_p1_m_p4y = 2f * yi - y1p - y4p; + float c1 = invdet43 * (dy4 * two_pi_m_p1_m_p4x - dx4 * two_pi_m_p1_m_p4y); + float c2 = invdet43 * (dx1 * two_pi_m_p1_m_p4y - dy1 * two_pi_m_p1_m_p4x); + + float x2p, y2p, x3p, y3p; + x2p = x1p + c1*dx1; + y2p = y1p + c1*dy1; + x3p = x4p + c2*dx4; + y3p = y4p + c2*dy4; + + leftOff[0] = x1p; leftOff[1] = y1p; + leftOff[2] = x2p; leftOff[3] = y2p; + leftOff[4] = x3p; leftOff[5] = y3p; + leftOff[6] = x4p; leftOff[7] = y4p; + + x1p = x1 - offset0[0]; y1p = y1 - offset0[1]; + xi = xi - 2f * offset1[0]; yi = yi - 2f * offset1[1]; + x4p = x4 - offset2[0]; y4p = y4 - offset2[1]; + + two_pi_m_p1_m_p4x = 2f * xi - x1p - x4p; + two_pi_m_p1_m_p4y = 2f * yi - y1p - y4p; + c1 = invdet43 * (dy4 * two_pi_m_p1_m_p4x - dx4 * two_pi_m_p1_m_p4y); + c2 = invdet43 * (dx1 * two_pi_m_p1_m_p4y - dy1 * two_pi_m_p1_m_p4x); + + x2p = x1p + c1*dx1; + y2p = y1p + c1*dy1; + x3p = x4p + c2*dx4; + y3p = y4p + c2*dy4; + + rightOff[0] = x1p; rightOff[1] = y1p; + rightOff[2] = x2p; rightOff[3] = y2p; + rightOff[4] = x3p; rightOff[5] = y3p; + rightOff[6] = x4p; rightOff[7] = y4p; + return 8; + } + + // return the kind of curve in the right and left arrays. + private int computeOffsetQuad(float[] pts, final int off, + float[] leftOff, float[] rightOff) + { + final float x1 = pts[off + 0], y1 = pts[off + 1]; + final float x2 = pts[off + 2], y2 = pts[off + 3]; + final float x3 = pts[off + 4], y3 = pts[off + 5]; + + final float dx3 = x3 - x2; + final float dy3 = y3 - y2; + final float dx1 = x2 - x1; + final float dy1 = y2 - y1; + + // this computes the offsets at t = 0, 1 + computeOffset(dx1, dy1, lineWidth2, offset0); + computeOffset(dx3, dy3, lineWidth2, offset1); + + leftOff[0] = x1 + offset0[0]; leftOff[1] = y1 + offset0[1]; + leftOff[4] = x3 + offset1[0]; leftOff[5] = y3 + offset1[1]; + rightOff[0] = x1 - offset0[0]; rightOff[1] = y1 - offset0[1]; + rightOff[4] = x3 - offset1[0]; rightOff[5] = y3 - offset1[1]; + + float x1p = leftOff[0]; // start + float y1p = leftOff[1]; // point + float x3p = leftOff[4]; // end + float y3p = leftOff[5]; // point + + // Corner cases: + // 1. If the two control vectors are parallel, we'll end up with NaN's + // in leftOff (and rightOff in the body of the if below), so we'll + // do getLineOffsets, which is right. + // 2. If the first or second two points are equal, then (dx1,dy1)==(0,0) + // or (dx3,dy3)==(0,0), so (x1p, y1p)==(x1p+dx1, y1p+dy1) + // or (x3p, y3p)==(x3p-dx3, y3p-dy3), which means that + // computeIntersection will put NaN's in leftOff and right off, and + // we will do getLineOffsets, which is right. + computeIntersection(x1p, y1p, x1p+dx1, y1p+dy1, x3p, y3p, x3p-dx3, y3p-dy3, leftOff, 2); + float cx = leftOff[2]; + float cy = leftOff[3]; + + if (!(isFinite(cx) && isFinite(cy))) { + // maybe the right path is not degenerate. + x1p = rightOff[0]; + y1p = rightOff[1]; + x3p = rightOff[4]; + y3p = rightOff[5]; + computeIntersection(x1p, y1p, x1p+dx1, y1p+dy1, x3p, y3p, x3p-dx3, y3p-dy3, rightOff, 2); + cx = rightOff[2]; + cy = rightOff[3]; + if (!(isFinite(cx) && isFinite(cy))) { + // both are degenerate. This curve is a line. + getLineOffsets(x1, y1, x3, y3, leftOff, rightOff); + return 4; + } + // {left,right}Off[0,1,4,5] are already set to the correct values. + leftOff[2] = 2f * x2 - cx; + leftOff[3] = 2f * y2 - cy; + return 6; + } + + // rightOff[2,3] = (x2,y2) - ((left_x2, left_y2) - (x2, y2)) + // == 2*(x2, y2) - (left_x2, left_y2) + rightOff[2] = 2f * x2 - cx; + rightOff[3] = 2f * y2 - cy; + return 6; + } + + private static boolean isFinite(float x) { + return (Float.NEGATIVE_INFINITY < x && x < Float.POSITIVE_INFINITY); + } + + // If this class is compiled with ecj, then Hotspot crashes when OSR + // compiling this function. See bugs 7004570 and 6675699 + // TODO: until those are fixed, we should work around that by + // manually inlining this into curveTo and quadTo. +/******************************* WORKAROUND ********************************** + private void somethingTo(final int type) { + // need these so we can update the state at the end of this method + final float xf = middle[type-2], yf = middle[type-1]; + float dxs = middle[2] - middle[0]; + float dys = middle[3] - middle[1]; + float dxf = middle[type - 2] - middle[type - 4]; + float dyf = middle[type - 1] - middle[type - 3]; + switch(type) { + case 6: + if ((dxs == 0f && dys == 0f) || + (dxf == 0f && dyf == 0f)) { + dxs = dxf = middle[4] - middle[0]; + dys = dyf = middle[5] - middle[1]; + } + break; + case 8: + boolean p1eqp2 = (dxs == 0f && dys == 0f); + boolean p3eqp4 = (dxf == 0f && dyf == 0f); + if (p1eqp2) { + dxs = middle[4] - middle[0]; + dys = middle[5] - middle[1]; + if (dxs == 0f && dys == 0f) { + dxs = middle[6] - middle[0]; + dys = middle[7] - middle[1]; + } + } + if (p3eqp4) { + dxf = middle[6] - middle[2]; + dyf = middle[7] - middle[3]; + if (dxf == 0f && dyf == 0f) { + dxf = middle[6] - middle[0]; + dyf = middle[7] - middle[1]; + } + } + } + if (dxs == 0f && dys == 0f) { + // this happens iff the "curve" is just a point + lineTo(middle[0], middle[1]); + return; + } + // if these vectors are too small, normalize them, to avoid future + // precision problems. + if (Math.abs(dxs) < 0.1f && Math.abs(dys) < 0.1f) { + float len = (float) sqrt(dxs*dxs + dys*dys); + dxs /= len; + dys /= len; + } + if (Math.abs(dxf) < 0.1f && Math.abs(dyf) < 0.1f) { + float len = (float) sqrt(dxf*dxf + dyf*dyf); + dxf /= len; + dyf /= len; + } + + computeOffset(dxs, dys, lineWidth2, offset0); + final float mx = offset0[0]; + final float my = offset0[1]; + drawJoin(cdx, cdy, cx0, cy0, dxs, dys, cmx, cmy, mx, my); + + int nSplits = findSubdivPoints(curve, middle, subdivTs, type, lineWidth2); + + int kind = 0; + BreakPtrIterator it = curve.breakPtsAtTs(middle, type, subdivTs, nSplits); + while(it.hasNext()) { + int curCurveOff = it.next(); + + switch (type) { + case 8: + kind = computeOffsetCubic(middle, curCurveOff, lp, rp); + break; + case 6: + kind = computeOffsetQuad(middle, curCurveOff, lp, rp); + break; + } + emitLineTo(lp[0], lp[1]); + switch(kind) { + case 8: + emitCurveTo(lp[2], lp[3], lp[4], lp[5], lp[6], lp[7]); + emitCurveToRev(rp[0], rp[1], rp[2], rp[3], rp[4], rp[5]); + break; + case 6: + emitQuadTo(lp[2], lp[3], lp[4], lp[5]); + emitQuadToRev(rp[0], rp[1], rp[2], rp[3]); + break; + case 4: + emitLineTo(lp[2], lp[3]); + emitLineTo(rp[0], rp[1], true); + break; + } + emitLineTo(rp[kind - 2], rp[kind - 1], true); + } + + this.cmx = (lp[kind - 2] - rp[kind - 2]) / 2; + this.cmy = (lp[kind - 1] - rp[kind - 1]) / 2; + this.cdx = dxf; + this.cdy = dyf; + this.cx0 = xf; + this.cy0 = yf; + this.prev = DRAWING_OP_TO; + } +****************************** END WORKAROUND *******************************/ + + // finds values of t where the curve in pts should be subdivided in order + // to get good offset curves a distance of w away from the middle curve. + // Stores the points in ts, and returns how many of them there were. + private static int findSubdivPoints(final Curve c, float[] pts, float[] ts, + final int type, final float w) + { + final float x12 = pts[2] - pts[0]; + final float y12 = pts[3] - pts[1]; + // if the curve is already parallel to either axis we gain nothing + // from rotating it. + if (y12 != 0f && x12 != 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. + final float hypot = (float) sqrt(x12 * x12 + y12 * y12); + final float cos = x12 / hypot; + final float sin = y12 / hypot; + final float x1 = cos * pts[0] + sin * pts[1]; + final float y1 = cos * pts[1] - sin * pts[0]; + final float x2 = cos * pts[2] + sin * pts[3]; + final float y2 = cos * pts[3] - sin * pts[2]; + final float x3 = cos * pts[4] + sin * pts[5]; + final float y3 = cos * pts[5] - sin * pts[4]; + + switch(type) { + case 8: + final float x4 = cos * pts[6] + sin * pts[7]; + final float y4 = cos * pts[7] - sin * pts[6]; + c.set(x1, y1, x2, y2, x3, y3, x4, y4); + break; + case 6: + c.set(x1, y1, x2, y2, x3, y3); + break; + default: + } + } else { + c.set(pts, type); + } + + int ret = 0; + // we subdivide at values of t such that the remaining rotated + // curves are monotonic in x and y. + ret += c.dxRoots(ts, ret); + ret += c.dyRoots(ts, ret); + // subdivide at inflection points. + if (type == 8) { + // quadratic curves can't have inflection points + ret += c.infPoints(ts, ret); + } + + // now we must subdivide at points where one of the offset curves will have + // a cusp. This happens at ts where the radius of curvature is equal to w. + ret += c.rootsOfROCMinusW(ts, ret, w, 0.0001f); + + ret = Helpers.filterOutNotInAB(ts, 0, ret, 0.0001f, 0.9999f); + Helpers.isort(ts, 0, ret); + return ret; + } + + @Override public void curveTo(float x1, float y1, + float x2, float y2, + float x3, float y3) + { + final float[] mid = middle; + + mid[0] = cx0; mid[1] = cy0; + mid[2] = x1; mid[3] = y1; + mid[4] = x2; mid[5] = y2; + mid[6] = x3; mid[7] = y3; + + // inlined version of somethingTo(8); + // See the TODO on somethingTo + + // need these so we can update the state at the end of this method + final float xf = mid[6], yf = mid[7]; + float dxs = mid[2] - mid[0]; + float dys = mid[3] - mid[1]; + float dxf = mid[6] - mid[4]; + float dyf = mid[7] - mid[5]; + + boolean p1eqp2 = (dxs == 0f && dys == 0f); + boolean p3eqp4 = (dxf == 0f && dyf == 0f); + if (p1eqp2) { + dxs = mid[4] - mid[0]; + dys = mid[5] - mid[1]; + if (dxs == 0f && dys == 0f) { + dxs = mid[6] - mid[0]; + dys = mid[7] - mid[1]; + } + } + if (p3eqp4) { + dxf = mid[6] - mid[2]; + dyf = mid[7] - mid[3]; + if (dxf == 0f && dyf == 0f) { + dxf = mid[6] - mid[0]; + dyf = mid[7] - mid[1]; + } + } + if (dxs == 0f && dys == 0f) { + // this happens if the "curve" is just a point + lineTo(mid[0], mid[1]); + return; + } + + // if these vectors are too small, normalize them, to avoid future + // precision problems. + if (Math.abs(dxs) < 0.1f && Math.abs(dys) < 0.1f) { + float len = (float) sqrt(dxs*dxs + dys*dys); + dxs /= len; + dys /= len; + } + if (Math.abs(dxf) < 0.1f && Math.abs(dyf) < 0.1f) { + float len = (float) sqrt(dxf*dxf + dyf*dyf); + dxf /= len; + dyf /= len; + } + + computeOffset(dxs, dys, lineWidth2, offset0); + drawJoin(cdx, cdy, cx0, cy0, dxs, dys, cmx, cmy, offset0[0], offset0[1]); + + int nSplits = findSubdivPoints(curve, mid, subdivTs, 8, lineWidth2); + + final float[] l = lp; + final float[] r = rp; + + int kind = 0; + BreakPtrIterator it = curve.breakPtsAtTs(mid, 8, subdivTs, nSplits); + while(it.hasNext()) { + int curCurveOff = it.next(); + + kind = computeOffsetCubic(mid, curCurveOff, l, r); + emitLineTo(l[0], l[1]); + + switch(kind) { + case 8: + emitCurveTo(l[2], l[3], l[4], l[5], l[6], l[7]); + emitCurveToRev(r[0], r[1], r[2], r[3], r[4], r[5]); + break; + case 4: + emitLineTo(l[2], l[3]); + emitLineToRev(r[0], r[1]); + break; + default: + } + emitLineToRev(r[kind - 2], r[kind - 1]); + } + + this.cmx = (l[kind - 2] - r[kind - 2]) / 2f; + this.cmy = (l[kind - 1] - r[kind - 1]) / 2f; + this.cdx = dxf; + this.cdy = dyf; + this.cx0 = xf; + this.cy0 = yf; + this.prev = DRAWING_OP_TO; + } + + @Override public void quadTo(float x1, float y1, float x2, float y2) { + final float[] mid = middle; + + mid[0] = cx0; mid[1] = cy0; + mid[2] = x1; mid[3] = y1; + mid[4] = x2; mid[5] = y2; + + // inlined version of somethingTo(8); + // See the TODO on somethingTo + + // need these so we can update the state at the end of this method + final float xf = mid[4], yf = mid[5]; + float dxs = mid[2] - mid[0]; + float dys = mid[3] - mid[1]; + float dxf = mid[4] - mid[2]; + float dyf = mid[5] - mid[3]; + if ((dxs == 0f && dys == 0f) || (dxf == 0f && dyf == 0f)) { + dxs = dxf = mid[4] - mid[0]; + dys = dyf = mid[5] - mid[1]; + } + if (dxs == 0f && dys == 0f) { + // this happens if the "curve" is just a point + lineTo(mid[0], mid[1]); + return; + } + // if these vectors are too small, normalize them, to avoid future + // precision problems. + if (Math.abs(dxs) < 0.1f && Math.abs(dys) < 0.1f) { + float len = (float) sqrt(dxs*dxs + dys*dys); + dxs /= len; + dys /= len; + } + if (Math.abs(dxf) < 0.1f && Math.abs(dyf) < 0.1f) { + float len = (float) sqrt(dxf*dxf + dyf*dyf); + dxf /= len; + dyf /= len; + } + + computeOffset(dxs, dys, lineWidth2, offset0); + drawJoin(cdx, cdy, cx0, cy0, dxs, dys, cmx, cmy, offset0[0], offset0[1]); + + int nSplits = findSubdivPoints(curve, mid, subdivTs, 6, lineWidth2); + + final float[] l = lp; + final float[] r = rp; + + int kind = 0; + BreakPtrIterator it = curve.breakPtsAtTs(mid, 6, subdivTs, nSplits); + while(it.hasNext()) { + int curCurveOff = it.next(); + + kind = computeOffsetQuad(mid, curCurveOff, l, r); + emitLineTo(l[0], l[1]); + + switch(kind) { + case 6: + emitQuadTo(l[2], l[3], l[4], l[5]); + emitQuadToRev(r[0], r[1], r[2], r[3]); + break; + case 4: + emitLineTo(l[2], l[3]); + emitLineToRev(r[0], r[1]); + break; + default: + } + emitLineToRev(r[kind - 2], r[kind - 1]); + } + + this.cmx = (l[kind - 2] - r[kind - 2]) / 2f; + this.cmy = (l[kind - 1] - r[kind - 1]) / 2f; + this.cdx = dxf; + this.cdy = dyf; + this.cx0 = xf; + this.cy0 = yf; + this.prev = DRAWING_OP_TO; + } + + @Override public long getNativeConsumer() { + throw new InternalError("Stroker doesn't use a native consumer"); + } + + // a stack of polynomial curves where each curve shares endpoints with + // adjacent ones. + static final class PolyStack { + private static final byte TYPE_LINETO = (byte) 0; + private static final byte TYPE_QUADTO = (byte) 1; + private static final byte TYPE_CUBICTO = (byte) 2; + + float[] curves; + int end; + byte[] curveTypes; + int numCurves; + + // per-thread renderer context + final RendererContext rdrCtx; + + // per-thread initial arrays (large enough to satisfy most usages: 8192) + // +1 to avoid recycling in Helpers.widenArray() + private final float[] curves_initial = new float[INITIAL_LARGE_ARRAY + 1]; // 32K + private final byte[] curveTypes_initial = new byte[INITIAL_LARGE_ARRAY + 1]; // 8K + + // used marks (stats only) + int curveTypesUseMark; + int curvesUseMark; + + /** + * Constructor + * @param rdrCtx per-thread renderer context + */ + PolyStack(final RendererContext rdrCtx) { + this.rdrCtx = rdrCtx; + + curves = curves_initial; + curveTypes = curveTypes_initial; + end = 0; + numCurves = 0; + + if (doStats) { + curveTypesUseMark = 0; + curvesUseMark = 0; + } + } + + /** + * Disposes this PolyStack: + * clean up before reusing this instance + */ + void dispose() { + end = 0; + numCurves = 0; + + if (doStats) { + RendererContext.stats.stat_rdr_poly_stack_types + .add(curveTypesUseMark); + RendererContext.stats.stat_rdr_poly_stack_curves + .add(curvesUseMark); + // reset marks + curveTypesUseMark = 0; + curvesUseMark = 0; + } + + // Return arrays: + // curves and curveTypes are kept dirty + if (curves != curves_initial) { + rdrCtx.putDirtyFloatArray(curves); + curves = curves_initial; + } + + if (curveTypes != curveTypes_initial) { + rdrCtx.putDirtyByteArray(curveTypes); + curveTypes = curveTypes_initial; + } + } + + private void ensureSpace(final int n) { + // use substraction to avoid integer overflow: + if (curves.length - end < n) { + if (doStats) { + RendererContext.stats.stat_array_stroker_polystack_curves + .add(end + n); + } + curves = rdrCtx.widenDirtyFloatArray(curves, end, end + n); + } + if (curveTypes.length <= numCurves) { + if (doStats) { + RendererContext.stats.stat_array_stroker_polystack_curveTypes + .add(numCurves + 1); + } + curveTypes = rdrCtx.widenDirtyByteArray(curveTypes, + numCurves, + numCurves + 1); + } + } + + void pushCubic(float x0, float y0, + float x1, float y1, + float x2, float y2) + { + ensureSpace(6); + curveTypes[numCurves++] = TYPE_CUBICTO; + // we reverse the coordinate order to make popping easier + final float[] _curves = curves; + int e = end; + _curves[e++] = x2; _curves[e++] = y2; + _curves[e++] = x1; _curves[e++] = y1; + _curves[e++] = x0; _curves[e++] = y0; + end = e; + } + + void pushQuad(float x0, float y0, + float x1, float y1) + { + ensureSpace(4); + curveTypes[numCurves++] = TYPE_QUADTO; + final float[] _curves = curves; + int e = end; + _curves[e++] = x1; _curves[e++] = y1; + _curves[e++] = x0; _curves[e++] = y0; + end = e; + } + + void pushLine(float x, float y) { + ensureSpace(2); + curveTypes[numCurves++] = TYPE_LINETO; + curves[end++] = x; curves[end++] = y; + } + + void popAll(PathConsumer2D io) { + if (doStats) { + // update used marks: + if (numCurves > curveTypesUseMark) { + curveTypesUseMark = numCurves; + } + if (end > curvesUseMark) { + curvesUseMark = end; + } + } + final byte[] _curveTypes = curveTypes; + final float[] _curves = curves; + int nc = numCurves; + int e = end; + + while (nc != 0) { + switch(_curveTypes[--nc]) { + case TYPE_LINETO: + e -= 2; + io.lineTo(_curves[e], _curves[e+1]); + continue; + case TYPE_QUADTO: + e -= 4; + io.quadTo(_curves[e+0], _curves[e+1], + _curves[e+2], _curves[e+3]); + continue; + case TYPE_CUBICTO: + e -= 6; + io.curveTo(_curves[e+0], _curves[e+1], + _curves[e+2], _curves[e+3], + _curves[e+4], _curves[e+5]); + continue; + default: + } + } + numCurves = 0; + end = 0; + } + + @Override + public String toString() { + String ret = ""; + int nc = numCurves; + int e = end; + int len; + while (nc != 0) { + switch(curveTypes[--nc]) { + case TYPE_LINETO: + len = 2; + ret += "line: "; + break; + case TYPE_QUADTO: + len = 4; + ret += "quad: "; + break; + case TYPE_CUBICTO: + len = 6; + ret += "cubic: "; + break; + default: + len = 0; + } + e -= len; + ret += Arrays.toString(Arrays.copyOfRange(curves, e, e+len)) + + "\n"; + } + return ret; + } + } +} diff --git a/src/share/classes/sun/java2d/marlin/TransformingPathConsumer2D.java b/src/share/classes/sun/java2d/marlin/TransformingPathConsumer2D.java new file mode 100644 index 0000000000000000000000000000000000000000..6258d8dfae681e0b0fc29344abf6944f2ed964ab --- /dev/null +++ b/src/share/classes/sun/java2d/marlin/TransformingPathConsumer2D.java @@ -0,0 +1,507 @@ +/* + * Copyright (c) 2007, 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. 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.java2d.marlin; + +import sun.awt.geom.PathConsumer2D; +import java.awt.geom.AffineTransform; +import java.awt.geom.Path2D; + +final class TransformingPathConsumer2D { + + TransformingPathConsumer2D() { + // used by RendererContext + } + + // recycled PathConsumer2D instance from transformConsumer() + private final Path2DWrapper wp_Path2DWrapper = new Path2DWrapper(); + + PathConsumer2D wrapPath2d(Path2D.Float p2d) + { + return wp_Path2DWrapper.init(p2d); + } + + // recycled PathConsumer2D instances from transformConsumer() + private final TranslateFilter tx_TranslateFilter = new TranslateFilter(); + private final DeltaScaleFilter tx_DeltaScaleFilter = new DeltaScaleFilter(); + private final ScaleFilter tx_ScaleFilter = new ScaleFilter(); + private final DeltaTransformFilter tx_DeltaTransformFilter = new DeltaTransformFilter(); + private final TransformFilter tx_TransformFilter = new TransformFilter(); + + PathConsumer2D transformConsumer(PathConsumer2D out, + AffineTransform at) + { + if (at == null) { + return out; + } + float mxx = (float) at.getScaleX(); + float mxy = (float) at.getShearX(); + float mxt = (float) at.getTranslateX(); + float myx = (float) at.getShearY(); + float myy = (float) at.getScaleY(); + float myt = (float) at.getTranslateY(); + if (mxy == 0f && myx == 0f) { + if (mxx == 1f && myy == 1f) { + if (mxt == 0f && myt == 0f) { + return out; + } else { + return tx_TranslateFilter.init(out, mxt, myt); + } + } else { + if (mxt == 0f && myt == 0f) { + return tx_DeltaScaleFilter.init(out, mxx, myy); + } else { + return tx_ScaleFilter.init(out, mxx, myy, mxt, myt); + } + } + } else if (mxt == 0f && myt == 0f) { + return tx_DeltaTransformFilter.init(out, mxx, mxy, myx, myy); + } else { + return tx_TransformFilter.init(out, mxx, mxy, mxt, myx, myy, myt); + } + } + + // recycled PathConsumer2D instances from deltaTransformConsumer() + private final DeltaScaleFilter dt_DeltaScaleFilter = new DeltaScaleFilter(); + private final DeltaTransformFilter dt_DeltaTransformFilter = new DeltaTransformFilter(); + + PathConsumer2D deltaTransformConsumer(PathConsumer2D out, + AffineTransform at) + { + if (at == null) { + return out; + } + float mxx = (float) at.getScaleX(); + float mxy = (float) at.getShearX(); + float myx = (float) at.getShearY(); + float myy = (float) at.getScaleY(); + if (mxy == 0f && myx == 0f) { + if (mxx == 1f && myy == 1f) { + return out; + } else { + return dt_DeltaScaleFilter.init(out, mxx, myy); + } + } else { + return dt_DeltaTransformFilter.init(out, mxx, mxy, myx, myy); + } + } + + // recycled PathConsumer2D instances from inverseDeltaTransformConsumer() + private final DeltaScaleFilter iv_DeltaScaleFilter = new DeltaScaleFilter(); + private final DeltaTransformFilter iv_DeltaTransformFilter = new DeltaTransformFilter(); + + PathConsumer2D inverseDeltaTransformConsumer(PathConsumer2D out, + AffineTransform at) + { + if (at == null) { + return out; + } + float mxx = (float) at.getScaleX(); + float mxy = (float) at.getShearX(); + float myx = (float) at.getShearY(); + float myy = (float) at.getScaleY(); + if (mxy == 0f && myx == 0f) { + if (mxx == 1f && myy == 1f) { + return out; + } else { + return iv_DeltaScaleFilter.init(out, 1.0f/mxx, 1.0f/myy); + } + } else { + float det = mxx * myy - mxy * myx; + return iv_DeltaTransformFilter.init(out, + myy / det, + -mxy / det, + -myx / det, + mxx / det); + } + } + + static final class TranslateFilter implements PathConsumer2D { + private PathConsumer2D out; + private float tx, ty; + + TranslateFilter() {} + + TranslateFilter init(PathConsumer2D out, + float tx, float ty) + { + this.out = out; + this.tx = tx; + this.ty = ty; + return this; // fluent API + } + + @Override + public void moveTo(float x0, float y0) { + out.moveTo(x0 + tx, y0 + ty); + } + + @Override + public void lineTo(float x1, float y1) { + out.lineTo(x1 + tx, y1 + ty); + } + + @Override + public void quadTo(float x1, float y1, + float x2, float y2) + { + out.quadTo(x1 + tx, y1 + ty, + x2 + tx, y2 + ty); + } + + @Override + public void curveTo(float x1, float y1, + float x2, float y2, + float x3, float y3) + { + out.curveTo(x1 + tx, y1 + ty, + x2 + tx, y2 + ty, + x3 + tx, y3 + ty); + } + + @Override + public void closePath() { + out.closePath(); + } + + @Override + public void pathDone() { + out.pathDone(); + } + + @Override + public long getNativeConsumer() { + return 0; + } + } + + static final class ScaleFilter implements PathConsumer2D { + private PathConsumer2D out; + private float sx, sy, tx, ty; + + ScaleFilter() {} + + ScaleFilter init(PathConsumer2D out, + float sx, float sy, + float tx, float ty) + { + this.out = out; + this.sx = sx; + this.sy = sy; + this.tx = tx; + this.ty = ty; + return this; // fluent API + } + + @Override + public void moveTo(float x0, float y0) { + out.moveTo(x0 * sx + tx, y0 * sy + ty); + } + + @Override + public void lineTo(float x1, float y1) { + out.lineTo(x1 * sx + tx, y1 * sy + ty); + } + + @Override + public void quadTo(float x1, float y1, + float x2, float y2) + { + out.quadTo(x1 * sx + tx, y1 * sy + ty, + x2 * sx + tx, y2 * sy + ty); + } + + @Override + public void curveTo(float x1, float y1, + float x2, float y2, + float x3, float y3) + { + out.curveTo(x1 * sx + tx, y1 * sy + ty, + x2 * sx + tx, y2 * sy + ty, + x3 * sx + tx, y3 * sy + ty); + } + + @Override + public void closePath() { + out.closePath(); + } + + @Override + public void pathDone() { + out.pathDone(); + } + + @Override + public long getNativeConsumer() { + return 0; + } + } + + static final class TransformFilter implements PathConsumer2D { + private PathConsumer2D out; + private float mxx, mxy, mxt, myx, myy, myt; + + TransformFilter() {} + + TransformFilter init(PathConsumer2D out, + float mxx, float mxy, float mxt, + float myx, float myy, float myt) + { + this.out = out; + this.mxx = mxx; + this.mxy = mxy; + this.mxt = mxt; + this.myx = myx; + this.myy = myy; + this.myt = myt; + return this; // fluent API + } + + @Override + public void moveTo(float x0, float y0) { + out.moveTo(x0 * mxx + y0 * mxy + mxt, + x0 * myx + y0 * myy + myt); + } + + @Override + public void lineTo(float x1, float y1) { + out.lineTo(x1 * mxx + y1 * mxy + mxt, + x1 * myx + y1 * myy + myt); + } + + @Override + public void quadTo(float x1, float y1, + float x2, float y2) + { + out.quadTo(x1 * mxx + y1 * mxy + mxt, + x1 * myx + y1 * myy + myt, + x2 * mxx + y2 * mxy + mxt, + x2 * myx + y2 * myy + myt); + } + + @Override + public void curveTo(float x1, float y1, + float x2, float y2, + float x3, float y3) + { + out.curveTo(x1 * mxx + y1 * mxy + mxt, + x1 * myx + y1 * myy + myt, + x2 * mxx + y2 * mxy + mxt, + x2 * myx + y2 * myy + myt, + x3 * mxx + y3 * mxy + mxt, + x3 * myx + y3 * myy + myt); + } + + @Override + public void closePath() { + out.closePath(); + } + + @Override + public void pathDone() { + out.pathDone(); + } + + @Override + public long getNativeConsumer() { + return 0; + } + } + + static final class DeltaScaleFilter implements PathConsumer2D { + private PathConsumer2D out; + private float sx, sy; + + DeltaScaleFilter() {} + + DeltaScaleFilter init(PathConsumer2D out, + float mxx, float myy) + { + this.out = out; + sx = mxx; + sy = myy; + return this; // fluent API + } + + @Override + public void moveTo(float x0, float y0) { + out.moveTo(x0 * sx, y0 * sy); + } + + @Override + public void lineTo(float x1, float y1) { + out.lineTo(x1 * sx, y1 * sy); + } + + @Override + public void quadTo(float x1, float y1, + float x2, float y2) + { + out.quadTo(x1 * sx, y1 * sy, + x2 * sx, y2 * sy); + } + + @Override + public void curveTo(float x1, float y1, + float x2, float y2, + float x3, float y3) + { + out.curveTo(x1 * sx, y1 * sy, + x2 * sx, y2 * sy, + x3 * sx, y3 * sy); + } + + @Override + public void closePath() { + out.closePath(); + } + + @Override + public void pathDone() { + out.pathDone(); + } + + @Override + public long getNativeConsumer() { + return 0; + } + } + + static final class DeltaTransformFilter implements PathConsumer2D { + private PathConsumer2D out; + private float mxx, mxy, myx, myy; + + DeltaTransformFilter() {} + + DeltaTransformFilter init(PathConsumer2D out, + float mxx, float mxy, + float myx, float myy) + { + this.out = out; + this.mxx = mxx; + this.mxy = mxy; + this.myx = myx; + this.myy = myy; + return this; // fluent API + } + + @Override + public void moveTo(float x0, float y0) { + out.moveTo(x0 * mxx + y0 * mxy, + x0 * myx + y0 * myy); + } + + @Override + public void lineTo(float x1, float y1) { + out.lineTo(x1 * mxx + y1 * mxy, + x1 * myx + y1 * myy); + } + + @Override + public void quadTo(float x1, float y1, + float x2, float y2) + { + out.quadTo(x1 * mxx + y1 * mxy, + x1 * myx + y1 * myy, + x2 * mxx + y2 * mxy, + x2 * myx + y2 * myy); + } + + @Override + public void curveTo(float x1, float y1, + float x2, float y2, + float x3, float y3) + { + out.curveTo(x1 * mxx + y1 * mxy, + x1 * myx + y1 * myy, + x2 * mxx + y2 * mxy, + x2 * myx + y2 * myy, + x3 * mxx + y3 * mxy, + x3 * myx + y3 * myy); + } + + @Override + public void closePath() { + out.closePath(); + } + + @Override + public void pathDone() { + out.pathDone(); + } + + @Override + public long getNativeConsumer() { + return 0; + } + } + + static final class Path2DWrapper implements PathConsumer2D { + private Path2D.Float p2d; + + Path2DWrapper() {} + + Path2DWrapper init(Path2D.Float p2d) { + this.p2d = p2d; + return this; + } + + @Override + public void moveTo(float x0, float y0) { + p2d.moveTo(x0, y0); + } + + @Override + public void lineTo(float x1, float y1) { + p2d.lineTo(x1, y1); + } + + @Override + public void closePath() { + p2d.closePath(); + } + + @Override + public void pathDone() {} + + @Override + public void curveTo(float x1, float y1, + float x2, float y2, + float x3, float y3) + { + p2d.curveTo(x1, y1, x2, y2, x3, y3); + } + + @Override + public void quadTo(float x1, float y1, float x2, float y2) { + p2d.quadTo(x1, y1, x2, y2); + } + + @Override + public long getNativeConsumer() { + throw new InternalError("Not using a native peer"); + } + } +} diff --git a/src/share/classes/sun/java2d/marlin/Version.java b/src/share/classes/sun/java2d/marlin/Version.java new file mode 100644 index 0000000000000000000000000000000000000000..1d144169376b1b29b8dcc880ebf13bad27d702c3 --- /dev/null +++ b/src/share/classes/sun/java2d/marlin/Version.java @@ -0,0 +1,39 @@ +/* + * 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. 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.java2d.marlin; + +public final class Version { + + private static final String version = "marlin-0.7.3.2-Unsafe-OpenJDK"; + + public static String getVersion() { + return version; + } + + private Version() { + } + +} diff --git a/src/share/classes/sun/java2d/marlin/stats/Histogram.java b/src/share/classes/sun/java2d/marlin/stats/Histogram.java new file mode 100644 index 0000000000000000000000000000000000000000..324e9ff4af6cd0ec52b240c117b5b7abe41962f9 --- /dev/null +++ b/src/share/classes/sun/java2d/marlin/stats/Histogram.java @@ -0,0 +1,102 @@ +/* + * 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. 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.java2d.marlin.stats; + +import java.util.Arrays; + +/** + * Generic histogram based on long statistics + */ +public final class Histogram extends StatLong { + + static final int BUCKET = 2; + static final int MAX = 20; + static final int LAST = MAX - 1; + static final int[] STEPS = new int[MAX]; + + static { + STEPS[0] = 0; + STEPS[1] = 1; + + for (int i = 2; i < MAX; i++) { + STEPS[i] = STEPS[i - 1] * BUCKET; + } +// System.out.println("Histogram.STEPS = " + Arrays.toString(STEPS)); + } + + static int bucket(int val) { + for (int i = 1; i < MAX; i++) { + if (val < STEPS[i]) { + return i - 1; + } + } + return LAST; + } + + private final StatLong[] stats = new StatLong[MAX]; + + public Histogram(final String name) { + super(name); + for (int i = 0; i < MAX; i++) { + stats[i] = new StatLong(String.format("%5s .. %5s", STEPS[i], + ((i + 1 < MAX) ? STEPS[i + 1] : "~"))); + } + } + + @Override + public void reset() { + super.reset(); + for (int i = 0; i < MAX; i++) { + stats[i].reset(); + } + } + + @Override + public void add(int val) { + super.add(val); + stats[bucket(val)].add(val); + } + + @Override + public void add(long val) { + add((int) val); + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(2048); + super.toString(sb).append(" { "); + + for (int i = 0; i < MAX; i++) { + if (stats[i].count != 0l) { + sb.append("\n ").append(stats[i].toString()); + } + } + + return sb.append(" }").toString(); + } +} + diff --git a/src/share/classes/sun/java2d/marlin/stats/Monitor.java b/src/share/classes/sun/java2d/marlin/stats/Monitor.java new file mode 100644 index 0000000000000000000000000000000000000000..dcb3c8b05ceacd2008551bb96dfc21b232b68ea0 --- /dev/null +++ b/src/share/classes/sun/java2d/marlin/stats/Monitor.java @@ -0,0 +1,53 @@ +/* + * 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. 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.java2d.marlin.stats; + +/** + * Generic monitor ie gathers time statistics as nanos. + */ +public final class Monitor extends StatLong { + + private static final long INVALID = -1L; + + private long start = INVALID; + + public Monitor(final String name) { + super(name); + } + + public void start() { + start = System.nanoTime(); + } + + public void stop() { + final long elapsed = System.nanoTime() - start; + if (start != INVALID && elapsed > 0l) { + add(elapsed); + } + start = INVALID; + } +} + diff --git a/src/share/classes/sun/java2d/marlin/stats/StatLong.java b/src/share/classes/sun/java2d/marlin/stats/StatLong.java new file mode 100644 index 0000000000000000000000000000000000000000..50f906f708ec73d10741a99268c0f420c6c1da8c --- /dev/null +++ b/src/share/classes/sun/java2d/marlin/stats/StatLong.java @@ -0,0 +1,97 @@ +/* + * 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. 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.java2d.marlin.stats; + +/** + * Statistics as long values + */ +public class StatLong { + + public final String name; + public long count = 0l; + public long sum = 0l; + public long min = Integer.MAX_VALUE; + public long max = Integer.MIN_VALUE; + + public StatLong(final String name) { + this.name = name; + } + + public void reset() { + count = 0l; + sum = 0l; + min = Integer.MAX_VALUE; + max = Integer.MIN_VALUE; + } + + public void add(final int val) { + count++; + sum += val; + if (val < min) { + min = val; + } + if (val > max) { + max = val; + } + } + + public void add(final long val) { + count++; + sum += val; + if (val < min) { + min = val; + } + if (val > max) { + max = val; + } + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(128); + toString(sb); + return sb.toString(); + } + + public final StringBuilder toString(final StringBuilder sb) { + sb.append(name).append('[').append(count); + sb.append("] sum: ").append(sum).append(" avg: "); + sb.append(trimTo3Digits(((double) sum) / count)); + sb.append(" [").append(min).append(" | ").append(max).append("]"); + return sb; + } + + /** + * Adjust the given double value to keep only 3 decimal digits + * + * @param value value to adjust + * @return double value with only 3 decimal digits + */ + public static double trimTo3Digits(final double value) { + return ((long) (1e3d * value)) / 1e3d; + } +} + diff --git a/src/share/classes/sun/java2d/pipe/AAShapePipe.java b/src/share/classes/sun/java2d/pipe/AAShapePipe.java index 239d134fca06d383dd1b01008204a6ac383ae9d3..3046ff69c6041ddf05acd22680a68786d03e3ef9 100644 --- a/src/share/classes/sun/java2d/pipe/AAShapePipe.java +++ b/src/share/classes/sun/java2d/pipe/AAShapePipe.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -22,15 +22,17 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ - package sun.java2d.pipe; import java.awt.BasicStroke; import java.awt.Rectangle; import java.awt.Shape; import java.awt.geom.Rectangle2D; -import java.awt.geom.PathIterator; +import java.util.concurrent.ConcurrentLinkedQueue; import sun.awt.SunHints; +import sun.java2d.ReentrantContext; +import sun.java2d.ReentrantContextProvider; +import sun.java2d.ReentrantContextProviderTL; import sun.java2d.SunGraphics2D; /** @@ -40,19 +42,31 @@ import sun.java2d.SunGraphics2D; * This class sets up the Generator and computes the alpha tiles * and then passes them on to a CompositePipe object for painting. */ -public class AAShapePipe +public final class AAShapePipe implements ShapeDrawPipe, ParallelogramPipe { - static RenderingEngine renderengine = RenderingEngine.getInstance(); + static final RenderingEngine renderengine = RenderingEngine.getInstance(); + + // Per-thread TileState (~1K very small so do not use any Weak Reference) + private static final ReentrantContextProvider tileStateProvider = + new ReentrantContextProviderTL( + ReentrantContextProvider.REF_HARD) + { + @Override + protected TileState newContext() { + return new TileState(); + } + }; - CompositePipe outpipe; + final CompositePipe outpipe; public AAShapePipe(CompositePipe pipe) { outpipe = pipe; } + @Override public void draw(SunGraphics2D sg, Shape s) { - BasicStroke bs; + final BasicStroke bs; if (sg.stroke instanceof BasicStroke) { bs = (BasicStroke) sg.stroke; @@ -64,24 +78,12 @@ public class AAShapePipe renderPath(sg, s, bs); } + @Override public void fill(SunGraphics2D sg, Shape s) { renderPath(sg, s, null); } - private static Rectangle2D computeBBox(double ux1, double uy1, - double ux2, double uy2) - { - if ((ux2 -= ux1) < 0) { - ux1 += ux2; - ux2 = -ux2; - } - if ((uy2 -= uy1) < 0) { - uy1 += uy2; - uy2 = -uy2; - } - return new Rectangle2D.Double(ux1, uy1, ux2, uy2); - } - + @Override public void fillParallelogram(SunGraphics2D sg, double ux1, double uy1, double ux2, double uy2, @@ -89,19 +91,23 @@ public class AAShapePipe double dx1, double dy1, double dx2, double dy2) { - Region clip = sg.getCompClip(); - int abox[] = new int[4]; - AATileGenerator aatg = - renderengine.getAATileGenerator(x, y, dx1, dy1, dx2, dy2, 0, 0, - clip, abox); - if (aatg == null) { - // Nothing to render - return; - } + final TileState ts = tileStateProvider.acquire(); + try { + final int[] abox = ts.abox; - renderTiles(sg, computeBBox(ux1, uy1, ux2, uy2), aatg, abox); + final AATileGenerator aatg = + renderengine.getAATileGenerator(x, y, dx1, dy1, dx2, dy2, 0, 0, + sg.getCompClip(), abox); + if (aatg != null) { + renderTiles(sg, ts.computeBBox(ux1, uy1, ux2, uy2), + aatg, abox, ts); + } + } finally { + tileStateProvider.release(ts); + } } + @Override public void drawParallelogram(SunGraphics2D sg, double ux1, double uy1, double ux2, double uy2, @@ -110,82 +116,77 @@ public class AAShapePipe double dx2, double dy2, double lw1, double lw2) { - Region clip = sg.getCompClip(); - int abox[] = new int[4]; - AATileGenerator aatg = - renderengine.getAATileGenerator(x, y, dx1, dy1, dx2, dy2, lw1, lw2, - clip, abox); - if (aatg == null) { - // Nothing to render - return; - } - - // Note that bbox is of the original shape, not the wide path. - // This is appropriate for handing to Paint methods... - renderTiles(sg, computeBBox(ux1, uy1, ux2, uy2), aatg, abox); - } - - private static byte[] theTile; + final TileState ts = tileStateProvider.acquire(); + try { + final int[] abox = ts.abox; - private synchronized static byte[] getAlphaTile(int len) { - byte[] t = theTile; - if (t == null || t.length < len) { - t = new byte[len]; - } else { - theTile = null; + final AATileGenerator aatg = + renderengine.getAATileGenerator(x, y, dx1, dy1, dx2, dy2, lw1, + lw2, sg.getCompClip(), abox); + if (aatg != null) { + // Note that bbox is of the original shape, not the wide path. + // This is appropriate for handing to Paint methods... + renderTiles(sg, ts.computeBBox(ux1, uy1, ux2, uy2), + aatg, abox, ts); + } + } finally { + tileStateProvider.release(ts); } - return t; - } - - private synchronized static void dropAlphaTile(byte[] t) { - theTile = t; } public void renderPath(SunGraphics2D sg, Shape s, BasicStroke bs) { - boolean adjust = (bs != null && + final boolean adjust = (bs != null && sg.strokeHint != SunHints.INTVAL_STROKE_PURE); - boolean thin = (sg.strokeState <= SunGraphics2D.STROKE_THINDASHED); - - Region clip = sg.getCompClip(); - int abox[] = new int[4]; - AATileGenerator aatg = - renderengine.getAATileGenerator(s, sg.transform, clip, - bs, thin, adjust, abox); - if (aatg == null) { - // Nothing to render - return; - } + final boolean thin = (sg.strokeState <= SunGraphics2D.STROKE_THINDASHED); - renderTiles(sg, s, aatg, abox); + final TileState ts = tileStateProvider.acquire(); + try { + final int[] abox = ts.abox; + + final AATileGenerator aatg = + renderengine.getAATileGenerator(s, sg.transform, sg.getCompClip(), + bs, thin, adjust, abox); + if (aatg != null) { + renderTiles(sg, s, aatg, abox, ts); + } + } finally { + tileStateProvider.release(ts); + } } public void renderTiles(SunGraphics2D sg, Shape s, - AATileGenerator aatg, int abox[]) + final AATileGenerator aatg, + final int[] abox, final TileState ts) { Object context = null; - byte alpha[] = null; try { + // reentrance: outpipe may also use AAShapePipe: context = outpipe.startSequence(sg, s, - new Rectangle(abox[0], abox[1], - abox[2] - abox[0], - abox[3] - abox[1]), + ts.computeDevBox(abox), abox); - int tw = aatg.getTileWidth(); - int th = aatg.getTileHeight(); - alpha = getAlphaTile(tw * th); + // copy of int[] abox as local variables for performance: + final int x0 = abox[0]; + final int y0 = abox[1]; + final int x1 = abox[2]; + final int y1 = abox[3]; + + final int tw = aatg.getTileWidth(); + final int th = aatg.getTileHeight(); + // get tile from thread local storage: + final byte[] alpha = ts.getAlphaTile(tw * th); byte[] atile; - for (int y = abox[1]; y < abox[3]; y += th) { - for (int x = abox[0]; x < abox[2]; x += tw) { - int w = Math.min(tw, abox[2] - x); - int h = Math.min(th, abox[3] - y); + for (int y = y0; y < y1; y += th) { + final int h = Math.min(th, y1 - y); + + for (int x = x0; x < x1; x += tw) { + final int w = Math.min(tw, x1 - x); + + final int a = aatg.getTypicalAlpha(); - int a = aatg.getTypicalAlpha(); - if (a == 0x00 || - outpipe.needTile(context, x, y, w, h) == false) - { + if (a == 0x00 || !outpipe.needTile(context, x, y, w, h)) { aatg.nextTile(); outpipe.skipTile(context, x, y); continue; @@ -198,8 +199,7 @@ public class AAShapePipe aatg.getAlpha(alpha, 0, tw); } - outpipe.renderPathTile(context, atile, 0, tw, - x, y, w, h); + outpipe.renderPathTile(context, atile, 0, tw, x, y, w, h); } } } finally { @@ -207,9 +207,55 @@ public class AAShapePipe if (context != null) { outpipe.endSequence(context); } - if (alpha != null) { - dropAlphaTile(alpha); + } + } + + // Tile state used by AAShapePipe + static final class TileState extends ReentrantContext { + // cached tile (32 x 32 tile by default) + private byte[] theTile = new byte[32 * 32]; + // dirty aabox array + final int[] abox = new int[4]; + // dirty bbox rectangle + private final Rectangle dev = new Rectangle(); + // dirty bbox rectangle2D.Double + private final Rectangle2D.Double bbox2D = new Rectangle2D.Double(); + + byte[] getAlphaTile(int len) { + byte[] t = theTile; + if (t.length < len) { + // create a larger tile and may free current theTile (too small) + theTile = t = new byte[len]; + } + return t; + } + + Rectangle computeDevBox(final int[] abox) { + final Rectangle box = this.dev; + box.x = abox[0]; + box.y = abox[1]; + box.width = abox[2] - abox[0]; + box.height = abox[3] - abox[1]; + return box; + } + + Rectangle2D computeBBox(double ux1, double uy1, + double ux2, double uy2) + { + if ((ux2 -= ux1) < 0.0) { + ux1 += ux2; + ux2 = -ux2; + } + if ((uy2 -= uy1) < 0.0) { + uy1 += uy2; + uy2 = -uy2; } + final Rectangle2D.Double box = this.bbox2D; + box.x = ux1; + box.y = uy1; + box.width = ux2; + box.height = uy2; + return box; } } } diff --git a/src/share/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine b/src/share/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine index 607ff59051afc71eebd7198aec7ecb2813e947ef..e542b6f8c2b2e05a137c4844f48c5745f2fa058e 100644 --- a/src/share/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine +++ b/src/share/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine @@ -1,2 +1,8 @@ +# note: the last class is the default Rendering Engine +# Pisces in JDK8u, Marlin in JDK9+ + +# Marlin Rendering Engine module +sun.java2d.marlin.MarlinRenderingEngine + # Pisces Rendering Engine module sun.java2d.pisces.PiscesRenderingEngine diff --git a/src/share/classes/sun/java2d/pisces/Stroker.java b/src/share/classes/sun/java2d/pisces/Stroker.java index 6d4a4c75ac54d34a7627b2e9257e6e142edbb45f..f388da4fd0c7c4c52e1660d36f08aed7e9e1ab1b 100644 --- a/src/share/classes/sun/java2d/pisces/Stroker.java +++ b/src/share/classes/sun/java2d/pisces/Stroker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -193,11 +193,11 @@ final class Stroker implements PathConsumer2D { // The sign of the dot product of mx,my and omx,omy is equal to the // the sign of the cosine of ext // (ext is the angle between omx,omy and mx,my). - double cosext = omx * mx + omy * my; + final float cosext = omx * mx + omy * my; // If it is >=0, we know that abs(ext) is <= 90 degrees, so we only // need 1 curve to approximate the circle section that joins omx,omy // and mx,my. - final int numCurves = cosext >= 0 ? 1 : 2; + final int numCurves = (cosext >= 0f) ? 1 : 2; switch (numCurves) { case 1: @@ -242,14 +242,22 @@ final class Stroker implements PathConsumer2D { final float mx, final float my, boolean rev) { - float cosext2 = (omx * mx + omy * my) / (2 * lineWidth2 * lineWidth2); + final float cosext2 = (omx * mx + omy * my) / (2f * lineWidth2 * lineWidth2); + + // check round off errors producing cos(ext) > 1 and a NaN below + // cos(ext) == 1 implies colinear segments and an empty join anyway + if (cosext2 >= 0.5f) { + // just return to avoid generating a flat curve: + return; + } + // cv is the length of P1-P0 and P2-P3 divided by the radius of the arc // (so, cv assumes the arc has radius 1). P0, P1, P2, P3 are the points that // define the bezier curve we're computing. // It is computed using the constraints that P1-P0 and P3-P2 are parallel // to the arc tangents at the endpoints, and that |P1-P0|=|P3-P2|. - float cv = (float) ((4.0 / 3.0) * sqrt(0.5-cosext2) / - (1.0 + sqrt(cosext2+0.5))); + float cv = (float) ((4.0 / 3.0) * sqrt(0.5 - cosext2) / + (1.0 + sqrt(cosext2 + 0.5))); // if clockwise, we need to negate cv. if (rev) { // rev is equivalent to isCW(omx, omy, mx, my) cv = -cv; diff --git a/src/share/classes/sun/management/ExtendedPlatformComponent.java b/src/share/classes/sun/management/ExtendedPlatformComponent.java index ff33ff9b52e5b360c8dfa88d9ae78efa260e6348..7eaadc782885a4ada2dddb11fa4ff987560ad2e0 100644 --- a/src/share/classes/sun/management/ExtendedPlatformComponent.java +++ b/src/share/classes/sun/management/ExtendedPlatformComponent.java @@ -25,9 +25,12 @@ package sun.management; +import java.lang.reflect.InvocationTargetException; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.lang.management.PlatformManagedObject; +import java.lang.reflect.Method; /** * Class to allow for an extended set of platform MXBeans @@ -40,7 +43,12 @@ public final class ExtendedPlatformComponent { * platform MBeanServer, or an empty list if there are no such MXBeans. */ public static List getMXBeans() { - return Collections.emptyList(); + PlatformManagedObject o = getFlightRecorderBean(); + if (o != null) { + return Collections.singletonList(o); + } else { + return Collections.emptyList(); + } } /** @@ -49,6 +57,23 @@ public final class ExtendedPlatformComponent { */ public static T getMXBean(Class mxbeanInterface) { + + if ("jdk.management.jfr.FlightRecorderMXBean".equals(mxbeanInterface.getName())) { + return (T)getFlightRecorderBean(); + } return null; } + + private static PlatformManagedObject getFlightRecorderBean() { + PlatformManagedObject object = null; + try { + Class provider = Class.forName("jdk.management.jfr.internal.FlightRecorderMXBeanProvider"); + Method m = provider.getDeclaredMethod("getFlightRecorderMXBean"); + + object = (PlatformManagedObject)m.invoke(null); + } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + // no jfr? + } + return object; + } } diff --git a/src/share/classes/sun/misc/JavaSecuritySignatureAccess.java b/src/share/classes/sun/misc/JavaSecuritySignatureAccess.java new file mode 100644 index 0000000000000000000000000000000000000000..382f8140be1c9dc5f400d570d907ce248cd9180f --- /dev/null +++ b/src/share/classes/sun/misc/JavaSecuritySignatureAccess.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * 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.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/share/classes/sun/misc/SharedSecrets.java b/src/share/classes/sun/misc/SharedSecrets.java index 39c62a35ca749d17678c99c0319e00e81b2875b2..e266fbf3e7b1be8c4e172617ea862792811cdc71 100644 --- a/src/share/classes/sun/misc/SharedSecrets.java +++ b/src/share/classes/sun/misc/SharedSecrets.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ import java.io.Console; import java.io.FileDescriptor; import java.io.ObjectInputStream; import java.security.ProtectionDomain; +import java.security.Signature; import java.security.AccessController; @@ -62,6 +63,7 @@ public class SharedSecrets { private static JavaObjectInputStreamReadString javaObjectInputStreamReadString; private static JavaObjectInputStreamAccess javaObjectInputStreamAccess; private static TenantAccess tenantAccess; + private static JavaSecuritySignatureAccess javaSecuritySignatureAccess; public static JavaUtilJarAccess javaUtilJarAccess() { if (javaUtilJarAccess == null) { @@ -226,6 +228,17 @@ public class SharedSecrets { javaObjectInputStreamAccess = access; } + 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/share/classes/sun/net/idn/Punycode.java b/src/share/classes/sun/net/idn/Punycode.java index 00279131add1af0c55b40dd51b5a29e17c17011a..7c22d7c1edd3714735b05fdb739473b2099d2926 100644 --- a/src/share/classes/sun/net/idn/Punycode.java +++ b/src/share/classes/sun/net/idn/Punycode.java @@ -185,7 +185,7 @@ public final class Punycode { for(j=0; j(); } diff --git a/src/share/classes/sun/rmi/transport/tcp/TCPEndpoint.java b/src/share/classes/sun/rmi/transport/tcp/TCPEndpoint.java index 0d849ed7f293b84ba7775f0349da7cb9cf7fb09b..409b6fb809149ec9228e17539fd14e6a68aa4f4c 100644 --- a/src/share/classes/sun/rmi/transport/tcp/TCPEndpoint.java +++ b/src/share/classes/sun/rmi/transport/tcp/TCPEndpoint.java @@ -554,7 +554,7 @@ public class TCPEndpoint implements Endpoint { host = in.readUTF(); port = in.readInt(); csf = (RMIClientSocketFactory) in.readObject(); - if (Proxy.isProxyClass(csf.getClass())) { + if (csf != null && Proxy.isProxyClass(csf.getClass())) { throw new IOException("Invalid SocketFactory"); } break; diff --git a/src/share/classes/sun/security/ec/CurveDB.java b/src/share/classes/sun/security/ec/CurveDB.java index 2bf70d38d5e0ba7be7db1504945a2b8b4c3e96d5..cfe56ebbbd1c06fe67c2c9e665c323595991d2ef 100644 --- a/src/share/classes/sun/security/ec/CurveDB.java +++ b/src/share/classes/sun/security/ec/CurveDB.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved. * 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,8 @@ import java.security.spec.*; import java.util.*; import java.util.regex.Pattern; +import sun.security.util.ECUtil; + /** * Repository for well-known Elliptic Curve parameters. It is used by both * the SunPKCS11 and SunJSSE code. @@ -104,21 +106,10 @@ public class CurveDB { if (namedCurve.getCurve().getField().getFieldSize() != fieldSize) { continue; } - if (namedCurve.getCurve().equals(params.getCurve()) == false) { - continue; - } - if (namedCurve.getGenerator().equals(params.getGenerator()) == - false) { - continue; - } - if (namedCurve.getOrder().equals(params.getOrder()) == false) { - continue; - } - if (namedCurve.getCofactor() != params.getCofactor()) { - continue; + if (ECUtil.equals(namedCurve, params)) { + // everything matches our named curve, return it + return namedCurve; } - // everything matches our named curve, return it - return namedCurve; } // no match found return null; diff --git a/src/share/classes/sun/security/ec/ECDSASignature.java b/src/share/classes/sun/security/ec/ECDSASignature.java index 03aceae374aa98a635212fb9b1d5fd6bf6aa930e..bb50e3ae77a1929c7dcc66341dc181fc8bdc97c0 100644 --- a/src/share/classes/sun/security/ec/ECDSASignature.java +++ b/src/share/classes/sun/security/ec/ECDSASignature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ package sun.security.ec; -import java.io.IOException; import java.nio.ByteBuffer; -import java.math.BigInteger; import java.security.*; import java.security.interfaces.*; @@ -68,6 +66,9 @@ abstract class ECDSASignature extends SignatureSpi { // public key, if initialized for verifying private ECPublicKey publicKey; + // signature parameters + private ECParameterSpec sigParams = null; + /** * Constructs a new ECDSASignature. Used by Raw subclass. * @@ -198,10 +199,14 @@ abstract class ECDSASignature extends SignatureSpi { @Override protected void engineInitVerify(PublicKey publicKey) throws InvalidKeyException { - this.publicKey = (ECPublicKey) ECKeyFactory.toECKey(publicKey); + ECPublicKey key = (ECPublicKey) ECKeyFactory.toECKey(publicKey); + if (!isCompatible(this.sigParams, key.getParams())) { + throw new InvalidKeyException("Key params does not match signature params"); + } // Should check that the supplied key is appropriate for signature // algorithm (e.g. P-256 for SHA256withECDSA) + this.publicKey = key; this.privateKey = null; resetDigest(); } @@ -217,10 +222,14 @@ abstract class ECDSASignature extends SignatureSpi { @Override protected void engineInitSign(PrivateKey privateKey, SecureRandom random) throws InvalidKeyException { - this.privateKey = (ECPrivateKey) ECKeyFactory.toECKey(privateKey); + ECPrivateKey key = (ECPrivateKey) ECKeyFactory.toECKey(privateKey); + if (!isCompatible(this.sigParams, key.getParams())) { + throw new InvalidKeyException("Key params does not match signature params"); + } // Should check that the supplied key is appropriate for signature // algorithm (e.g. P-256 for SHA256withECDSA) + this.privateKey = key; this.publicKey = null; this.random = random; resetDigest(); @@ -273,6 +282,16 @@ abstract class ECDSASignature extends SignatureSpi { needsReset = true; } + private static boolean isCompatible(ECParameterSpec sigParams, + ECParameterSpec keyParams) { + if (sigParams == null) { + // no restriction on key param + return true; + } + return ECUtil.equals(sigParams, keyParams); + } + + private byte[] signDigestImpl(ECDSAOperations ops, int seedBits, byte[] digest, ECPrivateKeyImpl privImpl, SecureRandom random) throws SignatureException { @@ -366,7 +385,7 @@ abstract class ECDSASignature extends SignatureSpi { sig = signDigestNative(privateKey, digest, random); } - return encodeSignature(sig); + return ECUtil.encodeSignature(sig); } // verify the data and return the result. See JCA doc @@ -387,7 +406,8 @@ abstract class ECDSASignature extends SignatureSpi { try { return verifySignedDigest( - decodeSignature(signature), getDigestValue(), w, encodedParams); + ECUtil.decodeSignature(signature), getDigestValue(), + w, encodedParams); } catch (GeneralSecurityException e) { throw new SignatureException("Could not verify signature", e); @@ -402,6 +422,21 @@ abstract class ECDSASignature extends SignatureSpi { throw new UnsupportedOperationException("setParameter() not supported"); } + @Override + protected void engineSetParameter(AlgorithmParameterSpec params) + throws InvalidAlgorithmParameterException { + if (params != null && !(params instanceof ECParameterSpec)) { + throw new InvalidAlgorithmParameterException("No parameter accepted"); + } + ECKey key = (this.privateKey == null? this.publicKey : this.privateKey); + if ((key != null) && !isCompatible((ECParameterSpec)params, key.getParams())) { + throw new InvalidAlgorithmParameterException + ("Signature params does not match key params"); + } + + sigParams = (ECParameterSpec) params; + } + // get parameter, not supported. See JCA doc @Override @Deprecated @@ -410,77 +445,19 @@ abstract class ECDSASignature extends SignatureSpi { throw new UnsupportedOperationException("getParameter() not supported"); } - // Convert the concatenation of R and S into their DER encoding - private byte[] encodeSignature(byte[] signature) throws SignatureException { - - try { - - int n = signature.length >> 1; - byte[] bytes = new byte[n]; - System.arraycopy(signature, 0, bytes, 0, n); - BigInteger r = new BigInteger(1, bytes); - System.arraycopy(signature, n, bytes, 0, n); - BigInteger s = new BigInteger(1, bytes); - - DerOutputStream out = new DerOutputStream(signature.length + 10); - out.putInteger(r); - out.putInteger(s); - DerValue result = - new DerValue(DerValue.tag_Sequence, out.toByteArray()); - - return result.toByteArray(); - - } catch (Exception e) { - throw new SignatureException("Could not encode signature", e); + @Override + protected AlgorithmParameters engineGetParameters() { + if (sigParams == null) { + return null; } - } - - // Convert the DER encoding of R and S into a concatenation of R and S - private byte[] decodeSignature(byte[] sig) throws SignatureException { - try { - // Enforce strict DER checking for signatures - DerInputStream in = new DerInputStream(sig, 0, sig.length, false); - DerValue[] values = in.getSequence(2); - - // check number of components in the read sequence - // and trailing data - if ((values.length != 2) || (in.available() != 0)) { - throw new IOException("Invalid encoding for signature"); - } - - BigInteger r = values[0].getPositiveBigInteger(); - BigInteger s = values[1].getPositiveBigInteger(); - - // trim leading zeroes - byte[] rBytes = trimZeroes(r.toByteArray()); - byte[] sBytes = trimZeroes(s.toByteArray()); - int k = Math.max(rBytes.length, sBytes.length); - // r and s each occupy half the array - byte[] result = new byte[k << 1]; - System.arraycopy(rBytes, 0, result, k - rBytes.length, - rBytes.length); - System.arraycopy(sBytes, 0, result, result.length - sBytes.length, - sBytes.length); - return result; - + AlgorithmParameters ap = AlgorithmParameters.getInstance("EC"); + ap.init(sigParams); + return ap; } catch (Exception e) { - throw new SignatureException("Invalid encoding for signature", e); - } - } - - // trim leading (most significant) zeroes from the result - private static byte[] trimZeroes(byte[] b) { - int i = 0; - while ((i < b.length - 1) && (b[i] == 0)) { - i++; - } - if (i == 0) { - return b; + // should never happen + throw new ProviderException("Error retrieving EC parameters", e); } - byte[] t = new byte[b.length - i]; - System.arraycopy(b, i, t, 0, t.length); - return t; } /** diff --git a/src/share/classes/sun/security/jgss/GSSCredentialImpl.java b/src/share/classes/sun/security/jgss/GSSCredentialImpl.java index 65f6847fd3e87649a8b401b841fd94600c4d70c3..2b8b11b9242ffced7d9fe7167d2162ee92bad845 100644 --- a/src/share/classes/sun/security/jgss/GSSCredentialImpl.java +++ b/src/share/classes/sun/security/jgss/GSSCredentialImpl.java @@ -535,8 +535,8 @@ public class GSSCredentialImpl implements ExtendedGSSCredential { /** * Returns the specified mechanism's credential-element. * - * @param mechOid - the oid for mechanism to retrieve - * @param throwExcep - boolean indicating if the function is + * @param mechOid the oid for mechanism to retrieve + * @param initiate boolean indicating if the function is * to throw exception or return null when element is not * found. * @return mechanism credential object diff --git a/src/share/classes/sun/security/jgss/GSSToken.java b/src/share/classes/sun/security/jgss/GSSToken.java index 7fa3047f86d43978285bed6250d453eb8ae6b217..5c887b051e9f524a7ea0443aae127450164f5d28 100644 --- a/src/share/classes/sun/security/jgss/GSSToken.java +++ b/src/share/classes/sun/security/jgss/GSSToken.java @@ -84,7 +84,7 @@ public abstract class GSSToken { * * @param data the array containing the bytes of the integer value * @param pos the offset in the array - * @size the number of bytes to read from the array. + * @param size the number of bytes to read from the array. * @return the integer value */ public static final int readLittleEndian(byte[] data, int pos, int size) { @@ -141,7 +141,7 @@ public abstract class GSSToken { * Reads a two byte integer value from an InputStream. * * @param is the InputStream to read from - * @returns the integer value + * @return the integer value * @throws IOException if some errors occurs while reading the integer * bytes. */ @@ -155,7 +155,7 @@ public abstract class GSSToken { * * @param src the byte arra to read from * @param pos the offset to start reading from - * @returns the integer value + * @return the integer value */ public static final int readInt(byte[] src, int pos) { return ((0xFF & src[pos])<<8 | (0xFF & src[pos+1])); @@ -167,8 +167,8 @@ public abstract class GSSToken { * * @param is the InputStream to read from * @param buffer the buffer to store the bytes into - * @param throws EOFException if EOF is reached before all bytes are - * read. + * @throws EOFException if EOF is reached before all bytes are + * read. * @throws IOException is an error occurs while reading */ public static final void readFully(InputStream is, byte[] buffer) @@ -184,8 +184,8 @@ public abstract class GSSToken { * @param buffer the buffer to store the bytes into * @param offset the offset to start storing at * @param len the number of bytes to read - * @param throws EOFException if EOF is reached before all bytes are - * read. + * @throws EOFException if EOF is reached before all bytes are + * read. * @throws IOException is an error occurs while reading */ public static final void readFully(InputStream is, diff --git a/src/share/classes/sun/security/jgss/LoginConfigImpl.java b/src/share/classes/sun/security/jgss/LoginConfigImpl.java index 9ae3d5a08a295ba91f248a2f2ee52bdd1f9e1cf6..eab531d8dbacd4e1154f7befd30753f397d21b20 100644 --- a/src/share/classes/sun/security/jgss/LoginConfigImpl.java +++ b/src/share/classes/sun/security/jgss/LoginConfigImpl.java @@ -59,7 +59,7 @@ public class LoginConfigImpl extends Configuration { * A new instance of LoginConfigImpl must be created for each login request * since it's only used by a single (caller, mech) pair * @param caller defined in GSSUtil as CALLER_XXX final fields - * @param oid defined in GSSUtil as XXX_MECH_OID final fields + * @param mech defined in GSSUtil as XXX_MECH_OID final fields */ public LoginConfigImpl(GSSCaller caller, Oid mech) { diff --git a/src/share/classes/sun/security/jgss/ProviderList.java b/src/share/classes/sun/security/jgss/ProviderList.java index bfc48acf49a985640236fb03e636d32080a56468..d7dfffe9837e37d748c0851c199edf8b99f4277e 100644 --- a/src/share/classes/sun/security/jgss/ProviderList.java +++ b/src/share/classes/sun/security/jgss/ProviderList.java @@ -46,7 +46,7 @@ import sun.security.action.GetPropertyAction; * queries this class whenever it needs a mechanism's factory.

    * * This class stores an ordered list of pairs of the form - * . When it attempts to instantiate a mechanism + * {@code }. When it attempts to instantiate a mechanism * defined by oid o, it steps through the list looking for an entry * with oid=o, or with oid=null. (An entry with oid=null matches all * mechanisms.) When it finds such an entry, the corresponding @@ -74,12 +74,12 @@ import sun.security.action.GetPropertyAction; * the system ones don't suffice.

    * * If a mechanism's factory is being obtained from a provider as a - * result of encountering a entryof the form where + * result of encountering a entryof the form {@code } where * oid is non-null, then the assumption is that the application added * this entry and it wants this mechanism to be obtained from this * provider. Thus is the provider does not actually contain the * requested mechanism, an exception will be thrown. However, if the - * entry were of the form , then it is viewed more + * entry were of the form {@code }, then it is viewed more * liberally and is simply skipped over if the provider does not claim to * support the requested mechanism. */ diff --git a/src/share/classes/sun/security/jgss/krb5/Krb5NameElement.java b/src/share/classes/sun/security/jgss/krb5/Krb5NameElement.java index 37d0b77bbbb9ea0a5decd6c0d4c6b6d6d55dc5db..461e2481e5d972ab8f40b82758630f81a6deb188 100644 --- a/src/share/classes/sun/security/jgss/krb5/Krb5NameElement.java +++ b/src/share/classes/sun/security/jgss/krb5/Krb5NameElement.java @@ -214,7 +214,7 @@ public class Krb5NameElement * return false. * * @param other to be compared with - * @returns true if they both refer to the same entity, else false + * @return true if they both refer to the same entity, else false * @exception GSSException with major codes of BAD_NAMETYPE, * BAD_NAME, FAILURE */ @@ -239,7 +239,7 @@ public class Krb5NameElement * situation where an error occurs. * * @param another the object to be compared to - * @returns true if they both refer to the same entity, else false + * @return true if they both refer to the same entity, else false * @see #equals(GSSNameSpi) */ public boolean equals(Object another) { diff --git a/src/share/classes/sun/security/jgss/spi/GSSContextSpi.java b/src/share/classes/sun/security/jgss/spi/GSSContextSpi.java index 1a68a4456c8da317a1e92e3a08cd62eeafce9f0d..07b1c7de4f2376cc4ae82a728edd5838e8d2a898 100644 --- a/src/share/classes/sun/security/jgss/spi/GSSContextSpi.java +++ b/src/share/classes/sun/security/jgss/spi/GSSContextSpi.java @@ -52,14 +52,14 @@ import com.sun.security.jgss.*; * and the context flags before the context is fully established. The * isProtReady method is used to indicate that these services are * available. - *

    + *

    * * Context establishment tokens are defined in a mechanism independent * format in section 3.1 of RFC 2743. The GSS-Framework will add * and remove the mechanism independent header portion of this token format * depending on whether a token is received or is being sent. The mechanism - * should only generate or expect to read the inner-context token portion.. - *

    + * should only generate or expect to read the inner-context token portion. + *
    * On the other hands, tokens used for per-message calls are generated * entirely by the mechanism. It is possible that the mechanism chooses to * encase inner-level per-message tokens in a header similar to that used @@ -240,7 +240,7 @@ public interface GSSContextSpi { * asked to provide. * @param confReq a flag indicating whether confidentiality will be * requested or not - * @param outputSize the maximum size of the output token + * @param maxTokSize the maximum size of the output token * @return the maximum size for the input message that can be * provided to the wrap() method in order to guarantee that these * requirements are met. @@ -255,7 +255,7 @@ public interface GSSContextSpi { * @param is the user-provided message to be protected * @param os the token to be sent to the peer. It includes * the message from is with the requested protection. - * @param msgPro on input it contains the requested qop and + * @param msgProp on input it contains the requested qop and * confidentiality state, on output, the applied values * @exception GSSException may be thrown * @see unwrap @@ -366,7 +366,7 @@ public interface GSSContextSpi { * * @param is token generated by getMIC * @param msgStr the message to check integrity for - * @param msgProp will contain the applied QOP and confidentiality + * @param mProp will contain the applied QOP and confidentiality * states of the token as well as any informatory status codes * @exception GSSException may be thrown */ diff --git a/src/share/classes/sun/security/jgss/spi/GSSNameSpi.java b/src/share/classes/sun/security/jgss/spi/GSSNameSpi.java index 61fc20746550212ffc695266ab542488481c2cfa..24362d0074f58962dfbc375d2e49330daa6833d6 100644 --- a/src/share/classes/sun/security/jgss/spi/GSSNameSpi.java +++ b/src/share/classes/sun/security/jgss/spi/GSSNameSpi.java @@ -46,7 +46,7 @@ public interface GSSNameSpi { * return false. * * @param name to be compared with - * @returns true if they both refer to the same entity, else false + * @return true if they both refer to the same entity, else false * @exception GSSException with major codes of BAD_NAMETYPE, * BAD_NAME, FAILURE */ @@ -60,7 +60,7 @@ public interface GSSNameSpi { * situation where an error occurs. * * @param another the object to be compared to - * @returns true if they both refer to the same entity, else false + * @return true if they both refer to the same entity, else false * @see #equals(GSSNameSpi) */ public boolean equals(Object another); diff --git a/src/share/classes/sun/security/jgss/spi/MechanismFactory.java b/src/share/classes/sun/security/jgss/spi/MechanismFactory.java index 5d40fffe409296f217943a121f9bbfec54d32563..e5bba5f29317b610836cb0a68e5aba42f43ab722 100644 --- a/src/share/classes/sun/security/jgss/spi/MechanismFactory.java +++ b/src/share/classes/sun/security/jgss/spi/MechanismFactory.java @@ -147,7 +147,7 @@ public interface MechanismFactory { *

    * An exported name will generally be passed in using this method. * - * @param nameBytes the bytes describing this entity to the mechanism + * @param name the bytes describing this entity to the mechanism * @param nameType an Oid serving as a clue as to how the mechanism should * interpret the nameStr * @throws GSSException if any of the errors described in RFC 2743 for diff --git a/src/share/classes/sun/security/krb5/Checksum.java b/src/share/classes/sun/security/krb5/Checksum.java index 92a5de8d58cdd84352a5b9a3badc6ae33ac00d37..3f89f97cd4b8124ca4338a9335fe3de05ad4352b 100644 --- a/src/share/classes/sun/security/krb5/Checksum.java +++ b/src/share/classes/sun/security/krb5/Checksum.java @@ -133,8 +133,8 @@ public class Checksum { * own calculating and verification rules. It does has the same * ASN.1 encoding though. * - * @data the byte array of checksum. - * @new_cksumType the type of checksum. + * @param data the byte array of checksum. + * @param new_cksumType the type of checksum. */ public Checksum(byte[] data, int new_cksumType) { cksumType = new_cksumType; @@ -235,12 +235,12 @@ public class Checksum { /** * Encodes a Checksum object. - *

    + * <pre>{@code * Checksum ::= SEQUENCE { * cksumtype [0] Int32, * checksum [1] OCTET STRING * } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 diff --git a/src/share/classes/sun/security/krb5/Config.java b/src/share/classes/sun/security/krb5/Config.java index fe6565cbab697e8541026faeec91eb4dd798dbbe..e981c31d97e3005290cfe199217a4d20b84fab4c 100644 --- a/src/share/classes/sun/security/krb5/Config.java +++ b/src/share/classes/sun/security/krb5/Config.java @@ -361,7 +361,7 @@ public class Config { * * @param s the string duration * @return time in seconds - * @throw KrbException if format is illegal + * @throws KrbException if format is illegal */ public static int duration(String s) throws KrbException { @@ -423,7 +423,7 @@ public class Config { * @param keys the keys * @return the int value, Integer.MIN_VALUE is returned if it cannot be * found or the value is not a legal integer. - * @throw IllegalArgumentException if any of the keys is illegal + * @throws IllegalArgumentException if any of the keys is illegal * @see #get(java.lang.String[]) */ public int getIntValue(String... keys) { diff --git a/src/share/classes/sun/security/krb5/Credentials.java b/src/share/classes/sun/security/krb5/Credentials.java index b364a628e957d3740a9f6b7635cd699a8476dda3..0fed291d6844fe01993b74d67b8731c1704cb2d9 100644 --- a/src/share/classes/sun/security/krb5/Credentials.java +++ b/src/share/classes/sun/security/krb5/Credentials.java @@ -313,7 +313,7 @@ public class Credentials { * @param ticketCache the path to the tickets file. A value * of null will be accepted to indicate that the default * path should be searched - * @returns the TGT credentials or null if none were found. If the tgt + * @return the TGT credentials or null if none were found. If the tgt * expired, it is the responsibility of the caller to determine this. */ public static Credentials acquireTGTFromCache(PrincipalName princ, diff --git a/src/share/classes/sun/security/krb5/EncryptedData.java b/src/share/classes/sun/security/krb5/EncryptedData.java index 4c5cab780177845d593cc4fc48c75215ff0be226..7f93db2b9b57429a3eea5e7d78fcaed5b61f44d8 100644 --- a/src/share/classes/sun/security/krb5/EncryptedData.java +++ b/src/share/classes/sun/security/krb5/EncryptedData.java @@ -259,20 +259,20 @@ public class EncryptedData implements Cloneable { /** * Returns an ASN.1 encoded EncryptedData type. * - *

    + * <pre>{@code * EncryptedData ::= SEQUENCE { * etype [0] Int32 -- EncryptionType --, * kvno [1] UInt32 OPTIONAL, * cipher [2] OCTET STRING -- ciphertext * } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 * specification available at * * http://www.ietf.org/rfc/rfc4120.txt. - *

    + * * @return byte array of encoded EncryptedData object. * @exception Asn1Exception if an error occurs while decoding an * ASN1 encoded data. diff --git a/src/share/classes/sun/security/krb5/EncryptionKey.java b/src/share/classes/sun/security/krb5/EncryptionKey.java index b83fe8c861176e409db8a7fa672a7e65fad0b7b7..4823b2525b0e602910eb1f350b650fe01f4eb39b 100644 --- a/src/share/classes/sun/security/krb5/EncryptionKey.java +++ b/src/share/classes/sun/security/krb5/EncryptionKey.java @@ -101,11 +101,11 @@ public class EncryptionKey * Obtains all versions of the secret key of the principal from a * keytab. * - * @Param princ the principal whose secret key is desired + * @param princ the principal whose secret key is desired * @param keytab the path to the keytab file. A value of null * will be accepted to indicate that the default path should be * searched. - * @returns an array of secret keys or null if none were found. + * @return an array of secret keys or null if none were found. */ public static EncryptionKey[] acquireSecretKeys(PrincipalName princ, String keytab) { @@ -127,7 +127,7 @@ public class EncryptionKey * @param password NOT null * @param etype * @param snp can be NULL - * @returns never null + * @return never null */ public static EncryptionKey acquireSecretKey(PrincipalName cname, char[] password, int etype, PAData.SaltAndParams snp) @@ -150,7 +150,7 @@ public class EncryptionKey * @param salt NOT null * @param etype * @param s2kparams can be NULL - * @returns never null + * @return never null */ public static EncryptionKey acquireSecretKey(char[] password, String salt, int etype, byte[] s2kparams) @@ -381,11 +381,11 @@ public class EncryptionKey /** * Returns the ASN.1 encoding of this EncryptionKey. * - *

    + * <pre>{@code * EncryptionKey ::= SEQUENCE { * keytype[0] INTEGER, * keyvalue[1] OCTET STRING } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 diff --git a/src/share/classes/sun/security/krb5/KrbAsReqBuilder.java b/src/share/classes/sun/security/krb5/KrbAsReqBuilder.java index 445fa19dfbaa93e9428a930677422671f6763668..c626cfda8e21789c80698f907de23ffc7d925d99 100644 --- a/src/share/classes/sun/security/krb5/KrbAsReqBuilder.java +++ b/src/share/classes/sun/security/krb5/KrbAsReqBuilder.java @@ -112,7 +112,7 @@ public final class KrbAsReqBuilder { * realm, where default realm will be used. This realm will be the target * realm for AS-REQ. I believe a client should only get initial TGT from * its own realm. - * @param keys must not be null. if empty, might be quite useless. + * @param ktab must not be null. If empty, might be quite useless. * This argument will neither be modified nor stored by the method. * @throws KrbException */ diff --git a/src/share/classes/sun/security/krb5/KrbTgsRep.java b/src/share/classes/sun/security/krb5/KrbTgsRep.java index 83f0b28c014a6087dce5687c70014e511ded1fd6..04f36acf4f4c004e9b56ee48c419e1441eee210d 100644 --- a/src/share/classes/sun/security/krb5/KrbTgsRep.java +++ b/src/share/classes/sun/security/krb5/KrbTgsRep.java @@ -95,9 +95,16 @@ public class KrbTgsRep extends KrbKdcRep { } } + PrincipalName clientAlias = null; + if (rep.cname.equals(req.reqBody.cname)) { + // Only propagate the client alias if it is not an + // impersonation ticket (S4U2Self or S4U2Proxy). + clientAlias = tgsReq.getClientAlias(); + } + this.creds = new Credentials(rep.ticket, rep.cname, - tgsReq.getClientAlias(), + clientAlias, enc_part.sname, serverAlias, enc_part.key, diff --git a/src/share/classes/sun/security/krb5/PrincipalName.java b/src/share/classes/sun/security/krb5/PrincipalName.java index 4a16eb39c7d27480c049508fb09044a023770111..e2dadb32682c49257df51c5e555d5cf747b7fbe9 100644 --- a/src/share/classes/sun/security/krb5/PrincipalName.java +++ b/src/share/classes/sun/security/krb5/PrincipalName.java @@ -45,14 +45,14 @@ import sun.security.krb5.internal.util.KerberosString; /** * Implements the ASN.1 PrincipalName type and its realm in a single class. - *

    + * <pre>{@code * Realm ::= KerberosString * * PrincipalName ::= SEQUENCE { * name-type [0] Int32, * name-string [1] SEQUENCE OF KerberosString * } - * + * } * This class is immutable. * @see Realm */ @@ -219,14 +219,14 @@ public class PrincipalName implements Cloneable { /** * Returns the ASN.1 encoding of the - * + * <pre>{@code * PrincipalName ::= SEQUENCE { * name-type [0] Int32, * name-string [1] SEQUENCE OF KerberosString * } * * KerberosString ::= GeneralString (IA5String) - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 @@ -657,7 +657,8 @@ public class PrincipalName implements Cloneable { * name, the second component is returned. * Null is returned if there are not two or more * components in the name. - * @returns instance component of a multi-component name. + * + * @return instance component of a multi-component name. */ public String getInstanceComponent() { diff --git a/src/share/classes/sun/security/krb5/Realm.java b/src/share/classes/sun/security/krb5/Realm.java index 2cf7bbfadf43178d8c8a2478e96e0141ea66d177..ffd64651015cde015118498262347401f733ca6b 100644 --- a/src/share/classes/sun/security/krb5/Realm.java +++ b/src/share/classes/sun/security/krb5/Realm.java @@ -41,9 +41,8 @@ import sun.security.krb5.internal.util.KerberosString; /** * Implements the ASN.1 Realm type. * - *

    - * Realm ::= GeneralString - * + * {@code Realm ::= GeneralString} + * * This class is immutable. */ public class Realm implements Cloneable { diff --git a/src/share/classes/sun/security/krb5/internal/APOptions.java b/src/share/classes/sun/security/krb5/internal/APOptions.java index c9644af6a0f500459f02c0117252a46dfe47c22a..88ef620d076bdb59887c8c8995e5f45e7bcf9af1 100644 --- a/src/share/classes/sun/security/krb5/internal/APOptions.java +++ b/src/share/classes/sun/security/krb5/internal/APOptions.java @@ -38,17 +38,17 @@ import java.io.IOException; /** * Implements the ASN.1 APOptions type. * - * + * <pre>{@code * APOptions ::= KerberosFlags * -- reserved(0), * -- use-session-key(1), * -- mutual-required(2) - * * * KerberosFlags ::= BIT STRING (SIZE (32..MAX)) * -- minimum number of bits shall be sent, * -- but no fewer than 32 * + * } *

    * This definition reflects the Network Working Group RFC4120 * specification available at diff --git a/src/share/classes/sun/security/krb5/internal/APRep.java b/src/share/classes/sun/security/krb5/internal/APRep.java index 4a8bea86b2d40cd9304d0995c6aa4384b06d290d..017159d6d91c8359285f9cddfbed20727cf54b8b 100644 --- a/src/share/classes/sun/security/krb5/internal/APRep.java +++ b/src/share/classes/sun/security/krb5/internal/APRep.java @@ -39,13 +39,13 @@ import java.math.BigInteger; /** * Implements the ASN.1 AP-REP type. * - *

    + * <pre>{@code * AP-REP ::= [APPLICATION 15] SEQUENCE { * pvno [0] INTEGER (5), * msg-type [1] INTEGER (15), * enc-part [2] EncryptedData -- EncAPRepPart * } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 diff --git a/src/share/classes/sun/security/krb5/internal/APReq.java b/src/share/classes/sun/security/krb5/internal/APReq.java index c70fe20289f9714b2e55ca2e60dc83e649788125..30a6aa668fe44461bdc288a8393d8104694a4aa6 100644 --- a/src/share/classes/sun/security/krb5/internal/APReq.java +++ b/src/share/classes/sun/security/krb5/internal/APReq.java @@ -38,7 +38,7 @@ import java.math.BigInteger; /** * Implements the ASN.1 AP-REQ type. * - *

    + * <pre>{@code * AP-REQ ::= [APPLICATION 14] SEQUENCE { * pvno [0] INTEGER (5), * msg-type [1] INTEGER (14), @@ -46,7 +46,7 @@ import java.math.BigInteger; * ticket [3] Ticket, * authenticator [4] EncryptedData -- Authenticator * } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 diff --git a/src/share/classes/sun/security/krb5/internal/Authenticator.java b/src/share/classes/sun/security/krb5/internal/Authenticator.java index 622013553e0fa8ddbad18dd51af8040478e397e5..16e04a2f704d85e887bf06a098c1aa9b26523f6e 100644 --- a/src/share/classes/sun/security/krb5/internal/Authenticator.java +++ b/src/share/classes/sun/security/krb5/internal/Authenticator.java @@ -38,7 +38,7 @@ import java.math.BigInteger; /** * Implements the ASN.1 Authenticator type. * - *

    + * <pre>{@code * Authenticator ::= [APPLICATION 2] SEQUENCE { * authenticator-vno [0] INTEGER (5), * crealm [1] Realm, @@ -50,7 +50,7 @@ import java.math.BigInteger; * seq-number [7] UInt32 OPTIONAL, * authorization-data [8] AuthorizationData OPTIONAL * } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 diff --git a/src/share/classes/sun/security/krb5/internal/CredentialsUtil.java b/src/share/classes/sun/security/krb5/internal/CredentialsUtil.java index 6cfcd41d839448400348c06131b9584371367b2c..0478b8a416655457e79d5c36bf3881802abd90b1 100644 --- a/src/share/classes/sun/security/krb5/internal/CredentialsUtil.java +++ b/src/share/classes/sun/security/krb5/internal/CredentialsUtil.java @@ -32,6 +32,8 @@ package sun.security.krb5.internal; import sun.security.krb5.*; +import sun.security.util.DerValue; + import java.io.IOException; import java.util.LinkedList; import java.util.List; @@ -45,6 +47,10 @@ public class CredentialsUtil { private static boolean DEBUG = sun.security.krb5.internal.Krb5.DEBUG; + private static enum S4U2Type { + NONE, SELF, PROXY + } + /** * Used by a middle server to acquire credentials on behalf of a * client to itself using the S4U2self extension. @@ -54,20 +60,44 @@ public class CredentialsUtil { */ public static Credentials acquireS4U2selfCreds(PrincipalName client, Credentials ccreds) throws KrbException, IOException { + if (!ccreds.isForwardable()) { + throw new KrbException("S4U2self needs a FORWARDABLE ticket"); + } + PrincipalName sname = ccreds.getClient(); String uRealm = client.getRealmString(); String localRealm = ccreds.getClient().getRealmString(); if (!uRealm.equals(localRealm)) { - // TODO: we do not support kerberos referral now - throw new KrbException("Cross realm impersonation not supported"); - } - if (!ccreds.isForwardable()) { - throw new KrbException("S4U2self needs a FORWARDABLE ticket"); + // Referrals will be required because the middle service + // and the client impersonated are on different realms. + if (Config.DISABLE_REFERRALS) { + throw new KrbException("Cross-realm S4U2Self request not" + + " possible when referrals are disabled."); + } + if (ccreds.getClientAlias() != null) { + // If the name was canonicalized, the user pick + // has preference. This gives the possibility of + // using FQDNs that KDCs may use to return referrals. + // I.e.: a SVC/host.realm-2.com@REALM-1.COM name + // may be used by REALM-1.COM KDC to return a + // referral to REALM-2.COM. + sname = ccreds.getClientAlias(); + } + sname = new PrincipalName(sname.getNameType(), + sname.getNameStrings(), new Realm(uRealm)); } - Credentials creds = serviceCreds(KDCOptions.with(KDCOptions.FORWARDABLE), - ccreds, ccreds.getClient(), ccreds.getClient(), null, - new PAData[] {new PAData(Krb5.PA_FOR_USER, - new PAForUserEnc(client, - ccreds.getSessionKey()).asn1Encode())}); + Credentials creds = serviceCreds( + KDCOptions.with(KDCOptions.FORWARDABLE), + ccreds, ccreds.getClient(), sname, null, + new PAData[] { + new PAData(Krb5.PA_FOR_USER, + new PAForUserEnc(client, + ccreds.getSessionKey()).asn1Encode()), + new PAData(Krb5.PA_PAC_OPTIONS, + new PaPacOptions() + .setResourceBasedConstrainedDelegation(true) + .setClaims(true) + .asn1Encode()) + }, S4U2Type.SELF); if (!creds.getClient().equals(client)) { throw new KrbException("S4U2self request not honored by KDC"); } @@ -89,10 +119,31 @@ public class CredentialsUtil { String backend, Ticket second, PrincipalName client, Credentials ccreds) throws KrbException, IOException { + PrincipalName backendPrincipal = new PrincipalName(backend); + String backendRealm = backendPrincipal.getRealmString(); + String localRealm = ccreds.getClient().getRealmString(); + if (!backendRealm.equals(localRealm)) { + // The middle service and the backend service are on + // different realms, so referrals will be required. + if (Config.DISABLE_REFERRALS) { + throw new KrbException("Cross-realm S4U2Proxy request not" + + " possible when referrals are disabled."); + } + backendPrincipal = new PrincipalName( + backendPrincipal.getNameType(), + backendPrincipal.getNameStrings(), + new Realm(localRealm)); + } Credentials creds = serviceCreds(KDCOptions.with( KDCOptions.CNAME_IN_ADDL_TKT, KDCOptions.FORWARDABLE), - ccreds, ccreds.getClient(), new PrincipalName(backend), - new Ticket[] {second}, null); + ccreds, ccreds.getClient(), backendPrincipal, + new Ticket[] {second}, new PAData[] { + new PAData(Krb5.PA_PAC_OPTIONS, + new PaPacOptions() + .setResourceBasedConstrainedDelegation(true) + .setClaims(true) + .asn1Encode()) + }, S4U2Type.PROXY); if (!creds.getClient().equals(client)) { throw new KrbException("S4U2proxy request not honored by KDC"); } @@ -261,7 +312,8 @@ public class CredentialsUtil { PrincipalName service, Credentials ccreds) throws KrbException, IOException { return serviceCreds(new KDCOptions(), ccreds, - ccreds.getClient(), service, null, null); + ccreds.getClient(), service, null, null, + S4U2Type.NONE); } /* @@ -273,20 +325,21 @@ public class CredentialsUtil { private static Credentials serviceCreds( KDCOptions options, Credentials asCreds, PrincipalName cname, PrincipalName sname, - Ticket[] additionalTickets, PAData[] extraPAs) + Ticket[] additionalTickets, PAData[] extraPAs, + S4U2Type s4u2Type) throws KrbException, IOException { if (!Config.DISABLE_REFERRALS) { try { - return serviceCredsReferrals(options, asCreds, - cname, sname, additionalTickets, extraPAs); + return serviceCredsReferrals(options, asCreds, cname, sname, + s4u2Type, additionalTickets, extraPAs); } catch (KrbException e) { // Server may raise an error if CANONICALIZE is true. // Try CANONICALIZE false. } } return serviceCredsSingle(options, asCreds, cname, - asCreds.getClientAlias(), sname, sname, additionalTickets, - extraPAs); + asCreds.getClientAlias(), sname, sname, s4u2Type, + additionalTickets, extraPAs); } /* @@ -296,8 +349,9 @@ public class CredentialsUtil { private static Credentials serviceCredsReferrals( KDCOptions options, Credentials asCreds, PrincipalName cname, PrincipalName sname, - Ticket[] additionalTickets, PAData[] extraPAs) - throws KrbException, IOException { + S4U2Type s4u2Type, Ticket[] additionalTickets, + PAData[] extraPAs) + throws KrbException, IOException { options = new KDCOptions(options.toBooleanArray()); options.set(KDCOptions.CANONICALIZE, true); PrincipalName cSname = sname; @@ -312,34 +366,58 @@ public class CredentialsUtil { String toRealm = null; if (ref == null) { creds = serviceCredsSingle(options, asCreds, cname, - clientAlias, refSname, cSname, additionalTickets, - extraPAs); + clientAlias, refSname, cSname, s4u2Type, + additionalTickets, extraPAs); PrincipalName server = creds.getServer(); if (!refSname.equals(server)) { String[] serverNameStrings = server.getNameStrings(); if (serverNameStrings.length == 2 && serverNameStrings[0].equals( PrincipalName.TGS_DEFAULT_SRV_NAME) && - !refSname.getRealmAsString().equals(serverNameStrings[1])) { + !refSname.getRealmAsString().equals( + serverNameStrings[1])) { // Server Name (sname) has the following format: // krbtgt/TO-REALM.COM@FROM-REALM.COM - ReferralsCache.put(cname, sname, server.getRealmString(), - serverNameStrings[1], creds); + if (s4u2Type == S4U2Type.NONE) { + // Do not store S4U2Self or S4U2Proxy referral + // TGTs in the cache. Caching such tickets is not + // defined in MS-SFU and may cause unexpected + // results when using them in a different context. + ReferralsCache.put(cname, sname, + server.getRealmString(), + serverNameStrings[1], creds); + } toRealm = serverNameStrings[1]; isReferral = true; - asCreds = creds; } } } else { + creds = ref.getCreds(); toRealm = ref.getToRealm(); - asCreds = ref.getCreds(); isReferral = true; } if (isReferral) { + if (s4u2Type == S4U2Type.PROXY) { + Credentials[] credsInOut = + new Credentials[] {creds, null}; + toRealm = handleS4U2ProxyReferral(asCreds, + credsInOut, sname); + creds = credsInOut[0]; + if (additionalTickets == null || + additionalTickets.length == 0 || + credsInOut[1] == null) { + throw new KrbException("Additional tickets expected" + + " for S4U2Proxy."); + } + additionalTickets[0] = credsInOut[1].getTicket(); + } else if (s4u2Type == S4U2Type.SELF) { + handleS4U2SelfReferral(extraPAs, asCreds, creds); + } if (referrals.contains(toRealm)) { // Referrals loop detected return null; } + asCreds = creds; refSname = new PrincipalName(refSname.getNameString(), refSname.getNameType(), toRealm); referrals.add(toRealm); @@ -362,8 +440,9 @@ public class CredentialsUtil { KDCOptions options, Credentials asCreds, PrincipalName cname, PrincipalName clientAlias, PrincipalName refSname, PrincipalName sname, - Ticket[] additionalTickets, PAData[] extraPAs) - throws KrbException, IOException { + S4U2Type s4u2Type, Ticket[] additionalTickets, + PAData[] extraPAs) + throws KrbException, IOException { Credentials theCreds = null; boolean[] okAsDelegate = new boolean[]{true}; String[] serverAsCredsNames = asCreds.getServer().getNameStrings(); @@ -389,6 +468,9 @@ public class CredentialsUtil { " serviceCredsSingle: "); Credentials.printDebug(newTgt); } + if (s4u2Type == S4U2Type.SELF) { + handleS4U2SelfReferral(extraPAs, asCreds, newTgt); + } asCreds = newTgt; cname = asCreds.getClient(); } else if (DEBUG) { @@ -409,4 +491,79 @@ public class CredentialsUtil { } return theCreds; } + + /** + * PA-FOR-USER may need to be regenerated if credentials + * change. This may happen when obtaining a TGT for a + * different realm or when using a referral TGT. + */ + private static void handleS4U2SelfReferral(PAData[] pas, + Credentials oldCeds, Credentials newCreds) + throws Asn1Exception, KrbException, IOException { + if (DEBUG) { + System.out.println(">>> Handling S4U2Self referral"); + } + for (int i = 0; i < pas.length; i++) { + PAData pa = pas[i]; + if (pa.getType() == Krb5.PA_FOR_USER) { + PAForUserEnc paForUser = new PAForUserEnc( + new DerValue(pa.getValue()), + oldCeds.getSessionKey()); + pas[i] = new PAData(Krb5.PA_FOR_USER, + new PAForUserEnc(paForUser.getName(), + newCreds.getSessionKey()).asn1Encode()); + break; + } + } + } + + /** + * This method is called after receiving the first realm referral for + * a S4U2Proxy request. The credentials and tickets needed for the + * final S4U2Proxy request (in the referrals chain) are returned. + * + * Referrals are handled as described by MS-SFU (section 3.1.5.2.2 + * Receives Referral). + * + * @param asCreds middle service credentials used for the first S4U2Proxy + * request + * @param credsInOut (in/out parameter): + * * input: first S4U2Proxy referral TGT received, null + * * output: referral TGT for final S4U2Proxy service request, + * client referral TGT for final S4U2Proxy service request + * (to be sent as additional-ticket) + * @param sname the backend service name + * @param additionalTickets (out parameter): the additional ticket for the + * last S4U2Proxy request is returned + * @return the backend realm for the last S4U2Proxy request + */ + private static String handleS4U2ProxyReferral(Credentials asCreds, + Credentials[] credsInOut, PrincipalName sname) + throws KrbException, IOException { + if (DEBUG) { + System.out.println(">>> Handling S4U2Proxy referral"); + } + Credentials refTGT = null; + // Get a credential for the middle service to the backend so we know + // the backend realm, as described in MS-SFU (section 3.1.5.2.2). + Credentials middleSvcCredsInBackendRealm = + serviceCreds(sname, asCreds); + String backendRealm = + middleSvcCredsInBackendRealm.getServer().getRealmString(); + String toRealm = credsInOut[0].getServer().getNameStrings()[1]; + if (!toRealm.equals(backendRealm)) { + // More than 1 hop. Follow the referrals chain and obtain a + // TGT for the backend realm. + refTGT = getTGTforRealm(toRealm, backendRealm, credsInOut[0], + new boolean[1]); + } else { + // There was only 1 hop. The referral TGT received is already + // for the backend realm. + refTGT = credsInOut[0]; + } + credsInOut[0] = getTGTforRealm(asCreds.getClient().getRealmString(), + backendRealm, asCreds, new boolean[1]); + credsInOut[1] = refTGT; + return backendRealm; + } } diff --git a/src/share/classes/sun/security/krb5/internal/EncAPRepPart.java b/src/share/classes/sun/security/krb5/internal/EncAPRepPart.java index fdebf1de98021403b8100dfc2f5be3c6cc283fc8..5f323ac8de641259953ac76ad3bf9db8631c53e6 100644 --- a/src/share/classes/sun/security/krb5/internal/EncAPRepPart.java +++ b/src/share/classes/sun/security/krb5/internal/EncAPRepPart.java @@ -39,14 +39,14 @@ import java.math.BigInteger; /** * Implements the ASN.1 EncAPRepPart type. * - *

    + * <pre>{@code * EncAPRepPart ::= [APPLICATION 27] SEQUENCE { * ctime [0] KerberosTime, * cusec [1] Microseconds, * subkey [2] EncryptionKey OPTIONAL, * seq-number [3] UInt32 OPTIONAL * } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 diff --git a/src/share/classes/sun/security/krb5/internal/EncKDCRepPart.java b/src/share/classes/sun/security/krb5/internal/EncKDCRepPart.java index 5c603649633e891495176b696ff2dbe7b12af33d..9db87e27bfbf32581eaf064d42494b2f95bb7fc7 100644 --- a/src/share/classes/sun/security/krb5/internal/EncKDCRepPart.java +++ b/src/share/classes/sun/security/krb5/internal/EncKDCRepPart.java @@ -39,7 +39,7 @@ import java.math.BigInteger; /** * Implements the ASN.1 EncKDCRepPart type. * - *

    + * <pre>{@code * EncKDCRepPart ::= SEQUENCE { * key [0] EncryptionKey, * last-req [1] LastReq, @@ -55,7 +55,7 @@ import java.math.BigInteger; * caddr [11] HostAddresses OPTIONAL, * encrypted-pa-data [12] SEQUENCE OF PA-DATA OPTIONAL * } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 diff --git a/src/share/classes/sun/security/krb5/internal/EncKrbCredPart.java b/src/share/classes/sun/security/krb5/internal/EncKrbCredPart.java index 5fc5c9f31e35bc439f5b8b4be35123be9ccbd770..7015577192ccce98078ad242bb4d483cee62a4c3 100644 --- a/src/share/classes/sun/security/krb5/internal/EncKrbCredPart.java +++ b/src/share/classes/sun/security/krb5/internal/EncKrbCredPart.java @@ -40,7 +40,7 @@ import java.math.BigInteger; /** * Implements the ASN.1 EncKrbCredPart type. * - *

    + * <pre>{@code * EncKrbCredPart ::= [APPLICATION 29] SEQUENCE { * ticket-info [0] SEQUENCE OF KrbCredInfo, * nonce [1] UInt32 OPTIONAL, @@ -49,7 +49,7 @@ import java.math.BigInteger; * s-address [4] HostAddress OPTIONAL, * r-address [5] HostAddress OPTIONAL * } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 diff --git a/src/share/classes/sun/security/krb5/internal/EncKrbPrivPart.java b/src/share/classes/sun/security/krb5/internal/EncKrbPrivPart.java index a3cb42ccbc5f2bcd813e0bcb9626b38d803e6145..3c0eecf282310ce86946e5e2c0d9a52bbd224de2 100644 --- a/src/share/classes/sun/security/krb5/internal/EncKrbPrivPart.java +++ b/src/share/classes/sun/security/krb5/internal/EncKrbPrivPart.java @@ -38,7 +38,7 @@ import java.math.BigInteger; /** * Implements the ASN.1 EncKrbPrivPart type. * - *

    + * <pre>{@code * EncKrbPrivPart ::= [APPLICATION 28] SEQUENCE { * user-data [0] OCTET STRING, * timestamp [1] KerberosTime OPTIONAL, @@ -47,7 +47,7 @@ import java.math.BigInteger; * s-address [4] HostAddress -- sender's addr --, * r-address [5] HostAddress OPTIONAL -- recip's addr * } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 diff --git a/src/share/classes/sun/security/krb5/internal/EncTicketPart.java b/src/share/classes/sun/security/krb5/internal/EncTicketPart.java index 3b43f606214b781685cc0511f84ba82efae2a7a6..eba872166c4acd923e0a2559c9a9a3f5e0a9b6b4 100644 --- a/src/share/classes/sun/security/krb5/internal/EncTicketPart.java +++ b/src/share/classes/sun/security/krb5/internal/EncTicketPart.java @@ -39,7 +39,7 @@ import java.io.*; /** * Implements the ASN.1 EncTicketPart type. * - *

    + * <pre>{@code * EncTicketPart ::= [APPLICATION 3] SEQUENCE { * flags [0] TicketFlags, * key [1] EncryptionKey, @@ -53,7 +53,7 @@ import java.io.*; * caddr [9] HostAddresses OPTIONAL, * authorization-data [10] AuthorizationData OPTIONAL * } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 diff --git a/src/share/classes/sun/security/krb5/internal/HostAddress.java b/src/share/classes/sun/security/krb5/internal/HostAddress.java index 77e00a0d61dc7d4e9e0ea55df74173787887208a..e63d719d1deaab3af95620d8a9c51ef5aa973531 100644 --- a/src/share/classes/sun/security/krb5/internal/HostAddress.java +++ b/src/share/classes/sun/security/krb5/internal/HostAddress.java @@ -44,12 +44,12 @@ import java.util.Arrays; /** * Implements the ASN.1 HostAddress type. * - *

    + * <pre>{@code * HostAddress ::= SEQUENCE { * addr-type [0] Int32, * address [1] OCTET STRING * } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 @@ -132,7 +132,7 @@ public class HostAddress implements Cloneable { /** * Gets the InetAddress of this HostAddress. * @return the IP address for this specified host. - * @exception if no IP address for the host could be found. + * @exception UnknownHostException if no IP address for the host could be found. * */ public InetAddress getInetAddress() throws UnknownHostException { diff --git a/src/share/classes/sun/security/krb5/internal/HostAddresses.java b/src/share/classes/sun/security/krb5/internal/HostAddresses.java index 38bb6a348bccf958061f40aa0ad7dedfb22a994d..56dacdadc30b221af289a2aa9f10d46a39236b0c 100644 --- a/src/share/classes/sun/security/krb5/internal/HostAddresses.java +++ b/src/share/classes/sun/security/krb5/internal/HostAddresses.java @@ -45,7 +45,7 @@ import sun.security.krb5.internal.ccache.CCacheOutputStream; /** * Implements the ASN.1 HostAddresses type. * - *

    + * <pre>{@code * HostAddresses -- NOTE: subtly different from rfc1510, * -- but has a value mapping and encodes the same * ::= SEQUENCE OF HostAddress @@ -54,7 +54,7 @@ import sun.security.krb5.internal.ccache.CCacheOutputStream; * addr-type [0] Int32, * address [1] OCTET STRING * } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 diff --git a/src/share/classes/sun/security/krb5/internal/KDCOptions.java b/src/share/classes/sun/security/krb5/internal/KDCOptions.java index eb1b6f596c9502dd24943acba2e1a8c974cd4220..d9fdf43d6164a5c55104927232dd4413b973bdcd 100644 --- a/src/share/classes/sun/security/krb5/internal/KDCOptions.java +++ b/src/share/classes/sun/security/krb5/internal/KDCOptions.java @@ -40,7 +40,7 @@ import java.io.IOException; /** * Implements the ASN.1 KDCOptions type. * - *

    + * <pre>{@code * KDCOptions ::= KerberosFlags * -- reserved(0), * -- forwardable(1), @@ -69,7 +69,7 @@ import java.io.IOException; * -- minimum number of bits shall be sent, * -- but no fewer than 32 * - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 @@ -115,7 +115,7 @@ import java.io.IOException; * in the addresses field of the request. *

  • FORWARDED, PROXY, ENC_TKT_IN_SKEY, RENEW, VALIDATE are used only in * subsequent requests. - *

    + * */ public class KDCOptions extends KerberosFlags { diff --git a/src/share/classes/sun/security/krb5/internal/KDCRep.java b/src/share/classes/sun/security/krb5/internal/KDCRep.java index 5c4ca1e8f0d55443e9f0e7573fb7d134c23d1bd5..0548a1aa497061f0bf0c3c599e9619103169f746 100644 --- a/src/share/classes/sun/security/krb5/internal/KDCRep.java +++ b/src/share/classes/sun/security/krb5/internal/KDCRep.java @@ -38,7 +38,7 @@ import java.math.BigInteger; /** * Implements the ASN.1 KDC-REP type. * - *

    + * <pre>{@code * KDC-REP ::= SEQUENCE { * pvno [0] INTEGER (5), * msg-type [1] INTEGER (11 -- AS -- | 13 -- TGS --), @@ -51,7 +51,7 @@ import java.math.BigInteger; * -- EncASRepPart or EncTGSRepPart, * -- as appropriate * } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 diff --git a/src/share/classes/sun/security/krb5/internal/KDCReq.java b/src/share/classes/sun/security/krb5/internal/KDCReq.java index 12d410745d5ee1c5a0475a9cb1e5ec6c0b7b0fee..39e226a8de2dee03e555a45f21f5c1d2500f7bad 100644 --- a/src/share/classes/sun/security/krb5/internal/KDCReq.java +++ b/src/share/classes/sun/security/krb5/internal/KDCReq.java @@ -39,7 +39,7 @@ import java.math.BigInteger; /** * Implements the ASN.1 KRB_KDC_REQ type. * - *

    + * <pre>{@code * KDC-REQ ::= SEQUENCE { * -- NOTE: first tag is [1], not [0] * pvno [1] INTEGER (5) , @@ -48,7 +48,7 @@ import java.math.BigInteger; * -- NOTE: not empty --, * req-body [4] KDC-REQ-BODY * } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 @@ -95,7 +95,7 @@ public class KDCReq { * @param req_type a encoded asn1 type value. * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data. * @exception IOException if an I/O error occurs while reading encoded data. - * @exceptoin KrbErrException + * @exception KrbErrException */ public KDCReq(DerValue der, int req_type) throws Asn1Exception, IOException, KrbException { diff --git a/src/share/classes/sun/security/krb5/internal/KDCReqBody.java b/src/share/classes/sun/security/krb5/internal/KDCReqBody.java index 83178b6cc4ce6b23a0bd1204986aed7c564d2792..43444b5149f7cc64f4be7663f6913f45b89a9c66 100644 --- a/src/share/classes/sun/security/krb5/internal/KDCReqBody.java +++ b/src/share/classes/sun/security/krb5/internal/KDCReqBody.java @@ -39,7 +39,7 @@ import java.math.BigInteger; /** * Implements the ASN.1 KDC-REQ-BODY type. * - *

    + * <pre>{@code * KDC-REQ-BODY ::= SEQUENCE { * kdc-options [0] KDCOptions, * cname [1] PrincipalName OPTIONAL @@ -60,7 +60,7 @@ import java.math.BigInteger; * additional-tickets [11] SEQUENCE OF Ticket OPTIONAL * -- NOTE: not empty * } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 diff --git a/src/share/classes/sun/security/krb5/internal/KRBCred.java b/src/share/classes/sun/security/krb5/internal/KRBCred.java index ff719f432c2850791a80c49324018e354748637c..5ebe985bbed7ce5b32c2d9e40bfcd5b1b34b2198 100644 --- a/src/share/classes/sun/security/krb5/internal/KRBCred.java +++ b/src/share/classes/sun/security/krb5/internal/KRBCred.java @@ -41,14 +41,14 @@ import java.math.BigInteger; /** * Implements the ASN.1 Authenticator type. * - *

    + * <pre>{@code * KRB-CRED ::= [APPLICATION 22] SEQUENCE { * pvno [0] INTEGER (5), * msg-type [1] INTEGER (22), * tickets [2] SEQUENCE OF Ticket, * enc-part [3] EncryptedData -- EncKrbCredPart * } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 diff --git a/src/share/classes/sun/security/krb5/internal/KRBError.java b/src/share/classes/sun/security/krb5/internal/KRBError.java index 5b51706d3275bd0cb3cf3d0536d1ba30e34690ec..7c8a2a188a2cffa2e6510e158ddd2fbc67e3f805 100644 --- a/src/share/classes/sun/security/krb5/internal/KRBError.java +++ b/src/share/classes/sun/security/krb5/internal/KRBError.java @@ -48,7 +48,7 @@ import sun.security.krb5.internal.util.KerberosString; /** * Implements the ASN.1 KRBError type. * - *

    + * <pre>{@code * KRB-ERROR ::= [APPLICATION 30] SEQUENCE { * pvno [0] INTEGER (5), * msg-type [1] INTEGER (30), @@ -71,7 +71,7 @@ import sun.security.krb5.internal.util.KerberosString; * data-type [0] Int32, * data-value [1] OCTET STRING OPTIONAL * } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 diff --git a/src/share/classes/sun/security/krb5/internal/KRBPriv.java b/src/share/classes/sun/security/krb5/internal/KRBPriv.java index f0867ef5d94b038fbd289adb00cb50b27eb7b0fc..09adfe3aa0f375a2f95aa5571355cb491938f4cb 100644 --- a/src/share/classes/sun/security/krb5/internal/KRBPriv.java +++ b/src/share/classes/sun/security/krb5/internal/KRBPriv.java @@ -39,14 +39,14 @@ import java.math.BigInteger; /** * Implements the ASN.1 KRB-PRIV type. * - *

    + * <pre>{@code * KRB-PRIV ::= [APPLICATION 21] SEQUENCE { * pvno [0] INTEGER (5), * msg-type [1] INTEGER (21), * -- NOTE: there is no [2] tag * enc-part [3] EncryptedData -- EncKrbPrivPart * } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 diff --git a/src/share/classes/sun/security/krb5/internal/KRBSafe.java b/src/share/classes/sun/security/krb5/internal/KRBSafe.java index 52da89a7e7c7d2c3caeb7d807992f04ac56700fc..c9e85534ff01d1f3fbde7cae8a3da6a634f3ad41 100644 --- a/src/share/classes/sun/security/krb5/internal/KRBSafe.java +++ b/src/share/classes/sun/security/krb5/internal/KRBSafe.java @@ -40,14 +40,14 @@ import java.math.BigInteger; /** * Implements the ASN.1 KRBSafe type. * - *

    + * <pre>{@code * KRB-SAFE ::= [APPLICATION 20] SEQUENCE { * pvno [0] INTEGER (5), * msg-type [1] INTEGER (20), * safe-body [2] KRB-SAFE-BODY, * cksum [3] Checksum * } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 diff --git a/src/share/classes/sun/security/krb5/internal/KRBSafeBody.java b/src/share/classes/sun/security/krb5/internal/KRBSafeBody.java index 14187651f43ae37d5b23ce3e6cae31855c0fa901..d8b331cd115836421ff46f0c0c52fca93a14a6a9 100644 --- a/src/share/classes/sun/security/krb5/internal/KRBSafeBody.java +++ b/src/share/classes/sun/security/krb5/internal/KRBSafeBody.java @@ -39,7 +39,7 @@ import java.math.BigInteger; /** * Implements the ASN.1 KRBSafeBody type. * - *

    + * <pre>{@code * KRB-SAFE-BODY ::= SEQUENCE { * user-data [0] OCTET STRING, * timestamp [1] KerberosTime OPTIONAL, @@ -48,7 +48,7 @@ import java.math.BigInteger; * s-address [4] HostAddress, * r-address [5] HostAddress OPTIONAL * } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 diff --git a/src/share/classes/sun/security/krb5/internal/KerberosTime.java b/src/share/classes/sun/security/krb5/internal/KerberosTime.java index 64225c8eede8e0064b417f88f1e51c35238d6f1a..ec40930cdbbca7356deddc2d9e1f5501dd94825c 100644 --- a/src/share/classes/sun/security/krb5/internal/KerberosTime.java +++ b/src/share/classes/sun/security/krb5/internal/KerberosTime.java @@ -46,9 +46,7 @@ import java.util.TimeZone; /** * Implements the ASN.1 KerberosTime type. This is an immutable class. * - *

    - * KerberosTime ::= GeneralizedTime -- with no fractional seconds - * + * {@code KerberosTime ::= GeneralizedTime} -- with no fractional seconds * * The timestamps used in Kerberos are encoded as GeneralizedTimes. A * KerberosTime value shall not include any fractional portions of the diff --git a/src/share/classes/sun/security/krb5/internal/Krb5.java b/src/share/classes/sun/security/krb5/internal/Krb5.java index a2e7e3b86991325b36464e6aba937f86467dc819..0df61a61799a124d3c5df591f6935303828ca0e2 100644 --- a/src/share/classes/sun/security/krb5/internal/Krb5.java +++ b/src/share/classes/sun/security/krb5/internal/Krb5.java @@ -163,6 +163,7 @@ public class Krb5 { // S4U2user info public static final int PA_FOR_USER = 129; + public static final int PA_PAC_OPTIONS = 167; // FAST (RFC 6806) public static final int PA_REQ_ENC_PA_REP = 149; diff --git a/src/share/classes/sun/security/krb5/internal/KrbCredInfo.java b/src/share/classes/sun/security/krb5/internal/KrbCredInfo.java index 18fa7412facddc759587c4b97f7e270dbf30cffd..2b532b81cce837f5dad24874ae6e80f53e3ae658 100644 --- a/src/share/classes/sun/security/krb5/internal/KrbCredInfo.java +++ b/src/share/classes/sun/security/krb5/internal/KrbCredInfo.java @@ -38,7 +38,7 @@ import java.io.IOException; /** * Implements the ASN.1 KrbCredInfo type. * - * + * <pre>{@code * KrbCredInfo ::= SEQUENCE { * key [0] EncryptionKey, * prealm [1] Realm OPTIONAL, @@ -52,7 +52,7 @@ import java.io.IOException; * sname [9] PrincipalName OPTIONAL, * caddr [10] HostAddresses OPTIONAL * } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 diff --git a/src/share/classes/sun/security/krb5/internal/LastReq.java b/src/share/classes/sun/security/krb5/internal/LastReq.java index 45ff8a81274cb0dc9471f11ed0467910edc98bf7..9e160b0cf281e347c267207897cb2eee789263f8 100644 --- a/src/share/classes/sun/security/krb5/internal/LastReq.java +++ b/src/share/classes/sun/security/krb5/internal/LastReq.java @@ -38,12 +38,12 @@ import java.io.IOException; /** * Implements the ASN.1 LastReq type. * - *

    + * <pre>{@code * LastReq ::= SEQUENCE OF SEQUENCE { * lr-type [0] Int32, * lr-value [1] KerberosTime * } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 diff --git a/src/share/classes/sun/security/krb5/internal/LoginOptions.java b/src/share/classes/sun/security/krb5/internal/LoginOptions.java index 128339757709e1b673b5fa66bff68b82761581f9..76bc17487f7a5d950fc85bc03a58b3bea93e0826 100644 --- a/src/share/classes/sun/security/krb5/internal/LoginOptions.java +++ b/src/share/classes/sun/security/krb5/internal/LoginOptions.java @@ -36,7 +36,7 @@ import java.io.IOException; /** * Implements the ASN.1 KDCOptions type. * - *

    + * <pre>{@code * KDCOptions ::= KerberosFlags * -- reserved(0), * -- forwardable(1), @@ -64,7 +64,7 @@ import java.io.IOException; * KerberosFlags ::= BIT STRING (SIZE (32..MAX)) * -- minimum number of bits shall be sent, * -- but no fewer than 32 - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 diff --git a/src/share/classes/sun/security/krb5/internal/MethodData.java b/src/share/classes/sun/security/krb5/internal/MethodData.java index ef29461fa4f1dcfc7cd9d43caaea57b7262690c9..d700410ca00654e522cc08f0c0ded246ed5400ac 100644 --- a/src/share/classes/sun/security/krb5/internal/MethodData.java +++ b/src/share/classes/sun/security/krb5/internal/MethodData.java @@ -38,12 +38,12 @@ import java.math.BigInteger; /** * Implements the ASN.1 EncKrbPrivPart type. * - *

    + * <pre>{@code * METHOD-DATA ::= SEQUENCE { * method-type[0] INTEGER, * method-data[1] OCTET STRING OPTIONAL * } - * + * } */ public class MethodData { private int methodType; diff --git a/src/share/classes/sun/security/krb5/internal/PAData.java b/src/share/classes/sun/security/krb5/internal/PAData.java index fd1429a4c35578f542320df783b5d765be96d5c5..001a4832a7a4d3a7eeaefbfbfe84e563af77753e 100644 --- a/src/share/classes/sun/security/krb5/internal/PAData.java +++ b/src/share/classes/sun/security/krb5/internal/PAData.java @@ -43,13 +43,13 @@ import sun.security.krb5.internal.util.KerberosString; /** * Implements the ASN.1 PA-DATA type. * - * + * <pre>{@code * PA-DATA ::= SEQUENCE { * -- NOTE: first tag is [1], not [0] * padata-type [1] Int32, * padata-value [2] OCTET STRING -- might be encoded AP-REQ * } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 @@ -179,11 +179,14 @@ public class PAData { /** * Gets the preferred etype from the PAData array. - * 1. ETYPE-INFO2-ENTRY with unknown s2kparams ignored - * 2. ETYPE-INFO2 preferred to ETYPE-INFO - * 3. multiple entries for same etype in one PA-DATA, use the first one. - * 4. Multiple PA-DATA with same type, choose the last one + *

      + *
    1. ETYPE-INFO2-ENTRY with unknown s2kparams ignored
    2. + *
    3. ETYPE-INFO2 preferred to ETYPE-INFO
    4. + *
    5. Multiple entries for same etype in one PA-DATA, use the first one.
    6. + *
    7. Multiple PA-DATA with same type, choose the last one.
    8. + *
    * (This is useful when PA-DATAs from KRB-ERROR and AS-REP are combined). + * * @return the etype, or defaultEType if not enough info * @throws Asn1Exception|IOException if there is an encoding error */ diff --git a/src/share/classes/sun/security/krb5/internal/PAEncTSEnc.java b/src/share/classes/sun/security/krb5/internal/PAEncTSEnc.java index 833756470465f37435c465749c05b769173b7291..19554342d7467f50e24a0bc11ceaeb115d7856b1 100644 --- a/src/share/classes/sun/security/krb5/internal/PAEncTSEnc.java +++ b/src/share/classes/sun/security/krb5/internal/PAEncTSEnc.java @@ -38,12 +38,12 @@ import java.math.BigInteger; /** * Implements the ASN.1 PAEncTSEnc type. * - * + * <pre>{@code * PA-ENC-TS-ENC ::= SEQUENCE { * patimestamp [0] KerberosTime -- client's time --, * pausec [1] Microseconds OPTIONAL * } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 diff --git a/src/share/classes/sun/security/krb5/internal/PAForUserEnc.java b/src/share/classes/sun/security/krb5/internal/PAForUserEnc.java index a1952ffee5e6fdea54b231e93f1d83f56a287b89..ac8db4f87b5dfca5f9bcd625156fc0cd8cf7a40d 100644 --- a/src/share/classes/sun/security/krb5/internal/PAForUserEnc.java +++ b/src/share/classes/sun/security/krb5/internal/PAForUserEnc.java @@ -36,7 +36,7 @@ import sun.security.util.DerValue; /** * Implements the ASN.1 PA-FOR-USER type. * - *

    + * <pre>{@code * padata-type ::= PA-FOR-USER * -- value 129 * padata-value ::= EncryptedData @@ -47,7 +47,7 @@ import sun.security.util.DerValue; * cksum[2] Checksum, * auth-package[3] KerberosString * } - * + * } * *

    * This definition reflects MS-SFU. @@ -185,6 +185,10 @@ public class PAForUserEnc { } } + public PrincipalName getName() { + return name; + } + public String toString() { return "PA-FOR-USER: " + name; } diff --git a/src/share/classes/sun/security/krb5/internal/PaPacOptions.java b/src/share/classes/sun/security/krb5/internal/PaPacOptions.java new file mode 100644 index 0000000000000000000000000000000000000000..82fd12cc8be4e6aecb134452d35c51f698805708 --- /dev/null +++ b/src/share/classes/sun/security/krb5/internal/PaPacOptions.java @@ -0,0 +1,185 @@ +/* + * Copyright (c) 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 + * 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.krb5.internal; + +import java.io.IOException; +import sun.security.krb5.Asn1Exception; +import sun.security.krb5.internal.util.KerberosFlags; +import sun.security.util.DerOutputStream; +import sun.security.util.DerValue; + +/** + * Implements the ASN.1 PA-PAC-OPTIONS type. + * + *

    {@code
    + * PA-PAC-OPTIONS ::= SEQUENCE {
    + * KerberosFlags
    + *   -- Claims (0)
    + *   -- Branch Aware (1)
    + *   -- Forward to Full DC (2)
    + * }
    + * Note: KerberosFlags   ::= BIT STRING (SIZE (32..MAX))
    + *         -- minimum number of bits shall be sent, but no fewer than 32
    + *
    + * PA-PAC-OPTIONS ::= KerberosFlags
    + *   -- resource-based constrained delegation (3)
    + * }
    + * + * This definition reflects MS-KILE (section 2.2.10) + * and MS-SFU (section 2.2.5). + */ + +public class PaPacOptions { + + private static final int CLAIMS = 0; + private static final int BRANCH_AWARE = 1; + private static final int FORWARD_TO_FULL_DC = 2; + private static final int RESOURCE_BASED_CONSTRAINED_DELEGATION = 3; + + private KerberosFlags flags; + + public PaPacOptions() { + this.flags = new KerberosFlags(Krb5.AP_OPTS_MAX + 1); + } + + /** + * Constructs a PA-PAC-OPTIONS object from a DER encoding. + * @param encoding the ASN.1 encoded input + * @throws Asn1Exception if invalid DER + * @throws IOException if there is an error reading the DER value + */ + public PaPacOptions(DerValue encoding) throws Asn1Exception, IOException { + if (encoding.getTag() != DerValue.tag_Sequence) { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + + DerValue der = encoding.getData().getDerValue(); + if ((der.getTag() & 0x1F) == 0x00) { + flags = new KDCOptions( + der.getData().getDerValue()); + } else { + throw new Asn1Exception(Krb5.ASN1_BAD_ID); + } + } + + /** + * Setter for the claims flag + * @param value whether the claims flag is set or not + * @return the same PaPacOptions instance + */ + public PaPacOptions setClaims(boolean value) { + flags.set(CLAIMS, value); + return this; + } + + /** + * Getter for the claims flag + * @return the claims flag value + */ + public boolean getClaims() { + return flags.get(CLAIMS); + } + + /** + * Setter for the branch-aware flag + * @param value whether the branch-aware flag is set or not + * @return the same PaPacOptions instance + */ + public PaPacOptions setBranchAware(boolean value) { + flags.set(BRANCH_AWARE, value); + return this; + } + + /** + * Getter for the branch-aware flag + * @return the branch-aware flag value + */ + public boolean getBranchAware() { + return flags.get(BRANCH_AWARE); + } + + /** + * Setter for the forward-to-full-DC flag + * @param value whether the forward-to-full-DC flag is set or not + * @return the same PaPacOptions instance + */ + public PaPacOptions setForwardToFullDC(boolean value) { + flags.set(FORWARD_TO_FULL_DC, value); + return this; + } + + /** + * Getter for the forward-to-full-DC flag + * @return the forward-to-full-DC flag value + */ + public boolean getForwardToFullDC() { + return flags.get(FORWARD_TO_FULL_DC); + } + + /** + * Setter for the resource-based-constrained-delegation flag + * @param value whether the resource-based-constrained-delegation + * is set or not + * @return the same PaPacOptions instance + */ + public PaPacOptions setResourceBasedConstrainedDelegation(boolean value) { + flags.set(RESOURCE_BASED_CONSTRAINED_DELEGATION, value); + return this; + } + + /** + * Getter for the resource-based-constrained-delegation flag + * @return the resource-based-constrained-delegation flag value + */ + public boolean getResourceBasedConstrainedDelegation() { + return flags.get(RESOURCE_BASED_CONSTRAINED_DELEGATION); + } + + /** + * Encodes this PaPacOptions instance. + * @return an ASN.1 encoded PaPacOptions byte array + * @throws IOException if an I/O error occurs while encoding this + * PaPacOptions instance + */ + public byte[] asn1Encode() throws IOException { + byte[] bytes = null; + try(DerOutputStream temp = new DerOutputStream()) { + temp.write( + DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), + flags.asn1Encode()); + bytes = temp.toByteArray(); + } + try(DerOutputStream temp = new DerOutputStream()) { + temp.write(DerValue.tag_Sequence, bytes); + return temp.toByteArray(); + } + } + + @Override + public String toString() { + return flags.toString(); + } +} diff --git a/src/share/classes/sun/security/krb5/internal/Ticket.java b/src/share/classes/sun/security/krb5/internal/Ticket.java index 0f1c3d9af15098ea2e89c523387252e50d9d62f9..d279d144cc4cc54ef70b4e020a52b80a08d83702 100644 --- a/src/share/classes/sun/security/krb5/internal/Ticket.java +++ b/src/share/classes/sun/security/krb5/internal/Ticket.java @@ -42,14 +42,14 @@ import java.math.BigInteger; /** * Implements the ASN.1 Ticket type. * - * + * <pre>{@code * Ticket ::= [APPLICATION 1] SEQUENCE { * tkt-vno [0] INTEGER (5), * realm [1] Realm, * sname [2] PrincipalName, * enc-part [3] EncryptedData -- EncTicketPart * } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 diff --git a/src/share/classes/sun/security/krb5/internal/TransitedEncoding.java b/src/share/classes/sun/security/krb5/internal/TransitedEncoding.java index fc33f9fdb5824f03e16f4148d5cd84c22e4aec15..301d7c7e9503ccb6aa60347508a974dab787844b 100644 --- a/src/share/classes/sun/security/krb5/internal/TransitedEncoding.java +++ b/src/share/classes/sun/security/krb5/internal/TransitedEncoding.java @@ -38,12 +38,12 @@ import java.math.BigInteger; /** * Implements the ASN.1 TransitedEncoding type. * - *

    + * <pre>{@code * TransitedEncoding ::= SEQUENCE { * tr-type [0] Int32 -- must be registered --, * contents [1] OCTET STRING * } - * + * } * *

    * This definition reflects the Network Working Group RFC 4120 diff --git a/src/share/classes/sun/security/krb5/internal/crypto/Des.java b/src/share/classes/sun/security/krb5/internal/crypto/Des.java index 73dbc55babd109fd0415aca5156b42d4756864fd..2eb0f783ab6d5fbaab8fb40c8491bd18983db9d8 100644 --- a/src/share/classes/sun/security/krb5/internal/crypto/Des.java +++ b/src/share/classes/sun/security/krb5/internal/crypto/Des.java @@ -226,7 +226,7 @@ public final class Des { /** * Generates DES key from the password. - * @param password a char[] used to create the key. + * @param passwdChars a char[] used to create the key. * @return DES key. * * @modified by Yanni Zhang, Dec 6, 99 diff --git a/src/share/classes/sun/security/krb5/internal/crypto/DesMacCksumType.java b/src/share/classes/sun/security/krb5/internal/crypto/DesMacCksumType.java index 2e11a2042626b10a1878363457193ceda948c914..0d9310f54bb6977e45f71a10fecc664336a0c983 100644 --- a/src/share/classes/sun/security/krb5/internal/crypto/DesMacCksumType.java +++ b/src/share/classes/sun/security/krb5/internal/crypto/DesMacCksumType.java @@ -121,7 +121,7 @@ public class DesMacCksumType extends CksumType { * @param data the data. * @param size the length of data. * @param key the key used to encrypt the checksum. - * @param checksum + * @param checksum the checksum. * @return true if verification is successful. * * @modified by Yanni Zhang, 12/08/99. diff --git a/src/share/classes/sun/security/krb5/internal/crypto/HmacMd5ArcFourCksumType.java b/src/share/classes/sun/security/krb5/internal/crypto/HmacMd5ArcFourCksumType.java index 41388ec87d64b5e39f336614453af721b434d820..5ce9fa187479dee080f32aefd82348ca6fa08afa 100644 --- a/src/share/classes/sun/security/krb5/internal/crypto/HmacMd5ArcFourCksumType.java +++ b/src/share/classes/sun/security/krb5/internal/crypto/HmacMd5ArcFourCksumType.java @@ -89,7 +89,7 @@ public class HmacMd5ArcFourCksumType extends CksumType { * @param data the data. * @param size the length of data. * @param key the key used to encrypt the checksum. - * @param checksum + * @param checksum the checksum. * @return true if verification is successful. */ public boolean verifyChecksum(byte[] data, int size, diff --git a/src/share/classes/sun/security/krb5/internal/crypto/HmacSha1Aes128CksumType.java b/src/share/classes/sun/security/krb5/internal/crypto/HmacSha1Aes128CksumType.java index a16941ca050a395be09397a7f275b44dc96952c3..bb06f97ede7d66bd51e6c8a20a0ebfde58147c15 100644 --- a/src/share/classes/sun/security/krb5/internal/crypto/HmacSha1Aes128CksumType.java +++ b/src/share/classes/sun/security/krb5/internal/crypto/HmacSha1Aes128CksumType.java @@ -89,7 +89,7 @@ public class HmacSha1Aes128CksumType extends CksumType { * @param data the data. * @param size the length of data. * @param key the key used to encrypt the checksum. - * @param checksum + * @param checksum the checksum. * @return true if verification is successful. */ public boolean verifyChecksum(byte[] data, int size, diff --git a/src/share/classes/sun/security/krb5/internal/crypto/HmacSha1Aes256CksumType.java b/src/share/classes/sun/security/krb5/internal/crypto/HmacSha1Aes256CksumType.java index 9ce9347cc612c4e09b1a232d70453d35fd7ec3f8..f84bedda41c2c8b9aa80163d8daa5342e37ea7c8 100644 --- a/src/share/classes/sun/security/krb5/internal/crypto/HmacSha1Aes256CksumType.java +++ b/src/share/classes/sun/security/krb5/internal/crypto/HmacSha1Aes256CksumType.java @@ -89,7 +89,7 @@ public class HmacSha1Aes256CksumType extends CksumType { * @param data the data. * @param size the length of data. * @param key the key used to encrypt the checksum. - * @param checksum + * @param checksum the checksum. * @return true if verification is successful. */ public boolean verifyChecksum(byte[] data, int size, diff --git a/src/share/classes/sun/security/krb5/internal/crypto/HmacSha1Des3KdCksumType.java b/src/share/classes/sun/security/krb5/internal/crypto/HmacSha1Des3KdCksumType.java index 81e44205eac9d77c0120cb82361f305c298c8374..56cce8020d663e0849be757d3847a2f3dc0e86c6 100644 --- a/src/share/classes/sun/security/krb5/internal/crypto/HmacSha1Des3KdCksumType.java +++ b/src/share/classes/sun/security/krb5/internal/crypto/HmacSha1Des3KdCksumType.java @@ -83,7 +83,7 @@ public class HmacSha1Des3KdCksumType extends CksumType { * @param data the data. * @param size the length of data. * @param key the key used to encrypt the checksum. - * @param checksum + * @param checksum the checksum. * @return true if verification is successful. */ public boolean verifyChecksum(byte[] data, int size, diff --git a/src/share/classes/sun/security/krb5/internal/crypto/RsaMd5DesCksumType.java b/src/share/classes/sun/security/krb5/internal/crypto/RsaMd5DesCksumType.java index 0d55aed045acf97483290723ababba4c790cce73..29d33391bae0a3c7897501fef523ec1f8f738a0a 100644 --- a/src/share/classes/sun/security/krb5/internal/crypto/RsaMd5DesCksumType.java +++ b/src/share/classes/sun/security/krb5/internal/crypto/RsaMd5DesCksumType.java @@ -116,7 +116,7 @@ public final class RsaMd5DesCksumType extends CksumType { * @param data the data. * @param size the length of data. * @param key the key used to encrypt the checksum. - * @param checksum + * @param checksum the checksum. * @return true if verification is successful. * * @modified by Yanni Zhang, 12/08/99. diff --git a/src/share/classes/sun/security/krb5/internal/ktab/KeyTab.java b/src/share/classes/sun/security/krb5/internal/ktab/KeyTab.java index 5da7bc6f990c7f1fc9e56bf4ad7f490a7a05a641..53dd8cc0fb93cd3ba82997317d0919e4c2d7e512 100644 --- a/src/share/classes/sun/security/krb5/internal/ktab/KeyTab.java +++ b/src/share/classes/sun/security/krb5/internal/ktab/KeyTab.java @@ -513,7 +513,7 @@ public class KeyTab implements KeyTabConstants { /** * Creates key table file version. * @param file the key table file. - * @exception IOException. + * @exception IOException */ public synchronized void createVersion(File file) throws IOException { try (KeyTabOutputStream kos = diff --git a/src/share/classes/sun/security/krb5/internal/rcache/AuthList.java b/src/share/classes/sun/security/krb5/internal/rcache/AuthList.java index c97841746ebeffa063ce0b10cb4d046133aa049e..24a0db2dfe4756f64ec9c678458c57681c15cbfe 100644 --- a/src/share/classes/sun/security/krb5/internal/rcache/AuthList.java +++ b/src/share/classes/sun/security/krb5/internal/rcache/AuthList.java @@ -45,7 +45,7 @@ import sun.security.krb5.internal.KrbApErrException; * self-cleanup of expired items in the cache. * * AuthTimeWithHash objects inside a cache are always sorted from big (new) to - * small (old) as determined by {@see AuthTimeWithHash#compareTo}. In the most + * small (old) as determined by {@link AuthTimeWithHash#compareTo}. In the most * common case a newcomer should be newer than the first element. * * @author Yanni Zhang diff --git a/src/share/classes/sun/security/pkcs/ContentInfo.java b/src/share/classes/sun/security/pkcs/ContentInfo.java index bc78d0f1c0da81234d974aae428067aceeb88041..78417124afea827b3b61d829cc20d2b5cb21da17 100644 --- a/src/share/classes/sun/security/pkcs/ContentInfo.java +++ b/src/share/classes/sun/security/pkcs/ContentInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -130,6 +130,9 @@ public class ContentInfo { DerValue[] contents; typeAndContent = derin.getSequence(2); + if (typeAndContent.length < 1 || typeAndContent.length > 2) { + throw new ParsingException("Invalid length for ContentInfo"); + } // Parse the content type type = typeAndContent[0]; @@ -149,6 +152,9 @@ public class ContentInfo { disTaggedContent = new DerInputStream(taggedContent.toByteArray()); contents = disTaggedContent.getSet(1, true); + if (contents.length != 1) { + throw new ParsingException("ContentInfo encoding error"); + } content = contents[0]; } } diff --git a/src/share/classes/sun/security/pkcs/SignerInfo.java b/src/share/classes/sun/security/pkcs/SignerInfo.java index 628d6d0c82eda046a4f0468d889a33fb3ec24c5b..03d072b58807d6ccd67b7449ca0ad65dc0654f31 100644 --- a/src/share/classes/sun/security/pkcs/SignerInfo.java +++ b/src/share/classes/sun/security/pkcs/SignerInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. * 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,20 +28,12 @@ package sun.security.pkcs; import java.io.OutputStream; import java.io.IOException; import java.math.BigInteger; -import java.security.CryptoPrimitive; -import java.security.InvalidKeyException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.security.Principal; -import java.security.PublicKey; -import java.security.Signature; -import java.security.SignatureException; -import java.security.Timestamp; import java.security.cert.CertPathValidatorException; import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.security.cert.CertPath; import java.security.cert.X509Certificate; +import java.security.*; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -62,6 +54,7 @@ import sun.security.util.ObjectIdentifier; import sun.security.x509.AlgorithmId; import sun.security.x509.X500Name; import sun.security.x509.KeyUsageExtension; +import sun.security.util.SignatureUtil; /** * A SignerInfo, as defined in PKCS#7's signedData type. @@ -151,6 +144,9 @@ public class SignerInfo implements DerEncoder { // issuerAndSerialNumber DerValue[] issuerAndSerialNumber = derin.getSequence(2); + if (issuerAndSerialNumber.length != 2) { + throw new ParsingException("Invalid length for IssuerAndSerialNumber"); + } byte[] issuerBytes = issuerAndSerialNumber[0].toByteArray(); issuerName = new X500Name(new DerValue(DerValue.tag_Sequence, issuerBytes)); @@ -453,30 +449,34 @@ public class SignerInfo implements DerEncoder { } Signature sig = Signature.getInstance(algname); - sig.initVerify(key); + + AlgorithmParameters ap = + digestEncryptionAlgorithmId.getParameters(); + try { + SignatureUtil.initVerifyWithParam(sig, key, + SignatureUtil.getParamSpec(algname, ap)); + } catch (ProviderException | InvalidAlgorithmParameterException | + InvalidKeyException e) { + throw new SignatureException(e.getMessage(), e); + } + sig.update(dataSigned); if (sig.verify(encryptedDigest)) { return this; } - } catch (IOException e) { throw new SignatureException("IO error verifying signature:\n" + e.getMessage()); - - } catch (InvalidKeyException e) { - throw new SignatureException("InvalidKey: " + e.getMessage()); - } return null; } /* Verify the content of the pkcs7 block. */ SignerInfo verify(PKCS7 block) - throws NoSuchAlgorithmException, SignatureException { + throws NoSuchAlgorithmException, SignatureException { return verify(block, null); } - public BigInteger getVersion() { return version; } diff --git a/src/share/classes/sun/security/pkcs10/PKCS10.java b/src/share/classes/sun/security/pkcs10/PKCS10.java index 9302580db1cb3477f31da42a444676774e2dba2a..9698c18cf129bfd8b85c35649415b8495d460834 100644 --- a/src/share/classes/sun/security/pkcs10/PKCS10.java +++ b/src/share/classes/sun/security/pkcs10/PKCS10.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. * 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,11 +31,7 @@ import java.io.IOException; import java.math.BigInteger; import java.security.cert.CertificateException; -import java.security.NoSuchAlgorithmException; -import java.security.InvalidKeyException; -import java.security.Signature; -import java.security.SignatureException; -import java.security.PublicKey; +import java.security.*; import java.util.Base64; @@ -43,6 +39,8 @@ import sun.security.util.*; import sun.security.x509.AlgorithmId; import sun.security.x509.X509Key; import sun.security.x509.X500Name; +import sun.security.util.SignatureUtil; + /** * A PKCS #10 certificate request is created and sent to a Certificate @@ -169,12 +167,20 @@ public class PKCS10 { try { sigAlg = id.getName(); sig = Signature.getInstance(sigAlg); - sig.initVerify(subjectPublicKeyInfo); + SignatureUtil.initVerifyWithParam(sig, subjectPublicKeyInfo, + SignatureUtil.getParamSpec(sigAlg, id.getParameters())); + sig.update(data); - if (!sig.verify(sigData)) + if (!sig.verify(sigData)) { throw new SignatureException("Invalid PKCS #10 signature"); + } } catch (InvalidKeyException e) { - throw new SignatureException("invalid key"); + throw new SignatureException("Invalid key"); + } catch (InvalidAlgorithmParameterException e) { + throw new SignatureException("Invalid signature parameters", e); + } catch (ProviderException e) { + throw new SignatureException("Error parsing signature parameters", + e.getCause()); } } @@ -226,10 +232,14 @@ public class PKCS10 { */ 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/share/classes/sun/security/pkcs11/P11Key.java b/src/share/classes/sun/security/pkcs11/P11Key.java index a07e2082fa57b98ea33d793bffaa632260fdb3f1..bcffaf0ae60a405f638e1541afdfbe83afc3e576 100644 --- a/src/share/classes/sun/security/pkcs11/P11Key.java +++ b/src/share/classes/sun/security/pkcs11/P11Key.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * 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,7 +37,9 @@ import javax.crypto.*; import javax.crypto.interfaces.*; import javax.crypto.spec.*; +import sun.security.rsa.RSAUtil.KeyType; import sun.security.rsa.RSAPublicKeyImpl; +import sun.security.rsa.RSAPrivateCrtKeyImpl; import sun.security.internal.interfaces.TlsMasterSecret; @@ -543,11 +545,8 @@ abstract class P11Key implements Key, Length { if (encoded == null) { fetchValues(); try { - // XXX make constructor in SunRsaSign provider public - // and call it directly - KeyFactory factory = KeyFactory.getInstance - ("RSA", P11Util.getSunRsaSignProvider()); - Key newKey = factory.translateKey(this); + Key newKey = RSAPrivateCrtKeyImpl.newKey + (KeyType.RSA, null, n, e, d, p, q, pe, qe, coeff); encoded = newKey.getEncoded(); } catch (GeneralSecurityException e) { throw new ProviderException(e); @@ -647,7 +646,6 @@ abstract class P11Key implements Key, Length { private static final class P11RSAPublicKey extends P11Key implements RSAPublicKey { private static final long serialVersionUID = -826726289023854455L; - private BigInteger n, e; private byte[] encoded; P11RSAPublicKey(Session session, long keyID, String algorithm, @@ -676,7 +674,8 @@ abstract class P11Key implements Key, Length { if (encoded == null) { fetchValues(); try { - encoded = new RSAPublicKeyImpl(n, e).getEncoded(); + encoded = RSAPublicKeyImpl.newKey + (KeyType.RSA, null, n, e).getEncoded(); } catch (InvalidKeyException e) { throw new ProviderException(e); } diff --git a/src/share/classes/sun/security/pkcs11/P11KeyStore.java b/src/share/classes/sun/security/pkcs11/P11KeyStore.java index aee9542537d175f82da74f8d9dc1544cbec4fa8d..b9449c9a2c357657200cc039ac45e5c960ded6d4 100644 --- a/src/share/classes/sun/security/pkcs11/P11KeyStore.java +++ b/src/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 @@ -773,6 +773,8 @@ final class P11KeyStore extends KeyStoreSpi { } 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/share/classes/sun/security/pkcs11/P11RSAKeyFactory.java b/src/share/classes/sun/security/pkcs11/P11RSAKeyFactory.java index 0fc06a73343856ee4fc4309d7ff8419ee42fd3c1..b3bfcc7757d56b7ca316eafc3265e82327de4e09 100644 --- a/src/share/classes/sun/security/pkcs11/P11RSAKeyFactory.java +++ b/src/share/classes/sun/security/pkcs11/P11RSAKeyFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ import java.security.*; import java.security.interfaces.*; import java.security.spec.*; +import sun.security.rsa.RSAPublicKeyImpl; import static sun.security.pkcs11.TemplateManager.*; import sun.security.pkcs11.wrapper.*; import static sun.security.pkcs11.wrapper.PKCS11Constants.*; @@ -60,7 +61,7 @@ final class P11RSAKeyFactory extends P11KeyFactory { } else if ("X.509".equals(key.getFormat())) { // let SunRsaSign provider parse for us, then recurse byte[] encoded = key.getEncoded(); - key = new sun.security.rsa.RSAPublicKeyImpl(encoded); + key = RSAPublicKeyImpl.newKey(encoded); return implTranslatePublicKey(key); } else { throw new InvalidKeyException("PublicKey must be instance " @@ -113,7 +114,7 @@ final class P11RSAKeyFactory extends P11KeyFactory { if (keySpec instanceof X509EncodedKeySpec) { try { byte[] encoded = ((X509EncodedKeySpec)keySpec).getEncoded(); - PublicKey key = new sun.security.rsa.RSAPublicKeyImpl(encoded); + PublicKey key = RSAPublicKeyImpl.newKey(encoded); return implTranslatePublicKey(key); } catch (InvalidKeyException e) { throw new InvalidKeySpecException diff --git a/src/share/classes/sun/security/pkcs11/P11Signature.java b/src/share/classes/sun/security/pkcs11/P11Signature.java index af152d8153e81a0dd959222013b3b3cfc0f0208a..48a49f66bf1ffed80fec402264965348beb2841f 100644 --- a/src/share/classes/sun/security/pkcs11/P11Signature.java +++ b/src/share/classes/sun/security/pkcs11/P11Signature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ import java.nio.ByteBuffer; import java.security.*; import java.security.interfaces.*; +import java.security.spec.AlgorithmParameterSpec; import sun.nio.ch.DirectBuffer; import sun.security.util.*; @@ -378,14 +379,19 @@ final class P11Signature extends SignatureSpi { if (key instanceof P11Key) { keySize = ((P11Key) key).length(); } else { - if (keyAlgo.equals("RSA")) { - keySize = ((RSAKey) key).getModulus().bitLength(); - } else if (keyAlgo.equals("DSA")) { - keySize = ((DSAKey) key).getParams().getP().bitLength(); - } else if (keyAlgo.equals("EC")) { - keySize = ((ECKey) key).getParams().getCurve().getField().getFieldSize(); - } else { - throw new ProviderException("Error: unsupported algo " + keyAlgo); + try { + if (keyAlgo.equals("RSA")) { + keySize = ((RSAKey) key).getModulus().bitLength(); + } else if (keyAlgo.equals("DSA")) { + keySize = ((DSAKey) key).getParams().getP().bitLength(); + } else if (keyAlgo.equals("EC")) { + keySize = ((ECKey) key).getParams().getCurve().getField().getFieldSize(); + } else { + throw new ProviderException("Error: unsupported algo " + keyAlgo); + } + } catch (ClassCastException cce) { + throw new InvalidKeyException(keyAlgo + + " key must be the right type", cce); } } if ((minKeySize != -1) && (keySize < minKeySize)) { @@ -434,9 +440,9 @@ final class P11Signature extends SignatureSpi { } // see JCA spec + @Override protected void engineInitVerify(PublicKey publicKey) throws InvalidKeyException { - if (publicKey == null) { throw new InvalidKeyException("Key must not be null"); } @@ -451,9 +457,9 @@ final class P11Signature extends SignatureSpi { } // see JCA spec + @Override protected void engineInitSign(PrivateKey privateKey) throws InvalidKeyException { - if (privateKey == null) { throw new InvalidKeyException("Key must not be null"); } @@ -468,6 +474,7 @@ final class P11Signature extends SignatureSpi { } // see JCA spec + @Override protected void engineUpdate(byte b) throws SignatureException { ensureInitialized(); switch (type) { @@ -492,6 +499,7 @@ final class P11Signature extends SignatureSpi { } // see JCA spec + @Override protected void engineUpdate(byte[] b, int ofs, int len) throws SignatureException { @@ -535,6 +543,7 @@ final class P11Signature extends SignatureSpi { } // see JCA spec + @Override protected void engineUpdate(ByteBuffer byteBuffer) { ensureInitialized(); @@ -585,6 +594,7 @@ final class P11Signature extends SignatureSpi { } // see JCA spec + @Override protected byte[] engineSign() throws SignatureException { ensureInitialized(); @@ -641,6 +651,7 @@ final class P11Signature extends SignatureSpi { } // see JCA spec + @Override protected boolean engineVerify(byte[] signature) throws SignatureException { ensureInitialized(); boolean doCancel = true; @@ -828,14 +839,31 @@ final class P11Signature extends SignatureSpi { } // see JCA spec + @Override protected void engineSetParameter(String param, Object value) throws InvalidParameterException { throw new UnsupportedOperationException("setParameter() not supported"); } + // see JCA spec + @Override + protected void engineSetParameter(AlgorithmParameterSpec params) + throws InvalidAlgorithmParameterException { + if (params != null) { + throw new InvalidAlgorithmParameterException("No parameter accepted"); + } + } + // see JCA spec + @Override protected Object engineGetParameter(String param) throws InvalidParameterException { throw new UnsupportedOperationException("getParameter() not supported"); } + + // see JCA spec + @Override + protected AlgorithmParameters engineGetParameters() { + return null; + } } diff --git a/src/share/classes/sun/security/pkcs11/Secmod.java b/src/share/classes/sun/security/pkcs11/Secmod.java index 1d2c5c0bdc6c29e73977aea017eab2a01bc76443..94e4ada5ff1ca5b2807ecfcd42be04d06f7ed102 100644 --- a/src/share/classes/sun/security/pkcs11/Secmod.java +++ b/src/share/classes/sun/security/pkcs11/Secmod.java @@ -404,10 +404,6 @@ public final class Secmod { } else { type = ModuleType.EXTERNAL; } - if (fips) { - throw new RuntimeException("FIPS flag set for non-internal " - + "module: " + libraryName + ", " + commonName); - } } // On Ubuntu the libsoftokn3 library is located in a subdirectory // of the system libraries directory. (Since Ubuntu 11.04.) diff --git a/src/share/classes/sun/security/pkcs11/wrapper/CK_CREATEMUTEX.java b/src/share/classes/sun/security/pkcs11/wrapper/CK_CREATEMUTEX.java index 29dd09510b8e3e0cda097c7e66a1cb55415298ca..2721fb118e0ee82e09ff44d79f2b69884953fa75 100644 --- a/src/share/classes/sun/security/pkcs11/wrapper/CK_CREATEMUTEX.java +++ b/src/share/classes/sun/security/pkcs11/wrapper/CK_CREATEMUTEX.java @@ -50,17 +50,16 @@ package sun.security.pkcs11.wrapper; /** - * interface CK_CREATEMUTEX.

    + * interface CK_CREATEMUTEX. * - * @author Karl Scheibelhofer - * @author Martin Schlaeffer + * @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at> + * @author Martin Schlaeffer <schlaeff@sbox.tugraz.at> */ public interface CK_CREATEMUTEX { /** * Method CK_CREATEMUTEX * - * @param ppMutex * @return The mutex (lock) object. * @exception PKCS11Exception */ diff --git a/src/share/classes/sun/security/pkcs12/MacData.java b/src/share/classes/sun/security/pkcs12/MacData.java index 93bfef14b6c322c4978369bbac028ffd7a28e993..dc5716ff558b518e627c97cc0d25a13dbc0792f1 100644 --- a/src/share/classes/sun/security/pkcs12/MacData.java +++ b/src/share/classes/sun/security/pkcs12/MacData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,10 +59,16 @@ class MacData { throws IOException, ParsingException { DerValue[] macData = derin.getSequence(2); + if (macData.length < 2 || macData.length > 3) { + throw new ParsingException("Invalid length for MacData"); + } // Parse the digest info DerInputStream digestIn = new DerInputStream(macData[0].toByteArray()); DerValue[] digestInfo = digestIn.getSequence(2); + if (digestInfo.length != 2) { + throw new ParsingException("Invalid length for DigestInfo"); + } // Parse the DigestAlgorithmIdentifier. AlgorithmId digestAlgorithmId = AlgorithmId.parse(digestInfo[0]); diff --git a/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java b/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java index 07d8e98a045e4ef8e2b6b3556c164944d074b954..85163e50bace6520cce9f78d3d5ac9d1e4e447ee 100644 --- a/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java +++ b/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. * 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,6 +389,9 @@ public final class PKCS12KeyStore extends KeyStoreSpi { DerInputStream in = val.toDerInputStream(); int i = in.getInteger(); DerValue[] value = in.getSequence(2); + if (value.length < 1 || value.length > 2) { + throw new IOException("Invalid length for AlgorithmIdentifier"); + } AlgorithmId algId = new AlgorithmId(value[0].getOID()); String keyAlgo = algId.getName(); @@ -2000,11 +2003,17 @@ public final class PKCS12KeyStore extends KeyStoreSpi { DerInputStream edi = safeContents.getContent().toDerInputStream(); int edVersion = edi.getInteger(); - DerValue[] seq = edi.getSequence(2); + DerValue[] seq = edi.getSequence(3); + if (seq.length != 3) { + // We require the encryptedContent field, even though + // it is optional + throw new IOException("Invalid length for EncryptedContentInfo"); + } ObjectIdentifier edContentType = seq[0].getOID(); eAlgId = seq[1].toByteArray(); if (!seq[2].isContextSpecific((byte)0)) { - throw new IOException("encrypted content not present!"); + throw new IOException("unsupported encrypted content type " + + seq[2].tag); } byte newTag = DerValue.tag_OctetString; if (seq[2].isConstructed()) @@ -2152,18 +2161,9 @@ public final class PKCS12KeyStore extends KeyStoreSpi { } 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(); @@ -2227,6 +2227,9 @@ public final class PKCS12KeyStore extends KeyStoreSpi { } else if (bagId.equals((Object)CertBag_OID)) { DerInputStream cs = new DerInputStream(bagValue.toByteArray()); DerValue[] certValues = cs.getSequence(2); + if (certValues.length != 2) { + throw new IOException("Invalid length for CertBag"); + } ObjectIdentifier certId = certValues[0].getOID(); if (!certValues[1].isContextSpecific((byte)0)) { throw new IOException("unsupported PKCS12 cert value type " @@ -2242,6 +2245,9 @@ public final class PKCS12KeyStore extends KeyStoreSpi { } else if (bagId.equals((Object)SecretBag_OID)) { DerInputStream ss = new DerInputStream(bagValue.toByteArray()); DerValue[] secretValues = ss.getSequence(2); + if (secretValues.length != 2) { + throw new IOException("Invalid length for SecretBag"); + } ObjectIdentifier secretId = secretValues[0].getOID(); if (!secretValues[1].isContextSpecific((byte)0)) { throw new IOException( @@ -2280,6 +2286,9 @@ public final class PKCS12KeyStore extends KeyStoreSpi { byte[] encoded = attrSet[j].toByteArray(); DerInputStream as = new DerInputStream(encoded); DerValue[] attrSeq = as.getSequence(2); + if (attrSeq.length != 2) { + throw new IOException("Invalid length for Attribute"); + } ObjectIdentifier attrId = attrSeq[0].getOID(); DerInputStream vs = new DerInputStream(attrSeq[1].toByteArray()); diff --git a/src/share/classes/sun/security/provider/DSA.java b/src/share/classes/sun/security/provider/DSA.java index 6f08f906160d5a282779125888dd0eec3fc8e3d0..cf3eade2ce1d23f0ae473a9ec3e319d99a5ebe9d 100644 --- a/src/share/classes/sun/security/provider/DSA.java +++ b/src/share/classes/sun/security/provider/DSA.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. * 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,8 +33,7 @@ import java.nio.ByteBuffer; import java.security.*; import java.security.SecureRandom; import java.security.interfaces.*; -import java.security.spec.DSAParameterSpec; -import java.security.spec.InvalidParameterSpecException; +import java.security.spec.*; import sun.security.util.Debug; import sun.security.util.DerValue; @@ -314,11 +313,24 @@ abstract class DSA extends SignatureSpi { throw new InvalidParameterException("No parameter accepted"); } + @Override + protected void engineSetParameter(AlgorithmParameterSpec params) + throws InvalidAlgorithmParameterException { + if (params != null) { + throw new InvalidAlgorithmParameterException("No parameter accepted"); + } + } + @Deprecated protected Object engineGetParameter(String key) { return null; } + @Override + protected AlgorithmParameters engineGetParameters() { + return null; + } + private BigInteger generateR(BigInteger p, BigInteger q, BigInteger g, BigInteger k) { diff --git a/src/share/classes/sun/security/provider/JavaKeyStore.java b/src/share/classes/sun/security/provider/JavaKeyStore.java index 6befb54d688c2774c6cb4f65928f1a827a8f09e6..0ed7fa12871e6250f650ba93942e1f0b785c8ab2 100644 --- a/src/share/classes/sun/security/provider/JavaKeyStore.java +++ b/src/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 @@ -35,6 +35,7 @@ import java.util.*; import sun.misc.IOUtils; import sun.security.pkcs.EncryptedPrivateKeyInfo; import sun.security.pkcs12.PKCS12KeyStore; +import sun.security.util.Debug; /** * This class provides the keystore implementation referred to as "JKS". @@ -73,6 +74,7 @@ abstract class JavaKeyStore extends KeyStoreSpi { } } + 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; @@ -642,6 +644,7 @@ abstract class JavaKeyStore extends KeyStoreSpi { Hashtable cfs = null; ByteArrayInputStream bais = null; byte[] encoded = null; + int trustedKeyCount = 0, privateKeyCount = 0; if (stream == null) return; @@ -680,7 +683,7 @@ abstract class JavaKeyStore extends KeyStoreSpi { tag = dis.readInt(); if (tag == 1) { // private key entry - + privateKeyCount++; KeyEntry entry = new KeyEntry(); // Read the alias @@ -729,7 +732,7 @@ abstract class JavaKeyStore extends KeyStoreSpi { entries.put(alias, entry); } else if (tag == 2) { // trusted certificate entry - + trustedKeyCount++; TrustedCertEntry entry = new TrustedCertEntry(); // Read the alias @@ -764,10 +767,16 @@ abstract class JavaKeyStore extends KeyStoreSpi { 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/share/classes/sun/security/provider/SHA5.java b/src/share/classes/sun/security/provider/SHA5.java index ceba1fc2b2dd6b1b0c1ae8a71745b8c2cd4e0dc2..f35006e9f168b834abf6f64b51a2983a5c029dec 100644 --- a/src/share/classes/sun/security/provider/SHA5.java +++ b/src/share/classes/sun/security/provider/SHA5.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * 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,7 +121,14 @@ abstract class SHA5 extends DigestBase { i2bBig4((int)bitsProcessed, buffer, 124); implCompress(buffer, 0); - l2bBig(state, 0, out, ofs, engineGetDigestLength()); + int len = engineGetDigestLength(); + if (len == 28) { + // Special case for SHA-512/224 + l2bBig(state, 0, out, ofs, 24); + i2bBig4((int)(state[3] >> 32), out, ofs + 24); + } else { + l2bBig(state, 0, out, ofs, len); + } } /** @@ -308,4 +315,31 @@ abstract class SHA5 extends DigestBase { super("SHA-384", 48, INITIAL_HASHES); } } + public static final class SHA512_224 extends SHA5 { + + private static final long[] INITIAL_HASHES = { + 0x8C3D37C819544DA2L, 0x73E1996689DCD4D6L, + 0x1DFAB7AE32FF9C82L, 0x679DD514582F9FCFL, + 0x0F6D2B697BD44DA8L, 0x77E36F7304C48942L, + 0x3F9D85A86A1D36C8L, 0x1112E6AD91D692A1L + }; + + public SHA512_224() { + super("SHA-512/224", 28, INITIAL_HASHES); + } + } + + public static final class SHA512_256 extends SHA5 { + + private static final long[] INITIAL_HASHES = { + 0x22312194FC2BF72CL, 0x9F555FA3C84C64C2L, + 0x2393B86B6F53B151L, 0x963877195940EABDL, + 0x96283EE2A88EFFE3L, 0xBE5E1E2553863992L, + 0x2B0199FC2C85B8AAL, 0x0EB72DDC81C52CA2L + }; + + public SHA512_256() { + super("SHA-512/256", 32, INITIAL_HASHES); + } + } } diff --git a/src/share/classes/sun/security/provider/SunEntries.java b/src/share/classes/sun/security/provider/SunEntries.java index 0ec9813c90a29dc5186aeada75aa82c6c9350dbe..d856978418a13596cb459c673f5551d7fdf9983e 100644 --- a/src/share/classes/sun/security/provider/SunEntries.java +++ b/src/share/classes/sun/security/provider/SunEntries.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. * 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,6 +106,7 @@ final class SunEntries { map.put("SecureRandom.NativePRNG", "sun.security.provider.NativePRNG"); } + map.put("SecureRandom.SHA1PRNG", "sun.security.provider.SecureRandom"); if (nativeAvailable && !useNativePRNG) { @@ -200,6 +201,14 @@ final class SunEntries { map.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.3", "SHA-512"); map.put("Alg.Alias.MessageDigest.OID.2.16.840.1.101.3.4.2.3", "SHA-512"); + map.put("MessageDigest.SHA-512/224", "sun.security.provider.SHA5$SHA512_224"); + map.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.5", "SHA-512/224"); + map.put("Alg.Alias.MessageDigest.OID.2.16.840.1.101.3.4.2.5", + "SHA-512/224"); + map.put("MessageDigest.SHA-512/256", "sun.security.provider.SHA5$SHA512_256"); + map.put("Alg.Alias.MessageDigest.2.16.840.1.101.3.4.2.6", "SHA-512/256"); + map.put("Alg.Alias.MessageDigest.OID.2.16.840.1.101.3.4.2.6", + "SHA-512/256"); /* * Algorithm Parameter Generator engines diff --git a/src/share/classes/sun/security/provider/certpath/OCSPResponse.java b/src/share/classes/sun/security/provider/certpath/OCSPResponse.java index f2c23b991b7ecfa1c24758b4f23ef6fd6e62ce8a..933c6a036ded432eaf36144a28ab8e6af2d66bc6 100644 --- a/src/share/classes/sun/security/provider/certpath/OCSPResponse.java +++ b/src/share/classes/sun/security/provider/certpath/OCSPResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * 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,7 +261,7 @@ public final class OCSPResponse { DerInputStream basicOCSPResponse = new DerInputStream(derIn.getOctetString()); - DerValue[] seqTmp = basicOCSPResponse.getSequence(2); + DerValue[] seqTmp = basicOCSPResponse.getSequence(3); if (seqTmp.length < 3) { throw new IOException("Unexpected BasicOCSPResponse value"); } diff --git a/src/share/classes/sun/security/rsa/MGF1.java b/src/share/classes/sun/security/rsa/MGF1.java new file mode 100644 index 0000000000000000000000000000000000000000..6bd21664bd0b71cd7a204b0c3eec1266d7ebacc2 --- /dev/null +++ b/src/share/classes/sun/security/rsa/MGF1.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * 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.rsa; + +import java.security.*; + +/** + * This class implements the MGF1 mask generation function defined in PKCS#1 + * v2.2 B.2.1 (https://tools.ietf.org/html/rfc8017#appendix-B.2.1). A mask + * generation function takes an octet string of variable length and a + * desired output length as input and outputs an octet string of the + * desired length. MGF1 is a mask generation function based on a hash + * function, i.e. message digest algorithm. + * + * @since 8 + */ +public final class MGF1 { + + private final MessageDigest md; + + /** + * Construct an instance of MGF1 based on the specified digest algorithm. + */ + MGF1(String mdAlgo) throws NoSuchAlgorithmException { + this.md = MessageDigest.getInstance(mdAlgo); + } + + /** + * Using the specified seed bytes, generate the mask, xor the mask + * with the specified output buffer and store the result into the + * output buffer (essentially replaced in place). + * + * @param seed the buffer holding the seed bytes + * @param seedOfs the index of the seed bytes + * @param seedLen the length of the seed bytes to be used by MGF1 + * @param maskLen the intended length of the generated mask + * @param out the output buffer holding the mask + * @param outOfs the index of the output buffer for the mask + */ + void generateAndXor(byte[] seed, int seedOfs, int seedLen, int maskLen, + byte[] out, int outOfs) throws RuntimeException { + byte[] C = new byte[4]; // 32 bit counter + byte[] digest = new byte[md.getDigestLength()]; + while (maskLen > 0) { + md.update(seed, seedOfs, seedLen); + md.update(C); + try { + md.digest(digest, 0, digest.length); + } catch (DigestException e) { + // should never happen + throw new RuntimeException(e.toString()); + } + for (int i = 0; (i < digest.length) && (maskLen > 0); maskLen--) { + out[outOfs++] ^= digest[i++]; + } + if (maskLen > 0) { + // increment counter + for (int i = C.length - 1; (++C[i] == 0) && (i > 0); i--) { + // empty + } + } + } + } + + /** + * Returns the name of this MGF1 instance, i.e. "MGF1" followed by the + * digest algorithm it based on. + */ + String getName() { + return "MGF1" + md.getAlgorithm(); + } +} diff --git a/src/share/classes/sun/security/rsa/PSSParameters.java b/src/share/classes/sun/security/rsa/PSSParameters.java new file mode 100644 index 0000000000000000000000000000000000000000..6b7ff785f4eff431aa342723622ded1b93d321e6 --- /dev/null +++ b/src/share/classes/sun/security/rsa/PSSParameters.java @@ -0,0 +1,274 @@ +/* + * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * 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.rsa; + +import java.io.*; +import sun.security.util.*; +import sun.security.x509.*; +import java.security.AlgorithmParametersSpi; +import java.security.NoSuchAlgorithmException; +import java.security.spec.AlgorithmParameterSpec; +import java.security.spec.InvalidParameterSpecException; +import java.security.spec.MGF1ParameterSpec; +import java.security.spec.PSSParameterSpec; +import static java.security.spec.PSSParameterSpec.DEFAULT; + +/** + * This class implements the PSS parameters used with the RSA + * signatures in PSS padding. Here is its ASN.1 definition: + * RSASSA-PSS-params ::= SEQUENCE { + * hashAlgorithm [0] HashAlgorithm DEFAULT sha1, + * maskGenAlgorithm [1] MaskGenAlgorithm DEFAULT mgf1SHA1, + * saltLength [2] INTEGER DEFAULT 20 + * trailerField [3] TrailerField DEFAULT trailerFieldBC + * } + * + * @author Valerie Peng + * + */ + +public final class PSSParameters extends AlgorithmParametersSpi { + + private PSSParameterSpec spec; + + public PSSParameters() { + } + + @Override + protected void engineInit(AlgorithmParameterSpec paramSpec) + throws InvalidParameterSpecException { + if (!(paramSpec instanceof PSSParameterSpec)) { + throw new InvalidParameterSpecException + ("Inappropriate parameter specification"); + } + PSSParameterSpec spec = (PSSParameterSpec) paramSpec; + + String mgfName = spec.getMGFAlgorithm(); + if (!spec.getMGFAlgorithm().equalsIgnoreCase("MGF1")) { + throw new InvalidParameterSpecException("Unsupported mgf " + + mgfName + "; MGF1 only"); + } + AlgorithmParameterSpec mgfSpec = spec.getMGFParameters(); + if (!(mgfSpec instanceof MGF1ParameterSpec)) { + throw new InvalidParameterSpecException("Inappropriate mgf " + + "parameters; non-null MGF1ParameterSpec only"); + } + this.spec = spec; + } + + @Override + protected void engineInit(byte[] encoded) throws IOException { + // first initialize with the DEFAULT values before + // retrieving from the encoding bytes + 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 + 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(AlgorithmId.mgf1_oid)) { + throw new IOException("Only MGF1 mgf is supported"); + } + AlgorithmId params = AlgorithmId.parse( + new DerValue(val.getEncodedParams())); + String mgfDigestName = params.getName(); + switch (mgfDigestName) { + case "SHA-1": + mgfSpec = MGF1ParameterSpec.SHA1; + break; + case "SHA-224": + mgfSpec = MGF1ParameterSpec.SHA224; + break; + case "SHA-256": + mgfSpec = MGF1ParameterSpec.SHA256; + break; + case "SHA-384": + mgfSpec = MGF1ParameterSpec.SHA384; + break; + case "SHA-512": + mgfSpec = MGF1ParameterSpec.SHA512; + break; + case "SHA-512/224": + mgfSpec = MGF1ParameterSpec.SHA512_224; + break; + case "SHA-512/256": + mgfSpec = MGF1ParameterSpec.SHA512_256; + break; + default: + throw new IOException + ("Unrecognized message digest algorithm " + + mgfDigestName); + } + } else if (d.isContextSpecific((byte) 0x02)) { + // salt length + saltLength = d.data.getDerValue().getInteger(); + if (saltLength < 0) { + throw new IOException("Negative value for saltLength"); + } + } else if (d.isContextSpecific((byte) 0x03)) { + // trailer field + trailerField = d.data.getDerValue().getInteger(); + if (trailerField != 1) { + throw new IOException("Unsupported trailerField value " + + trailerField); + } + } else { + throw new IOException("Invalid encoded PSSParameters"); + } + } + + this.spec = new PSSParameterSpec(mdName, "MGF1", mgfSpec, + saltLength, trailerField); + } + + @Override + protected void engineInit(byte[] encoded, String decodingMethod) + throws IOException { + if ((decodingMethod != null) && + (!decodingMethod.equalsIgnoreCase("ASN.1"))) { + throw new IllegalArgumentException("Only support ASN.1 format"); + } + engineInit(encoded); + } + + @Override + protected + T engineGetParameterSpec(Class paramSpec) + throws InvalidParameterSpecException { + if (PSSParameterSpec.class.isAssignableFrom(paramSpec)) { + return paramSpec.cast(spec); + } else { + throw new InvalidParameterSpecException + ("Inappropriate parameter specification"); + } + } + + @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(spec.getDigestAlgorithm()); + } catch (NoSuchAlgorithmException nsae) { + 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); + } + + // MGF + AlgorithmId mgfDigestId; + try { + mgfDigestId = AlgorithmId.get(mgf1Spec.getDigestAlgorithm()); + } catch (NoSuchAlgorithmException nase) { + throw new IOException("AlgorithmId " + + 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); + } + + // SaltLength + if (spec.getSaltLength() != 20) { + tmp2 = new DerOutputStream(); + tmp2.putInteger(spec.getSaltLength()); + tmp.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 2), + tmp2); + } + + // TrailerField + 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(); + } +} diff --git a/src/share/classes/sun/security/rsa/RSAKeyFactory.java b/src/share/classes/sun/security/rsa/RSAKeyFactory.java index 54aa0d269f51fb12dfabdb296fe2b9b54757aacb..021fa931829c208810ba0cd919eb3acb0dfb49b7 100644 --- a/src/share/classes/sun/security/rsa/RSAKeyFactory.java +++ b/src/share/classes/sun/security/rsa/RSAKeyFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * 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,10 +32,15 @@ import java.security.interfaces.*; import java.security.spec.*; import sun.security.action.GetPropertyAction; +import sun.security.x509.AlgorithmId; +import static sun.security.rsa.RSAUtil.KeyType; /** - * KeyFactory for RSA keys. Keys must be instances of PublicKey or PrivateKey - * and getAlgorithm() must return "RSA". For such keys, it supports conversion + * KeyFactory for RSA keys, e.g. "RSA", "RSASSA-PSS". + * Keys must be instances of PublicKey or PrivateKey + * and getAlgorithm() must return a value which matches the type which are + * specified during construction time of the KeyFactory object. + * For such keys, it supports conversion * between the following: * * For public keys: @@ -58,21 +63,21 @@ import sun.security.action.GetPropertyAction; * @since 1.5 * @author Andreas Sterbenz */ -public final class RSAKeyFactory extends KeyFactorySpi { +public class RSAKeyFactory extends KeyFactorySpi { - private final static Class rsaPublicKeySpecClass = - RSAPublicKeySpec.class; - private final static Class rsaPrivateKeySpecClass = - RSAPrivateKeySpec.class; - private final static Class rsaPrivateCrtKeySpecClass = - RSAPrivateCrtKeySpec.class; - - private final static Class x509KeySpecClass = X509EncodedKeySpec.class; - private final static Class pkcs8KeySpecClass = PKCS8EncodedKeySpec.class; + private static final Class RSA_PUB_KEYSPEC_CLS = RSAPublicKeySpec.class; + private static final Class RSA_PRIV_KEYSPEC_CLS = + RSAPrivateKeySpec.class; + private static final Class RSA_PRIVCRT_KEYSPEC_CLS = + RSAPrivateCrtKeySpec.class; + private static final Class X509_KEYSPEC_CLS = X509EncodedKeySpec.class; + private static final Class PKCS8_KEYSPEC_CLS = PKCS8EncodedKeySpec.class; public final static int MIN_MODLEN = 512; public final static int MAX_MODLEN = 16384; + private final KeyType type; + /* * If the modulus length is above this value, restrict the size of * the exponent to something that can be reasonably computed. We @@ -88,11 +93,18 @@ public final class RSAKeyFactory extends KeyFactorySpi { new GetPropertyAction( "sun.security.rsa.restrictRSAExponent", "true"))); - // instance used for static translateKey(); - private final static RSAKeyFactory INSTANCE = new RSAKeyFactory(); + static RSAKeyFactory getInstance(KeyType type) { + return new RSAKeyFactory(type); + } - public RSAKeyFactory() { - // empty + // Internal utility method for checking key algorithm + private static void checkKeyAlgo(Key key, String expectedAlg) + throws InvalidKeyException { + String keyAlg = key.getAlgorithm(); + if (keyAlg == null || !(keyAlg.equalsIgnoreCase(expectedAlg))) { + throw new InvalidKeyException("Expected a " + expectedAlg + + " key, but got " + keyAlg); + } } /** @@ -103,12 +115,21 @@ public final class RSAKeyFactory extends KeyFactorySpi { * Used by RSASignature and RSACipher. */ public static RSAKey toRSAKey(Key key) throws InvalidKeyException { + if (key == null) { + throw new InvalidKeyException("Key must not be null"); + } if ((key instanceof RSAPrivateKeyImpl) || (key instanceof RSAPrivateCrtKeyImpl) || (key instanceof RSAPublicKeyImpl)) { return (RSAKey)key; } else { - return (RSAKey)INSTANCE.engineTranslateKey(key); + try { + KeyType type = KeyType.lookup(key.getAlgorithm()); + RSAKeyFactory kf = RSAKeyFactory.getInstance(type); + return (RSAKey) kf.engineTranslateKey(key); + } catch (ProviderException e) { + throw new InvalidKeyException(e); + } } } @@ -172,6 +193,15 @@ public final class RSAKeyFactory extends KeyFactorySpi { } } + // disallowed as KeyType is required + private RSAKeyFactory() { + this.type = KeyType.RSA; + } + + public RSAKeyFactory(KeyType type) { + this.type = type; + } + /** * Translate an RSA key into a SunRsaSign RSA key. If conversion is * not possible, throw an InvalidKeyException. @@ -181,9 +211,14 @@ public final class RSAKeyFactory extends KeyFactorySpi { if (key == null) { throw new InvalidKeyException("Key must not be null"); } - String keyAlg = key.getAlgorithm(); - if (keyAlg.equals("RSA") == false) { - throw new InvalidKeyException("Not an RSA key: " + keyAlg); + // ensure the key algorithm matches the current KeyFactory instance + checkKeyAlgo(key, type.keyAlgo()); + + // no translation needed if the key is already our own impl + if ((key instanceof RSAPrivateKeyImpl) || + (key instanceof RSAPrivateCrtKeyImpl) || + (key instanceof RSAPublicKeyImpl)) { + return key; } if (key instanceof PublicKey) { return translatePublicKey((PublicKey)key); @@ -222,22 +257,21 @@ public final class RSAKeyFactory extends KeyFactorySpi { private PublicKey translatePublicKey(PublicKey key) throws InvalidKeyException { if (key instanceof RSAPublicKey) { - if (key instanceof RSAPublicKeyImpl) { - return key; - } RSAPublicKey rsaKey = (RSAPublicKey)key; try { return new RSAPublicKeyImpl( + RSAUtil.createAlgorithmId(type, rsaKey.getParams()), rsaKey.getModulus(), - rsaKey.getPublicExponent() - ); - } catch (RuntimeException e) { + rsaKey.getPublicExponent()); + } catch (ProviderException e) { // catch providers that incorrectly implement RSAPublicKey throw new InvalidKeyException("Invalid key", e); } } else if ("X.509".equals(key.getFormat())) { - byte[] encoded = key.getEncoded(); - return new RSAPublicKeyImpl(encoded); + RSAPublicKey translated = new RSAPublicKeyImpl(key.getEncoded()); + // ensure the key algorithm matches the current KeyFactory instance + checkKeyAlgo(translated, type.keyAlgo()); + return translated; } else { throw new InvalidKeyException("Public keys must be instance " + "of RSAPublicKey or have X.509 encoding"); @@ -248,12 +282,10 @@ public final class RSAKeyFactory extends KeyFactorySpi { private PrivateKey translatePrivateKey(PrivateKey key) throws InvalidKeyException { if (key instanceof RSAPrivateCrtKey) { - if (key instanceof RSAPrivateCrtKeyImpl) { - return key; - } RSAPrivateCrtKey rsaKey = (RSAPrivateCrtKey)key; try { return new RSAPrivateCrtKeyImpl( + RSAUtil.createAlgorithmId(type, rsaKey.getParams()), rsaKey.getModulus(), rsaKey.getPublicExponent(), rsaKey.getPrivateExponent(), @@ -263,27 +295,28 @@ public final class RSAKeyFactory extends KeyFactorySpi { rsaKey.getPrimeExponentQ(), rsaKey.getCrtCoefficient() ); - } catch (RuntimeException e) { + } catch (ProviderException e) { // catch providers that incorrectly implement RSAPrivateCrtKey throw new InvalidKeyException("Invalid key", e); } } else if (key instanceof RSAPrivateKey) { - if (key instanceof RSAPrivateKeyImpl) { - return key; - } RSAPrivateKey rsaKey = (RSAPrivateKey)key; try { return new RSAPrivateKeyImpl( + RSAUtil.createAlgorithmId(type, rsaKey.getParams()), rsaKey.getModulus(), rsaKey.getPrivateExponent() ); - } catch (RuntimeException e) { + } catch (ProviderException e) { // catch providers that incorrectly implement RSAPrivateKey throw new InvalidKeyException("Invalid key", e); } } else if ("PKCS#8".equals(key.getFormat())) { - byte[] encoded = key.getEncoded(); - return RSAPrivateCrtKeyImpl.newKey(encoded); + RSAPrivateKey translated = + RSAPrivateCrtKeyImpl.newKey(key.getEncoded()); + // ensure the key algorithm matches the current KeyFactory instance + checkKeyAlgo(translated, type.keyAlgo()); + return translated; } else { throw new InvalidKeyException("Private keys must be instance " + "of RSAPrivate(Crt)Key or have PKCS#8 encoding"); @@ -295,13 +328,21 @@ public final class RSAKeyFactory extends KeyFactorySpi { throws GeneralSecurityException { if (keySpec instanceof X509EncodedKeySpec) { X509EncodedKeySpec x509Spec = (X509EncodedKeySpec)keySpec; - return new RSAPublicKeyImpl(x509Spec.getEncoded()); + RSAPublicKey generated = new RSAPublicKeyImpl(x509Spec.getEncoded()); + // ensure the key algorithm matches the current KeyFactory instance + checkKeyAlgo(generated, type.keyAlgo()); + return generated; } else if (keySpec instanceof RSAPublicKeySpec) { RSAPublicKeySpec rsaSpec = (RSAPublicKeySpec)keySpec; - return new RSAPublicKeyImpl( - rsaSpec.getModulus(), - rsaSpec.getPublicExponent() - ); + try { + return new RSAPublicKeyImpl( + RSAUtil.createAlgorithmId(type, rsaSpec.getParams()), + rsaSpec.getModulus(), + rsaSpec.getPublicExponent() + ); + } catch (ProviderException e) { + throw new InvalidKeySpecException(e); + } } else { throw new InvalidKeySpecException("Only RSAPublicKeySpec " + "and X509EncodedKeySpec supported for RSA public keys"); @@ -313,25 +354,38 @@ public final class RSAKeyFactory extends KeyFactorySpi { throws GeneralSecurityException { if (keySpec instanceof PKCS8EncodedKeySpec) { PKCS8EncodedKeySpec pkcsSpec = (PKCS8EncodedKeySpec)keySpec; - return RSAPrivateCrtKeyImpl.newKey(pkcsSpec.getEncoded()); + RSAPrivateKey generated = RSAPrivateCrtKeyImpl.newKey(pkcsSpec.getEncoded()); + // ensure the key algorithm matches the current KeyFactory instance + checkKeyAlgo(generated, type.keyAlgo()); + return generated; } else if (keySpec instanceof RSAPrivateCrtKeySpec) { RSAPrivateCrtKeySpec rsaSpec = (RSAPrivateCrtKeySpec)keySpec; - return new RSAPrivateCrtKeyImpl( - rsaSpec.getModulus(), - rsaSpec.getPublicExponent(), - rsaSpec.getPrivateExponent(), - rsaSpec.getPrimeP(), - rsaSpec.getPrimeQ(), - rsaSpec.getPrimeExponentP(), - rsaSpec.getPrimeExponentQ(), - rsaSpec.getCrtCoefficient() - ); + try { + return new RSAPrivateCrtKeyImpl( + RSAUtil.createAlgorithmId(type, rsaSpec.getParams()), + rsaSpec.getModulus(), + rsaSpec.getPublicExponent(), + rsaSpec.getPrivateExponent(), + rsaSpec.getPrimeP(), + rsaSpec.getPrimeQ(), + rsaSpec.getPrimeExponentP(), + rsaSpec.getPrimeExponentQ(), + rsaSpec.getCrtCoefficient() + ); + } catch (ProviderException e) { + throw new InvalidKeySpecException(e); + } } else if (keySpec instanceof RSAPrivateKeySpec) { RSAPrivateKeySpec rsaSpec = (RSAPrivateKeySpec)keySpec; - return new RSAPrivateKeyImpl( - rsaSpec.getModulus(), - rsaSpec.getPrivateExponent() - ); + try { + return new RSAPrivateKeyImpl( + RSAUtil.createAlgorithmId(type, rsaSpec.getParams()), + rsaSpec.getModulus(), + rsaSpec.getPrivateExponent() + ); + } catch (ProviderException e) { + throw new InvalidKeySpecException(e); + } } else { throw new InvalidKeySpecException("Only RSAPrivate(Crt)KeySpec " + "and PKCS8EncodedKeySpec supported for RSA private keys"); @@ -350,12 +404,13 @@ public final class RSAKeyFactory extends KeyFactorySpi { } if (key instanceof RSAPublicKey) { RSAPublicKey rsaKey = (RSAPublicKey)key; - if (rsaPublicKeySpecClass.isAssignableFrom(keySpec)) { + if (RSA_PUB_KEYSPEC_CLS.isAssignableFrom(keySpec)) { return keySpec.cast(new RSAPublicKeySpec( rsaKey.getModulus(), - rsaKey.getPublicExponent() + rsaKey.getPublicExponent(), + rsaKey.getParams() )); - } else if (x509KeySpecClass.isAssignableFrom(keySpec)) { + } else if (X509_KEYSPEC_CLS.isAssignableFrom(keySpec)) { return keySpec.cast(new X509EncodedKeySpec(key.getEncoded())); } else { throw new InvalidKeySpecException @@ -363,9 +418,9 @@ public final class RSAKeyFactory extends KeyFactorySpi { + "X509EncodedKeySpec for RSA public keys"); } } else if (key instanceof RSAPrivateKey) { - if (pkcs8KeySpecClass.isAssignableFrom(keySpec)) { + if (PKCS8_KEYSPEC_CLS.isAssignableFrom(keySpec)) { return keySpec.cast(new PKCS8EncodedKeySpec(key.getEncoded())); - } else if (rsaPrivateCrtKeySpecClass.isAssignableFrom(keySpec)) { + } else if (RSA_PRIVCRT_KEYSPEC_CLS.isAssignableFrom(keySpec)) { if (key instanceof RSAPrivateCrtKey) { RSAPrivateCrtKey crtKey = (RSAPrivateCrtKey)key; return keySpec.cast(new RSAPrivateCrtKeySpec( @@ -376,17 +431,19 @@ public final class RSAKeyFactory extends KeyFactorySpi { crtKey.getPrimeQ(), crtKey.getPrimeExponentP(), crtKey.getPrimeExponentQ(), - crtKey.getCrtCoefficient() + crtKey.getCrtCoefficient(), + crtKey.getParams() )); } else { throw new InvalidKeySpecException ("RSAPrivateCrtKeySpec can only be used with CRT keys"); } - } else if (rsaPrivateKeySpecClass.isAssignableFrom(keySpec)) { + } else if (RSA_PRIV_KEYSPEC_CLS.isAssignableFrom(keySpec)) { RSAPrivateKey rsaKey = (RSAPrivateKey)key; return keySpec.cast(new RSAPrivateKeySpec( rsaKey.getModulus(), - rsaKey.getPrivateExponent() + rsaKey.getPrivateExponent(), + rsaKey.getParams() )); } else { throw new InvalidKeySpecException @@ -398,4 +455,16 @@ public final class RSAKeyFactory extends KeyFactorySpi { throw new InvalidKeySpecException("Neither public nor private key"); } } + + public static final class Legacy extends RSAKeyFactory { + public Legacy() { + super(KeyType.RSA); + } + } + + public static final class PSS extends RSAKeyFactory { + public PSS() { + super(KeyType.PSS); + } + } } diff --git a/src/share/classes/sun/security/rsa/RSAKeyPairGenerator.java b/src/share/classes/sun/security/rsa/RSAKeyPairGenerator.java index 6ad77b52361aa7255af1701067006d3e7ed90e60..dc1b062bf35d4e843412e43031ac7ae0e6f50108 100644 --- a/src/share/classes/sun/security/rsa/RSAKeyPairGenerator.java +++ b/src/share/classes/sun/security/rsa/RSAKeyPairGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * 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,9 @@ import java.security.spec.RSAKeyGenParameterSpec; import sun.security.jca.JCAUtil; import static sun.security.util.SecurityProviderConstants.DEF_RSA_KEY_SIZE; +import static sun.security.util.SecurityProviderConstants.DEF_RSASSA_PSS_KEY_SIZE; +import sun.security.x509.AlgorithmId; +import static sun.security.rsa.RSAUtil.KeyType; /** * RSA keypair generation. Standard algorithm, minimum key length 512 bit. @@ -43,7 +46,7 @@ import static sun.security.util.SecurityProviderConstants.DEF_RSA_KEY_SIZE; * @since 1.5 * @author Andreas Sterbenz */ -public final class RSAKeyPairGenerator extends KeyPairGeneratorSpi { +public abstract class RSAKeyPairGenerator extends KeyPairGeneratorSpi { // public exponent to use private BigInteger publicExponent; @@ -51,35 +54,31 @@ public final class RSAKeyPairGenerator extends KeyPairGeneratorSpi { // size of the key to generate, >= RSAKeyFactory.MIN_MODLEN private int keySize; + private final KeyType type; + private AlgorithmId rsaId; + // PRNG to use private SecureRandom random; - public RSAKeyPairGenerator() { + RSAKeyPairGenerator(KeyType type, int defKeySize) { + this.type = type; // initialize to default in case the app does not call initialize() - initialize(DEF_RSA_KEY_SIZE, null); + initialize(defKeySize, null); } // initialize the generator. See JCA doc public void initialize(int keySize, SecureRandom random) { - - // do not allow unreasonably small or large key sizes, - // probably user error try { - RSAKeyFactory.checkKeyLengths(keySize, RSAKeyGenParameterSpec.F4, - 512, 64 * 1024); - } catch (InvalidKeyException e) { - throw new InvalidParameterException(e.getMessage()); + initialize(new RSAKeyGenParameterSpec(keySize, + RSAKeyGenParameterSpec.F4), null); + } catch (InvalidAlgorithmParameterException iape) { + throw new InvalidParameterException(iape.getMessage()); } - - this.keySize = keySize; - this.random = random; - this.publicExponent = RSAKeyGenParameterSpec.F4; } // 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"); @@ -88,6 +87,7 @@ public final class RSAKeyPairGenerator extends KeyPairGeneratorSpi { RSAKeyGenParameterSpec rsaSpec = (RSAKeyGenParameterSpec)params; int tmpKeySize = rsaSpec.getKeysize(); BigInteger tmpPublicExponent = rsaSpec.getPublicExponent(); + AlgorithmParameterSpec tmpParams = rsaSpec.getKeyParams(); if (tmpPublicExponent == null) { tmpPublicExponent = RSAKeyGenParameterSpec.F4; @@ -111,6 +111,13 @@ public final class RSAKeyPairGenerator extends KeyPairGeneratorSpi { "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; this.random = random; @@ -166,9 +173,9 @@ public final class RSAKeyPairGenerator extends KeyPairGeneratorSpi { BigInteger coeff = q.modInverse(p); try { - PublicKey publicKey = new RSAPublicKeyImpl(n, e); - PrivateKey privateKey = - new RSAPrivateCrtKeyImpl(n, e, d, p, q, pe, qe, coeff); + 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, @@ -178,4 +185,15 @@ public final class RSAKeyPairGenerator extends KeyPairGeneratorSpi { } } + public static final class Legacy extends RSAKeyPairGenerator { + public Legacy() { + super(KeyType.RSA, DEF_RSA_KEY_SIZE); + } + } + + public static final class PSS extends RSAKeyPairGenerator { + public PSS() { + super(KeyType.PSS, DEF_RSASSA_PSS_KEY_SIZE); + } + } } diff --git a/src/share/classes/sun/security/rsa/RSAPSSSignature.java b/src/share/classes/sun/security/rsa/RSAPSSSignature.java new file mode 100644 index 0000000000000000000000000000000000000000..dd29595fc67d55292691ed83d4b9efd357becf36 --- /dev/null +++ b/src/share/classes/sun/security/rsa/RSAPSSSignature.java @@ -0,0 +1,619 @@ +/* + * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * 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.rsa; + +import java.io.IOException; +import java.nio.ByteBuffer; + +import java.security.*; +import java.security.spec.AlgorithmParameterSpec; +import java.security.spec.PSSParameterSpec; +import java.security.spec.MGF1ParameterSpec; +import java.security.interfaces.*; + +import java.util.Arrays; +import java.util.Hashtable; + +import sun.security.util.*; +import sun.security.jca.JCAUtil; + + +/** + * PKCS#1 v2.2 RSASSA-PSS signatures with various message digest algorithms. + * RSASSA-PSS implementation takes the message digest algorithm, MGF algorithm, + * and salt length values through the required signature PSS parameters. + * We support SHA-1, SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, and + * SHA-512/256 message digest algorithms and MGF1 mask generation function. + * + * @since 8 + */ +public class RSAPSSSignature extends SignatureSpi { + + private static final boolean DEBUG = false; + + // utility method for comparing digest algorithms + // NOTE that first argument is assumed to be standard digest name + private boolean isDigestEqual(String stdAlg, String givenAlg) { + if (stdAlg == null || givenAlg == null) return false; + + if (givenAlg.indexOf("-") != -1) { + return stdAlg.equalsIgnoreCase(givenAlg); + } else { + if (stdAlg.equals("SHA-1")) { + return (givenAlg.equalsIgnoreCase("SHA") + || givenAlg.equalsIgnoreCase("SHA1")); + } else { + StringBuilder sb = new StringBuilder(givenAlg); + // case-insensitive check + if (givenAlg.regionMatches(true, 0, "SHA", 0, 3)) { + givenAlg = sb.insert(3, "-").toString(); + return stdAlg.equalsIgnoreCase(givenAlg); + } else { + throw new ProviderException("Unsupported digest algorithm " + + givenAlg); + } + } + } + } + + private static final byte[] EIGHT_BYTES_OF_ZEROS = new byte[8]; + + private static final Hashtable DIGEST_LENGTHS = + new Hashtable(); + static { + DIGEST_LENGTHS.put("SHA-1", 20); + DIGEST_LENGTHS.put("SHA", 20); + DIGEST_LENGTHS.put("SHA1", 20); + DIGEST_LENGTHS.put("SHA-224", 28); + DIGEST_LENGTHS.put("SHA224", 28); + DIGEST_LENGTHS.put("SHA-256", 32); + DIGEST_LENGTHS.put("SHA256", 32); + DIGEST_LENGTHS.put("SHA-384", 48); + DIGEST_LENGTHS.put("SHA384", 48); + DIGEST_LENGTHS.put("SHA-512", 64); + DIGEST_LENGTHS.put("SHA512", 64); + DIGEST_LENGTHS.put("SHA-512/224", 28); + DIGEST_LENGTHS.put("SHA512/224", 28); + DIGEST_LENGTHS.put("SHA-512/256", 32); + DIGEST_LENGTHS.put("SHA512/256", 32); + } + + // message digest implementation we use for hashing the data + private MessageDigest md; + // flag indicating whether the digest is reset + private boolean digestReset = true; + + // private key, if initialized for signing + private RSAPrivateKey privKey = null; + // public key, if initialized for verifying + private RSAPublicKey pubKey = null; + // PSS parameters from signatures and keys respectively + private PSSParameterSpec sigParams = null; // required for PSS signatures + + // PRNG used to generate salt bytes if none given + private SecureRandom random; + + /** + * Construct a new RSAPSSSignatur with arbitrary digest algorithm + */ + public RSAPSSSignature() { + this.md = null; + } + + // initialize for verification. See JCA doc + @Override + protected void engineInitVerify(PublicKey publicKey) + throws InvalidKeyException { + if (!(publicKey instanceof RSAPublicKey)) { + throw new InvalidKeyException("key must be RSAPublicKey"); + } + this.pubKey = (RSAPublicKey) isValid((RSAKey)publicKey); + this.privKey = null; + resetDigest(); + } + + // initialize for signing. See JCA doc + @Override + protected void engineInitSign(PrivateKey privateKey) + throws InvalidKeyException { + engineInitSign(privateKey, null); + } + + // initialize for signing. See JCA doc + @Override + protected void engineInitSign(PrivateKey privateKey, SecureRandom random) + throws InvalidKeyException { + if (!(privateKey instanceof RSAPrivateKey)) { + throw new InvalidKeyException("key must be RSAPrivateKey"); + } + this.privKey = (RSAPrivateKey) isValid((RSAKey)privateKey); + this.pubKey = null; + this.random = + (random == null? JCAUtil.getSecureRandom() : random); + resetDigest(); + } + + /** + * Utility method for checking the key PSS parameters against signature + * PSS parameters. + * Returns false if any of the digest/MGF algorithms and trailerField + * values does not match or if the salt length in key parameters is + * larger than the value in signature parameters. + */ + private static boolean isCompatible(AlgorithmParameterSpec keyParams, + PSSParameterSpec sigParams) { + if (keyParams == null) { + // key with null PSS parameters means no restriction + return true; + } + if (!(keyParams instanceof PSSParameterSpec)) { + return false; + } + // nothing to compare yet, defer the check to when sigParams is set + if (sigParams == null) { + return true; + } + PSSParameterSpec pssKeyParams = (PSSParameterSpec) keyParams; + // first check the salt length requirement + if (pssKeyParams.getSaltLength() > sigParams.getSaltLength()) { + return false; + } + + // compare equality of the rest of fields based on DER encoding + PSSParameterSpec keyParams2 = + new PSSParameterSpec(pssKeyParams.getDigestAlgorithm(), + pssKeyParams.getMGFAlgorithm(), + pssKeyParams.getMGFParameters(), + sigParams.getSaltLength(), + pssKeyParams.getTrailerField()); + PSSParameters ap = new PSSParameters(); + // skip the JCA overhead + try { + ap.engineInit(keyParams2); + byte[] encoded = ap.engineGetEncoded(); + ap.engineInit(sigParams); + byte[] encoded2 = ap.engineGetEncoded(); + return Arrays.equals(encoded, encoded2); + } catch (Exception e) { + if (DEBUG) { + e.printStackTrace(); + } + return false; + } + } + + /** + * Validate the specified RSAKey and its associated parameters against + * internal signature parameters. + */ + private RSAKey isValid(RSAKey rsaKey) throws InvalidKeyException { + try { + AlgorithmParameterSpec keyParams = rsaKey.getParams(); + // validate key parameters + if (!isCompatible(rsaKey.getParams(), this.sigParams)) { + throw new InvalidKeyException + ("Key contains incompatible PSS parameter values"); + } + // validate key length + if (this.sigParams != null) { + Integer hLen = + DIGEST_LENGTHS.get(this.sigParams.getDigestAlgorithm()); + if (hLen == null) { + throw new ProviderException("Unsupported digest algo: " + + this.sigParams.getDigestAlgorithm()); + } + checkKeyLength(rsaKey, hLen, this.sigParams.getSaltLength()); + } + return rsaKey; + } catch (SignatureException e) { + throw new InvalidKeyException(e); + } + } + + /** + * Validate the specified Signature PSS parameters. + */ + private PSSParameterSpec validateSigParams(AlgorithmParameterSpec p) + throws InvalidAlgorithmParameterException { + if (p == null) { + throw new InvalidAlgorithmParameterException + ("Parameters cannot be null"); + } + if (!(p instanceof PSSParameterSpec)) { + throw new InvalidAlgorithmParameterException + ("parameters must be type PSSParameterSpec"); + } + // no need to validate again if same as current signature parameters + PSSParameterSpec params = (PSSParameterSpec) p; + if (params == this.sigParams) return params; + + RSAKey key = (this.privKey == null? this.pubKey : this.privKey); + // check against keyParams if set + if (key != null) { + if (!isCompatible(key.getParams(), params)) { + throw new InvalidAlgorithmParameterException + ("Signature parameters does not match key parameters"); + } + } + // now sanity check the parameter values + if (!(params.getMGFAlgorithm().equalsIgnoreCase("MGF1"))) { + throw new InvalidAlgorithmParameterException("Only supports MGF1"); + + } + if (params.getTrailerField() != PSSParameterSpec.TRAILER_FIELD_BC) { + throw new InvalidAlgorithmParameterException + ("Only supports TrailerFieldBC(1)"); + + } + String digestAlgo = params.getDigestAlgorithm(); + // check key length again + if (key != null) { + try { + int hLen = DIGEST_LENGTHS.get(digestAlgo); + checkKeyLength(key, hLen, params.getSaltLength()); + } catch (SignatureException e) { + throw new InvalidAlgorithmParameterException(e); + } + } + return params; + } + + /** + * Ensure the object is initialized with key and parameters and + * reset digest + */ + private void ensureInit() throws SignatureException { + RSAKey key = (this.privKey == null? this.pubKey : this.privKey); + if (key == null) { + throw new SignatureException("Missing key"); + } + if (this.sigParams == null) { + // Parameters are required for signature verification + throw new SignatureException + ("Parameters required for RSASSA-PSS signatures"); + } + } + + /** + * Utility method for checking key length against digest length and + * salt length + */ + private static void checkKeyLength(RSAKey key, int digestLen, + int saltLen) throws SignatureException { + if (key != null) { + int keyLength = getKeyLengthInBits(key) >> 3; + int minLength = Math.addExact(Math.addExact(digestLen, saltLen), 2); + if (keyLength < minLength) { + throw new SignatureException + ("Key is too short, need min " + minLength); + } + } + } + + /** + * Reset the message digest if it is not already reset. + */ + private void resetDigest() { + if (digestReset == false) { + this.md.reset(); + digestReset = true; + } + } + + /** + * Return the message digest value. + */ + private byte[] getDigestValue() { + digestReset = true; + return this.md.digest(); + } + + // update the signature with the plaintext data. See JCA doc + @Override + protected void engineUpdate(byte b) throws SignatureException { + ensureInit(); + this.md.update(b); + digestReset = false; + } + + // update the signature with the plaintext data. See JCA doc + @Override + protected void engineUpdate(byte[] b, int off, int len) + throws SignatureException { + ensureInit(); + this.md.update(b, off, len); + digestReset = false; + } + + // update the signature with the plaintext data. See JCA doc + @Override + protected void engineUpdate(ByteBuffer b) { + try { + ensureInit(); + } catch (SignatureException se) { + // hack for working around API bug + throw new RuntimeException(se.getMessage()); + } + this.md.update(b); + digestReset = false; + } + + // sign the data and return the signature. See JCA doc + @Override + protected byte[] engineSign() throws SignatureException { + ensureInit(); + byte[] mHash = getDigestValue(); + try { + byte[] encoded = encodeSignature(mHash); + byte[] encrypted = RSACore.rsa(encoded, privKey, true); + return encrypted; + } catch (GeneralSecurityException e) { + throw new SignatureException("Could not sign data", e); + } catch (IOException e) { + throw new SignatureException("Could not encode data", e); + } + } + + // verify the data and return the result. See JCA doc + // should be reset to the state after engineInitVerify call. + @Override + protected boolean engineVerify(byte[] sigBytes) throws SignatureException { + ensureInit(); + try { + if (sigBytes.length != RSACore.getByteLength(this.pubKey)) { + throw new SignatureException + ("Signature length not correct: got " + + sigBytes.length + " but was expecting " + + RSACore.getByteLength(this.pubKey)); + } + byte[] mHash = getDigestValue(); + byte[] decrypted = RSACore.rsa(sigBytes, this.pubKey); + return decodeSignature(mHash, decrypted); + } catch (javax.crypto.BadPaddingException e) { + // occurs if the app has used the wrong RSA public key + // or if sigBytes is invalid + // return false rather than propagating the exception for + // compatibility/ease of use + return false; + } catch (IOException e) { + throw new SignatureException("Signature encoding error", e); + } finally { + resetDigest(); + } + } + + // return the modulus length in bits + private static int getKeyLengthInBits(RSAKey k) { + if (k != null) { + return k.getModulus().bitLength(); + } + return -1; + } + + /** + * Encode the digest 'mHash', return the to-be-signed data. + * Also used by the PKCS#11 provider. + */ + private byte[] encodeSignature(byte[] mHash) + throws IOException, DigestException { + AlgorithmParameterSpec mgfParams = this.sigParams.getMGFParameters(); + String mgfDigestAlgo; + if (mgfParams != null) { + mgfDigestAlgo = + ((MGF1ParameterSpec) mgfParams).getDigestAlgorithm(); + } else { + mgfDigestAlgo = this.md.getAlgorithm(); + } + try { + int emBits = getKeyLengthInBits(this.privKey) - 1; + int emLen =(emBits + 7) >> 3; + int hLen = this.md.getDigestLength(); + int dbLen = emLen - hLen - 1; + int sLen = this.sigParams.getSaltLength(); + + // maps DB into the corresponding region of EM and + // stores its bytes directly into EM + byte[] em = new byte[emLen]; + + // step7 and some of step8 + em[dbLen - sLen - 1] = (byte) 1; // set DB's padding2 into EM + em[em.length - 1] = (byte) 0xBC; // set trailer field of EM + + if (!digestReset) { + throw new ProviderException("Digest should be reset"); + } + // step5: generates M' using padding1, mHash, and salt + this.md.update(EIGHT_BYTES_OF_ZEROS); + digestReset = false; // mark digest as it now has data + this.md.update(mHash); + if (sLen != 0) { + // step4: generate random salt + byte[] salt = new byte[sLen]; + this.random.nextBytes(salt); + this.md.update(salt); + + // step8: set DB's salt into EM + System.arraycopy(salt, 0, em, dbLen - sLen, sLen); + } + // step6: generate H using M' + this.md.digest(em, dbLen, hLen); // set H field of EM + digestReset = true; + + // step7 and 8 are already covered by the code which setting up + // EM as above + + // step9 and 10: feed H into MGF and xor with DB in EM + MGF1 mgf1 = new MGF1(mgfDigestAlgo); + mgf1.generateAndXor(em, dbLen, hLen, dbLen, em, 0); + + // step11: set the leftmost (8emLen - emBits) bits of the leftmost + // octet to 0 + int numZeroBits = (emLen << 3) - emBits; + if (numZeroBits != 0) { + byte MASK = (byte) (0xff >>> numZeroBits); + em[0] = (byte) (em[0] & MASK); + } + + // step12: em should now holds maskedDB || hash h || 0xBC + return em; + } catch (NoSuchAlgorithmException e) { + throw new IOException(e.toString()); + } + } + + /** + * Decode the signature data. Verify that the object identifier matches + * and return the message digest. + */ + private boolean decodeSignature(byte[] mHash, byte[] em) + throws IOException { + int hLen = mHash.length; + int sLen = this.sigParams.getSaltLength(); + int emLen = em.length; + int emBits = getKeyLengthInBits(this.pubKey) - 1; + + // step3 + if (emLen < (hLen + sLen + 2)) { + return false; + } + + // step4 + if (em[emLen - 1] != (byte) 0xBC) { + return false; + } + + // step6: check if the leftmost (8emLen - emBits) bits of the leftmost + // octet are 0 + int numZeroBits = (emLen << 3) - emBits; + if (numZeroBits != 0) { + byte MASK = (byte) (0xff << (8 - numZeroBits)); + if ((em[0] & MASK) != 0) { + return false; + } + } + String mgfDigestAlgo; + AlgorithmParameterSpec mgfParams = this.sigParams.getMGFParameters(); + if (mgfParams != null) { + mgfDigestAlgo = + ((MGF1ParameterSpec) mgfParams).getDigestAlgorithm(); + } else { + mgfDigestAlgo = this.md.getAlgorithm(); + } + // step 7 and 8 + int dbLen = emLen - hLen - 1; + try { + MGF1 mgf1 = new MGF1(mgfDigestAlgo); + mgf1.generateAndXor(em, dbLen, hLen, dbLen, em, 0); + } catch (NoSuchAlgorithmException nsae) { + throw new IOException(nsae.toString()); + } + + // step9: set the leftmost (8emLen - emBits) bits of the leftmost + // octet to 0 + if (numZeroBits != 0) { + byte MASK = (byte) (0xff >>> numZeroBits); + em[0] = (byte) (em[0] & MASK); + } + + // step10 + int i = 0; + for (; i < dbLen - sLen - 1; i++) { + if (em[i] != 0) { + return false; + } + } + if (em[i] != 0x01) { + return false; + } + // step12 and 13 + this.md.update(EIGHT_BYTES_OF_ZEROS); + digestReset = false; + this.md.update(mHash); + if (sLen > 0) { + this.md.update(em, (dbLen - sLen), sLen); + } + byte[] digest2 = this.md.digest(); + digestReset = true; + + // step14 + byte[] digestInEM = Arrays.copyOfRange(em, dbLen, emLen - 1); + return MessageDigest.isEqual(digest2, digestInEM); + } + + // set parameter, not supported. See JCA doc + @Deprecated + @Override + protected void engineSetParameter(String param, Object value) + throws InvalidParameterException { + throw new UnsupportedOperationException("setParameter() not supported"); + } + + @Override + protected void engineSetParameter(AlgorithmParameterSpec params) + throws InvalidAlgorithmParameterException { + this.sigParams = validateSigParams(params); + // disallow changing parameters when digest has been used + if (!digestReset) { + throw new ProviderException + ("Cannot set parameters during operations"); + } + String newHashAlg = this.sigParams.getDigestAlgorithm(); + // re-allocate md if not yet assigned or algorithm changed + if ((this.md == null) || + !(this.md.getAlgorithm().equalsIgnoreCase(newHashAlg))) { + try { + this.md = MessageDigest.getInstance(newHashAlg); + } catch (NoSuchAlgorithmException nsae) { + // should not happen as we pick default digest algorithm + throw new InvalidAlgorithmParameterException + ("Unsupported digest algorithm " + + newHashAlg, nsae); + } + } + } + + // get parameter, not supported. See JCA doc + @Deprecated + @Override + protected Object engineGetParameter(String param) + throws InvalidParameterException { + throw new UnsupportedOperationException("getParameter() not supported"); + } + + @Override + protected AlgorithmParameters engineGetParameters() { + AlgorithmParameters ap = null; + if (this.sigParams != null) { + try { + ap = AlgorithmParameters.getInstance("RSASSA-PSS"); + ap.init(this.sigParams); + } catch (GeneralSecurityException gse) { + throw new ProviderException(gse.getMessage()); + } + } + return ap; + } +} diff --git a/src/share/classes/sun/security/rsa/RSAPadding.java b/src/share/classes/sun/security/rsa/RSAPadding.java index 5c9e6580dd45aa92289608172e19ca34e56f8a67..c0e3a560ab26cd14fae08bb875b04cc49a092608 100644 --- a/src/share/classes/sun/security/rsa/RSAPadding.java +++ b/src/share/classes/sun/security/rsa/RSAPadding.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,16 +39,13 @@ import sun.security.jca.JCAUtil; /** * RSA padding and unpadding. * - * The various PKCS#1 versions can be found in the EMC/RSA Labs - * web site, which is currently: + * The various PKCS#1 versions can be found in the IETF RFCs + * tracking the corresponding PKCS#1 standards. * - * http://www.emc.com/emc-plus/rsa-labs/index.htm - * - * or in the IETF RFCs derived from the above PKCS#1 standards. - * - * RFC 2313: v1.5 - * RFC 2437: v2.0 - * RFC 3447: v2.1 + * RFC 2313: PKCS#1 v1.5 + * RFC 2437: PKCS#1 v2.0 + * RFC 3447: PKCS#1 v2.1 + * RFC 8017: PKCS#1 v2.2 * * The format of PKCS#1 v1.5 padding is: * @@ -105,11 +102,11 @@ public final class RSAPadding { // maximum size of the data private final int maxDataSize; - // OAEP: main messagedigest + // OAEP: main message digest private MessageDigest md; - // OAEP: message digest for MGF1 - private MessageDigest mgfMd; + // OAEP: MGF1 + private MGF1 mgf; // OAEP: value of digest of data (user-supplied or zero-length) using md private byte[] lHash; @@ -164,7 +161,7 @@ public final class RSAPadding { break; case PAD_OAEP_MGF1: String mdName = "SHA-1"; - String mgfMdName = "SHA-1"; + String mgfMdName = mdName; byte[] digestInput = null; try { if (spec != null) { @@ -185,10 +182,9 @@ public final class RSAPadding { digestInput = ((PSource.PSpecified) pSrc).getValue(); } md = MessageDigest.getInstance(mdName); - mgfMd = MessageDigest.getInstance(mgfMdName); + mgf = new MGF1(mgfMdName); } catch (NoSuchAlgorithmException e) { - throw new InvalidKeyException - ("Digest " + mdName + " not available", e); + throw new InvalidKeyException("Digest not available", e); } lHash = getInitialHash(md, digestInput); int digestLen = lHash.length; @@ -196,7 +192,7 @@ public final class RSAPadding { if (maxDataSize <= 0) { throw new InvalidKeyException ("Key is too short for encryption using OAEPPadding" + - " with " + mdName + " and MGF1" + mgfMdName); + " with " + mdName + " and " + mgf.getName()); } break; default: @@ -432,10 +428,10 @@ public final class RSAPadding { System.arraycopy(M, 0, EM, mStart, M.length); // produce maskedDB - mgf1(EM, seedStart, seedLen, EM, dbStart, dbLen); + mgf.generateAndXor(EM, seedStart, seedLen, dbLen, EM, dbStart); // produce maskSeed - mgf1(EM, dbStart, dbLen, EM, seedStart, seedLen); + mgf.generateAndXor(EM, dbStart, dbLen, seedLen, EM, seedStart); return EM; } @@ -458,8 +454,8 @@ public final class RSAPadding { int dbStart = hLen + 1; int dbLen = EM.length - dbStart; - mgf1(EM, dbStart, dbLen, EM, seedStart, seedLen); - mgf1(EM, seedStart, seedLen, EM, dbStart, dbLen); + mgf.generateAndXor(EM, dbStart, dbLen, seedLen, EM, seedStart); + mgf.generateAndXor(EM, seedStart, seedLen, dbLen, EM, dbStart); // verify lHash == lHash' for (int i = 0; i < hLen; i++) { @@ -507,37 +503,4 @@ public final class RSAPadding { return m; } } - - /** - * Compute MGF1 using mgfMD as the message digest. - * Note that we combine MGF1 with the XOR operation to reduce data - * copying. - * - * We generate maskLen bytes of MGF1 from the seed and XOR it into - * out[] starting at outOfs; - */ - private void mgf1(byte[] seed, int seedOfs, int seedLen, - byte[] out, int outOfs, int maskLen) throws BadPaddingException { - byte[] C = new byte[4]; // 32 bit counter - byte[] digest = new byte[mgfMd.getDigestLength()]; - while (maskLen > 0) { - mgfMd.update(seed, seedOfs, seedLen); - mgfMd.update(C); - try { - mgfMd.digest(digest, 0, digest.length); - } catch (DigestException e) { - // should never happen - throw new BadPaddingException(e.toString()); - } - for (int i = 0; (i < digest.length) && (maskLen > 0); maskLen--) { - out[outOfs++] ^= digest[i++]; - } - if (maskLen > 0) { - // increment counter - for (int i = C.length - 1; (++C[i] == 0) && (i > 0); i--) { - // empty - } - } - } - } } diff --git a/src/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java b/src/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java index cb5e53579bb744e07305d54b88e91276b1a700ec..6b2199379812a185f45cf0b5f8749df924949f5e 100644 --- a/src/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java +++ b/src/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * 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,16 +29,20 @@ import java.io.IOException; import java.math.BigInteger; import java.security.*; +import java.security.spec.*; import java.security.interfaces.*; import sun.security.util.*; + import sun.security.x509.AlgorithmId; import sun.security.pkcs.PKCS8Key; +import static sun.security.rsa.RSAUtil.KeyType; + /** - * Key implementation for RSA private keys, CRT form. For non-CRT private - * keys, see RSAPrivateKeyImpl. We need separate classes to ensure - * correct behavior in instanceof checks, etc. + * RSA private key implementation for "RSA", "RSASSA-PSS" algorithms in CRT form. + * For non-CRT private keys, see RSAPrivateKeyImpl. We need separate classes + * to ensure correct behavior in instanceof checks, etc. * * Note: RSA keys must be at least 512 bits long * @@ -62,9 +66,10 @@ public final class RSAPrivateCrtKeyImpl private BigInteger qe; // prime exponent q private BigInteger coeff; // CRT coeffcient - // algorithmId used to identify RSA keys - final static AlgorithmId rsaId = - new AlgorithmId(AlgorithmId.RSAEncryption_oid); + // Optional parameters associated with this RSA key + // specified in the encoding of its AlgorithmId. + // Must be null for "RSA" keys. + private AlgorithmParameterSpec keyParams; /** * Generate a new key from its encoding. Returns a CRT key if possible @@ -73,9 +78,16 @@ public final class RSAPrivateCrtKeyImpl public static RSAPrivateKey newKey(byte[] encoded) throws InvalidKeyException { RSAPrivateCrtKeyImpl key = new RSAPrivateCrtKeyImpl(encoded); - if (key.getPublicExponent().signum() == 0) { - // public exponent is missing, return a non-CRT key + // check all CRT-specific components are available, if any one + // missing, return a non-CRT key instead + if ((key.getPublicExponent().signum() == 0) || + (key.getPrimeExponentP().signum() == 0) || + (key.getPrimeExponentQ().signum() == 0) || + (key.getPrimeP().signum() == 0) || + (key.getPrimeQ().signum() == 0) || + (key.getCrtCoefficient().signum() == 0)) { return new RSAPrivateKeyImpl( + key.algid, key.getModulus(), key.getPrivateExponent() ); @@ -84,21 +96,57 @@ public final class RSAPrivateCrtKeyImpl } } + /** + * Generate a new key from the specified type and components. + * Returns a CRT key if possible and a non-CRT key otherwise. + * Used by SunPKCS11 provider. + */ + public static RSAPrivateKey newKey(KeyType type, + AlgorithmParameterSpec params, + BigInteger n, BigInteger e, BigInteger d, + BigInteger p, BigInteger q, BigInteger pe, BigInteger qe, + BigInteger coeff) throws InvalidKeyException { + RSAPrivateKey key; + AlgorithmId rsaId = RSAUtil.createAlgorithmId(type, params); + if ((e.signum() == 0) || (p.signum() == 0) || + (q.signum() == 0) || (pe.signum() == 0) || + (qe.signum() == 0) || (coeff.signum() == 0)) { + // if any component is missing, return a non-CRT key + return new RSAPrivateKeyImpl(rsaId, n, d); + } else { + return new RSAPrivateCrtKeyImpl(rsaId, n, e, d, + p, q, pe, qe, coeff); + } + } + /** * Construct a key from its encoding. Called from newKey above. */ RSAPrivateCrtKeyImpl(byte[] encoded) throws InvalidKeyException { + if (encoded == null || encoded.length == 0) { + throw new InvalidKeyException("Missing key encoding"); + } + decode(encoded); RSAKeyFactory.checkRSAProviderKeyLengths(n.bitLength(), e); + try { + // this will check the validity of params + this.keyParams = RSAUtil.getParamSpec(algid); + } catch (ProviderException e) { + throw new InvalidKeyException(e); + } } /** - * Construct a key from its components. Used by the + * Construct a RSA key from its components. Used by the * RSAKeyFactory and the RSAKeyPairGenerator. */ - RSAPrivateCrtKeyImpl(BigInteger n, BigInteger e, BigInteger d, + RSAPrivateCrtKeyImpl(AlgorithmId rsaId, + BigInteger n, BigInteger e, BigInteger d, BigInteger p, BigInteger q, BigInteger pe, BigInteger qe, BigInteger coeff) throws InvalidKeyException { + RSAKeyFactory.checkRSAProviderKeyLengths(n.bitLength(), e); + this.n = n; this.e = e; this.d = d; @@ -107,7 +155,7 @@ public final class RSAPrivateCrtKeyImpl this.pe = pe; this.qe = qe; this.coeff = coeff; - RSAKeyFactory.checkRSAProviderKeyLengths(n.bitLength(), e); + this.keyParams = RSAUtil.getParamSpec(rsaId); // generate the encoding algid = rsaId; @@ -132,50 +180,73 @@ public final class RSAPrivateCrtKeyImpl } // see JCA doc + @Override public String getAlgorithm() { - return "RSA"; + return algid.getName(); } // see JCA doc + @Override public BigInteger getModulus() { return n; } // see JCA doc + @Override public BigInteger getPublicExponent() { return e; } // see JCA doc + @Override public BigInteger getPrivateExponent() { return d; } // see JCA doc + @Override public BigInteger getPrimeP() { return p; } // see JCA doc + @Override public BigInteger getPrimeQ() { return q; } // see JCA doc + @Override public BigInteger getPrimeExponentP() { return pe; } // see JCA doc + @Override public BigInteger getPrimeExponentQ() { return qe; } // see JCA doc + @Override public BigInteger getCrtCoefficient() { return coeff; } + // see JCA doc + @Override + public AlgorithmParameterSpec getParams() { + return keyParams; + } + + // return a string representation of this key for debugging + @Override + public String toString() { + return "SunRsaSign " + getAlgorithm() + " private CRT key, " + n.bitLength() + + " bits" + "\n params: " + keyParams + "\n modulus: " + n + + "\n private exponent: " + d; + } + /** * Parse the key. Called by PKCS8Key. */ diff --git a/src/share/classes/sun/security/rsa/RSAPrivateKeyImpl.java b/src/share/classes/sun/security/rsa/RSAPrivateKeyImpl.java index 1a7df130463c77a0e9ee4a9718eedb06fd6e7c07..df5abc1bfd0dd9b8079577df4cd1d0462ab8ce8a 100644 --- a/src/share/classes/sun/security/rsa/RSAPrivateKeyImpl.java +++ b/src/share/classes/sun/security/rsa/RSAPrivateKeyImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * 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,15 +29,18 @@ import java.io.IOException; import java.math.BigInteger; import java.security.*; +import java.security.spec.AlgorithmParameterSpec; import java.security.interfaces.*; import sun.security.util.*; +import sun.security.x509.AlgorithmId; import sun.security.pkcs.PKCS8Key; /** - * Key implementation for RSA private keys, non-CRT form (modulus, private - * exponent only). For CRT private keys, see RSAPrivateCrtKeyImpl. We need - * separate classes to ensure correct behavior in instanceof checks, etc. + * RSA private key implementation for "RSA", "RSASSA-PSS" algorithms in non-CRT + * form (modulus, private exponent only). For CRT private keys, see + * RSAPrivateCrtKeyImpl. We need separate classes to ensure correct behavior + * in instanceof checks, etc. * * Note: RSA keys must be at least 512 bits long * @@ -54,16 +57,25 @@ public final class RSAPrivateKeyImpl extends PKCS8Key implements RSAPrivateKey { private final BigInteger n; // modulus private final BigInteger d; // private exponent + // optional parameters associated with this RSA key + // specified in the encoding of its AlgorithmId. + // must be null for "RSA" keys. + private final AlgorithmParameterSpec keyParams; + /** * Construct a key from its components. Used by the * RSAKeyFactory and the RSAKeyPairGenerator. */ - RSAPrivateKeyImpl(BigInteger n, BigInteger d) throws InvalidKeyException { + RSAPrivateKeyImpl(AlgorithmId rsaId, BigInteger n, BigInteger d) + throws InvalidKeyException { + RSAKeyFactory.checkRSAProviderKeyLengths(n.bitLength(), null); + this.n = n; this.d = d; - RSAKeyFactory.checkRSAProviderKeyLengths(n.bitLength(), null); + this.keyParams = RSAUtil.getParamSpec(rsaId); + // generate the encoding - algid = RSAPrivateCrtKeyImpl.rsaId; + algid = rsaId; try { DerOutputStream out = new DerOutputStream(); out.putInteger(0); // version must be 0 @@ -85,17 +97,34 @@ public final class RSAPrivateKeyImpl extends PKCS8Key implements RSAPrivateKey { } // see JCA doc + @Override public String getAlgorithm() { - return "RSA"; + return algid.getName(); } // see JCA doc + @Override public BigInteger getModulus() { return n; } // see JCA doc + @Override public BigInteger getPrivateExponent() { return d; } + + // see JCA doc + @Override + public AlgorithmParameterSpec getParams() { + return keyParams; + } + + // return a string representation of this key for debugging + @Override + public String toString() { + return "Sun " + getAlgorithm() + " private key, " + n.bitLength() + + " bits" + "\n params: " + keyParams + "\n modulus: " + n + + "\n private exponent: " + d; + } } diff --git a/src/share/classes/sun/security/rsa/RSAPublicKeyImpl.java b/src/share/classes/sun/security/rsa/RSAPublicKeyImpl.java index b2739171e014bd3b4c754c59bb2815fa9fcd9e21..ebd035e06a842a2cadb2894f223a011867f13e87 100644 --- a/src/share/classes/sun/security/rsa/RSAPublicKeyImpl.java +++ b/src/share/classes/sun/security/rsa/RSAPublicKeyImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * 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,17 +29,22 @@ import java.io.IOException; import java.math.BigInteger; import java.security.*; +import java.security.spec.*; import java.security.interfaces.*; import sun.security.util.*; import sun.security.x509.X509Key; +import sun.security.x509.AlgorithmId; + +import static sun.security.rsa.RSAUtil.KeyType; /** - * Key implementation for RSA public keys. + * RSA public key implementation for "RSA", "RSASSA-PSS" algorithms. * * Note: RSA keys must be at least 512 bits long * * @see RSAPrivateCrtKeyImpl + * @see RSAPrivateKeyImpl * @see RSAKeyFactory * * @since 1.5 @@ -53,18 +58,46 @@ public final class RSAPublicKeyImpl extends X509Key implements RSAPublicKey { private BigInteger n; // modulus private BigInteger e; // public exponent + // optional parameters associated with this RSA key + // specified in the encoding of its AlgorithmId + // must be null for "RSA" keys. + private AlgorithmParameterSpec keyParams; + + /** + * Generate a new RSAPublicKey from the specified encoding. + * Used by SunPKCS11 provider. + */ + public static RSAPublicKey newKey(byte[] encoded) + throws InvalidKeyException { + return new RSAPublicKeyImpl(encoded); + } + + /** + * Generate a new RSAPublicKey from the specified type and components. + * Used by SunPKCS11 provider. + */ + public static RSAPublicKey newKey(KeyType type, + AlgorithmParameterSpec params, BigInteger n, BigInteger e) + throws InvalidKeyException { + AlgorithmId rsaId = RSAUtil.createAlgorithmId(type, params); + return new RSAPublicKeyImpl(rsaId, n, e); + } + /** - * Construct a key from its components. Used by the - * RSAKeyFactory and the RSAKeyPairGenerator. + * Construct a RSA key from AlgorithmId and its components. Used by + * RSAKeyFactory and RSAKeyPairGenerator. */ - public RSAPublicKeyImpl(BigInteger n, BigInteger e) + RSAPublicKeyImpl(AlgorithmId rsaId, BigInteger n, BigInteger e) throws InvalidKeyException { + RSAKeyFactory.checkRSAProviderKeyLengths(n.bitLength(), e); + checkExponentRange(n, e); + this.n = n; this.e = e; - RSAKeyFactory.checkRSAProviderKeyLengths(n.bitLength(), e); - checkExponentRange(); + this.keyParams = RSAUtil.getParamSpec(rsaId); + // generate the encoding - algid = RSAPrivateCrtKeyImpl.rsaId; + algid = rsaId; try { DerOutputStream out = new DerOutputStream(); out.putInteger(n); @@ -82,39 +115,60 @@ public final class RSAPublicKeyImpl extends X509Key implements RSAPublicKey { /** * Construct a key from its encoding. Used by RSAKeyFactory. */ - public RSAPublicKeyImpl(byte[] encoded) throws InvalidKeyException { - decode(encoded); + RSAPublicKeyImpl(byte[] encoded) throws InvalidKeyException { + if (encoded == null || encoded.length == 0) { + throw new InvalidKeyException("Missing key encoding"); + } + decode(encoded); // this sets n and e value RSAKeyFactory.checkRSAProviderKeyLengths(n.bitLength(), e); - checkExponentRange(); + checkExponentRange(n, e); + + try { + // this will check the validity of params + this.keyParams = RSAUtil.getParamSpec(algid); + } catch (ProviderException e) { + throw new InvalidKeyException(e); + } } - private void checkExponentRange() throws InvalidKeyException { + // pkg private utility method for checking RSA modulus and public exponent + static void checkExponentRange(BigInteger mod, BigInteger exp) + throws InvalidKeyException { // the exponent should be smaller than the modulus - if (e.compareTo(n) >= 0) { + if (exp.compareTo(mod) >= 0) { throw new InvalidKeyException("exponent is larger than modulus"); } // the exponent should be at least 3 - if (e.compareTo(THREE) < 0) { + if (exp.compareTo(THREE) < 0) { throw new InvalidKeyException("exponent is smaller than 3"); } } // see JCA doc + @Override public String getAlgorithm() { - return "RSA"; + return algid.getName(); } // see JCA doc + @Override public BigInteger getModulus() { return n; } // see JCA doc + @Override public BigInteger getPublicExponent() { return e; } + // see JCA doc + @Override + public AlgorithmParameterSpec getParams() { + return keyParams; + } + /** * Parse the key. Called by X509Key. */ @@ -137,9 +191,11 @@ public final class RSAPublicKeyImpl extends X509Key implements RSAPublicKey { } // return a string representation of this key for debugging + @Override public String toString() { - return "Sun RSA public key, " + n.bitLength() + " bits\n modulus: " - + n + "\n public exponent: " + e; + return "Sun " + getAlgorithm() + " public key, " + n.bitLength() + + " bits" + "\n params: " + keyParams + "\n modulus: " + n + + "\n public exponent: " + e; } protected Object writeReplace() throws java.io.ObjectStreamException { diff --git a/src/share/classes/sun/security/rsa/RSASignature.java b/src/share/classes/sun/security/rsa/RSASignature.java index 379d4019322d1f36508debbe391100c07a1a3ea0..0e719e806e9ffd313cb310d67a84ff01f587cd53 100644 --- a/src/share/classes/sun/security/rsa/RSASignature.java +++ b/src/share/classes/sun/security/rsa/RSASignature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * 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,16 +30,18 @@ import java.nio.ByteBuffer; import java.security.*; import java.security.interfaces.*; +import java.security.spec.AlgorithmParameterSpec; +import sun.security.rsa.RSAUtil.KeyType; import sun.security.util.*; import sun.security.x509.AlgorithmId; /** - * PKCS#1 RSA signatures with the various message digest algorithms. + * PKCS#1 v1.5 RSA signatures with the various message digest algorithms. * This file contains an abstract base class with all the logic plus * a nested static class for each of the message digest algorithms * (see end of the file). We support MD2, MD5, SHA-1, SHA-224, SHA-256, - * SHA-384, and SHA-512. + * SHA-384, SHA-512, SHA-512/224, and SHA-512/256. * * @since 1.5 * @author Andreas Sterbenz @@ -85,6 +87,7 @@ public abstract class RSASignature extends SignatureSpi { } // initialize for verification. See JCA doc + @Override protected void engineInitVerify(PublicKey publicKey) throws InvalidKeyException { RSAPublicKey rsaKey = (RSAPublicKey)RSAKeyFactory.toRSAKey(publicKey); @@ -94,12 +97,14 @@ public abstract class RSASignature extends SignatureSpi { } // initialize for signing. See JCA doc + @Override protected void engineInitSign(PrivateKey privateKey) throws InvalidKeyException { engineInitSign(privateKey, null); } // initialize for signing. See JCA doc + @Override protected void engineInitSign(PrivateKey privateKey, SecureRandom random) throws InvalidKeyException { RSAPrivateKey rsaKey = @@ -114,6 +119,11 @@ public abstract class RSASignature extends SignatureSpi { */ private void initCommon(RSAKey rsaKey, SecureRandom random) throws InvalidKeyException { + try { + RSAUtil.checkParamsAgainstType(KeyType.RSA, rsaKey.getParams()); + } catch (ProviderException e) { + throw new InvalidKeyException("Invalid key for RSA signatures", e); + } resetDigest(); int keySize = RSACore.getByteLength(rsaKey); try { @@ -148,12 +158,14 @@ public abstract class RSASignature extends SignatureSpi { } // update the signature with the plaintext data. See JCA doc + @Override protected void engineUpdate(byte b) throws SignatureException { md.update(b); digestReset = false; } // update the signature with the plaintext data. See JCA doc + @Override protected void engineUpdate(byte[] b, int off, int len) throws SignatureException { md.update(b, off, len); @@ -161,13 +173,18 @@ public abstract class RSASignature extends SignatureSpi { } // update the signature with the plaintext data. See JCA doc + @Override protected void engineUpdate(ByteBuffer b) { md.update(b); digestReset = false; } // sign the data and return the signature. See JCA doc + @Override protected byte[] engineSign() throws SignatureException { + if (privateKey == null) { + throw new SignatureException("Missing private key"); + } byte[] digest = getDigestValue(); try { byte[] encoded = encodeSignature(digestOID, digest); @@ -182,7 +199,12 @@ public abstract class RSASignature extends SignatureSpi { } // verify the data and return the result. See JCA doc + @Override protected boolean engineVerify(byte[] sigBytes) throws SignatureException { + if (publicKey == null) { + throw new SignatureException("Missing public key"); + } + if (sigBytes.length != RSACore.getByteLength(publicKey)) { throw new SignatureException("Signature length not correct: got " + sigBytes.length + " but was expecting " + @@ -245,18 +267,35 @@ public abstract class RSASignature extends SignatureSpi { // set parameter, not supported. See JCA doc @Deprecated + @Override protected void engineSetParameter(String param, Object value) throws InvalidParameterException { throw new UnsupportedOperationException("setParameter() not supported"); } + // See JCA doc + @Override + protected void engineSetParameter(AlgorithmParameterSpec params) + throws InvalidAlgorithmParameterException { + if (params != null) { + throw new InvalidAlgorithmParameterException("No parameters accepted"); + } + } + // get parameter, not supported. See JCA doc @Deprecated + @Override protected Object engineGetParameter(String param) throws InvalidParameterException { throw new UnsupportedOperationException("getParameter() not supported"); } + // See JCA doc + @Override + protected AlgorithmParameters engineGetParameters() { + return null; + } + // Nested class for MD2withRSA signatures public static final class MD2withRSA extends RSASignature { public MD2withRSA() { @@ -306,4 +345,17 @@ public abstract class RSASignature extends SignatureSpi { } } + // Nested class for SHA512/224withRSA signatures + public static final class SHA512_224withRSA extends RSASignature { + public SHA512_224withRSA() { + super("SHA-512/224", AlgorithmId.SHA512_224_oid, 11); + } + } + + // Nested class for SHA512/256withRSA signatures + public static final class SHA512_256withRSA extends RSASignature { + public SHA512_256withRSA() { + super("SHA-512/256", AlgorithmId.SHA512_256_oid, 11); + } + } } diff --git a/src/share/classes/sun/security/rsa/RSAUtil.java b/src/share/classes/sun/security/rsa/RSAUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..0889c03a5fbf6d3d73468fefd67a76fe5dbefc5e --- /dev/null +++ b/src/share/classes/sun/security/rsa/RSAUtil.java @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * 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.rsa; + +import java.io.IOException; +import java.security.*; +import java.security.spec.*; +import sun.security.util.ObjectIdentifier; +import sun.security.x509.AlgorithmId; + +/** + * Utility class for SunRsaSign provider. + * Currently used by RSAKeyPairGenerator and RSAKeyFactory. + * + * @since 8 + */ +public class RSAUtil { + + public enum KeyType { + RSA ("RSA"), + PSS ("RSASSA-PSS") + ; + + private final String algo; + + KeyType(String keyAlgo) { + this.algo = keyAlgo; + } + public String keyAlgo() { + return algo; + } + public static KeyType lookup(String name) + throws InvalidKeyException, ProviderException { + if (name == null) { + throw new InvalidKeyException("Null key algorithm"); + } + for (KeyType kt : KeyType.values()) { + if (kt.keyAlgo().equalsIgnoreCase(name)) { + return kt; + } + } + // no match + throw new ProviderException("Unsupported algorithm " + name); + } + } + + public static void checkParamsAgainstType(KeyType type, + AlgorithmParameterSpec paramSpec) throws ProviderException { + switch (type) { + case RSA: + if (paramSpec != null) { + throw new ProviderException("null params expected for " + + type.keyAlgo()); + } + break; + case PSS: + if ((paramSpec != null) && + !(paramSpec instanceof PSSParameterSpec)) { + throw new ProviderException + ("PSSParmeterSpec expected for " + type.keyAlgo()); + } + break; + default: + throw new ProviderException + ("Unsupported RSA algorithm " + type); + } + } + + public static AlgorithmId createAlgorithmId(KeyType type, + AlgorithmParameterSpec paramSpec) throws ProviderException { + + checkParamsAgainstType(type, paramSpec); + + ObjectIdentifier oid = null; + AlgorithmParameters params = null; + try { + switch (type) { + case RSA: + oid = AlgorithmId.RSAEncryption_oid; + break; + case PSS: + if (paramSpec != null) { + params = AlgorithmParameters.getInstance(type.keyAlgo()); + params.init(paramSpec); + } + oid = AlgorithmId.RSASSA_PSS_oid; + break; + default: + throw new ProviderException + ("Unsupported RSA algorithm " + type); + } + AlgorithmId result; + if (params == null) { + result = new AlgorithmId(oid); + } else { + result = new AlgorithmId(oid, params); + } + return result; + } catch (NoSuchAlgorithmException | InvalidParameterSpecException e) { + // should not happen + throw new ProviderException(e); + } + } + + public static AlgorithmParameterSpec getParamSpec(AlgorithmId algid) + throws ProviderException { + if (algid == null) { + throw new ProviderException("AlgorithmId should not be null"); + } + return getParamSpec(algid.getParameters()); + } + + public static AlgorithmParameterSpec getParamSpec(AlgorithmParameters params) + throws ProviderException { + if (params == null) return null; + + try { + String algName = params.getAlgorithm(); + KeyType type = KeyType.lookup(algName); + Class specCls; + switch (type) { + case RSA: + throw new ProviderException("No params accepted for " + + type.keyAlgo()); + case PSS: + specCls = PSSParameterSpec.class; + break; + default: + throw new ProviderException("Unsupported RSA algorithm: " + algName); + } + return params.getParameterSpec(specCls); + } catch (ProviderException pe) { + // pass it up + throw pe; + } catch (Exception e) { + throw new ProviderException(e); + } + } +} diff --git a/src/share/classes/sun/security/rsa/SunRsaSignEntries.java b/src/share/classes/sun/security/rsa/SunRsaSignEntries.java index 836fc5f201c3e194bc6fab2f4c72170f8b15b4a9..6af5fdf850398f6747c47d91c9291be45ae4b823 100644 --- a/src/share/classes/sun/security/rsa/SunRsaSignEntries.java +++ b/src/share/classes/sun/security/rsa/SunRsaSignEntries.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * 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,11 +41,10 @@ public final class SunRsaSignEntries { public static void putEntries(Map map) { // main algorithms - map.put("KeyFactory.RSA", - "sun.security.rsa.RSAKeyFactory"); + "sun.security.rsa.RSAKeyFactory$Legacy"); map.put("KeyPairGenerator.RSA", - "sun.security.rsa.RSAKeyPairGenerator"); + "sun.security.rsa.RSAKeyPairGenerator$Legacy"); map.put("Signature.MD2withRSA", "sun.security.rsa.RSASignature$MD2withRSA"); map.put("Signature.MD5withRSA", @@ -60,9 +59,21 @@ public final class SunRsaSignEntries { "sun.security.rsa.RSASignature$SHA384withRSA"); map.put("Signature.SHA512withRSA", "sun.security.rsa.RSASignature$SHA512withRSA"); + map.put("Signature.SHA512/224withRSA", + "sun.security.rsa.RSASignature$SHA512_224withRSA"); + map.put("Signature.SHA512/256withRSA", + "sun.security.rsa.RSASignature$SHA512_256withRSA"); + + map.put("KeyFactory.RSASSA-PSS", + "sun.security.rsa.RSAKeyFactory$PSS"); + map.put("KeyPairGenerator.RSASSA-PSS", + "sun.security.rsa.RSAKeyPairGenerator$PSS"); + map.put("Signature.RSASSA-PSS", + "sun.security.rsa.RSAPSSSignature"); + map.put("AlgorithmParameters.RSASSA-PSS", + "sun.security.rsa.PSSParameters"); // attributes for supported key classes - String rsaKeyClasses = "java.security.interfaces.RSAPublicKey" + "|java.security.interfaces.RSAPrivateKey"; map.put("Signature.MD2withRSA SupportedKeyClasses", rsaKeyClasses); @@ -72,9 +83,11 @@ public final class SunRsaSignEntries { map.put("Signature.SHA256withRSA SupportedKeyClasses", rsaKeyClasses); map.put("Signature.SHA384withRSA SupportedKeyClasses", rsaKeyClasses); map.put("Signature.SHA512withRSA SupportedKeyClasses", rsaKeyClasses); + map.put("Signature.SHA512/224withRSA SupportedKeyClasses", rsaKeyClasses); + map.put("Signature.SHA512/256withRSA SupportedKeyClasses", rsaKeyClasses); + map.put("Signature.RSASSA-PSS SupportedKeyClasses", rsaKeyClasses); // aliases - map.put("Alg.Alias.KeyFactory.1.2.840.113549.1.1", "RSA"); map.put("Alg.Alias.KeyFactory.OID.1.2.840.113549.1.1", "RSA"); @@ -102,6 +115,21 @@ public final class SunRsaSignEntries { map.put("Alg.Alias.Signature.1.2.840.113549.1.1.13", "SHA512withRSA"); map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.13", "SHA512withRSA"); + map.put("Alg.Alias.Signature.1.2.840.113549.1.1.15", "SHA512/224withRSA"); + map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.15", "SHA512/224withRSA"); + map.put("Alg.Alias.Signature.1.2.840.113549.1.1.16", "SHA512/256withRSA"); + map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.16", "SHA512/256withRSA"); + + map.put("Alg.Alias.KeyFactory.1.2.840.113549.1.1.10", "RSASSA-PSS"); + map.put("Alg.Alias.KeyFactory.OID.1.2.840.113549.1.1.10", "RSASSA-PSS"); + + map.put("Alg.Alias.KeyPairGenerator.1.2.840.113549.1.1.10", "RSASSA-PSS"); + map.put("Alg.Alias.KeyPairGenerator.OID.1.2.840.113549.1.1.10", "RSASSA-PSS"); + + map.put("Alg.Alias.Signature.1.2.840.113549.1.1.10", "RSASSA-PSS"); + map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.10", "RSASSA-PSS"); + map.put("Alg.Alias.AlgorithmParameters.1.2.840.113549.1.1.10", "RSASSA-PSS"); + map.put("Alg.Alias.AlgorithmParameters.OID.1.2.840.113549.1.1.10", "RSASSA-PSS"); } } diff --git a/src/share/classes/sun/security/ssl/ALPNExtension.java b/src/share/classes/sun/security/ssl/ALPNExtension.java new file mode 100644 index 0000000000000000000000000000000000000000..f97f2909a1be7c84527d3e64c240256717b65d05 --- /dev/null +++ b/src/share/classes/sun/security/ssl/ALPNExtension.java @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * 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.ssl; + +import java.io.IOException; +import java.nio.charset.*; +import java.util.*; + +import javax.net.ssl.*; + +/* + * [RFC 7301] + * This TLS extension facilitates the negotiation of application-layer protocols + * within the TLS handshake. Clients MAY include an extension of type + * "application_layer_protocol_negotiation" in the (extended) ClientHello + * message. The "extension_data" field of this extension SHALL contain a + * "ProtocolNameList" value: + * + * enum { + * application_layer_protocol_negotiation(16), (65535) + * } ExtensionType; + * + * opaque ProtocolName<1..2^8-1>; + * + * struct { + * ProtocolName protocol_name_list<2..2^16-1> + * } ProtocolNameList; + */ +final class ALPNExtension extends HelloExtension { + + final static int ALPN_HEADER_LENGTH = 1; + final static int MAX_APPLICATION_PROTOCOL_LENGTH = 255; + final static int MAX_APPLICATION_PROTOCOL_LIST_LENGTH = 65535; + private int listLength = 0; // ProtocolNameList length + private List protocolNames = null; + + // constructor for ServerHello + ALPNExtension(String protocolName) throws SSLException { + this(new String[]{ protocolName }); + } + + // constructor for ClientHello + ALPNExtension(String[] protocolNames) throws SSLException { + super(ExtensionType.EXT_ALPN); + if (protocolNames.length == 0) { // never null, never empty + throw new IllegalArgumentException( + "The list of application protocols cannot be empty"); + } + this.protocolNames = Arrays.asList(protocolNames); + for (String p : protocolNames) { + int length = p.getBytes(StandardCharsets.UTF_8).length; + if (length == 0) { + throw new SSLProtocolException( + "Application protocol name is empty"); + } + if (length <= MAX_APPLICATION_PROTOCOL_LENGTH) { + listLength += length + ALPN_HEADER_LENGTH; + } else { + throw new SSLProtocolException( + "Application protocol name is too long: " + p); + } + if (listLength > MAX_APPLICATION_PROTOCOL_LIST_LENGTH) { + throw new SSLProtocolException( + "Application protocol name list is too long"); + } + } + } + + // constructor for ServerHello for parsing ALPN extension + ALPNExtension(HandshakeInStream s, int len) throws IOException { + super(ExtensionType.EXT_ALPN); + + if (len >= 2) { + listLength = s.getInt16(); // list length + if (listLength < 2 || listLength + 2 != len) { + throw new SSLProtocolException( + "Invalid " + type + " extension: incorrect list length " + + "(length=" + listLength + ")"); + } + } else { + throw new SSLProtocolException( + "Invalid " + type + " extension: insufficient data " + + "(length=" + len + ")"); + } + + int remaining = listLength; + this.protocolNames = new ArrayList<>(); + while (remaining > 0) { + // opaque ProtocolName<1..2^8-1>; // RFC 7301 + byte[] bytes = s.getBytes8(); + if (bytes.length == 0) { + throw new SSLProtocolException("Invalid " + type + + " extension: empty application protocol name"); + } + String p = + new String(bytes, StandardCharsets.UTF_8); // app protocol + protocolNames.add(p); + remaining -= bytes.length + ALPN_HEADER_LENGTH; + } + + if (remaining != 0) { + throw new SSLProtocolException( + "Invalid " + type + " extension: extra data " + + "(length=" + remaining + ")"); + } + } + + List getPeerAPs() { + return protocolNames; + } + + /* + * Return the length in bytes, including extension type and length fields. + */ + @Override + int length() { + return 6 + listLength; + } + + @Override + void send(HandshakeOutStream s) throws IOException { + s.putInt16(type.id); + s.putInt16(listLength + 2); // length of extension_data + s.putInt16(listLength); // length of ProtocolNameList + + for (String p : protocolNames) { + s.putBytes8(p.getBytes(StandardCharsets.UTF_8)); + } + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + if (protocolNames == null || protocolNames.isEmpty()) { + sb.append(""); + } else { + for (String protocolName : protocolNames) { + sb.append("[" + protocolName + "]"); + } + } + + return "Extension " + type + + ", protocol names: " + sb; + } +} diff --git a/src/share/classes/sun/security/ssl/Alerts.java b/src/share/classes/sun/security/ssl/Alerts.java index 672d9b719d77b7d29793c7d65097099aa671390b..bdfe5770f13dee6370ebebd9571e063a81c29bd4 100644 --- a/src/share/classes/sun/security/ssl/Alerts.java +++ b/src/share/classes/sun/security/ssl/Alerts.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -83,6 +83,9 @@ final class Alerts { static final byte alert_bad_certificate_status_response = 113; static final byte alert_bad_certificate_hash_value = 114; + // from RFC 7301 (TLS ALPN Extension) + static final byte alert_no_application_protocol = 120; + static String alertDescription(byte code) { switch (code) { @@ -144,6 +147,8 @@ final class Alerts { return "bad_certificate_status_response"; case alert_bad_certificate_hash_value: return "bad_certificate_hash_value"; + case alert_no_application_protocol: + return "no_application_protocol"; default: return ""; @@ -189,6 +194,7 @@ final class Alerts { case alert_unrecognized_name: case alert_bad_certificate_status_response: case alert_bad_certificate_hash_value: + case alert_no_application_protocol: e = new SSLHandshakeException(reason); break; diff --git a/src/share/classes/sun/security/ssl/CipherSuite.java b/src/share/classes/sun/security/ssl/CipherSuite.java index 687eaee895f651d644db504c1cf638d45abd52d1..5396c2ae08654aebe480f2b779a24dbab2621d6f 100644 --- a/src/share/classes/sun/security/ssl/CipherSuite.java +++ b/src/share/classes/sun/security/ssl/CipherSuite.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -683,7 +683,7 @@ final class CipherSuite implements Comparable { final boolean N = (SunJSSE.isFIPS() == false); /* - * TLS Cipher Suite Registry, as of August 2010. + * TLS Cipher Suite Registry, as of November 2015. * * http://www.iana.org/assignments/tls-parameters/tls-parameters.xml * @@ -692,77 +692,77 @@ final class CipherSuite implements Comparable { * 192-254 Specification Required Refers to value of first byte * 255 Reserved for Private Use Refers to value of first byte * - * Value Description Reference - * 0x00,0x00 TLS_NULL_WITH_NULL_NULL [RFC5246] - * 0x00,0x01 TLS_RSA_WITH_NULL_MD5 [RFC5246] - * 0x00,0x02 TLS_RSA_WITH_NULL_SHA [RFC5246] - * 0x00,0x03 TLS_RSA_EXPORT_WITH_RC4_40_MD5 [RFC4346] - * 0x00,0x04 TLS_RSA_WITH_RC4_128_MD5 [RFC5246] - * 0x00,0x05 TLS_RSA_WITH_RC4_128_SHA [RFC5246] - * 0x00,0x06 TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 [RFC4346] - * 0x00,0x07 TLS_RSA_WITH_IDEA_CBC_SHA [RFC5469] - * 0x00,0x08 TLS_RSA_EXPORT_WITH_DES40_CBC_SHA [RFC4346] - * 0x00,0x09 TLS_RSA_WITH_DES_CBC_SHA [RFC5469] - * 0x00,0x0A TLS_RSA_WITH_3DES_EDE_CBC_SHA [RFC5246] - * 0x00,0x0B TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA [RFC4346] - * 0x00,0x0C TLS_DH_DSS_WITH_DES_CBC_SHA [RFC5469] - * 0x00,0x0D TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA [RFC5246] - * 0x00,0x0E TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA [RFC4346] - * 0x00,0x0F TLS_DH_RSA_WITH_DES_CBC_SHA [RFC5469] - * 0x00,0x10 TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA [RFC5246] - * 0x00,0x11 TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA [RFC4346] - * 0x00,0x12 TLS_DHE_DSS_WITH_DES_CBC_SHA [RFC5469] - * 0x00,0x13 TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA [RFC5246] - * 0x00,0x14 TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA [RFC4346] - * 0x00,0x15 TLS_DHE_RSA_WITH_DES_CBC_SHA [RFC5469] - * 0x00,0x16 TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA [RFC5246] - * 0x00,0x17 TLS_DH_anon_EXPORT_WITH_RC4_40_MD5 [RFC4346] - * 0x00,0x18 TLS_DH_anon_WITH_RC4_128_MD5 [RFC5246] - * 0x00,0x19 TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA [RFC4346] - * 0x00,0x1A TLS_DH_anon_WITH_DES_CBC_SHA [RFC5469] - * 0x00,0x1B TLS_DH_anon_WITH_3DES_EDE_CBC_SHA [RFC5246] - * 0x00,0x1C-1D Reserved to avoid conflicts with SSLv3 [RFC5246] - * 0x00,0x1E TLS_KRB5_WITH_DES_CBC_SHA [RFC2712] - * 0x00,0x1F TLS_KRB5_WITH_3DES_EDE_CBC_SHA [RFC2712] - * 0x00,0x20 TLS_KRB5_WITH_RC4_128_SHA [RFC2712] - * 0x00,0x21 TLS_KRB5_WITH_IDEA_CBC_SHA [RFC2712] - * 0x00,0x22 TLS_KRB5_WITH_DES_CBC_MD5 [RFC2712] - * 0x00,0x23 TLS_KRB5_WITH_3DES_EDE_CBC_MD5 [RFC2712] - * 0x00,0x24 TLS_KRB5_WITH_RC4_128_MD5 [RFC2712] - * 0x00,0x25 TLS_KRB5_WITH_IDEA_CBC_MD5 [RFC2712] - * 0x00,0x26 TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA [RFC2712] - * 0x00,0x27 TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA [RFC2712] - * 0x00,0x28 TLS_KRB5_EXPORT_WITH_RC4_40_SHA [RFC2712] - * 0x00,0x29 TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5 [RFC2712] - * 0x00,0x2A TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5 [RFC2712] - * 0x00,0x2B TLS_KRB5_EXPORT_WITH_RC4_40_MD5 [RFC2712] - * 0x00,0x2C TLS_PSK_WITH_NULL_SHA [RFC4785] - * 0x00,0x2D TLS_DHE_PSK_WITH_NULL_SHA [RFC4785] - * 0x00,0x2E TLS_RSA_PSK_WITH_NULL_SHA [RFC4785] - * 0x00,0x2F TLS_RSA_WITH_AES_128_CBC_SHA [RFC5246] - * 0x00,0x30 TLS_DH_DSS_WITH_AES_128_CBC_SHA [RFC5246] - * 0x00,0x31 TLS_DH_RSA_WITH_AES_128_CBC_SHA [RFC5246] - * 0x00,0x32 TLS_DHE_DSS_WITH_AES_128_CBC_SHA [RFC5246] - * 0x00,0x33 TLS_DHE_RSA_WITH_AES_128_CBC_SHA [RFC5246] - * 0x00,0x34 TLS_DH_anon_WITH_AES_128_CBC_SHA [RFC5246] - * 0x00,0x35 TLS_RSA_WITH_AES_256_CBC_SHA [RFC5246] - * 0x00,0x36 TLS_DH_DSS_WITH_AES_256_CBC_SHA [RFC5246] - * 0x00,0x37 TLS_DH_RSA_WITH_AES_256_CBC_SHA [RFC5246] - * 0x00,0x38 TLS_DHE_DSS_WITH_AES_256_CBC_SHA [RFC5246] - * 0x00,0x39 TLS_DHE_RSA_WITH_AES_256_CBC_SHA [RFC5246] - * 0x00,0x3A TLS_DH_anon_WITH_AES_256_CBC_SHA [RFC5246] - * 0x00,0x3B TLS_RSA_WITH_NULL_SHA256 [RFC5246] - * 0x00,0x3C TLS_RSA_WITH_AES_128_CBC_SHA256 [RFC5246] - * 0x00,0x3D TLS_RSA_WITH_AES_256_CBC_SHA256 [RFC5246] - * 0x00,0x3E TLS_DH_DSS_WITH_AES_128_CBC_SHA256 [RFC5246] - * 0x00,0x3F TLS_DH_RSA_WITH_AES_128_CBC_SHA256 [RFC5246] - * 0x00,0x40 TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 [RFC5246] - * 0x00,0x41 TLS_RSA_WITH_CAMELLIA_128_CBC_SHA [RFC5932] - * 0x00,0x42 TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA [RFC5932] - * 0x00,0x43 TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA [RFC5932] - * 0x00,0x44 TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA [RFC5932] - * 0x00,0x45 TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA [RFC5932] - * 0x00,0x46 TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA [RFC5932] + * Value Description Reference + * 0x00,0x00 TLS_NULL_WITH_NULL_NULL [RFC5246] + * 0x00,0x01 TLS_RSA_WITH_NULL_MD5 [RFC5246] + * 0x00,0x02 TLS_RSA_WITH_NULL_SHA [RFC5246] + * 0x00,0x03 TLS_RSA_EXPORT_WITH_RC4_40_MD5 [RFC4346] + * 0x00,0x04 TLS_RSA_WITH_RC4_128_MD5 [RFC5246] + * 0x00,0x05 TLS_RSA_WITH_RC4_128_SHA [RFC5246] + * 0x00,0x06 TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 [RFC4346] + * 0x00,0x07 TLS_RSA_WITH_IDEA_CBC_SHA [RFC5469] + * 0x00,0x08 TLS_RSA_EXPORT_WITH_DES40_CBC_SHA [RFC4346] + * 0x00,0x09 TLS_RSA_WITH_DES_CBC_SHA [RFC5469] + * 0x00,0x0A TLS_RSA_WITH_3DES_EDE_CBC_SHA [RFC5246] + * 0x00,0x0B TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA [RFC4346] + * 0x00,0x0C TLS_DH_DSS_WITH_DES_CBC_SHA [RFC5469] + * 0x00,0x0D TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA [RFC5246] + * 0x00,0x0E TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA [RFC4346] + * 0x00,0x0F TLS_DH_RSA_WITH_DES_CBC_SHA [RFC5469] + * 0x00,0x10 TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA [RFC5246] + * 0x00,0x11 TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA [RFC4346] + * 0x00,0x12 TLS_DHE_DSS_WITH_DES_CBC_SHA [RFC5469] + * 0x00,0x13 TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA [RFC5246] + * 0x00,0x14 TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA [RFC4346] + * 0x00,0x15 TLS_DHE_RSA_WITH_DES_CBC_SHA [RFC5469] + * 0x00,0x16 TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA [RFC5246] + * 0x00,0x17 TLS_DH_anon_EXPORT_WITH_RC4_40_MD5 [RFC4346] + * 0x00,0x18 TLS_DH_anon_WITH_RC4_128_MD5 [RFC5246] + * 0x00,0x19 TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA [RFC4346] + * 0x00,0x1A TLS_DH_anon_WITH_DES_CBC_SHA [RFC5469] + * 0x00,0x1B TLS_DH_anon_WITH_3DES_EDE_CBC_SHA [RFC5246] + * 0x00,0x1C-1D Reserved to avoid conflicts with SSLv3 [RFC5246] + * 0x00,0x1E TLS_KRB5_WITH_DES_CBC_SHA [RFC2712] + * 0x00,0x1F TLS_KRB5_WITH_3DES_EDE_CBC_SHA [RFC2712] + * 0x00,0x20 TLS_KRB5_WITH_RC4_128_SHA [RFC2712] + * 0x00,0x21 TLS_KRB5_WITH_IDEA_CBC_SHA [RFC2712] + * 0x00,0x22 TLS_KRB5_WITH_DES_CBC_MD5 [RFC2712] + * 0x00,0x23 TLS_KRB5_WITH_3DES_EDE_CBC_MD5 [RFC2712] + * 0x00,0x24 TLS_KRB5_WITH_RC4_128_MD5 [RFC2712] + * 0x00,0x25 TLS_KRB5_WITH_IDEA_CBC_MD5 [RFC2712] + * 0x00,0x26 TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA [RFC2712] + * 0x00,0x27 TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA [RFC2712] + * 0x00,0x28 TLS_KRB5_EXPORT_WITH_RC4_40_SHA [RFC2712] + * 0x00,0x29 TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5 [RFC2712] + * 0x00,0x2A TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5 [RFC2712] + * 0x00,0x2B TLS_KRB5_EXPORT_WITH_RC4_40_MD5 [RFC2712] + * 0x00,0x2C TLS_PSK_WITH_NULL_SHA [RFC4785] + * 0x00,0x2D TLS_DHE_PSK_WITH_NULL_SHA [RFC4785] + * 0x00,0x2E TLS_RSA_PSK_WITH_NULL_SHA [RFC4785] + * 0x00,0x2F TLS_RSA_WITH_AES_128_CBC_SHA [RFC5246] + * 0x00,0x30 TLS_DH_DSS_WITH_AES_128_CBC_SHA [RFC5246] + * 0x00,0x31 TLS_DH_RSA_WITH_AES_128_CBC_SHA [RFC5246] + * 0x00,0x32 TLS_DHE_DSS_WITH_AES_128_CBC_SHA [RFC5246] + * 0x00,0x33 TLS_DHE_RSA_WITH_AES_128_CBC_SHA [RFC5246] + * 0x00,0x34 TLS_DH_anon_WITH_AES_128_CBC_SHA [RFC5246] + * 0x00,0x35 TLS_RSA_WITH_AES_256_CBC_SHA [RFC5246] + * 0x00,0x36 TLS_DH_DSS_WITH_AES_256_CBC_SHA [RFC5246] + * 0x00,0x37 TLS_DH_RSA_WITH_AES_256_CBC_SHA [RFC5246] + * 0x00,0x38 TLS_DHE_DSS_WITH_AES_256_CBC_SHA [RFC5246] + * 0x00,0x39 TLS_DHE_RSA_WITH_AES_256_CBC_SHA [RFC5246] + * 0x00,0x3A TLS_DH_anon_WITH_AES_256_CBC_SHA [RFC5246] + * 0x00,0x3B TLS_RSA_WITH_NULL_SHA256 [RFC5246] + * 0x00,0x3C TLS_RSA_WITH_AES_128_CBC_SHA256 [RFC5246] + * 0x00,0x3D TLS_RSA_WITH_AES_256_CBC_SHA256 [RFC5246] + * 0x00,0x3E TLS_DH_DSS_WITH_AES_128_CBC_SHA256 [RFC5246] + * 0x00,0x3F TLS_DH_RSA_WITH_AES_128_CBC_SHA256 [RFC5246] + * 0x00,0x40 TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 [RFC5246] + * 0x00,0x41 TLS_RSA_WITH_CAMELLIA_128_CBC_SHA [RFC5932] + * 0x00,0x42 TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA [RFC5932] + * 0x00,0x43 TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA [RFC5932] + * 0x00,0x44 TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA [RFC5932] + * 0x00,0x45 TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA [RFC5932] + * 0x00,0x46 TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA [RFC5932] * 0x00,0x47-4F Reserved to avoid conflicts with * deployed implementations [Pasi_Eronen] * 0x00,0x50-58 Reserved to avoid conflicts [Pasi Eronen] @@ -771,143 +771,261 @@ final class CipherSuite implements Comparable { * 0x00,0x5D-5F Unassigned * 0x00,0x60-66 Reserved to avoid conflicts with widely * deployed implementations [Pasi_Eronen] - * 0x00,0x67 TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 [RFC5246] - * 0x00,0x68 TLS_DH_DSS_WITH_AES_256_CBC_SHA256 [RFC5246] - * 0x00,0x69 TLS_DH_RSA_WITH_AES_256_CBC_SHA256 [RFC5246] - * 0x00,0x6A TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 [RFC5246] - * 0x00,0x6B TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 [RFC5246] - * 0x00,0x6C TLS_DH_anon_WITH_AES_128_CBC_SHA256 [RFC5246] - * 0x00,0x6D TLS_DH_anon_WITH_AES_256_CBC_SHA256 [RFC5246] + * 0x00,0x67 TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 [RFC5246] + * 0x00,0x68 TLS_DH_DSS_WITH_AES_256_CBC_SHA256 [RFC5246] + * 0x00,0x69 TLS_DH_RSA_WITH_AES_256_CBC_SHA256 [RFC5246] + * 0x00,0x6A TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 [RFC5246] + * 0x00,0x6B TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 [RFC5246] + * 0x00,0x6C TLS_DH_anon_WITH_AES_128_CBC_SHA256 [RFC5246] + * 0x00,0x6D TLS_DH_anon_WITH_AES_256_CBC_SHA256 [RFC5246] * 0x00,0x6E-83 Unassigned - * 0x00,0x84 TLS_RSA_WITH_CAMELLIA_256_CBC_SHA [RFC5932] - * 0x00,0x85 TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA [RFC5932] - * 0x00,0x86 TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA [RFC5932] - * 0x00,0x87 TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA [RFC5932] - * 0x00,0x88 TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA [RFC5932] - * 0x00,0x89 TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA [RFC5932] - * 0x00,0x8A TLS_PSK_WITH_RC4_128_SHA [RFC4279] - * 0x00,0x8B TLS_PSK_WITH_3DES_EDE_CBC_SHA [RFC4279] - * 0x00,0x8C TLS_PSK_WITH_AES_128_CBC_SHA [RFC4279] - * 0x00,0x8D TLS_PSK_WITH_AES_256_CBC_SHA [RFC4279] - * 0x00,0x8E TLS_DHE_PSK_WITH_RC4_128_SHA [RFC4279] - * 0x00,0x8F TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA [RFC4279] - * 0x00,0x90 TLS_DHE_PSK_WITH_AES_128_CBC_SHA [RFC4279] - * 0x00,0x91 TLS_DHE_PSK_WITH_AES_256_CBC_SHA [RFC4279] - * 0x00,0x92 TLS_RSA_PSK_WITH_RC4_128_SHA [RFC4279] - * 0x00,0x93 TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA [RFC4279] - * 0x00,0x94 TLS_RSA_PSK_WITH_AES_128_CBC_SHA [RFC4279] - * 0x00,0x95 TLS_RSA_PSK_WITH_AES_256_CBC_SHA [RFC4279] - * 0x00,0x96 TLS_RSA_WITH_SEED_CBC_SHA [RFC4162] - * 0x00,0x97 TLS_DH_DSS_WITH_SEED_CBC_SHA [RFC4162] - * 0x00,0x98 TLS_DH_RSA_WITH_SEED_CBC_SHA [RFC4162] - * 0x00,0x99 TLS_DHE_DSS_WITH_SEED_CBC_SHA [RFC4162] - * 0x00,0x9A TLS_DHE_RSA_WITH_SEED_CBC_SHA [RFC4162] - * 0x00,0x9B TLS_DH_anon_WITH_SEED_CBC_SHA [RFC4162] - * 0x00,0x9C TLS_RSA_WITH_AES_128_GCM_SHA256 [RFC5288] - * 0x00,0x9D TLS_RSA_WITH_AES_256_GCM_SHA384 [RFC5288] - * 0x00,0x9E TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 [RFC5288] - * 0x00,0x9F TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 [RFC5288] - * 0x00,0xA0 TLS_DH_RSA_WITH_AES_128_GCM_SHA256 [RFC5288] - * 0x00,0xA1 TLS_DH_RSA_WITH_AES_256_GCM_SHA384 [RFC5288] - * 0x00,0xA2 TLS_DHE_DSS_WITH_AES_128_GCM_SHA256 [RFC5288] - * 0x00,0xA3 TLS_DHE_DSS_WITH_AES_256_GCM_SHA384 [RFC5288] - * 0x00,0xA4 TLS_DH_DSS_WITH_AES_128_GCM_SHA256 [RFC5288] - * 0x00,0xA5 TLS_DH_DSS_WITH_AES_256_GCM_SHA384 [RFC5288] - * 0x00,0xA6 TLS_DH_anon_WITH_AES_128_GCM_SHA256 [RFC5288] - * 0x00,0xA7 TLS_DH_anon_WITH_AES_256_GCM_SHA384 [RFC5288] - * 0x00,0xA8 TLS_PSK_WITH_AES_128_GCM_SHA256 [RFC5487] - * 0x00,0xA9 TLS_PSK_WITH_AES_256_GCM_SHA384 [RFC5487] - * 0x00,0xAA TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 [RFC5487] - * 0x00,0xAB TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 [RFC5487] - * 0x00,0xAC TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 [RFC5487] - * 0x00,0xAD TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 [RFC5487] - * 0x00,0xAE TLS_PSK_WITH_AES_128_CBC_SHA256 [RFC5487] - * 0x00,0xAF TLS_PSK_WITH_AES_256_CBC_SHA384 [RFC5487] - * 0x00,0xB0 TLS_PSK_WITH_NULL_SHA256 [RFC5487] - * 0x00,0xB1 TLS_PSK_WITH_NULL_SHA384 [RFC5487] - * 0x00,0xB2 TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 [RFC5487] - * 0x00,0xB3 TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 [RFC5487] - * 0x00,0xB4 TLS_DHE_PSK_WITH_NULL_SHA256 [RFC5487] - * 0x00,0xB5 TLS_DHE_PSK_WITH_NULL_SHA384 [RFC5487] - * 0x00,0xB6 TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 [RFC5487] - * 0x00,0xB7 TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 [RFC5487] - * 0x00,0xB8 TLS_RSA_PSK_WITH_NULL_SHA256 [RFC5487] - * 0x00,0xB9 TLS_RSA_PSK_WITH_NULL_SHA384 [RFC5487] - * 0x00,0xBA TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 [RFC5932] - * 0x00,0xBB TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256 [RFC5932] - * 0x00,0xBC TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256 [RFC5932] - * 0x00,0xBD TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256 [RFC5932] - * 0x00,0xBE TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 [RFC5932] - * 0x00,0xBF TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256 [RFC5932] - * 0x00,0xC0 TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 [RFC5932] - * 0x00,0xC1 TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256 [RFC5932] - * 0x00,0xC2 TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256 [RFC5932] - * 0x00,0xC3 TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256 [RFC5932] - * 0x00,0xC4 TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 [RFC5932] - * 0x00,0xC5 TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256 [RFC5932] + * 0x00,0x84 TLS_RSA_WITH_CAMELLIA_256_CBC_SHA [RFC5932] + * 0x00,0x85 TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA [RFC5932] + * 0x00,0x86 TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA [RFC5932] + * 0x00,0x87 TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA [RFC5932] + * 0x00,0x88 TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA [RFC5932] + * 0x00,0x89 TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA [RFC5932] + * 0x00,0x8A TLS_PSK_WITH_RC4_128_SHA [RFC4279] + * 0x00,0x8B TLS_PSK_WITH_3DES_EDE_CBC_SHA [RFC4279] + * 0x00,0x8C TLS_PSK_WITH_AES_128_CBC_SHA [RFC4279] + * 0x00,0x8D TLS_PSK_WITH_AES_256_CBC_SHA [RFC4279] + * 0x00,0x8E TLS_DHE_PSK_WITH_RC4_128_SHA [RFC4279] + * 0x00,0x8F TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA [RFC4279] + * 0x00,0x90 TLS_DHE_PSK_WITH_AES_128_CBC_SHA [RFC4279] + * 0x00,0x91 TLS_DHE_PSK_WITH_AES_256_CBC_SHA [RFC4279] + * 0x00,0x92 TLS_RSA_PSK_WITH_RC4_128_SHA [RFC4279] + * 0x00,0x93 TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA [RFC4279] + * 0x00,0x94 TLS_RSA_PSK_WITH_AES_128_CBC_SHA [RFC4279] + * 0x00,0x95 TLS_RSA_PSK_WITH_AES_256_CBC_SHA [RFC4279] + * 0x00,0x96 TLS_RSA_WITH_SEED_CBC_SHA [RFC4162] + * 0x00,0x97 TLS_DH_DSS_WITH_SEED_CBC_SHA [RFC4162] + * 0x00,0x98 TLS_DH_RSA_WITH_SEED_CBC_SHA [RFC4162] + * 0x00,0x99 TLS_DHE_DSS_WITH_SEED_CBC_SHA [RFC4162] + * 0x00,0x9A TLS_DHE_RSA_WITH_SEED_CBC_SHA [RFC4162] + * 0x00,0x9B TLS_DH_anon_WITH_SEED_CBC_SHA [RFC4162] + * 0x00,0x9C TLS_RSA_WITH_AES_128_GCM_SHA256 [RFC5288] + * 0x00,0x9D TLS_RSA_WITH_AES_256_GCM_SHA384 [RFC5288] + * 0x00,0x9E TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 [RFC5288] + * 0x00,0x9F TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 [RFC5288] + * 0x00,0xA0 TLS_DH_RSA_WITH_AES_128_GCM_SHA256 [RFC5288] + * 0x00,0xA1 TLS_DH_RSA_WITH_AES_256_GCM_SHA384 [RFC5288] + * 0x00,0xA2 TLS_DHE_DSS_WITH_AES_128_GCM_SHA256 [RFC5288] + * 0x00,0xA3 TLS_DHE_DSS_WITH_AES_256_GCM_SHA384 [RFC5288] + * 0x00,0xA4 TLS_DH_DSS_WITH_AES_128_GCM_SHA256 [RFC5288] + * 0x00,0xA5 TLS_DH_DSS_WITH_AES_256_GCM_SHA384 [RFC5288] + * 0x00,0xA6 TLS_DH_anon_WITH_AES_128_GCM_SHA256 [RFC5288] + * 0x00,0xA7 TLS_DH_anon_WITH_AES_256_GCM_SHA384 [RFC5288] + * 0x00,0xA8 TLS_PSK_WITH_AES_128_GCM_SHA256 [RFC5487] + * 0x00,0xA9 TLS_PSK_WITH_AES_256_GCM_SHA384 [RFC5487] + * 0x00,0xAA TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 [RFC5487] + * 0x00,0xAB TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 [RFC5487] + * 0x00,0xAC TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 [RFC5487] + * 0x00,0xAD TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 [RFC5487] + * 0x00,0xAE TLS_PSK_WITH_AES_128_CBC_SHA256 [RFC5487] + * 0x00,0xAF TLS_PSK_WITH_AES_256_CBC_SHA384 [RFC5487] + * 0x00,0xB0 TLS_PSK_WITH_NULL_SHA256 [RFC5487] + * 0x00,0xB1 TLS_PSK_WITH_NULL_SHA384 [RFC5487] + * 0x00,0xB2 TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 [RFC5487] + * 0x00,0xB3 TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 [RFC5487] + * 0x00,0xB4 TLS_DHE_PSK_WITH_NULL_SHA256 [RFC5487] + * 0x00,0xB5 TLS_DHE_PSK_WITH_NULL_SHA384 [RFC5487] + * 0x00,0xB6 TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 [RFC5487] + * 0x00,0xB7 TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 [RFC5487] + * 0x00,0xB8 TLS_RSA_PSK_WITH_NULL_SHA256 [RFC5487] + * 0x00,0xB9 TLS_RSA_PSK_WITH_NULL_SHA384 [RFC5487] + * 0x00,0xBA TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 [RFC5932] + * 0x00,0xBB TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256 [RFC5932] + * 0x00,0xBC TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256 [RFC5932] + * 0x00,0xBD TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256 [RFC5932] + * 0x00,0xBE TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 [RFC5932] + * 0x00,0xBF TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256 [RFC5932] + * 0x00,0xC0 TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 [RFC5932] + * 0x00,0xC1 TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256 [RFC5932] + * 0x00,0xC2 TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256 [RFC5932] + * 0x00,0xC3 TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256 [RFC5932] + * 0x00,0xC4 TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 [RFC5932] + * 0x00,0xC5 TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256 [RFC5932] * 0x00,0xC6-FE Unassigned - * 0x00,0xFF TLS_EMPTY_RENEGOTIATION_INFO_SCSV [RFC5746] - * 0x01-BF,* Unassigned - * 0xC0,0x01 TLS_ECDH_ECDSA_WITH_NULL_SHA [RFC4492] - * 0xC0,0x02 TLS_ECDH_ECDSA_WITH_RC4_128_SHA [RFC4492] - * 0xC0,0x03 TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA [RFC4492] - * 0xC0,0x04 TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA [RFC4492] - * 0xC0,0x05 TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA [RFC4492] - * 0xC0,0x06 TLS_ECDHE_ECDSA_WITH_NULL_SHA [RFC4492] - * 0xC0,0x07 TLS_ECDHE_ECDSA_WITH_RC4_128_SHA [RFC4492] - * 0xC0,0x08 TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA [RFC4492] - * 0xC0,0x09 TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA [RFC4492] - * 0xC0,0x0A TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA [RFC4492] - * 0xC0,0x0B TLS_ECDH_RSA_WITH_NULL_SHA [RFC4492] - * 0xC0,0x0C TLS_ECDH_RSA_WITH_RC4_128_SHA [RFC4492] - * 0xC0,0x0D TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA [RFC4492] - * 0xC0,0x0E TLS_ECDH_RSA_WITH_AES_128_CBC_SHA [RFC4492] - * 0xC0,0x0F TLS_ECDH_RSA_WITH_AES_256_CBC_SHA [RFC4492] - * 0xC0,0x10 TLS_ECDHE_RSA_WITH_NULL_SHA [RFC4492] - * 0xC0,0x11 TLS_ECDHE_RSA_WITH_RC4_128_SHA [RFC4492] - * 0xC0,0x12 TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA [RFC4492] - * 0xC0,0x13 TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA [RFC4492] - * 0xC0,0x14 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA [RFC4492] - * 0xC0,0x15 TLS_ECDH_anon_WITH_NULL_SHA [RFC4492] - * 0xC0,0x16 TLS_ECDH_anon_WITH_RC4_128_SHA [RFC4492] - * 0xC0,0x17 TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA [RFC4492] - * 0xC0,0x18 TLS_ECDH_anon_WITH_AES_128_CBC_SHA [RFC4492] - * 0xC0,0x19 TLS_ECDH_anon_WITH_AES_256_CBC_SHA [RFC4492] - * 0xC0,0x1A TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA [RFC5054] - * 0xC0,0x1B TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA [RFC5054] - * 0xC0,0x1C TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA [RFC5054] - * 0xC0,0x1D TLS_SRP_SHA_WITH_AES_128_CBC_SHA [RFC5054] - * 0xC0,0x1E TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA [RFC5054] - * 0xC0,0x1F TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA [RFC5054] - * 0xC0,0x20 TLS_SRP_SHA_WITH_AES_256_CBC_SHA [RFC5054] - * 0xC0,0x21 TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA [RFC5054] - * 0xC0,0x22 TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA [RFC5054] - * 0xC0,0x23 TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 [RFC5289] - * 0xC0,0x24 TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 [RFC5289] - * 0xC0,0x25 TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 [RFC5289] - * 0xC0,0x26 TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 [RFC5289] - * 0xC0,0x27 TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 [RFC5289] - * 0xC0,0x28 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 [RFC5289] - * 0xC0,0x29 TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 [RFC5289] - * 0xC0,0x2A TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 [RFC5289] - * 0xC0,0x2B TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 [RFC5289] - * 0xC0,0x2C TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 [RFC5289] - * 0xC0,0x2D TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 [RFC5289] - * 0xC0,0x2E TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 [RFC5289] - * 0xC0,0x2F TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 [RFC5289] - * 0xC0,0x30 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 [RFC5289] - * 0xC0,0x31 TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 [RFC5289] - * 0xC0,0x32 TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 [RFC5289] - * 0xC0,0x33 TLS_ECDHE_PSK_WITH_RC4_128_SHA [RFC5489] - * 0xC0,0x34 TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA [RFC5489] - * 0xC0,0x35 TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA [RFC5489] - * 0xC0,0x36 TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA [RFC5489] - * 0xC0,0x37 TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 [RFC5489] - * 0xC0,0x38 TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 [RFC5489] - * 0xC0,0x39 TLS_ECDHE_PSK_WITH_NULL_SHA [RFC5489] - * 0xC0,0x3A TLS_ECDHE_PSK_WITH_NULL_SHA256 [RFC5489] - * 0xC0,0x3B TLS_ECDHE_PSK_WITH_NULL_SHA384 [RFC5489] - * 0xC0,0x3C-FF Unassigned + * 0x00,0xFF TLS_EMPTY_RENEGOTIATION_INFO_SCSV [RFC5746] + * 0x01-55,* Unassigned + * 0x56,0x00 TLS_FALLBACK_SCSV [RFC7507] + * 0x56,0x01-0xC0,0x00 Unassigned + * 0xC0,0x01 TLS_ECDH_ECDSA_WITH_NULL_SHA [RFC4492] + * 0xC0,0x02 TLS_ECDH_ECDSA_WITH_RC4_128_SHA [RFC4492] + * 0xC0,0x03 TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA [RFC4492] + * 0xC0,0x04 TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA [RFC4492] + * 0xC0,0x05 TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA [RFC4492] + * 0xC0,0x06 TLS_ECDHE_ECDSA_WITH_NULL_SHA [RFC4492] + * 0xC0,0x07 TLS_ECDHE_ECDSA_WITH_RC4_128_SHA [RFC4492] + * 0xC0,0x08 TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA [RFC4492] + * 0xC0,0x09 TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA [RFC4492] + * 0xC0,0x0A TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA [RFC4492] + * 0xC0,0x0B TLS_ECDH_RSA_WITH_NULL_SHA [RFC4492] + * 0xC0,0x0C TLS_ECDH_RSA_WITH_RC4_128_SHA [RFC4492] + * 0xC0,0x0D TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA [RFC4492] + * 0xC0,0x0E TLS_ECDH_RSA_WITH_AES_128_CBC_SHA [RFC4492] + * 0xC0,0x0F TLS_ECDH_RSA_WITH_AES_256_CBC_SHA [RFC4492] + * 0xC0,0x10 TLS_ECDHE_RSA_WITH_NULL_SHA [RFC4492] + * 0xC0,0x11 TLS_ECDHE_RSA_WITH_RC4_128_SHA [RFC4492] + * 0xC0,0x12 TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA [RFC4492] + * 0xC0,0x13 TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA [RFC4492] + * 0xC0,0x14 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA [RFC4492] + * 0xC0,0x15 TLS_ECDH_anon_WITH_NULL_SHA [RFC4492] + * 0xC0,0x16 TLS_ECDH_anon_WITH_RC4_128_SHA [RFC4492] + * 0xC0,0x17 TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA [RFC4492] + * 0xC0,0x18 TLS_ECDH_anon_WITH_AES_128_CBC_SHA [RFC4492] + * 0xC0,0x19 TLS_ECDH_anon_WITH_AES_256_CBC_SHA [RFC4492] + * 0xC0,0x1A TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA [RFC5054] + * 0xC0,0x1B TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA [RFC5054] + * 0xC0,0x1C TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA [RFC5054] + * 0xC0,0x1D TLS_SRP_SHA_WITH_AES_128_CBC_SHA [RFC5054] + * 0xC0,0x1E TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA [RFC5054] + * 0xC0,0x1F TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA [RFC5054] + * 0xC0,0x20 TLS_SRP_SHA_WITH_AES_256_CBC_SHA [RFC5054] + * 0xC0,0x21 TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA [RFC5054] + * 0xC0,0x22 TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA [RFC5054] + * 0xC0,0x23 TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 [RFC5289] + * 0xC0,0x24 TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 [RFC5289] + * 0xC0,0x25 TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 [RFC5289] + * 0xC0,0x26 TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 [RFC5289] + * 0xC0,0x27 TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 [RFC5289] + * 0xC0,0x28 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 [RFC5289] + * 0xC0,0x29 TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 [RFC5289] + * 0xC0,0x2A TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 [RFC5289] + * 0xC0,0x2B TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 [RFC5289] + * 0xC0,0x2C TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 [RFC5289] + * 0xC0,0x2D TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 [RFC5289] + * 0xC0,0x2E TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 [RFC5289] + * 0xC0,0x2F TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 [RFC5289] + * 0xC0,0x30 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 [RFC5289] + * 0xC0,0x31 TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 [RFC5289] + * 0xC0,0x32 TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 [RFC5289] + * 0xC0,0x33 TLS_ECDHE_PSK_WITH_RC4_128_SHA [RFC5489] + * 0xC0,0x34 TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA [RFC5489] + * 0xC0,0x35 TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA [RFC5489] + * 0xC0,0x36 TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA [RFC5489] + * 0xC0,0x37 TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 [RFC5489] + * 0xC0,0x38 TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 [RFC5489] + * 0xC0,0x39 TLS_ECDHE_PSK_WITH_NULL_SHA [RFC5489] + * 0xC0,0x3A TLS_ECDHE_PSK_WITH_NULL_SHA256 [RFC5489] + * 0xC0,0x3B TLS_ECDHE_PSK_WITH_NULL_SHA384 [RFC5489] + * 0xC0,0x3C TLS_RSA_WITH_ARIA_128_CBC_SHA256 [RFC6209] + * 0xC0,0x3D TLS_RSA_WITH_ARIA_256_CBC_SHA384 [RFC6209] + * 0xC0,0x3E TLS_DH_DSS_WITH_ARIA_128_CBC_SHA256 [RFC6209] + * 0xC0,0x3F TLS_DH_DSS_WITH_ARIA_256_CBC_SHA384 [RFC6209] + * 0xC0,0x40 TLS_DH_RSA_WITH_ARIA_128_CBC_SHA256 [RFC6209] + * 0xC0,0x41 TLS_DH_RSA_WITH_ARIA_256_CBC_SHA384 [RFC6209] + * 0xC0,0x42 TLS_DHE_DSS_WITH_ARIA_128_CBC_SHA256 [RFC6209] + * 0xC0,0x43 TLS_DHE_DSS_WITH_ARIA_256_CBC_SHA384 [RFC6209] + * 0xC0,0x44 TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256 [RFC6209] + * 0xC0,0x45 TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384 [RFC6209] + * 0xC0,0x46 TLS_DH_anon_WITH_ARIA_128_CBC_SHA256 [RFC6209] + * 0xC0,0x47 TLS_DH_anon_WITH_ARIA_256_CBC_SHA384 [RFC6209] + * 0xC0,0x48 TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256 [RFC6209] + * 0xC0,0x49 TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384 [RFC6209] + * 0xC0,0x4A TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256 [RFC6209] + * 0xC0,0x4B TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384 [RFC6209] + * 0xC0,0x4C TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256 [RFC6209] + * 0xC0,0x4D TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384 [RFC6209] + * 0xC0,0x4E TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256 [RFC6209] + * 0xC0,0x4F TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384 [RFC6209] + * 0xC0,0x50 TLS_RSA_WITH_ARIA_128_GCM_SHA256 [RFC6209] + * 0xC0,0x51 TLS_RSA_WITH_ARIA_256_GCM_SHA384 [RFC6209] + * 0xC0,0x52 TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256 [RFC6209] + * 0xC0,0x53 TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384 [RFC6209] + * 0xC0,0x54 TLS_DH_RSA_WITH_ARIA_128_GCM_SHA256 [RFC6209] + * 0xC0,0x55 TLS_DH_RSA_WITH_ARIA_256_GCM_SHA384 [RFC6209] + * 0xC0,0x56 TLS_DHE_DSS_WITH_ARIA_128_GCM_SHA256 [RFC6209] + * 0xC0,0x57 TLS_DHE_DSS_WITH_ARIA_256_GCM_SHA384 [RFC6209] + * 0xC0,0x58 TLS_DH_DSS_WITH_ARIA_128_GCM_SHA256 [RFC6209] + * 0xC0,0x59 TLS_DH_DSS_WITH_ARIA_256_GCM_SHA384 [RFC6209] + * 0xC0,0x5A TLS_DH_anon_WITH_ARIA_128_GCM_SHA256 [RFC6209] + * 0xC0,0x5B TLS_DH_anon_WITH_ARIA_256_GCM_SHA384 [RFC6209] + * 0xC0,0x5C TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256 [RFC6209] + * 0xC0,0x5D TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384 [RFC6209] + * 0xC0,0x5E TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256 [RFC6209] + * 0xC0,0x5F TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384 [RFC6209] + * 0xC0,0x60 TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256 [RFC6209] + * 0xC0,0x61 TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384 [RFC6209] + * 0xC0,0x62 TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256 [RFC6209] + * 0xC0,0x63 TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384 [RFC6209] + * 0xC0,0x64 TLS_PSK_WITH_ARIA_128_CBC_SHA256 [RFC6209] + * 0xC0,0x65 TLS_PSK_WITH_ARIA_256_CBC_SHA384 [RFC6209] + * 0xC0,0x66 TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256 [RFC6209] + * 0xC0,0x67 TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384 [RFC6209] + * 0xC0,0x68 TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256 [RFC6209] + * 0xC0,0x69 TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384 [RFC6209] + * 0xC0,0x6A TLS_PSK_WITH_ARIA_128_GCM_SHA256 [RFC6209] + * 0xC0,0x6B TLS_PSK_WITH_ARIA_256_GCM_SHA384 [RFC6209] + * 0xC0,0x6C TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256 [RFC6209] + * 0xC0,0x6D TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384 [RFC6209] + * 0xC0,0x6E TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256 [RFC6209] + * 0xC0,0x6F TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384 [RFC6209] + * 0xC0,0x70 TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256 [RFC6209] + * 0xC0,0x71 TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384 [RFC6209] + * 0xC0,0x72 TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 [RFC6367] + * 0xC0,0x73 TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 [RFC6367] + * 0xC0,0x74 TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 [RFC6367] + * 0xC0,0x75 TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 [RFC6367] + * 0xC0,0x76 TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 [RFC6367] + * 0xC0,0x77 TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 [RFC6367] + * 0xC0,0x78 TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 [RFC6367] + * 0xC0,0x79 TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 [RFC6367] + * 0xC0,0x7A TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 [RFC6367] + * 0xC0,0x7B TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 [RFC6367] + * 0xC0,0x7C TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 [RFC6367] + * 0xC0,0x7D TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 [RFC6367] + * 0xC0,0x7E TLS_DH_RSA_WITH_CAMELLIA_128_GCM_SHA256 [RFC6367] + * 0xC0,0x7F TLS_DH_RSA_WITH_CAMELLIA_256_GCM_SHA384 [RFC6367] + * 0xC0,0x80 TLS_DHE_DSS_WITH_CAMELLIA_128_GCM_SHA256 [RFC6367] + * 0xC0,0x81 TLS_DHE_DSS_WITH_CAMELLIA_256_GCM_SHA384 [RFC6367] + * 0xC0,0x82 TLS_DH_DSS_WITH_CAMELLIA_128_GCM_SHA256 [RFC6367] + * 0xC0,0x83 TLS_DH_DSS_WITH_CAMELLIA_256_GCM_SHA384 [RFC6367] + * 0xC0,0x84 TLS_DH_anon_WITH_CAMELLIA_128_GCM_SHA256 [RFC6367] + * 0xC0,0x85 TLS_DH_anon_WITH_CAMELLIA_256_GCM_SHA384 [RFC6367] + * 0xC0,0x86 TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 [RFC6367] + * 0xC0,0x87 TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 [RFC6367] + * 0xC0,0x88 TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 [RFC6367] + * 0xC0,0x89 TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 [RFC6367] + * 0xC0,0x8A TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 [RFC6367] + * 0xC0,0x8B TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 [RFC6367] + * 0xC0,0x8C TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 [RFC6367] + * 0xC0,0x8D TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 [RFC6367] + * 0xC0,0x8E TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 [RFC6367] + * 0xC0,0x8F TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 [RFC6367] + * 0xC0,0x90 TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 [RFC6367] + * 0xC0,0x91 TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 [RFC6367] + * 0xC0,0x92 TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 [RFC6367] + * 0xC0,0x93 TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 [RFC6367] + * 0xC0,0x94 TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 [RFC6367] + * 0xC0,0x95 TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 [RFC6367] + * 0xC0,0x96 TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 [RFC6367] + * 0xC0,0x97 TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 [RFC6367] + * 0xC0,0x98 TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 [RFC6367] + * 0xC0,0x99 TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 [RFC6367] + * 0xC0,0x9A TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 [RFC6367] + * 0xC0,0x9B TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 [RFC6367] + * 0xC0,0x9C TLS_RSA_WITH_AES_128_CCM [RFC6655] + * 0xC0,0x9D TLS_RSA_WITH_AES_256_CCM [RFC6655] + * 0xC0,0x9E TLS_DHE_RSA_WITH_AES_128_CCM [RFC6655] + * 0xC0,0x9F TLS_DHE_RSA_WITH_AES_256_CCM [RFC6655] + * 0xC0,0xA0 TLS_RSA_WITH_AES_128_CCM_8 [RFC6655] + * 0xC0,0xA1 TLS_RSA_WITH_AES_256_CCM_8 [RFC6655] + * 0xC0,0xA2 TLS_DHE_RSA_WITH_AES_128_CCM_8 [RFC6655] + * 0xC0,0xA3 TLS_DHE_RSA_WITH_AES_256_CCM_8 [RFC6655] + * 0xC0,0xA4 TLS_PSK_WITH_AES_128_CCM [RFC6655] + * 0xC0,0xA5 TLS_PSK_WITH_AES_256_CCM [RFC6655] + * 0xC0,0xA6 TLS_DHE_PSK_WITH_AES_128_CCM [RFC6655] + * 0xC0,0xA7 TLS_DHE_PSK_WITH_AES_256_CCM [RFC6655] + * 0xC0,0xA8 TLS_PSK_WITH_AES_128_CCM_8 [RFC6655] + * 0xC0,0xA9 TLS_PSK_WITH_AES_256_CCM_8 [RFC6655] + * 0xC0,0xAA TLS_PSK_DHE_WITH_AES_128_CCM_8 [RFC6655] + * 0xC0,0xAB TLS_PSK_DHE_WITH_AES_256_CCM_8 [RFC6655] + * 0xC0,0xAC TLS_ECDHE_ECDSA_WITH_AES_128_CCM [RFC7251] + * 0xC0,0xAD TLS_ECDHE_ECDSA_WITH_AES_256_CCM [RFC7251] + * 0xC0,0xAE TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 [RFC7251] + * 0xC0,0xAF TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 [RFC7251] + * 0xC0,0xB0-FF Unassigned * 0xC1-FD,* Unassigned * 0xFE,0x00-FD Unassigned * 0xFE,0xFE-FF Reserved to avoid conflicts with widely @@ -1220,149 +1338,276 @@ final class CipherSuite implements Comparable { // the debug output. // remaining unsupported ciphersuites defined in RFC2246. - add("SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5", 0x0006); - add("SSL_RSA_WITH_IDEA_CBC_SHA", 0x0007); - add("SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA", 0x000b); - add("SSL_DH_DSS_WITH_DES_CBC_SHA", 0x000c); - add("SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA", 0x000d); - add("SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA", 0x000e); - add("SSL_DH_RSA_WITH_DES_CBC_SHA", 0x000f); - add("SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA", 0x0010); + add("SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5", 0x0006); + add("SSL_RSA_WITH_IDEA_CBC_SHA", 0x0007); + add("SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA", 0x000b); + add("SSL_DH_DSS_WITH_DES_CBC_SHA", 0x000c); + add("SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA", 0x000d); + add("SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA", 0x000e); + add("SSL_DH_RSA_WITH_DES_CBC_SHA", 0x000f); + add("SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA", 0x0010); // SSL 3.0 Fortezza ciphersuites - add("SSL_FORTEZZA_DMS_WITH_NULL_SHA", 0x001c); - add("SSL_FORTEZZA_DMS_WITH_FORTEZZA_CBC_SHA", 0x001d); + add("SSL_FORTEZZA_DMS_WITH_NULL_SHA", 0x001c); + add("SSL_FORTEZZA_DMS_WITH_FORTEZZA_CBC_SHA", 0x001d); // 1024/56 bit exportable ciphersuites from expired internet draft - add("SSL_RSA_EXPORT1024_WITH_DES_CBC_SHA", 0x0062); - add("SSL_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA", 0x0063); - add("SSL_RSA_EXPORT1024_WITH_RC4_56_SHA", 0x0064); - add("SSL_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA", 0x0065); - add("SSL_DHE_DSS_WITH_RC4_128_SHA", 0x0066); + add("SSL_RSA_EXPORT1024_WITH_DES_CBC_SHA", 0x0062); + add("SSL_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA", 0x0063); + add("SSL_RSA_EXPORT1024_WITH_RC4_56_SHA", 0x0064); + add("SSL_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA", 0x0065); + add("SSL_DHE_DSS_WITH_RC4_128_SHA", 0x0066); // Netscape old and new SSL 3.0 FIPS ciphersuites // see http://www.mozilla.org/projects/security/pki/nss/ssl/fips-ssl-ciphersuites.html - add("NETSCAPE_RSA_FIPS_WITH_3DES_EDE_CBC_SHA", 0xffe0); - add("NETSCAPE_RSA_FIPS_WITH_DES_CBC_SHA", 0xffe1); - add("SSL_RSA_FIPS_WITH_DES_CBC_SHA", 0xfefe); - add("SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA", 0xfeff); + add("NETSCAPE_RSA_FIPS_WITH_3DES_EDE_CBC_SHA", 0xffe0); + add("NETSCAPE_RSA_FIPS_WITH_DES_CBC_SHA", 0xffe1); + add("SSL_RSA_FIPS_WITH_DES_CBC_SHA", 0xfefe); + add("SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA", 0xfeff); // Unsupported Kerberos cipher suites from RFC 2712 - add("TLS_KRB5_WITH_IDEA_CBC_SHA", 0x0021); - add("TLS_KRB5_WITH_IDEA_CBC_MD5", 0x0025); - add("TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA", 0x0027); - add("TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5", 0x002a); + add("TLS_KRB5_WITH_IDEA_CBC_SHA", 0x0021); + add("TLS_KRB5_WITH_IDEA_CBC_MD5", 0x0025); + add("TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA", 0x0027); + add("TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5", 0x002a); // Unsupported cipher suites from RFC 4162 - add("TLS_RSA_WITH_SEED_CBC_SHA", 0x0096); - add("TLS_DH_DSS_WITH_SEED_CBC_SHA", 0x0097); - add("TLS_DH_RSA_WITH_SEED_CBC_SHA", 0x0098); - add("TLS_DHE_DSS_WITH_SEED_CBC_SHA", 0x0099); - add("TLS_DHE_RSA_WITH_SEED_CBC_SHA", 0x009a); - add("TLS_DH_anon_WITH_SEED_CBC_SHA", 0x009b); + add("TLS_RSA_WITH_SEED_CBC_SHA", 0x0096); + add("TLS_DH_DSS_WITH_SEED_CBC_SHA", 0x0097); + add("TLS_DH_RSA_WITH_SEED_CBC_SHA", 0x0098); + add("TLS_DHE_DSS_WITH_SEED_CBC_SHA", 0x0099); + add("TLS_DHE_RSA_WITH_SEED_CBC_SHA", 0x009a); + add("TLS_DH_anon_WITH_SEED_CBC_SHA", 0x009b); // Unsupported cipher suites from RFC 4279 - add("TLS_PSK_WITH_RC4_128_SHA", 0x008a); - add("TLS_PSK_WITH_3DES_EDE_CBC_SHA", 0x008b); - add("TLS_PSK_WITH_AES_128_CBC_SHA", 0x008c); - add("TLS_PSK_WITH_AES_256_CBC_SHA", 0x008d); - add("TLS_DHE_PSK_WITH_RC4_128_SHA", 0x008e); - add("TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA", 0x008f); - add("TLS_DHE_PSK_WITH_AES_128_CBC_SHA", 0x0090); - add("TLS_DHE_PSK_WITH_AES_256_CBC_SHA", 0x0091); - add("TLS_RSA_PSK_WITH_RC4_128_SHA", 0x0092); - add("TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA", 0x0093); - add("TLS_RSA_PSK_WITH_AES_128_CBC_SHA", 0x0094); - add("TLS_RSA_PSK_WITH_AES_256_CBC_SHA", 0x0095); + add("TLS_PSK_WITH_RC4_128_SHA", 0x008a); + add("TLS_PSK_WITH_3DES_EDE_CBC_SHA", 0x008b); + add("TLS_PSK_WITH_AES_128_CBC_SHA", 0x008c); + add("TLS_PSK_WITH_AES_256_CBC_SHA", 0x008d); + add("TLS_DHE_PSK_WITH_RC4_128_SHA", 0x008e); + add("TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA", 0x008f); + add("TLS_DHE_PSK_WITH_AES_128_CBC_SHA", 0x0090); + add("TLS_DHE_PSK_WITH_AES_256_CBC_SHA", 0x0091); + add("TLS_RSA_PSK_WITH_RC4_128_SHA", 0x0092); + add("TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA", 0x0093); + add("TLS_RSA_PSK_WITH_AES_128_CBC_SHA", 0x0094); + add("TLS_RSA_PSK_WITH_AES_256_CBC_SHA", 0x0095); // Unsupported cipher suites from RFC 4785 - add("TLS_PSK_WITH_NULL_SHA", 0x002c); - add("TLS_DHE_PSK_WITH_NULL_SHA", 0x002d); - add("TLS_RSA_PSK_WITH_NULL_SHA", 0x002e); + add("TLS_PSK_WITH_NULL_SHA", 0x002c); + add("TLS_DHE_PSK_WITH_NULL_SHA", 0x002d); + add("TLS_RSA_PSK_WITH_NULL_SHA", 0x002e); // Unsupported cipher suites from RFC 5246 - add("TLS_DH_DSS_WITH_AES_128_CBC_SHA", 0x0030); - add("TLS_DH_RSA_WITH_AES_128_CBC_SHA", 0x0031); - add("TLS_DH_DSS_WITH_AES_256_CBC_SHA", 0x0036); - add("TLS_DH_RSA_WITH_AES_256_CBC_SHA", 0x0037); - add("TLS_DH_DSS_WITH_AES_128_CBC_SHA256", 0x003e); - add("TLS_DH_RSA_WITH_AES_128_CBC_SHA256", 0x003f); - add("TLS_DH_DSS_WITH_AES_256_CBC_SHA256", 0x0068); - add("TLS_DH_RSA_WITH_AES_256_CBC_SHA256", 0x0069); + add("TLS_DH_DSS_WITH_AES_128_CBC_SHA", 0x0030); + add("TLS_DH_RSA_WITH_AES_128_CBC_SHA", 0x0031); + add("TLS_DH_DSS_WITH_AES_256_CBC_SHA", 0x0036); + add("TLS_DH_RSA_WITH_AES_256_CBC_SHA", 0x0037); + add("TLS_DH_DSS_WITH_AES_128_CBC_SHA256", 0x003e); + add("TLS_DH_RSA_WITH_AES_128_CBC_SHA256", 0x003f); + add("TLS_DH_DSS_WITH_AES_256_CBC_SHA256", 0x0068); + add("TLS_DH_RSA_WITH_AES_256_CBC_SHA256", 0x0069); // Unsupported cipher suites from RFC 5288 - add("TLS_DH_RSA_WITH_AES_128_GCM_SHA256", 0x00a0); - add("TLS_DH_RSA_WITH_AES_256_GCM_SHA384", 0x00a1); - add("TLS_DH_DSS_WITH_AES_128_GCM_SHA256", 0x00a4); - add("TLS_DH_DSS_WITH_AES_256_GCM_SHA384", 0x00a5); + add("TLS_DH_RSA_WITH_AES_128_GCM_SHA256", 0x00a0); + add("TLS_DH_RSA_WITH_AES_256_GCM_SHA384", 0x00a1); + add("TLS_DH_DSS_WITH_AES_128_GCM_SHA256", 0x00a4); + add("TLS_DH_DSS_WITH_AES_256_GCM_SHA384", 0x00a5); // Unsupported cipher suites from RFC 5487 - add("TLS_PSK_WITH_AES_128_GCM_SHA256", 0x00a8); - add("TLS_PSK_WITH_AES_256_GCM_SHA384", 0x00a9); - add("TLS_DHE_PSK_WITH_AES_128_GCM_SHA256", 0x00aa); - add("TLS_DHE_PSK_WITH_AES_256_GCM_SHA384", 0x00ab); - add("TLS_RSA_PSK_WITH_AES_128_GCM_SHA256", 0x00ac); - add("TLS_RSA_PSK_WITH_AES_256_GCM_SHA384", 0x00ad); - add("TLS_PSK_WITH_AES_128_CBC_SHA256", 0x00ae); - add("TLS_PSK_WITH_AES_256_CBC_SHA384", 0x00af); - add("TLS_PSK_WITH_NULL_SHA256", 0x00b0); - add("TLS_PSK_WITH_NULL_SHA384", 0x00b1); - add("TLS_DHE_PSK_WITH_AES_128_CBC_SHA256", 0x00b2); - add("TLS_DHE_PSK_WITH_AES_256_CBC_SHA384", 0x00b3); - add("TLS_DHE_PSK_WITH_NULL_SHA256", 0x00b4); - add("TLS_DHE_PSK_WITH_NULL_SHA384", 0x00b5); - add("TLS_RSA_PSK_WITH_AES_128_CBC_SHA256", 0x00b6); - add("TLS_RSA_PSK_WITH_AES_256_CBC_SHA384", 0x00b7); - add("TLS_RSA_PSK_WITH_NULL_SHA256", 0x00b8); - add("TLS_RSA_PSK_WITH_NULL_SHA384", 0x00b9); + add("TLS_PSK_WITH_AES_128_GCM_SHA256", 0x00a8); + add("TLS_PSK_WITH_AES_256_GCM_SHA384", 0x00a9); + add("TLS_DHE_PSK_WITH_AES_128_GCM_SHA256", 0x00aa); + add("TLS_DHE_PSK_WITH_AES_256_GCM_SHA384", 0x00ab); + add("TLS_RSA_PSK_WITH_AES_128_GCM_SHA256", 0x00ac); + add("TLS_RSA_PSK_WITH_AES_256_GCM_SHA384", 0x00ad); + add("TLS_PSK_WITH_AES_128_CBC_SHA256", 0x00ae); + add("TLS_PSK_WITH_AES_256_CBC_SHA384", 0x00af); + add("TLS_PSK_WITH_NULL_SHA256", 0x00b0); + add("TLS_PSK_WITH_NULL_SHA384", 0x00b1); + add("TLS_DHE_PSK_WITH_AES_128_CBC_SHA256", 0x00b2); + add("TLS_DHE_PSK_WITH_AES_256_CBC_SHA384", 0x00b3); + add("TLS_DHE_PSK_WITH_NULL_SHA256", 0x00b4); + add("TLS_DHE_PSK_WITH_NULL_SHA384", 0x00b5); + add("TLS_RSA_PSK_WITH_AES_128_CBC_SHA256", 0x00b6); + add("TLS_RSA_PSK_WITH_AES_256_CBC_SHA384", 0x00b7); + add("TLS_RSA_PSK_WITH_NULL_SHA256", 0x00b8); + add("TLS_RSA_PSK_WITH_NULL_SHA384", 0x00b9); // Unsupported cipher suites from RFC 5932 - add("TLS_RSA_WITH_CAMELLIA_128_CBC_SHA", 0x0041); - add("TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA", 0x0042); - add("TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA", 0x0043); - add("TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA", 0x0044); - add("TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA", 0x0045); - add("TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA", 0x0046); - add("TLS_RSA_WITH_CAMELLIA_256_CBC_SHA", 0x0084); - add("TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA", 0x0085); - add("TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA", 0x0086); - add("TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA", 0x0087); - add("TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA", 0x0088); - add("TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA", 0x0089); - add("TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256", 0x00ba); - add("TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256", 0x00bb); - add("TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256", 0x00bc); - add("TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256", 0x00bd); - add("TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256", 0x00be); - add("TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256", 0x00bf); - add("TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256", 0x00c0); - add("TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256", 0x00c1); - add("TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256", 0x00c2); - add("TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256", 0x00c3); - add("TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256", 0x00c4); - add("TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256", 0x00c5); + add("TLS_RSA_WITH_CAMELLIA_128_CBC_SHA", 0x0041); + add("TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA", 0x0042); + add("TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA", 0x0043); + add("TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA", 0x0044); + add("TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA", 0x0045); + add("TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA", 0x0046); + add("TLS_RSA_WITH_CAMELLIA_256_CBC_SHA", 0x0084); + add("TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA", 0x0085); + add("TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA", 0x0086); + add("TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA", 0x0087); + add("TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA", 0x0088); + add("TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA", 0x0089); + add("TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256", 0x00ba); + add("TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256", 0x00bb); + add("TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256", 0x00bc); + add("TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256", 0x00bd); + add("TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256", 0x00be); + add("TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256", 0x00bf); + add("TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256", 0x00c0); + add("TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256", 0x00c1); + add("TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256", 0x00c2); + add("TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256", 0x00c3); + add("TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256", 0x00c4); + add("TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256", 0x00c5); + + // TLS Fallback Signaling Cipher Suite Value (SCSV) RFC 7507 + add("TLS_FALLBACK_SCSV", 0x5600); // Unsupported cipher suites from RFC 5054 - add("TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA", 0xc01a); - add("TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA", 0xc01b); - add("TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA", 0xc01c); - add("TLS_SRP_SHA_WITH_AES_128_CBC_SHA", 0xc01d); - add("TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA", 0xc01e); - add("TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA", 0xc01f); - add("TLS_SRP_SHA_WITH_AES_256_CBC_SHA", 0xc020); - add("TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA", 0xc021); - add("TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA", 0xc022); + add("TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA", 0xc01a); + add("TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA", 0xc01b); + add("TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA", 0xc01c); + add("TLS_SRP_SHA_WITH_AES_128_CBC_SHA", 0xc01d); + add("TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA", 0xc01e); + add("TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA", 0xc01f); + add("TLS_SRP_SHA_WITH_AES_256_CBC_SHA", 0xc020); + add("TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA", 0xc021); + add("TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA", 0xc022); // Unsupported cipher suites from RFC 5489 - add("TLS_ECDHE_PSK_WITH_RC4_128_SHA", 0xc033); - add("TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA", 0xc034); - add("TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA", 0xc035); - add("TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA", 0xc036); - add("TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256", 0xc037); - add("TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384", 0xc038); - add("TLS_ECDHE_PSK_WITH_NULL_SHA", 0xc039); - add("TLS_ECDHE_PSK_WITH_NULL_SHA256", 0xc03a); - add("TLS_ECDHE_PSK_WITH_NULL_SHA384", 0xc03b); + add("TLS_ECDHE_PSK_WITH_RC4_128_SHA", 0xc033); + add("TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA", 0xc034); + add("TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA", 0xc035); + add("TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA", 0xc036); + add("TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256", 0xc037); + add("TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384", 0xc038); + add("TLS_ECDHE_PSK_WITH_NULL_SHA", 0xc039); + add("TLS_ECDHE_PSK_WITH_NULL_SHA256", 0xc03a); + add("TLS_ECDHE_PSK_WITH_NULL_SHA384", 0xc03b); + + // Unsupported cipher suites from RFC 6209 + add("TLS_RSA_WITH_ARIA_128_CBC_SHA256", 0xc03c); + add("TLS_RSA_WITH_ARIA_256_CBC_SHA384", 0xc03d); + add("TLS_DH_DSS_WITH_ARIA_128_CBC_SHA256", 0xc03e); + add("TLS_DH_DSS_WITH_ARIA_256_CBC_SHA384", 0xc03f); + add("TLS_DH_RSA_WITH_ARIA_128_CBC_SHA256", 0xc040); + add("TLS_DH_RSA_WITH_ARIA_256_CBC_SHA384", 0xc041); + add("TLS_DHE_DSS_WITH_ARIA_128_CBC_SHA256", 0xc042); + add("TLS_DHE_DSS_WITH_ARIA_256_CBC_SHA384", 0xc043); + add("TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256", 0xc044); + add("TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384", 0xc045); + add("TLS_DH_anon_WITH_ARIA_128_CBC_SHA256", 0xc046); + add("TLS_DH_anon_WITH_ARIA_256_CBC_SHA384", 0xc047); + add("TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256", 0xc048); + add("TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384", 0xc049); + add("TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256", 0xc04a); + add("TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384", 0xc04b); + add("TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256", 0xc04c); + add("TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384", 0xc04d); + add("TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256", 0xc04e); + add("TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384", 0xc04f); + add("TLS_RSA_WITH_ARIA_128_GCM_SHA256", 0xc050); + add("TLS_RSA_WITH_ARIA_256_GCM_SHA384", 0xc051); + add("TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256", 0xc052); + add("TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384", 0xc053); + add("TLS_DH_RSA_WITH_ARIA_128_GCM_SHA256", 0xc054); + add("TLS_DH_RSA_WITH_ARIA_256_GCM_SHA384", 0xc055); + add("TLS_DHE_DSS_WITH_ARIA_128_GCM_SHA256", 0xc056); + add("TLS_DHE_DSS_WITH_ARIA_256_GCM_SHA384", 0xc057); + add("TLS_DH_DSS_WITH_ARIA_128_GCM_SHA256", 0xc058); + add("TLS_DH_DSS_WITH_ARIA_256_GCM_SHA384", 0xc059); + add("TLS_DH_anon_WITH_ARIA_128_GCM_SHA256", 0xc05a); + add("TLS_DH_anon_WITH_ARIA_256_GCM_SHA384", 0xc05b); + add("TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256", 0xc05c); + add("TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384", 0xc05d); + add("TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256", 0xc05e); + add("TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384", 0xc05f); + add("TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256", 0xc060); + add("TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384", 0xc061); + add("TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256", 0xc062); + add("TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384", 0xc063); + add("TLS_PSK_WITH_ARIA_128_CBC_SHA256", 0xc064); + add("TLS_PSK_WITH_ARIA_256_CBC_SHA384", 0xc065); + add("TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256", 0xc066); + add("TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384", 0xc067); + add("TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256", 0xc068); + add("TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384", 0xc069); + add("TLS_PSK_WITH_ARIA_128_GCM_SHA256", 0xc06a); + add("TLS_PSK_WITH_ARIA_256_GCM_SHA384", 0xc06b); + add("TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256", 0xc06c); + add("TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384", 0xc06d); + add("TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256", 0xc06e); + add("TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384", 0xc06f); + add("TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256", 0xc070); + add("TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384", 0xc071); + + // Unsupported cipher suites from RFC 6367 + add("TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256", 0xc072); + add("TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384", 0xc073); + add("TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256", 0xc074); + add("TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384", 0xc075); + add("TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256", 0xc076); + add("TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384", 0xc077); + add("TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256", 0xc078); + add("TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384", 0xc079); + add("TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256", 0xc07a); + add("TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384", 0xc07b); + add("TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256", 0xc07c); + add("TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384", 0xc07d); + add("TLS_DH_RSA_WITH_CAMELLIA_128_GCM_SHA256", 0xc07e); + add("TLS_DH_RSA_WITH_CAMELLIA_256_GCM_SHA384", 0xc07f); + add("TLS_DHE_DSS_WITH_CAMELLIA_128_GCM_SHA256", 0xc080); + add("TLS_DHE_DSS_WITH_CAMELLIA_256_GCM_SHA384", 0xc081); + add("TLS_DH_DSS_WITH_CAMELLIA_128_GCM_SHA256", 0xc082); + add("TLS_DH_DSS_WITH_CAMELLIA_256_GCM_SHA384", 0xc083); + add("TLS_DH_anon_WITH_CAMELLIA_128_GCM_SHA256", 0xc084); + add("TLS_DH_anon_WITH_CAMELLIA_256_GCM_SHA384", 0xc085); + add("TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256", 0xc086); + add("TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384", 0xc087); + add("TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256", 0xc088); + add("TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384", 0xc089); + add("TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256", 0xc08a); + add("TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384", 0xc08b); + add("TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256", 0xc08c); + add("TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384", 0xc08d); + add("TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256", 0xc08e); + add("TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384", 0xc08f); + add("TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256", 0xc090); + add("TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384", 0xc091); + add("TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256", 0xc092); + add("TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384", 0xc093); + add("TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256", 0xc094); + add("TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384", 0xc095); + add("TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256", 0xc096); + add("TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384", 0xc097); + add("TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256", 0xc098); + add("TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384", 0xc099); + add("TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256", 0xc09a); + add("TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384", 0xc09b); + + // Unsupported cipher suites from RFC 6655 + add("TLS_RSA_WITH_AES_128_CCM", 0xc09c); + add("TLS_RSA_WITH_AES_256_CCM", 0xc09d); + add("TLS_DHE_RSA_WITH_AES_128_CCM", 0xc09e); + add("TLS_DHE_RSA_WITH_AES_256_CCM", 0xc09f); + add("TLS_RSA_WITH_AES_128_CCM_8", 0xc0A0); + add("TLS_RSA_WITH_AES_256_CCM_8", 0xc0A1); + add("TLS_DHE_RSA_WITH_AES_128_CCM_8", 0xc0A2); + add("TLS_DHE_RSA_WITH_AES_256_CCM_8", 0xc0A3); + add("TLS_PSK_WITH_AES_128_CCM", 0xc0A4); + add("TLS_PSK_WITH_AES_256_CCM", 0xc0A5); + add("TLS_DHE_PSK_WITH_AES_128_CCM", 0xc0A6); + add("TLS_DHE_PSK_WITH_AES_256_CCM", 0xc0A7); + add("TLS_PSK_WITH_AES_128_CCM_8", 0xc0A8); + add("TLS_PSK_WITH_AES_256_CCM_8", 0xc0A9); + add("TLS_PSK_DHE_WITH_AES_128_CCM_8", 0xc0Aa); + add("TLS_PSK_DHE_WITH_AES_256_CCM_8", 0xc0Ab); + + // Unsupported cipher suites from RFC 7251 + add("TLS_ECDHE_ECDSA_WITH_AES_128_CCM", 0xc0Ac); + add("TLS_ECDHE_ECDSA_WITH_AES_256_CCM", 0xc0Ad); + add("TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8", 0xc0Ae); + add("TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8", 0xc0Af); } // ciphersuite SSL_NULL_WITH_NULL_NULL diff --git a/src/share/classes/sun/security/ssl/ClientHandshaker.java b/src/share/classes/sun/security/ssl/ClientHandshaker.java index 187ae314f76917199723d93bdd01fec740aa606a..16e0ac60930e1a923beed4366239f0d033a96bf1 100644 --- a/src/share/classes/sun/security/ssl/ClientHandshaker.java +++ b/src/share/classes/sun/security/ssl/ClientHandshaker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -141,6 +141,9 @@ final class ClientHandshaker extends Handshaker { private final static boolean allowUnsafeServerCertChange = Debug.getBooleanProperty("jdk.tls.allowUnsafeServerCertChange", false); + // Whether an ALPN extension was sent in the ClientHello + private boolean alpnActive = false; + private List requestedServerNames = Collections.emptyList(); @@ -689,6 +692,45 @@ final class ClientHandshaker extends Handshaker { } } + // check the ALPN extension + ALPNExtension serverHelloALPN = + (ALPNExtension) mesg.extensions.get(ExtensionType.EXT_ALPN); + + if (serverHelloALPN != null) { + // Check whether an ALPN extension was sent in ClientHello message + if (!alpnActive) { + fatalSE(Alerts.alert_unsupported_extension, + "Server sent " + ExtensionType.EXT_ALPN + + " extension when not requested by client"); + } + + List protocols = serverHelloALPN.getPeerAPs(); + // Only one application protocol name should be present + String p; + if ((protocols.size() == 1) && + !((p = protocols.get(0)).isEmpty())) { + int i; + for (i = 0; i < localApl.length; i++) { + if (localApl[i].equals(p)) { + break; + } + } + if (i == localApl.length) { + fatalSE(Alerts.alert_handshake_failure, + "Server has selected an application protocol name " + + "which was not offered by the client: " + p); + + } + applicationProtocol = p; + } else { + fatalSE(Alerts.alert_handshake_failure, + "Incorrect data in ServerHello " + ExtensionType.EXT_ALPN + + " message"); + } + } else { + applicationProtocol = ""; + } + if (resumingSession && session != null) { setHandshakeSessionSE(session); // Reserve the handshake state if this is a session-resumption @@ -708,6 +750,7 @@ final class ClientHandshaker extends Handshaker { } else if ((type != ExtensionType.EXT_ELLIPTIC_CURVES) && (type != ExtensionType.EXT_EC_POINT_FORMATS) && (type != ExtensionType.EXT_SERVER_NAME) + && (type != ExtensionType.EXT_ALPN) && (type != ExtensionType.EXT_RENEGOTIATION_INFO) && (type != ExtensionType.EXT_EXTENDED_MASTER_SECRET)){ fatalSE(Alerts.alert_unsupported_extension, @@ -1294,7 +1337,7 @@ final class ClientHandshaker extends Handshaker { @Override HandshakeMessage getKickstartMessage() throws SSLException { // session ID of the ClientHello message - SessionId sessionId = SSLSessionImpl.nullSession.getSessionId(); + SessionId sessionId = new SessionId(new byte[0]); // a list of cipher suites sent by the client CipherSuiteList cipherSuites = getActiveCipherSuites(); @@ -1399,7 +1442,7 @@ final class ClientHandshaker extends Handshaker { String sessionIdentityAlg = session.getEndpointIdentificationAlgorithm(); - if (!Objects.equals(identityAlg, sessionIdentityAlg)) { + if (!identityAlg.equalsIgnoreCase(sessionIdentityAlg)) { if (debug != null && Debug.isOn("session")) { System.out.println("%% can't resume, endpoint id" + @@ -1537,6 +1580,12 @@ final class ClientHandshaker extends Handshaker { } } + // Add ALPN extension + if (localApl != null && localApl.length > 0) { + clientHelloMessage.addALPNExtension(localApl); + alpnActive = true; + } + // reset the client random cookie clnt_random = clientHelloMessage.clnt_random; diff --git a/src/share/classes/sun/security/ssl/ExtensionType.java b/src/share/classes/sun/security/ssl/ExtensionType.java index 4c5dcf2522ef4747f7f29a4fe6a05a4ff8294122..21888ab2d5fab94cecc42b1f9c9642e0ef16b4b2 100644 --- a/src/share/classes/sun/security/ssl/ExtensionType.java +++ b/src/share/classes/sun/security/ssl/ExtensionType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved. * 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,7 +43,8 @@ final class ExtensionType { return name; } - static List knownExtensions = new ArrayList(14); + static List knownExtensions = + new ArrayList(15); static ExtensionType get(int id) { for (ExtensionType ext : knownExtensions) { @@ -96,6 +97,11 @@ final class ExtensionType { final static ExtensionType EXT_SIGNATURE_ALGORITHMS = e(0x000D, "signature_algorithms"); // IANA registry value: 13 + // extension defined in RFC 7301 (ALPN) + static final ExtensionType EXT_ALPN = + e(0x0010, "application_layer_protocol_negotiation"); + // IANA registry value: 16 + // extensions defined in RFC 7627 static final ExtensionType EXT_EXTENDED_MASTER_SECRET = e(0x0017, "extended_master_secret"); // IANA registry value: 23 diff --git a/src/share/classes/sun/security/ssl/HandshakeMessage.java b/src/share/classes/sun/security/ssl/HandshakeMessage.java index f453b650df21207f8a7d8954657c8b502abe5ab1..b7bef38e1a988eaabf9113fcd07416a50e62abe4 100644 --- a/src/share/classes/sun/security/ssl/HandshakeMessage.java +++ b/src/share/classes/sun/security/ssl/HandshakeMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -280,6 +280,11 @@ static final class ClientHello extends HandshakeMessage { extensions.add(new ExtendedMasterSecretExtension()); } + // add application_layer_protocol_negotiation extension + void addALPNExtension(String[] applicationProtocols) throws SSLException { + extensions.add(new ALPNExtension(applicationProtocols)); + } + @Override int messageType() { return ht_client_hello; } diff --git a/src/share/classes/sun/security/ssl/Handshaker.java b/src/share/classes/sun/security/ssl/Handshaker.java index beee9fdb97b2e68c89b16c98732010de9a63c2be..df082ae7f005c92b88f18f74e40f1fc6732445e8 100644 --- a/src/share/classes/sun/security/ssl/Handshaker.java +++ b/src/share/classes/sun/security/ssl/Handshaker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. * 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 @@ package sun.security.ssl; import java.io.*; import java.util.*; +import java.util.function.BiFunction; import java.security.*; import javax.crypto.*; @@ -109,6 +110,20 @@ abstract class Handshaker { List serverNames = Collections.emptyList(); Collection sniMatchers = Collections.emptyList(); + // List of local ApplicationProtocols + String[] localApl = null; + + // Negotiated ALPN value + String applicationProtocol = null; + + // Application protocol callback function (for SSLEngine) + BiFunction,String> + appProtocolSelectorSSLEngine = null; + + // Application protocol callback function (for SSLSocket) + BiFunction,String> + appProtocolSelectorSSLSocket = null; + private boolean isClient; private boolean needCertVerify; @@ -488,6 +503,36 @@ abstract class Handshaker { this.sniMatchers = sniMatchers; } + /** + * Sets the Application Protocol list. + */ + void setApplicationProtocols(String[] apl) { + this.localApl = apl; + } + + /** + * Gets the "negotiated" ALPN value. + */ + String getHandshakeApplicationProtocol() { + return applicationProtocol; + } + + /** + * Sets the Application Protocol selector function for SSLEngine. + */ + void setApplicationProtocolSelectorSSLEngine( + BiFunction,String> selector) { + this.appProtocolSelectorSSLEngine = selector; + } + + /** + * Sets the Application Protocol selector function for SSLSocket. + */ + void setApplicationProtocolSelectorSSLSocket( + BiFunction,String> selector) { + this.appProtocolSelectorSSLSocket = selector; + } + /** * Sets the cipher suites preference. */ diff --git a/src/share/classes/sun/security/ssl/HelloExtensions.java b/src/share/classes/sun/security/ssl/HelloExtensions.java index 4fd03aaf08d59ee36e8ad14cd980e65ddb22a520..00db1995ad1d72e588a7e016c147b34e76974469 100644 --- a/src/share/classes/sun/security/ssl/HelloExtensions.java +++ b/src/share/classes/sun/security/ssl/HelloExtensions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved. * 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,8 +33,8 @@ import javax.net.ssl.*; /** * This file contains all the classes relevant to TLS Extensions for the * ClientHello and ServerHello messages. The extension mechanism and - * several extensions are defined in RFC 3546. Additional extensions are - * defined in the ECC RFC 4492. + * several extensions are defined in RFC 6066. Additional extensions are + * defined in the ECC RFC 4492 and the ALPN extension is defined in RFC 7301. * * Currently, only the two ECC extensions are fully supported. * @@ -52,6 +52,7 @@ import javax.net.ssl.*; * . EllipticCurvesExtension: the ECC supported curves extension. * . EllipticPointFormatsExtension: the ECC supported point formats * (compressed/uncompressed) extension. + * . ALPNExtension: the application_layer_protocol_negotiation extension. * * @since 1.6 * @author Andreas Sterbenz @@ -86,6 +87,8 @@ final class HelloExtensions { extension = new RenegotiationInfoExtension(s, extlen); } else if (extType == ExtensionType.EXT_EXTENDED_MASTER_SECRET) { extension = new ExtendedMasterSecretExtension(s, extlen); + } else if (extType == ExtensionType.EXT_ALPN) { + extension = new ALPNExtension(s, extlen); } else { extension = new UnknownExtension(s, extlen, extType); } diff --git a/src/share/classes/sun/security/ssl/RSASignature.java b/src/share/classes/sun/security/ssl/RSASignature.java index 94a1e8eceded8e991163f62b39fdef989c5a410e..23a57eec70ffa6c3fe76c8673a7a660dd7536aeb 100644 --- a/src/share/classes/sun/security/ssl/RSASignature.java +++ b/src/share/classes/sun/security/ssl/RSASignature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. * 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,6 +27,7 @@ package sun.security.ssl; import java.security.*; +import java.security.spec.AlgorithmParameterSpec; /** * Signature implementation for the SSL/TLS RSA Signature variant with both @@ -198,10 +199,22 @@ public final class RSASignature extends SignatureSpi { sha = digests[1]; } + @Override + protected void engineSetParameter(AlgorithmParameterSpec params) + throws InvalidAlgorithmParameterException { + if (params != null) { + throw new InvalidAlgorithmParameterException("No parameters accepted"); + } + } + @Override protected Object engineGetParameter(String param) throws InvalidParameterException { throw new InvalidParameterException("Parameters not supported"); } + @Override + protected AlgorithmParameters engineGetParameters() { + return null; + } } diff --git a/src/share/classes/sun/security/ssl/SSLEngineImpl.java b/src/share/classes/sun/security/ssl/SSLEngineImpl.java index d4ce0e1514eaa61785ab083a555a0288ee3ebeea..df520a558578eccd437e0881c642140cdce08adc 100644 --- a/src/share/classes/sun/security/ssl/SSLEngineImpl.java +++ b/src/share/classes/sun/security/ssl/SSLEngineImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * 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.*; import java.nio.*; import java.util.*; import java.security.*; +import java.util.function.BiFunction; import javax.crypto.BadPaddingException; @@ -259,6 +260,19 @@ final public class SSLEngineImpl extends SSLEngine { Collection sniMatchers = Collections.emptyList(); + // Configured application protocol values + String[] applicationProtocols = new String[0]; + + // Negotiated application protocol value. + // + // The value under negotiation will be obtained from handshaker. + String applicationProtocol = null; + + + // Callback function that selects the application protocol value during + // the SSL/TLS handshake. + BiFunction, String> applicationProtocolSelector; + // Have we been told whether we're client or server? private boolean serverModeSet = false; private boolean roleIsServer; @@ -361,7 +375,7 @@ final public class SSLEngineImpl extends SSLEngine { } sslContext = ctx; - sess = SSLSessionImpl.nullSession; + sess = new SSLSessionImpl(); handshakeSession = null; /* @@ -486,6 +500,9 @@ final public class SSLEngineImpl extends SSLEngine { } handshaker.setEnabledCipherSuites(enabledCipherSuites); handshaker.setEnableSessionCreation(enableSessionCreation); + handshaker.setApplicationProtocols(applicationProtocols); + handshaker.setApplicationProtocolSelectorSSLEngine( + applicationProtocolSelector); } /* @@ -1027,6 +1044,9 @@ final public class SSLEngineImpl extends SSLEngine { handshaker.isSecureRenegotiation(); clientVerifyData = handshaker.getClientVerifyData(); serverVerifyData = handshaker.getServerVerifyData(); + // set connection ALPN value + applicationProtocol = + handshaker.getHandshakeApplicationProtocol(); sess = handshaker.getSession(); handshakeSession = null; @@ -2091,6 +2111,7 @@ final public class SSLEngineImpl extends SSLEngine { params.setSNIMatchers(sniMatchers); params.setServerNames(serverNames); params.setUseCipherSuitesOrder(preferLocalCipherSuites); + params.setApplicationProtocols(applicationProtocols); return params; } @@ -2116,10 +2137,12 @@ final public class SSLEngineImpl extends SSLEngine { if (matchers != null) { sniMatchers = matchers; } + applicationProtocols = params.getApplicationProtocols(); if ((handshaker != null) && !handshaker.started()) { handshaker.setIdentificationProtocol(identificationProtocol); handshaker.setAlgorithmConstraints(algorithmConstraints); + applicationProtocols = params.getApplicationProtocols(); if (roleIsServer) { handshaker.setSNIMatchers(sniMatchers); handshaker.setUseCipherSuitesOrder(preferLocalCipherSuites); @@ -2129,6 +2152,34 @@ final public class SSLEngineImpl extends SSLEngine { } } + @Override + public synchronized String getApplicationProtocol() { + return applicationProtocol; + } + + @Override + public synchronized String getHandshakeApplicationProtocol() { + if ((handshaker != null) && handshaker.started()) { + return handshaker.getHandshakeApplicationProtocol(); + } + return null; + } + + @Override + public synchronized void setHandshakeApplicationProtocolSelector( + BiFunction, String> selector) { + applicationProtocolSelector = selector; + if ((handshaker != null) && !handshaker.activated()) { + handshaker.setApplicationProtocolSelectorSSLEngine(selector); + } + } + + @Override + public synchronized BiFunction, String> + getHandshakeApplicationProtocolSelector() { + return this.applicationProtocolSelector; + } + /** * Returns a printable representation of this end of the connection. */ diff --git a/src/share/classes/sun/security/ssl/SSLServerSocketImpl.java b/src/share/classes/sun/security/ssl/SSLServerSocketImpl.java index 464bab23ad41cbde6ad99308b97c1a462aa49d2c..74d2bd769bed3b3292d2d5b88718e814e21ffe45 100644 --- a/src/share/classes/sun/security/ssl/SSLServerSocketImpl.java +++ b/src/share/classes/sun/security/ssl/SSLServerSocketImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. * 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,6 +92,9 @@ class SSLServerSocketImpl extends SSLServerSocket Collection sniMatchers = Collections.emptyList(); + // Configured application protocol values + String[] applicationProtocols = new String[0]; + /* * Whether local cipher suites preference in server side should be * honored during handshaking? @@ -311,7 +314,7 @@ class SSLServerSocketImpl extends SSLServerSocket params.setAlgorithmConstraints(algorithmConstraints); params.setSNIMatchers(sniMatchers); params.setUseCipherSuitesOrder(preferLocalCipherSuites); - + params.setApplicationProtocols(applicationProtocols); return params; } @@ -331,6 +334,7 @@ class SSLServerSocketImpl extends SSLServerSocket if (matchers != null) { sniMatchers = params.getSNIMatchers(); } + applicationProtocols = params.getApplicationProtocols(); } /** @@ -343,7 +347,7 @@ class SSLServerSocketImpl extends SSLServerSocket SSLSocketImpl s = new SSLSocketImpl(sslContext, useServerMode, enabledCipherSuites, doClientAuth, enableSessionCreation, enabledProtocols, identificationProtocol, algorithmConstraints, - sniMatchers, preferLocalCipherSuites); + sniMatchers, preferLocalCipherSuites, applicationProtocols); implAccept(s); s.doneConnect(); diff --git a/src/share/classes/sun/security/ssl/SSLSessionImpl.java b/src/share/classes/sun/security/ssl/SSLSessionImpl.java index b3efe7ccf81a2f555218222557799697a8089499..0dc8326da89ec33af6e8e96903dc50485e217470 100644 --- a/src/share/classes/sun/security/ssl/SSLSessionImpl.java +++ b/src/share/classes/sun/security/ssl/SSLSessionImpl.java @@ -73,11 +73,6 @@ import static sun.security.ssl.CipherSuite.KeyExchange.*; */ final class SSLSessionImpl extends ExtendedSSLSession { - /* - * we only really need a single null session - */ - static final SSLSessionImpl nullSession = new SSLSessionImpl(); - // compression methods private static final byte compression_null = 0; @@ -148,7 +143,7 @@ final class SSLSessionImpl extends ExtendedSSLSession { * be used either by a client or by a server, as a connection is * first opened and before handshaking begins. */ - private SSLSessionImpl() { + SSLSessionImpl() { this(ProtocolVersion.NONE, CipherSuite.C_NULL, null, new SessionId(false, null), null, -1, false, null); } @@ -657,14 +652,6 @@ final class SSLSessionImpl extends ExtendedSSLSession { */ @Override synchronized public void invalidate() { - // - // Can't invalidate the NULL session -- this would be - // attempted when we get a handshaking error on a brand - // new connection, with no "real" session yet. - // - if (this == nullSession) { - return; - } invalidated = true; if (debug != null && Debug.isOn("session")) { System.out.println("%% Invalidated: " + this); diff --git a/src/share/classes/sun/security/ssl/SSLSocketImpl.java b/src/share/classes/sun/security/ssl/SSLSocketImpl.java index d6171c3a515cfa154ea8346f999d88c53a395ea4..f7c5a548f73828091806d4f1874094a90954954d 100644 --- a/src/share/classes/sun/security/ssl/SSLSocketImpl.java +++ b/src/share/classes/sun/security/ssl/SSLSocketImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,7 @@ import java.security.AlgorithmConstraints; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.ReentrantLock; +import java.util.function.BiFunction; import javax.crypto.BadPaddingException; import javax.net.ssl.*; @@ -220,6 +221,18 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl { // Is the sniMatchers set to empty with SSLParameters.setSNIMatchers()? private boolean noSniMatcher = false; + // Configured application protocol values + String[] applicationProtocols = new String[0]; + + // Negotiated application protocol value. + // + // The value under negotiation will be obtained from handshaker. + String applicationProtocol = null; + + // Callback function that selects the application protocol value during + // the SSL/TLS handshake. + BiFunction, String> applicationProtocolSelector; + /* * READ ME * READ ME * READ ME * READ ME * READ ME * READ ME * * IMPORTANT STUFF TO UNDERSTANDING THE SYNCHRONIZATION ISSUES. @@ -506,7 +519,8 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl { String identificationProtocol, AlgorithmConstraints algorithmConstraints, Collection sniMatchers, - boolean preferLocalCipherSuites) throws IOException { + boolean preferLocalCipherSuites, + String[] applicationProtocols) throws IOException { super(); doClientAuth = clientAuth; @@ -515,6 +529,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl { this.algorithmConstraints = algorithmConstraints; this.sniMatchers = sniMatchers; this.preferLocalCipherSuites = preferLocalCipherSuites; + this.applicationProtocols = applicationProtocols; init(context, serverMode); /* @@ -595,7 +610,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl { */ private void init(SSLContextImpl context, boolean isServer) { sslContext = context; - sess = SSLSessionImpl.nullSession; + sess = new SSLSessionImpl(); handshakeSession = null; /* @@ -1078,6 +1093,9 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl { handshaker.isSecureRenegotiation(); clientVerifyData = handshaker.getClientVerifyData(); serverVerifyData = handshaker.getServerVerifyData(); + // set connection ALPN value + applicationProtocol = + handshaker.getHandshakeApplicationProtocol(); sess = handshaker.getSession(); handshakeSession = null; @@ -1329,6 +1347,9 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl { } handshaker.setEnabledCipherSuites(enabledCipherSuites); handshaker.setEnableSessionCreation(enableSessionCreation); + handshaker.setApplicationProtocols(applicationProtocols); + handshaker.setApplicationProtocolSelectorSSLSocket( + applicationProtocolSelector); } /** @@ -2617,6 +2638,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl { } params.setUseCipherSuitesOrder(preferLocalCipherSuites); + params.setApplicationProtocols(applicationProtocols); return params; } @@ -2645,9 +2667,12 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl { sniMatchers = matchers; } + applicationProtocols = params.getApplicationProtocols(); + if ((handshaker != null) && !handshaker.started()) { handshaker.setIdentificationProtocol(identificationProtocol); handshaker.setAlgorithmConstraints(algorithmConstraints); + handshaker.setApplicationProtocols(applicationProtocols); if (roleIsServer) { handshaker.setSNIMatchers(sniMatchers); handshaker.setUseCipherSuitesOrder(preferLocalCipherSuites); @@ -2657,6 +2682,34 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl { } } + @Override + public synchronized String getApplicationProtocol() { + return applicationProtocol; + } + + @Override + public synchronized String getHandshakeApplicationProtocol() { + if ((handshaker != null) && handshaker.started()) { + return handshaker.getHandshakeApplicationProtocol(); + } + return null; + } + + @Override + public synchronized void setHandshakeApplicationProtocolSelector( + BiFunction, String> selector) { + applicationProtocolSelector = selector; + if ((handshaker != null) && !handshaker.activated()) { + handshaker.setApplicationProtocolSelectorSSLSocket(selector); + } + } + + @Override + public synchronized BiFunction, String> + getHandshakeApplicationProtocolSelector() { + return this.applicationProtocolSelector; + } + // // We allocate a separate thread to deliver handshake completion // events. This ensures that the notifications don't block the diff --git a/src/share/classes/sun/security/ssl/ServerHandshaker.java b/src/share/classes/sun/security/ssl/ServerHandshaker.java index bc2431e93519c1305f6ffb25ee24735198507abc..acc2a7836fefec25332cf6546aab27c693c09c86 100644 --- a/src/share/classes/sun/security/ssl/ServerHandshaker.java +++ b/src/share/classes/sun/security/ssl/ServerHandshaker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. * 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 @@ import java.security.cert.*; import java.security.interfaces.*; import java.security.spec.ECParameterSpec; import java.math.BigInteger; +import java.util.function.BiFunction; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; @@ -508,6 +509,44 @@ final class ServerHandshaker extends Handshaker { } } + // check the ALPN extension + ALPNExtension clientHelloALPN = (ALPNExtension) + mesg.extensions.get(ExtensionType.EXT_ALPN); + + // Use the application protocol callback when provided. + // Otherwise use the local list of application protocols. + boolean hasAPCallback = + ((engine != null && appProtocolSelectorSSLEngine != null) || + (conn != null && appProtocolSelectorSSLSocket != null)); + + if (!hasAPCallback) { + if ((clientHelloALPN != null) && (localApl.length > 0)) { + + // Intersect the requested and the locally supported, + // and save for later. + String negotiatedValue = null; + List protocols = clientHelloALPN.getPeerAPs(); + + // Use server preference order + for (String ap : localApl) { + if (protocols.contains(ap)) { + negotiatedValue = ap; + break; + } + } + + if (negotiatedValue == null) { + fatalSE(Alerts.alert_no_application_protocol, + new SSLHandshakeException( + "No matching ALPN values")); + } + applicationProtocol = negotiatedValue; + + } else { + applicationProtocol = ""; + } + } // Otherwise, applicationProtocol will be set by the callback. + /* * Always make sure this entire record has been digested before we * start emitting output, to ensure correct digesting order. @@ -705,7 +744,7 @@ final class ServerHandshaker extends Handshaker { String sessionIdentityAlg = previous.getEndpointIdentificationAlgorithm(); - if (!Objects.equals(identityAlg, sessionIdentityAlg)) { + if (!identityAlg.equalsIgnoreCase(sessionIdentityAlg)) { if (debug != null && Debug.isOn("session")) { System.out.println("%% can't resume, endpoint id" @@ -858,6 +897,39 @@ final class ServerHandshaker extends Handshaker { m1.extensions.add(new ExtendedMasterSecretExtension()); } + // Prepare the ALPN response + if (clientHelloALPN != null) { + List peerAPs = clientHelloALPN.getPeerAPs(); + + // check for a callback function + if (hasAPCallback) { + if (conn != null) { + applicationProtocol = + appProtocolSelectorSSLSocket.apply(conn, peerAPs); + } else { + applicationProtocol = + appProtocolSelectorSSLEngine.apply(engine, peerAPs); + } + } + + // check for no-match and that the selected name was also proposed + // by the TLS peer + if (applicationProtocol == null || + (!applicationProtocol.isEmpty() && + !peerAPs.contains(applicationProtocol))) { + + fatalSE(Alerts.alert_no_application_protocol, + new SSLHandshakeException( + "No matching ALPN values")); + + } else if (!applicationProtocol.isEmpty()) { + m1.extensions.add(new ALPNExtension(applicationProtocol)); + } + } else { + // Nothing was negotiated, returned at end of the handshake + applicationProtocol = ""; + } + if (debug != null && Debug.isOn("handshake")) { m1.print(System.out); System.out.println("Cipher suite: " + session.getSuite()); diff --git a/src/share/classes/sun/security/ssl/SunJSSE.java b/src/share/classes/sun/security/ssl/SunJSSE.java index 63119dd14d3c7ea1c2625fa61086e5aee4f6f96b..11e2fcc838d737125901c40e63c912bbe85c692e 100644 --- a/src/share/classes/sun/security/ssl/SunJSSE.java +++ b/src/share/classes/sun/security/ssl/SunJSSE.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -160,12 +160,12 @@ public abstract class SunJSSE extends java.security.Provider { private void doRegister(boolean isfips) { if (isfips == false) { put("KeyFactory.RSA", - "sun.security.rsa.RSAKeyFactory"); + "sun.security.rsa.RSAKeyFactory$Legacy"); put("Alg.Alias.KeyFactory.1.2.840.113549.1.1", "RSA"); put("Alg.Alias.KeyFactory.OID.1.2.840.113549.1.1", "RSA"); put("KeyPairGenerator.RSA", - "sun.security.rsa.RSAKeyPairGenerator"); + "sun.security.rsa.RSAKeyPairGenerator$Legacy"); put("Alg.Alias.KeyPairGenerator.1.2.840.113549.1.1", "RSA"); put("Alg.Alias.KeyPairGenerator.OID.1.2.840.113549.1.1", "RSA"); diff --git a/src/share/classes/sun/security/tools/keytool/CertAndKeyGen.java b/src/share/classes/sun/security/tools/keytool/CertAndKeyGen.java index a8a748cdb1493ab3cbea1fd4dde686a711b696e1..a218f639eb3e44dc898b5e512c7fb98d0374c9bb 100644 --- a/src/share/classes/sun/security/tools/keytool/CertAndKeyGen.java +++ b/src/share/classes/sun/security/tools/keytool/CertAndKeyGen.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. * 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.X509Certificate; 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. @@ -250,12 +250,14 @@ public final class CertAndKeyGen { 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); @@ -265,13 +267,19 @@ public final class CertAndKeyGen { 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()); } } @@ -297,6 +305,7 @@ public final class CertAndKeyGen { * @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/share/classes/sun/security/tools/keytool/Main.java b/src/share/classes/sun/security/tools/keytool/Main.java index 005a54070d202243f30f98fa829a7f56d5d3922e..955c5b6fa74dabb69d4538808d364ea91486ce31 100644 --- a/src/share/classes/sun/security/tools/keytool/Main.java +++ b/src/share/classes/sun/security/tools/keytool/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * 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,6 +50,7 @@ import java.security.cert.CertStoreException; import java.security.cert.CRL; import java.security.cert.X509Certificate; import java.security.cert.CertificateException; +import java.security.spec.AlgorithmParameterSpec; import java.text.Collator; import java.text.MessageFormat; import java.util.*; @@ -77,6 +78,7 @@ import sun.security.provider.X509Factory; import sun.security.provider.certpath.CertStoreHelper; 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; @@ -1293,17 +1295,20 @@ public final class Main { sigAlgName = getCompatibleSigAlgName(privateKey.getAlgorithm()); } 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)); @@ -1347,7 +1352,7 @@ public final class Main { 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) { @@ -1449,7 +1454,10 @@ public final class Main { } 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); @@ -1705,6 +1713,8 @@ public final class Main { keysize = SecurityProviderConstants.DEF_EC_KEY_SIZE; } else if ("RSA".equalsIgnoreCase(keyAlgName)) { keysize = SecurityProviderConstants.DEF_RSA_KEY_SIZE; + } else if ("RSASSA-PSS".equalsIgnoreCase(keyAlgName)) { + keysize = SecurityProviderConstants.DEF_RSASSA_PSS_KEY_SIZE; } else if ("DSA".equalsIgnoreCase(keyAlgName)) { keysize = SecurityProviderConstants.DEF_DSA_KEY_SIZE; } @@ -2236,9 +2246,9 @@ public final class Main { out.println(form.format(source)); out.println(); - for (Enumeration e = keyStore.aliases(); - e.hasMoreElements(); ) { - String alias = e.nextElement(); + List aliases = Collections.list(keyStore.aliases()); + aliases.sort(String::compareTo); + for (String alias : aliases) { doPrintEntry("<" + alias + ">", alias, out); if (verbose || rfc) { out.println(rb.getString("NEWLINE")); @@ -2742,7 +2752,9 @@ public final class Main { // 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); @@ -2759,7 +2771,7 @@ public final class Main { 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, @@ -3331,6 +3343,11 @@ public final class Main { { Key key = null; + if (KeyStoreUtil.isWindowsKeyStore(storetype)) { + key = keyStore.getKey(alias, null); + return Pair.of(key, null); + } + if (keyStore.containsAlias(alias) == false) { MessageFormat form = new MessageFormat (rb.getString("Alias.alias.does.not.exist")); diff --git a/src/share/classes/sun/security/util/DerInputBuffer.java b/src/share/classes/sun/security/util/DerInputBuffer.java index 54eade390441ec8576ccf60ff31f776b5077ccd7..a5cf8fdaafc45072a7af0b241028ed09e4e627b4 100644 --- a/src/share/classes/sun/security/util/DerInputBuffer.java +++ b/src/share/classes/sun/security/util/DerInputBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. * 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,7 +27,6 @@ package sun.security.util; import java.io.ByteArrayInputStream; import java.io.IOException; -import java.io.OutputStream; import java.math.BigInteger; import java.util.Date; import sun.util.calendar.CalendarDate; @@ -275,7 +274,7 @@ class DerInputBuffer extends ByteArrayInputStream implements Cloneable { if (len > available()) throw new IOException("short read of DER Generalized Time"); - if (len < 13 || len > 23) + if (len < 13) throw new IOException("DER Generalized Time length error"); return getTime(len, true); @@ -313,15 +312,15 @@ class DerInputBuffer extends ByteArrayInputStream implements Cloneable { if (generalized) { type = "Generalized"; - year = 1000 * Character.digit((char)buf[pos++], 10); - year += 100 * Character.digit((char)buf[pos++], 10); - year += 10 * Character.digit((char)buf[pos++], 10); - year += Character.digit((char)buf[pos++], 10); + year = 1000 * toDigit(buf[pos++], type); + year += 100 * toDigit(buf[pos++], type); + year += 10 * toDigit(buf[pos++], type); + year += toDigit(buf[pos++], type); len -= 2; // For the two extra YY } else { type = "UTC"; - year = 10 * Character.digit((char)buf[pos++], 10); - year += Character.digit((char)buf[pos++], 10); + year = 10 * toDigit(buf[pos++], type); + year += toDigit(buf[pos++], type); if (year < 50) // origin 2000 year += 2000; @@ -329,17 +328,17 @@ class DerInputBuffer extends ByteArrayInputStream implements Cloneable { year += 1900; // origin 1900 } - month = 10 * Character.digit((char)buf[pos++], 10); - month += Character.digit((char)buf[pos++], 10); + month = 10 * toDigit(buf[pos++], type); + month += toDigit(buf[pos++], type); - day = 10 * Character.digit((char)buf[pos++], 10); - day += Character.digit((char)buf[pos++], 10); + day = 10 * toDigit(buf[pos++], type); + day += toDigit(buf[pos++], type); - hour = 10 * Character.digit((char)buf[pos++], 10); - hour += Character.digit((char)buf[pos++], 10); + hour = 10 * toDigit(buf[pos++], type); + hour += toDigit(buf[pos++], type); - minute = 10 * Character.digit((char)buf[pos++], 10); - minute += Character.digit((char)buf[pos++], 10); + minute = 10 * toDigit(buf[pos++], type); + minute += toDigit(buf[pos++], type); len -= 10; // YYMMDDhhmm @@ -350,41 +349,48 @@ class DerInputBuffer extends ByteArrayInputStream implements Cloneable { */ millis = 0; - if (len > 2 && len < 12) { - second = 10 * Character.digit((char)buf[pos++], 10); - second += Character.digit((char)buf[pos++], 10); + if (len > 2) { + second = 10 * toDigit(buf[pos++], type); + second += toDigit(buf[pos++], type); len -= 2; // handle fractional seconds (if present) - if (buf[pos] == '.' || buf[pos] == ',') { + if (generalized && (buf[pos] == '.' || buf[pos] == ',')) { len --; + if (len == 0) { + throw new IOException("Parse " + type + + " time, empty fractional part"); + } pos++; - // handle upto milisecond precision only int precision = 0; - int peek = pos; - while (buf[peek] != 'Z' && - buf[peek] != '+' && - buf[peek] != '-') { - peek++; + while (buf[pos] != 'Z' && + buf[pos] != '+' && + buf[pos] != '-') { + // Validate all digits in the fractional part but + // store millisecond precision only + int thisDigit = toDigit(buf[pos], type); precision++; - } - switch (precision) { - case 3: - millis += 100 * Character.digit((char)buf[pos++], 10); - millis += 10 * Character.digit((char)buf[pos++], 10); - millis += Character.digit((char)buf[pos++], 10); - break; - case 2: - millis += 100 * Character.digit((char)buf[pos++], 10); - millis += 10 * Character.digit((char)buf[pos++], 10); - break; - case 1: - millis += 100 * Character.digit((char)buf[pos++], 10); - break; - default: + len--; + if (len == 0) { throw new IOException("Parse " + type + - " time, unsupported precision for seconds value"); + " time, invalid fractional part"); + } + pos++; + switch (precision) { + case 1: + millis += 100 * thisDigit; + break; + case 2: + millis += 10 * thisDigit; + break; + case 3: + millis += thisDigit; + break; + } + } + if (precision == 0) { + throw new IOException("Parse " + type + + " time, empty fractional part"); } - len -= precision; } } else second = 0; @@ -414,10 +420,13 @@ class DerInputBuffer extends ByteArrayInputStream implements Cloneable { switch (buf[pos++]) { case '+': - hr = 10 * Character.digit((char)buf[pos++], 10); - hr += Character.digit((char)buf[pos++], 10); - min = 10 * Character.digit((char)buf[pos++], 10); - min += Character.digit((char)buf[pos++], 10); + if (len != 5) { + throw new IOException("Parse " + type + " time, invalid offset"); + } + hr = 10 * toDigit(buf[pos++], type); + hr += toDigit(buf[pos++], type); + min = 10 * toDigit(buf[pos++], type); + min += toDigit(buf[pos++], type); if (hr >= 24 || min >= 60) throw new IOException("Parse " + type + " time, +hhmm"); @@ -426,10 +435,13 @@ class DerInputBuffer extends ByteArrayInputStream implements Cloneable { break; case '-': - hr = 10 * Character.digit((char)buf[pos++], 10); - hr += Character.digit((char)buf[pos++], 10); - min = 10 * Character.digit((char)buf[pos++], 10); - min += Character.digit((char)buf[pos++], 10); + if (len != 5) { + throw new IOException("Parse " + type + " time, invalid offset"); + } + hr = 10 * toDigit(buf[pos++], type); + hr += toDigit(buf[pos++], type); + min = 10 * toDigit(buf[pos++], type); + min += toDigit(buf[pos++], type); if (hr >= 24 || min >= 60) throw new IOException("Parse " + type + " time, -hhmm"); @@ -438,6 +450,9 @@ class DerInputBuffer extends ByteArrayInputStream implements Cloneable { break; case 'Z': + if (len != 1) { + throw new IOException("Parse " + type + " time, invalid format"); + } break; default: @@ -445,4 +460,16 @@ class DerInputBuffer extends ByteArrayInputStream implements Cloneable { } return new Date(time); } + + /** + * Converts byte (represented as a char) to int. + * @throws IOException if integer is not a valid digit in the specified + * radix (10) + */ + private static int toDigit(byte b, String type) throws IOException { + if (b < '0' || b > '9') { + throw new IOException("Parse " + type + " time, invalid format"); + } + return b - '0'; + } } diff --git a/src/share/classes/sun/security/util/DerInputStream.java b/src/share/classes/sun/security/util/DerInputStream.java index f513c93c4a3c85670ef43a28e37de296fc6895a4..ad5d6da273f0067f16ac975a3e86631d045efc69 100644 --- a/src/share/classes/sun/security/util/DerInputStream.java +++ b/src/share/classes/sun/security/util/DerInputStream.java @@ -191,7 +191,7 @@ public class DerInputStream { if (buffer.read() != DerValue.tag_Integer) { throw new IOException("DER input, Integer tag error"); } - return buffer.getInteger(getLength(buffer)); + return buffer.getInteger(getDefiniteLength(buffer)); } /** @@ -203,7 +203,7 @@ public class DerInputStream { if (buffer.read() != DerValue.tag_Integer) { throw new IOException("DER input, Integer tag error"); } - return buffer.getBigInteger(getLength(buffer), false); + return buffer.getBigInteger(getDefiniteLength(buffer), false); } /** @@ -217,7 +217,7 @@ public class DerInputStream { if (buffer.read() != DerValue.tag_Integer) { throw new IOException("DER input, Integer tag error"); } - return buffer.getBigInteger(getLength(buffer), true); + return buffer.getBigInteger(getDefiniteLength(buffer), true); } /** @@ -229,7 +229,7 @@ public class DerInputStream { if (buffer.read() != DerValue.tag_Enumerated) { throw new IOException("DER input, Enumerated tag error"); } - return buffer.getInteger(getLength(buffer)); + return buffer.getInteger(getDefiniteLength(buffer)); } /** @@ -240,7 +240,7 @@ public class DerInputStream { if (buffer.read() != DerValue.tag_BitString) throw new IOException("DER input not an bit string"); - return buffer.getBitString(getLength(buffer)); + return buffer.getBitString(getDefiniteLength(buffer)); } /** @@ -248,15 +248,21 @@ public class DerInputStream { * not be byte-aligned. */ public BitArray getUnalignedBitString() throws IOException { - if (buffer.read() != DerValue.tag_BitString) + if (buffer.read() != DerValue.tag_BitString) { throw new IOException("DER input not a bit string"); + } + + int length = getDefiniteLength(buffer); - int length = getLength(buffer) - 1; + if (length == 0) { + return new BitArray(0); + } /* * First byte = number of excess bits in the last octet of the * representation. */ + length--; int excessBits = buffer.read(); if (excessBits < 0) { throw new IOException("Unused bits of bit string invalid"); @@ -282,7 +288,7 @@ public class DerInputStream { if (buffer.read() != DerValue.tag_OctetString) throw new IOException("DER input not an octet string"); - int length = getLength(buffer); + int length = getDefiniteLength(buffer); byte[] retval = new byte[length]; if ((length != 0) && (buffer.read(retval) != length)) throw new IOException("Short read of DER octet string"); @@ -397,7 +403,7 @@ public class DerInputStream { if (tag != buffer.read()) throw new IOException("Indefinite length encoding" + " not supported"); - len = DerInputStream.getLength(buffer); + len = DerInputStream.getDefiniteLength(buffer); } if (len == 0) @@ -514,7 +520,7 @@ public class DerInputStream { throw new IOException("DER input not a " + stringName + " string"); - int length = getLength(buffer); + int length = getDefiniteLength(buffer); byte[] retval = new byte[length]; if ((length != 0) && (buffer.read(retval) != length)) throw new IOException("Short read of DER " + @@ -529,7 +535,7 @@ public class DerInputStream { public Date getUTCTime() throws IOException { if (buffer.read() != DerValue.tag_UtcTime) throw new IOException("DER input, UTCtime tag invalid "); - return buffer.getUTCTime(getLength(buffer)); + return buffer.getUTCTime(getDefiniteLength(buffer)); } /** @@ -538,7 +544,7 @@ public class DerInputStream { public Date getGeneralizedTime() throws IOException { if (buffer.read() != DerValue.tag_GeneralizedTime) throw new IOException("DER input, GeneralizedTime tag invalid "); - return buffer.getGeneralizedTime(getLength(buffer)); + return buffer.getGeneralizedTime(getDefiniteLength(buffer)); } /* @@ -618,6 +624,24 @@ public class DerInputStream { return value; } + int getDefiniteLength() throws IOException { + return getDefiniteLength(buffer); + } + + /* + * Get a length from the input stream. + * + * @return the length + * @exception IOException on parsing error or if indefinite length found. + */ + static int getDefiniteLength(InputStream in) throws IOException { + int len = getLength(in); + if (len < 0) { + throw new IOException("Indefinite length encoding not supported"); + } + return len; + } + /** * Mark the current position in the buffer, so that * a later call to reset will return here. diff --git a/src/share/classes/sun/security/util/DerValue.java b/src/share/classes/sun/security/util/DerValue.java index 9372537375a5010de84d82a4ea7e55e3b84b09ad..3950dfd95a82db1b74a769b30b2343c46963d0ba 100644 --- a/src/share/classes/sun/security/util/DerValue.java +++ b/src/share/classes/sun/security/util/DerValue.java @@ -271,7 +271,7 @@ public class DerValue { if (tag != inbuf.read()) throw new IOException ("Indefinite length encoding not supported"); - length = DerInputStream.getLength(inbuf); + length = DerInputStream.getDefiniteLength(inbuf); buffer = inbuf.dup(); buffer.truncate(length); data = new DerInputStream(buffer); @@ -403,7 +403,7 @@ public class DerValue { if (tag != in.read()) throw new IOException ("Indefinite length encoding not supported"); - length = DerInputStream.getLength(in); + length = DerInputStream.getDefiniteLength(in); } if (fullyBuffered && in.available() != length) @@ -779,19 +779,6 @@ public class DerValue { return buffer.getGeneralizedTime(data.available()); } - /** - * Returns true iff the other object is a DER value which - * is bitwise equal to this one. - * - * @param other the object being compared with this one - */ - public boolean equals(Object other) { - if (other instanceof DerValue) - return equals((DerValue)other); - else - return false; - } - /** * Bitwise equality comparison. DER encoded values have a single * encoding, so that bitwise equality of the encoded values is an @@ -799,10 +786,15 @@ public class DerValue { * * @param other the object being compared with this one */ - public boolean equals(DerValue other) { - if (this == other) { + @Override + public boolean equals(Object o) { + if (this == o) { return true; } + if (!(o instanceof DerValue)) { + return false; + } + DerValue other = (DerValue) o; if (tag != other.tag) { return false; } @@ -835,6 +827,7 @@ public class DerValue { * * @return printable representation of the value */ + @Override public String toString() { try { @@ -962,6 +955,7 @@ public class DerValue { * * @return a hashcode for this DerValue. */ + @Override public int hashCode() { return toString().hashCode(); } diff --git a/src/share/classes/sun/security/util/ECUtil.java b/src/share/classes/sun/security/util/ECUtil.java index fac103421a3de7aa6724e141ff7913f9aa792163..fafb81c02fc5a5e23ea34d59ac2abd4f3b11d583 100644 --- a/src/share/classes/sun/security/util/ECUtil.java +++ b/src/share/classes/sun/security/util/ECUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ import java.util.Arrays; import sun.security.x509.X509Key; -public class ECUtil { +public final class ECUtil { // Used by SunPKCS11 and SunJSSE. public static ECPoint decodePoint(byte[] data, EllipticCurve curve) @@ -186,5 +186,78 @@ public class ECUtil { return nameSpec.getName(); } + public static boolean equals(ECParameterSpec spec1, ECParameterSpec spec2) { + if (spec1 == spec2) { + return true; + } + + if (spec1 == null || spec2 == null) { + return false; + } + return (spec1.getCofactor() == spec2.getCofactor() && + spec1.getOrder().equals(spec2.getOrder()) && + spec1.getCurve().equals(spec2.getCurve()) && + spec1.getGenerator().equals(spec2.getGenerator())); + } + + // Convert the concatenation R and S in into their DER encoding + public static byte[] encodeSignature(byte[] signature) throws SignatureException { + + try { + + int n = signature.length >> 1; + byte[] bytes = new byte[n]; + System.arraycopy(signature, 0, bytes, 0, n); + BigInteger r = new BigInteger(1, bytes); + System.arraycopy(signature, n, bytes, 0, n); + BigInteger s = new BigInteger(1, bytes); + + DerOutputStream out = new DerOutputStream(signature.length + 10); + out.putInteger(r); + out.putInteger(s); + DerValue result = + new DerValue(DerValue.tag_Sequence, out.toByteArray()); + + return result.toByteArray(); + + } catch (Exception e) { + throw new SignatureException("Could not encode signature", e); + } + } + + // Convert the DER encoding of R and S into a concatenation of R and S + public static byte[] decodeSignature(byte[] sig) throws SignatureException { + + try { + // Enforce strict DER checking for signatures + DerInputStream in = new DerInputStream(sig, 0, sig.length, false); + DerValue[] values = in.getSequence(2); + + // check number of components in the read sequence + // and trailing data + if ((values.length != 2) || (in.available() != 0)) { + throw new IOException("Invalid encoding for signature"); + } + + BigInteger r = values[0].getPositiveBigInteger(); + BigInteger s = values[1].getPositiveBigInteger(); + + // trim leading zeroes + byte[] rBytes = trimZeroes(r.toByteArray()); + byte[] sBytes = trimZeroes(s.toByteArray()); + int k = Math.max(rBytes.length, sBytes.length); + // r and s each occupy half the array + byte[] result = new byte[k << 1]; + System.arraycopy(rBytes, 0, result, k - rBytes.length, + rBytes.length); + System.arraycopy(sBytes, 0, result, result.length - sBytes.length, + sBytes.length); + return result; + + } catch (Exception e) { + throw new SignatureException("Invalid encoding for signature", e); + } + } + private ECUtil() {} } diff --git a/src/share/classes/sun/security/util/HostnameChecker.java b/src/share/classes/sun/security/util/HostnameChecker.java index 89712ddd9990fa17211fc5393f6aa1569fab2fe3..230b67d3b540e585d53c1be0a48c93ee238854fd 100644 --- a/src/share/classes/sun/security/util/HostnameChecker.java +++ b/src/share/classes/sun/security/util/HostnameChecker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * 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 @@ import java.util.*; import java.security.Principal; import java.security.cert.*; +import java.text.Normalizer; import javax.security.auth.x500.X500Principal; import javax.net.ssl.SNIHostName; @@ -220,7 +221,12 @@ public class HostnameChecker { (X500Name.commonName_oid); if (derValue != null) { try { - if (isMatched(expectedName, derValue.getAsString())) { + String cname = derValue.getAsString(); + if (!Normalizer.isNormalized(cname, Normalizer.Form.NFKC)) { + throw new CertificateException("Not a formal name " + + cname); + } + if (isMatched(expectedName, cname)) { return; } } catch (IOException e) { diff --git a/src/share/classes/sun/security/util/ObjectIdentifier.java b/src/share/classes/sun/security/util/ObjectIdentifier.java index cfa50b616650d6dabeda0270f885524786b796ec..862fd53b70fa1e9b2d9eb3af3103fa3dc74421e6 100644 --- a/src/share/classes/sun/security/util/ObjectIdentifier.java +++ b/src/share/classes/sun/security/util/ObjectIdentifier.java @@ -53,6 +53,26 @@ import java.util.Arrays; final public class ObjectIdentifier implements Serializable { + /* + * The maximum encoded OID length, excluding the ASN.1 encoding tag and + * length. + * + * In theory, there is no maximum size for OIDs. However, there are some + * limitation in practice. + * + * RFC 5280 mandates support for OIDs that have arc elements with values + * that are less than 2^28 (that is, they MUST be between 0 and + * 268,435,455, inclusive), and implementations MUST be able to handle + * OIDs with up to 20 elements (inclusive). Per RFC 5280, an encoded + * OID should be less than 80 bytes for safe interoperability. + * + * This class could be used for protocols other than X.509 certificates. + * To be safe, a relatively large but still reasonable value is chosen + * as the restriction in JDK. + */ + private static final int MAXIMUM_OID_SIZE = 4096; // 2^12 + + /** * We use the DER value (no tag, no length) as the internal format * @serial @@ -115,7 +135,13 @@ class ObjectIdentifier implements Serializable if (componentLen > comp.length) { componentLen = comp.length; } + + // Check the estimated size before it is too later. + checkOidSize(componentLen); + init(comp, componentLen); + } else { + checkOidSize(encoding.length); } } @@ -198,6 +224,8 @@ class ObjectIdentifier implements Serializable } start = end + 1; count++; + + checkOidSize(pos); } while (end != -1); checkCount(count); @@ -259,12 +287,14 @@ class ObjectIdentifier implements Serializable + " (tag = " + type_id + ")" ); - int len = in.getLength(); + int len = in.getDefiniteLength(); + checkOidSize(len); if (len > in.available()) { - throw new IOException("ObjectIdentifier() -- length exceeds" + + throw new IOException("ObjectIdentifier length exceeds " + "data available. Length: " + len + ", Available: " + in.available()); } + encoding = new byte[len]; in.getBytes(encoding); check(encoding); @@ -278,26 +308,32 @@ class ObjectIdentifier implements Serializable ObjectIdentifier (DerInputBuffer buf) throws IOException { DerInputStream in = new DerInputStream(buf); - encoding = new byte[in.available()]; + int len = in.available(); + checkOidSize(len); + + encoding = new byte[len]; in.getBytes(encoding); check(encoding); } - private void init(int[] components, int length) { + private void init(int[] components, int length) throws IOException { int pos = 0; - byte[] tmp = new byte[length*5+1]; // +1 for empty input + byte[] tmp = new byte[length * 5 + 1]; // +1 for empty input - if (components[1] < Integer.MAX_VALUE - components[0]*40) - pos += pack7Oid(components[0]*40+components[1], tmp, pos); - else { + if (components[1] < Integer.MAX_VALUE - components[0] * 40) { + pos += pack7Oid(components[0] * 40 + components[1], tmp, pos); + } else { BigInteger big = BigInteger.valueOf(components[1]); - big = big.add(BigInteger.valueOf(components[0]*40)); + big = big.add(BigInteger.valueOf(components[0] * 40)); pos += pack7Oid(big, tmp, pos); } - for (int i=2; i MAXIMUM_OID_SIZE) { + throw new IOException( + "ObjectIdentifier encoded length exceeds " + + "the restriction in JDK (OId length(>=): " + oidLength + + ", Restriction: " + MAXIMUM_OID_SIZE + ")"); + } + } } diff --git a/src/share/classes/sun/security/util/SecurityProviderConstants.java b/src/share/classes/sun/security/util/SecurityProviderConstants.java index 2631558c9e7545ed43d7f1f36c78c1a218653c41..b9d0d26a21bb16af1d6e75e05175d6b30d353468 100644 --- a/src/share/classes/sun/security/util/SecurityProviderConstants.java +++ b/src/share/classes/sun/security/util/SecurityProviderConstants.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ public final class SecurityProviderConstants { public static final int DEF_DSA_KEY_SIZE; public static final int DEF_RSA_KEY_SIZE; + public static final int DEF_RSASSA_PSS_KEY_SIZE; public static final int DEF_DH_KEY_SIZE; public static final int DEF_EC_KEY_SIZE; @@ -66,6 +67,7 @@ public final class SecurityProviderConstants { (KEY_LENGTH_PROP); int dsaKeySize = 2048; int rsaKeySize = 2048; + int rsaSsaPssKeySize = rsaKeySize; // default to same value as RSA int dhKeySize = 2048; int ecKeySize = 256; @@ -98,6 +100,8 @@ public final class SecurityProviderConstants { dsaKeySize = value; } else if (algoName.equals("RSA")) { rsaKeySize = value; + } else if (algoName.equals("RSASSA-PSS")) { + rsaSsaPssKeySize = value; } else if (algoName.equals("DH")) { dhKeySize = value; } else if (algoName.equals("EC")) { @@ -125,6 +129,7 @@ public final class SecurityProviderConstants { } DEF_DSA_KEY_SIZE = dsaKeySize; DEF_RSA_KEY_SIZE = rsaKeySize; + DEF_RSASSA_PSS_KEY_SIZE = rsaSsaPssKeySize; DEF_DH_KEY_SIZE = dhKeySize; DEF_EC_KEY_SIZE = ecKeySize; } diff --git a/src/share/classes/sun/security/util/SignatureUtil.java b/src/share/classes/sun/security/util/SignatureUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..9516a62c7a92b5ff995379778f6eb4e5a4cfd94a --- /dev/null +++ b/src/share/classes/sun/security/util/SignatureUtil.java @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * 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.IOException; +import java.security.*; +import java.security.spec.*; +import java.util.Locale; +import sun.security.rsa.RSAUtil; +import sun.misc.SharedSecrets; + +/** + * Utility class for Signature related operations. Currently used by various + * internal PKI classes such as sun.security.x509.X509CertImpl, + * sun.security.pkcs.SignerInfo, for setting signature parameters. + * + * @since 8 + */ +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); + return result; + } catch (NoSuchAlgorithmException | IOException e) { + throw new ProviderException(e); + } + } + + // Utility method for converting the specified AlgorithmParameters object + // into an AlgorithmParameterSpec object. + public static AlgorithmParameterSpec getParamSpec(String sigName, + AlgorithmParameters params) + throws ProviderException { + + sigName = checkName(sigName).toUpperCase(Locale.ENGLISH); + AlgorithmParameterSpec paramSpec = null; + if (params != null) { + // 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); + } + } + + if (sigName.indexOf("RSA") != -1) { + paramSpec = RSAUtil.getParamSpec(params); + } else if (sigName.indexOf("ECDSA") != -1) { + try { + paramSpec = params.getParameterSpec(ECParameterSpec.class); + } catch (Exception e) { + throw new ProviderException("Error handling EC parameters", e); + } + } else { + throw new ProviderException + ("Unrecognized algorithm for signature parameters " + + sigName); + } + } + return paramSpec; + } + + // 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).toUpperCase(Locale.ENGLISH); + AlgorithmParameterSpec paramSpec = null; + + if (paramBytes != null) { + if (sigName.indexOf("RSA") != -1) { + AlgorithmParameters params = + createAlgorithmParameters(sigName, paramBytes); + paramSpec = RSAUtil.getParamSpec(params); + } else if (sigName.indexOf("ECDSA") != -1) { + try { + Provider p = Signature.getInstance(sigName).getProvider(); + paramSpec = ECUtil.getECParameterSpec(p, paramBytes); + } catch (Exception e) { + throw new ProviderException("Error handling EC parameters", e); + } + // ECUtil discards exception and returns null, so we need to check + // the returned value + if (paramSpec == null) { + throw new ProviderException("Error handling EC parameters"); + } + } else { + throw new ProviderException + ("Unrecognized algorithm for signature parameters " + + sigName); + } + } + return paramSpec; + } + + // 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); + } + + // 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/share/classes/sun/security/x509/AlgorithmId.java b/src/share/classes/sun/security/x509/AlgorithmId.java index 44eda75d1b302ed8404257d844090e7386a48a4b..339b9099728794f24d39192b928ef2fe1dabfe2c 100644 --- a/src/share/classes/sun/security/x509/AlgorithmId.java +++ b/src/share/classes/sun/security/x509/AlgorithmId.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. * 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.*; @@ -182,13 +187,20 @@ public class AlgorithmId implements Serializable, DerEncoder { algid.equals((Object)SHA256_oid) || algid.equals((Object)SHA384_oid) || algid.equals((Object)SHA512_oid) || + algid.equals((Object)SHA512_224_oid) || + algid.equals((Object)SHA512_256_oid) || algid.equals((Object)DSA_oid) || algid.equals((Object)sha1WithDSA_oid)) { ; // no parameter part encoded } 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); } @@ -224,6 +236,9 @@ public class AlgorithmId implements Serializable, DerEncoder { * return a name such as "MD5withRSA" for a signature algorithm on * some systems. It also returns names like "OID.1.2.3.4", when * no particular name for the algorithm is known. + * + * Note: for ecdsa-with-SHA2 plus hash algorithm (Ex: SHA-256), this method + * returns the "full" signature algorithm (Ex: SHA256withECDSA) directly. */ public String getName() { String algName = nameTable.get(algid); @@ -233,7 +248,7 @@ public class AlgorithmId implements Serializable, DerEncoder { if ((params != null) && algid.equals((Object)specifiedWithECDSA_oid)) { try { AlgorithmId paramsId = - AlgorithmId.parse(new DerValue(getEncodedParams())); + AlgorithmId.parse(new DerValue(params.toByteArray())); String paramsName = paramsId.getName(); algName = makeSigAlg(paramsName, "EC"); } catch (IOException e) { @@ -249,12 +264,18 @@ public class AlgorithmId implements Serializable, DerEncoder { /** * Returns the DER encoded parameter, which can then be - * used to initialize java.security.AlgorithmParamters. + * used to initialize java.security.AlgorithmParameters. + * + * Note: for ecdsa-with-SHA2 plus hash algorithm (Ex: SHA-256), this method + * returns null because {@link #getName()} has already returned the "full" + * signature algorithm (Ex: SHA256withECDSA). * * @return DER encoded parameters, or null not present. */ public byte[] getEncodedParams() throws IOException { - return (params == null) ? null : params.toByteArray(); + return (params == null || algid.equals(specifiedWithECDSA_oid)) + ? null + : params.toByteArray(); } /** @@ -483,11 +504,24 @@ public class AlgorithmId implements Serializable, DerEncoder { name.equalsIgnoreCase("SHA224")) { return AlgorithmId.SHA224_oid; } - + if (name.equalsIgnoreCase("SHA-512/224") || + name.equalsIgnoreCase("SHA512/224")) { + return AlgorithmId.SHA512_224_oid; + } + if (name.equalsIgnoreCase("SHA-512/256") || + name.equalsIgnoreCase("SHA512/256")) { + return AlgorithmId.SHA512_256_oid; + } // Various public key algorithms if (name.equalsIgnoreCase("RSA")) { return AlgorithmId.RSAEncryption_oid; } + if (name.equalsIgnoreCase("RSASSA-PSS")) { + return AlgorithmId.RSASSA_PSS_oid; + } + if (name.equalsIgnoreCase("RSAES-OAEP")) { + return AlgorithmId.RSAES_OAEP_oid; + } if (name.equalsIgnoreCase("Diffie-Hellman") || name.equalsIgnoreCase("DH")) { return AlgorithmId.DH_oid; @@ -645,6 +679,12 @@ public class AlgorithmId implements Serializable, DerEncoder { public static final ObjectIdentifier SHA512_oid = ObjectIdentifier.newInternal(new int[] {2, 16, 840, 1, 101, 3, 4, 2, 3}); + public static final ObjectIdentifier SHA512_224_oid = + ObjectIdentifier.newInternal(new int[] {2, 16, 840, 1, 101, 3, 4, 2, 5}); + + public static final ObjectIdentifier SHA512_256_oid = + ObjectIdentifier.newInternal(new int[] {2, 16, 840, 1, 101, 3, 4, 2, 6}); + /* * COMMON PUBLIC KEY TYPES */ @@ -653,8 +693,6 @@ public class AlgorithmId implements Serializable, DerEncoder { private static final int DSA_OIW_data[] = { 1, 3, 14, 3, 2, 12 }; private static final int DSA_PKIX_data[] = { 1, 2, 840, 10040, 4, 1 }; private static final int RSA_data[] = { 2, 5, 8, 1, 1 }; - private static final int RSAEncryption_data[] = - { 1, 2, 840, 113549, 1, 1, 1 }; public static final ObjectIdentifier DH_oid; public static final ObjectIdentifier DH_PKIX_oid; @@ -663,7 +701,14 @@ public class AlgorithmId implements Serializable, DerEncoder { public static final ObjectIdentifier EC_oid = oid(1, 2, 840, 10045, 2, 1); public static final ObjectIdentifier ECDH_oid = oid(1, 3, 132, 1, 12); public static final ObjectIdentifier RSA_oid; - public static final ObjectIdentifier RSAEncryption_oid; + public static final ObjectIdentifier RSAEncryption_oid = + 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); /* * COMMON SECRET KEY TYPES @@ -690,6 +735,7 @@ public class AlgorithmId implements Serializable, DerEncoder { { 1, 2, 840, 113549, 1, 1, 12 }; private static final int sha512WithRSAEncryption_data[] = { 1, 2, 840, 113549, 1, 1, 13 }; + private static final int shaWithDSA_OIW_data[] = { 1, 3, 14, 3, 2, 13 }; private static final int sha1WithDSA_OIW_data[] = @@ -705,6 +751,11 @@ public class AlgorithmId implements Serializable, DerEncoder { public static final ObjectIdentifier sha256WithRSAEncryption_oid; public static final ObjectIdentifier sha384WithRSAEncryption_oid; public static final ObjectIdentifier sha512WithRSAEncryption_oid; + public static final ObjectIdentifier sha512_224WithRSAEncryption_oid = + oid(1, 2, 840, 113549, 1, 1, 15); + public static final ObjectIdentifier sha512_256WithRSAEncryption_oid = + oid(1, 2, 840, 113549, 1, 1, 16);; + public static final ObjectIdentifier shaWithDSA_OIW_oid; public static final ObjectIdentifier sha1WithDSA_OIW_oid; public static final ObjectIdentifier sha1WithDSA_oid; @@ -793,13 +844,6 @@ public class AlgorithmId implements Serializable, DerEncoder { */ RSA_oid = ObjectIdentifier.newInternal(RSA_data); - /** - * Algorithm ID for RSA keys used with RSA encryption, as defined - * in PKCS #1. There are no parameters associated with this algorithm. - * OID = 1.2.840.113549.1.1.1 - */ - RSAEncryption_oid = ObjectIdentifier.newInternal(RSAEncryption_data); - /** * Identifies a signing algorithm where an MD2 digest is encrypted * using an RSA private key; defined in PKCS #1. Use of this @@ -895,6 +939,8 @@ public class AlgorithmId implements Serializable, DerEncoder { nameTable.put(SHA256_oid, "SHA-256"); nameTable.put(SHA384_oid, "SHA-384"); nameTable.put(SHA512_oid, "SHA-512"); + nameTable.put(SHA512_224_oid, "SHA-512/224"); + nameTable.put(SHA512_256_oid, "SHA-512/256"); nameTable.put(RSAEncryption_oid, "RSA"); nameTable.put(RSA_oid, "RSA"); nameTable.put(DH_oid, "Diffie-Hellman"); @@ -924,6 +970,11 @@ public class AlgorithmId implements Serializable, DerEncoder { nameTable.put(sha256WithRSAEncryption_oid, "SHA256withRSA"); nameTable.put(sha384WithRSAEncryption_oid, "SHA384withRSA"); nameTable.put(sha512WithRSAEncryption_oid, "SHA512withRSA"); + nameTable.put(sha512_224WithRSAEncryption_oid, "SHA512/224withRSA"); + nameTable.put(sha512_256WithRSAEncryption_oid, "SHA512/256withRSA"); + nameTable.put(RSASSA_PSS_oid, "RSASSA-PSS"); + nameTable.put(RSAES_OAEP_oid, "RSAES-OAEP"); + nameTable.put(pbeWithMD5AndDES_oid, "PBEWithMD5AndDES"); nameTable.put(pbeWithMD5AndRC2_oid, "PBEWithMD5AndRC2"); nameTable.put(pbeWithSHA1AndDES_oid, "PBEWithSHA1AndDES"); @@ -977,4 +1028,90 @@ public class AlgorithmId implements Serializable, DerEncoder { } return null; } + + // 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; + } + } + + // Same values for RSA and DSA (from 8056174) + private static String ifcFfcStrength(int bitLength) { + if (bitLength > 7680) { // 256 bits + return "SHA512"; + } else if (bitLength > 3072) { // 192 bits + return "SHA384"; + } else { // 128 bits and less + return "SHA256"; + } + } } diff --git a/src/share/classes/sun/security/x509/CertificateValidity.java b/src/share/classes/sun/security/x509/CertificateValidity.java index cd9b00fa235533d306662c2f77115e7f0dc3118a..bedc83294a9b073831d8470a199d321a0f2f8e2d 100644 --- a/src/share/classes/sun/security/x509/CertificateValidity.java +++ b/src/share/classes/sun/security/x509/CertificateValidity.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * 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,7 +51,10 @@ public class CertificateValidity implements CertAttrSet { public static final String NAME = "validity"; public static final String NOT_BEFORE = "notBefore"; public static final String NOT_AFTER = "notAfter"; - private static final long YR_2050 = 2524636800000L; + /** + * YR_2050 date and time set to Jan01 00:00 2050 GMT + */ + static final long YR_2050 = 2524608000000L; // Private data members private Date notBefore; diff --git a/src/share/classes/sun/security/x509/X509CRLEntryImpl.java b/src/share/classes/sun/security/x509/X509CRLEntryImpl.java index ab7270995fb3f81d96a974344536ee7d571269ed..dab41973d5c6a810f837d02aa25c5619cfbb512a 100644 --- a/src/share/classes/sun/security/x509/X509CRLEntryImpl.java +++ b/src/share/classes/sun/security/x509/X509CRLEntryImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -77,7 +77,6 @@ public class X509CRLEntryImpl extends X509CRLEntry private X500Principal certIssuer; private final static boolean isExplicit = false; - private static final long YR_2050 = 2524636800000L; /** * Constructs a revoked certificate entry using the given @@ -162,7 +161,7 @@ public class X509CRLEntryImpl extends X509CRLEntry // sequence { serialNumber, revocationDate, extensions } serialNumber.encode(tmp); - if (revocationDate.getTime() < YR_2050) { + if (revocationDate.getTime() < CertificateValidity.YR_2050) { tmp.putUTCTime(revocationDate); } else { tmp.putGeneralizedTime(revocationDate); diff --git a/src/share/classes/sun/security/x509/X509CRLImpl.java b/src/share/classes/sun/security/x509/X509CRLImpl.java index 8cb54ff984f9f39c0fdda842328e3bbe9666eaad..c5decfa8d4ad450fdfdf8dbe5e6e5c0c167491c4 100644 --- a/src/share/classes/sun/security/x509/X509CRLImpl.java +++ b/src/share/classes/sun/security/x509/X509CRLImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * 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,20 +29,12 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; import java.math.BigInteger; -import java.security.Principal; -import java.security.PublicKey; -import java.security.PrivateKey; -import java.security.Provider; -import java.security.Signature; -import java.security.NoSuchAlgorithmException; -import java.security.InvalidKeyException; -import java.security.NoSuchProviderException; -import java.security.SignatureException; import java.security.cert.Certificate; import java.security.cert.X509CRL; import java.security.cert.X509Certificate; import java.security.cert.X509CRLEntry; import java.security.cert.CRLException; +import java.security.*; import java.util.*; import javax.security.auth.x500.X500Principal; @@ -108,7 +100,6 @@ public class X509CRLImpl extends X509CRL implements DerEncoder { private List revokedList = new LinkedList<>(); private CRLExtensions extensions = null; private final static boolean isExplicit = true; - private static final long YR_2050 = 2524636800000L; private boolean readOnly = false; @@ -295,13 +286,13 @@ public class X509CRLImpl extends X509CRL implements DerEncoder { throw new CRLException("Null Issuer DN not allowed in v1 CRL"); issuer.encode(tmp); - if (thisUpdate.getTime() < YR_2050) + if (thisUpdate.getTime() < CertificateValidity.YR_2050) tmp.putUTCTime(thisUpdate); else tmp.putGeneralizedTime(thisUpdate); if (nextUpdate != null) { - if (nextUpdate.getTime() < YR_2050) + if (nextUpdate.getTime() < CertificateValidity.YR_2050) tmp.putUTCTime(nextUpdate); else tmp.putGeneralizedTime(nextUpdate); @@ -379,12 +370,21 @@ public class X509CRLImpl extends X509CRL implements DerEncoder { throw new CRLException("Uninitialized CRL"); } Signature sigVerf = null; + String sigName = sigAlgId.getName(); if (sigProvider.length() == 0) { - sigVerf = Signature.getInstance(sigAlgId.getName()); + sigVerf = Signature.getInstance(sigName); } else { - sigVerf = Signature.getInstance(sigAlgId.getName(), sigProvider); + sigVerf = Signature.getInstance(sigName, sigProvider); + } + + try { + SignatureUtil.initVerifyWithParam(sigVerf, key, + SignatureUtil.getParamSpec(sigName, getSigAlgParams())); + } catch (ProviderException e) { + throw new CRLException(e.getMessage(), e.getCause()); + } catch (InvalidAlgorithmParameterException e) { + throw new CRLException(e); } - sigVerf.initVerify(key); if (tbsCertList == null) { throw new CRLException("Uninitialized CRL"); @@ -423,12 +423,21 @@ public class X509CRLImpl extends X509CRL implements DerEncoder { 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); + } + + try { + SignatureUtil.initVerifyWithParam(sigVerf, key, + SignatureUtil.getParamSpec(sigName, getSigAlgParams())); + } catch (ProviderException e) { + throw new CRLException(e.getMessage(), e.getCause()); + } catch (InvalidAlgorithmParameterException e) { + throw new CRLException(e); } - sigVerf.initVerify(key); if (tbsCertList == null) { throw new CRLException("Uninitialized CRL"); @@ -442,18 +451,6 @@ public class X509CRLImpl extends X509CRL implements DerEncoder { verifiedPublicKey = key; } - /** - * This static method is the default implementation of the - * verify(PublicKey key, Provider sigProvider) method in X509CRL. - * Called from java.security.cert.X509CRL.verify(PublicKey key, - * Provider sigProvider) - */ - public static void verify(X509CRL crl, PublicKey key, - Provider sigProvider) throws CRLException, - NoSuchAlgorithmException, InvalidKeyException, SignatureException { - crl.verify(key, sigProvider); - } - /** * Encodes an X.509 CRL, and signs it using the given key. * @@ -501,7 +498,7 @@ public class X509CRLImpl extends X509CRL implements DerEncoder { 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/share/classes/sun/security/x509/X509CertImpl.java b/src/share/classes/sun/security/x509/X509CertImpl.java index ab1c45096bf1ae8e5eb8285a2d206099d1179beb..012bb8cf823ef6b9a34286e08b2ac9abb0aeeea7 100644 --- a/src/share/classes/sun/security/x509/X509CertImpl.java +++ b/src/share/classes/sun/security/x509/X509CertImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. * 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 java.io.InputStreamReader; import java.io.OutputStream; import java.math.BigInteger; import java.security.*; +import java.security.spec.AlgorithmParameterSpec; import java.security.cert.*; import java.security.cert.Certificate; import java.util.*; @@ -42,7 +43,6 @@ import java.util.concurrent.ConcurrentHashMap; import javax.security.auth.x500.X500Principal; import sun.misc.HexDumpEncoder; -import java.util.Base64; import sun.security.util.*; import sun.security.provider.X509Factory; @@ -388,7 +388,6 @@ public class X509CertImpl extends X509Certificate implements DerEncoder { public void verify(PublicKey key) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException { - verify(key, ""); } @@ -430,12 +429,21 @@ public class X509CertImpl extends X509Certificate implements DerEncoder { } // Verify the signature ... Signature sigVerf = null; + String sigName = algId.getName(); if (sigProvider.length() == 0) { - sigVerf = Signature.getInstance(algId.getName()); + sigVerf = Signature.getInstance(sigName); } else { - sigVerf = Signature.getInstance(algId.getName(), sigProvider); + sigVerf = Signature.getInstance(sigName, sigProvider); + } + + try { + SignatureUtil.initVerifyWithParam(sigVerf, key, + SignatureUtil.getParamSpec(sigName, getSigAlgParams())); + } catch (ProviderException e) { + throw new CertificateException(e.getMessage(), e.getCause()); + } catch (InvalidAlgorithmParameterException e) { + throw new CertificateException(e); } - sigVerf.initVerify(key); byte[] rawCert = info.getEncodedInfo(); sigVerf.update(rawCert, 0, rawCert.length); @@ -475,12 +483,21 @@ public class X509CertImpl extends X509Certificate implements DerEncoder { } // 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); + } + + try { + SignatureUtil.initVerifyWithParam(sigVerf, key, + SignatureUtil.getParamSpec(sigName, getSigAlgParams())); + } catch (ProviderException e) { + throw new CertificateException(e.getMessage(), e.getCause()); + } catch (InvalidAlgorithmParameterException e) { + throw new CertificateException(e); } - sigVerf.initVerify(key); byte[] rawCert = info.getEncodedInfo(); sigVerf.update(rawCert, 0, rawCert.length); @@ -494,18 +511,6 @@ public class X509CertImpl extends X509Certificate implements DerEncoder { } } - /** - * This static method is the default implementation of the - * verify(PublicKey key, Provider sigProvider) method in X509Certificate. - * Called from java.security.cert.X509Certificate.verify(PublicKey key, - * Provider sigProvider) - */ - public static void verify(X509Certificate cert, PublicKey key, - Provider sigProvider) throws CertificateException, - NoSuchAlgorithmException, InvalidKeyException, SignatureException { - cert.verify(key, sigProvider); - } - /** * Creates an X.509 certificate, and signs it using the given key * (associating a signature algorithm and an X.500 name). @@ -549,20 +554,63 @@ public class X509CertImpl extends X509Certificate implements DerEncoder { throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException { try { - if (readOnly) + sign(key, null, algorithm, provider); + } catch (InvalidAlgorithmParameterException e) { + // should not happen; re-throw just in case + throw new SignatureException(e); + } + } + + /** + * Creates an X.509 certificate, and signs it using the given key + * (associating a signature algorithm and an X.500 name), signature + * parameters, and security provider. If the given provider name + * is null or empty, the implementation look up will be based on + * provider configurations. + * This operation is used to implement the certificate generation + * functionality of a certificate authority. + * + * @param key the private key used for signing + * @param signingParams the parameters used for signing + * @param algorithm the name of the signature algorithm used + * @param provider the name of the provider, may be null + * + * @exception NoSuchAlgorithmException on unsupported signature + * algorithms + * @exception InvalidKeyException on incorrect key + * @exception InvalidAlgorithmParameterException on invalid signature + * parameters + * @exception NoSuchProviderException on incorrect provider + * @exception SignatureException on signature errors + * @exception CertificateException on encoding errors + */ + public void sign(PrivateKey key, AlgorithmParameterSpec signingParams, + String algorithm, String provider) + throws CertificateException, NoSuchAlgorithmException, + InvalidKeyException, InvalidAlgorithmParameterException, + NoSuchProviderException, SignatureException { + try { + 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.length() == 0)) { sigEngine = Signature.getInstance(algorithm); - else + } else { sigEngine = Signature.getInstance(algorithm, provider); + } - sigEngine.initSign(key); - - // in case the name is reset - algId = AlgorithmId.get(sigEngine.getAlgorithm()); + SignatureUtil.initSignWithParam(sigEngine, key, signingParams, + null); + // in case the name is reset + if (signingParams != null) { + algId = AlgorithmId.get(sigEngine.getParameters()); + } else { + algId = AlgorithmId.get(algorithm); + } DerOutputStream out = new DerOutputStream(); DerOutputStream tmp = new DerOutputStream(); @@ -695,9 +743,10 @@ public class X509CertImpl extends X509Certificate implements DerEncoder { public void set(String name, Object obj) throws CertificateException, IOException { // check if immutable - if (readOnly) + if (readOnly) { throw new CertificateException("cannot over-write existing" + " certificate"); + } X509AttributeName attr = new X509AttributeName(name); String id = attr.getPrefix(); @@ -736,9 +785,10 @@ public class X509CertImpl extends X509Certificate implements DerEncoder { public void delete(String name) throws CertificateException, IOException { // check if immutable - if (readOnly) + if (readOnly) { throw new CertificateException("cannot over-write existing" + " certificate"); + } X509AttributeName attr = new X509AttributeName(name); String id = attr.getPrefix(); @@ -1768,9 +1818,10 @@ public class X509CertImpl extends X509Certificate implements DerEncoder { private void parse(DerValue val) throws CertificateException, IOException { // check if can over write the certificate - if (readOnly) + if (readOnly) { throw new CertificateParsingException( "cannot over-write existing certificate"); + } if (val.data == null || val.tag != DerValue.tag_Sequence) throw new CertificateParsingException( diff --git a/src/share/classes/sun/text/resources/hr/JavaTimeSupplementary_hr.java b/src/share/classes/sun/text/resources/hr/JavaTimeSupplementary_hr.java index cd0903905238b2fbab51e3fe8fca24790c06c98c..c0821ffdd919b76a0fa685b891d7c72e77176cd4 100644 --- a/src/share/classes/sun/text/resources/hr/JavaTimeSupplementary_hr.java +++ b/src/share/classes/sun/text/resources/hr/JavaTimeSupplementary_hr.java @@ -145,6 +145,26 @@ public class JavaTimeSupplementary_hr extends OpenListResourceBundle { "d.M.y. G", } }, + { "java.time.japanese.long.Eras", + new String[] { + "poslije Krista", + "Meiji", + "Taish\u014d", + "Sh\u014dwa", + "Heisei", + "Reiwa", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "p. Kr.", + "Meiji", + "Taish\u014d", + "Sh\u014dwa", + "Heisei", + "Reiwa", + } + }, { "java.time.long.Eras", new String[] { "Prije Krista", diff --git a/src/share/classes/sun/text/resources/in/JavaTimeSupplementary_in.java b/src/share/classes/sun/text/resources/in/JavaTimeSupplementary_in.java new file mode 100644 index 0000000000000000000000000000000000000000..e8e1d58dacd31adb2ec40c749f830cc39f333144 --- /dev/null +++ b/src/share/classes/sun/text/resources/in/JavaTimeSupplementary_in.java @@ -0,0 +1,497 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2016 Unicode, Inc. All rights reserved. + * Distributed under the Terms of Use in + * http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of the Unicode data files and any associated documentation + * (the "Data Files") or Unicode software and any associated documentation + * (the "Software") to deal in the Data Files or Software + * without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, and/or sell copies of + * the Data Files or Software, and to permit persons to whom the Data Files + * or Software are furnished to do so, provided that + * (a) this copyright and permission notice appear with all copies + * of the Data Files or Software, + * (b) this copyright and permission notice appear in associated + * documentation, and + * (c) there is clear notice in each modified Data File or in the Software + * as well as in the documentation associated with the Data File(s) or + * Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF + * ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT OF THIRD PARTY RIGHTS. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS + * NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL 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 THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, + * use or other dealings in these Data Files or Software without prior + * written authorization of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.in; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_in extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "K1", + "K2", + "K3", + "K4", + } + }, + { "QuarterNames", + new String[] { + "Kuartal ke-1", + "Kuartal ke-2", + "Kuartal ke-3", + "Kuartal ke-4", + } + }, + { "calendarname.buddhist", + "Kalender Buddha" }, + { "calendarname.gregorian", + "Kalender Gregorian" }, + { "calendarname.gregory", + "Kalender Gregorian" }, + { "calendarname.islamic", + "Kalender Islam" }, + { "calendarname.islamic-civil", + "Kalender Sipil Islam" }, + { "calendarname.japanese", + "Kalender Jepang" }, + { "calendarname.roc", + "Kalendar Minguo" }, + { "field.dayperiod", + "AM/PM" }, + { "field.hour", + "Jam" }, + { "field.minute", + "Menit" }, + { "field.month", + "Bulan" }, + { "field.second", + "Detik" }, + { "field.week", + "Minggu" }, + { "field.weekday", + "Hari dalam Seminggu" }, + { "field.year", + "Tahun" }, + { "field.zone", + "Zona Waktu" }, + { "islamic.AmPmMarkers", + new String[] { + "AM", + "PM", + } + }, + { "islamic.DatePatterns", + new String[] { + "EEEE, dd MMMM y GGGG", + "d MMMM y GGGG", + "d MMM y GGGG", + "d/M/y G", + } + }, + { "islamic.DayAbbreviations", + new String[] { + "Min", + "Sen", + "Sel", + "Rab", + "Kam", + "Jum", + "Sab", + } + }, + { "islamic.DayNames", + new String[] { + "Minggu", + "Senin", + "Selasa", + "Rabu", + "Kamis", + "Jumat", + "Sabtu", + } + }, + { "islamic.DayNarrows", + new String[] { + "M", + "S", + "S", + "R", + "K", + "J", + "S", + } + }, + { "islamic.Eras", + new String[] { + "", + "AH", + } + }, + { "islamic.MonthAbbreviations", + new String[] { + "Muh.", + "Saf.", + "Rab. I", + "Rab. II", + "Jum. I", + "Jum. II", + "Raj.", + "Sha.", + "Ram.", + "Syaw.", + "Dhu\u02bbl-Q.", + "Dhu\u02bbl-H.", + "", + } + }, + { "islamic.MonthNames", + new String[] { + "Muharram", + "Safar", + "Rabi\u02bb I", + "Rabi\u02bb II", + "Jumada I", + "Jumada II", + "Rajab", + "Sya\u2019ban", + "Ramadhan", + "Syawal", + "Dhu\u02bbl-Qi\u02bbdah", + "Dhu\u02bbl-Hijjah", + "", + } + }, + { "islamic.QuarterAbbreviations", + new String[] { + "K1", + "K2", + "K3", + "K4", + } + }, + { "islamic.QuarterNames", + new String[] { + "Kuartal ke-1", + "Kuartal ke-2", + "Kuartal ke-3", + "Kuartal ke-4", + } + }, + { "islamic.QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "islamic.TimePatterns", + new String[] { + "HH.mm.ss zzzz", + "HH.mm.ss z", + "HH.mm.ss", + "HH.mm", + } + }, + { "islamic.long.Eras", + new String[] { + "", + "AH", + } + }, + { "islamic.narrow.AmPmMarkers", + new String[] { + "AM", + "PM", + } + }, + { "islamic.narrow.Eras", + new String[] { + "", + "AH", + } + }, + { "islamic.short.Eras", + new String[] { + "", + "AH", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, dd MMMM y G", + "d MMMM y G", + "d MMM y G", + "d/M/y GGGGG", + } + }, + { "java.time.buddhist.long.Eras", + new String[] { + "BC", + "BE", + } + }, + { "java.time.buddhist.short.Eras", + new String[] { + "BC", + "BE", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE, dd MMMM y G", + "d MMMM y G", + "d MMM y G", + "d/M/y GGGGG", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, dd MMMM y G", + "d MMMM y G", + "d MMM y G", + "d/M/y GGGGG", + } + }, + { "java.time.japanese.long.Eras", + new String[] { + "M", + "Meiji", + "Taish\u014d", + "Sh\u014dwa", + "Heisei", + "Reiwa", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "M", + "Meiji", + "Taish\u014d", + "Sh\u014dwa", + "Heisei", + "Reiwa", + } + }, + { "java.time.long.Eras", + new String[] { + "Sebelum Masehi", + "M", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, dd MMMM y G", + "d MMMM y G", + "d MMM y G", + "d/M/y GGGGG", + } + }, + { "java.time.short.Eras", + new String[] { + "BCE", + "CE", + } + }, + { "roc.AmPmMarkers", + new String[] { + "AM", + "PM", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, dd MMMM y GGGG", + "d MMMM y GGGG", + "d MMM y GGGG", + "d/M/y G", + } + }, + { "roc.DayAbbreviations", + new String[] { + "Min", + "Sen", + "Sel", + "Rab", + "Kam", + "Jum", + "Sab", + } + }, + { "roc.DayNames", + new String[] { + "Minggu", + "Senin", + "Selasa", + "Rabu", + "Kamis", + "Jumat", + "Sabtu", + } + }, + { "roc.DayNarrows", + new String[] { + "M", + "S", + "S", + "R", + "K", + "J", + "S", + } + }, + { "roc.Eras", + new String[] { + "Sebelum R.O.C.", + "R.O.C.", + } + }, + { "roc.MonthAbbreviations", + new String[] { + "Jan", + "Feb", + "Mar", + "Apr", + "Mei", + "Jun", + "Jul", + "Agt", + "Sep", + "Okt", + "Nov", + "Des", + "", + } + }, + { "roc.MonthNames", + new String[] { + "Januari", + "Februari", + "Maret", + "April", + "Mei", + "Juni", + "Juli", + "Agustus", + "September", + "Oktober", + "November", + "Desember", + "", + } + }, + { "roc.MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "A", + "S", + "O", + "N", + "D", + "", + } + }, + { "roc.QuarterAbbreviations", + new String[] { + "K1", + "K2", + "K3", + "K4", + } + }, + { "roc.QuarterNames", + new String[] { + "Kuartal ke-1", + "Kuartal ke-2", + "Kuartal ke-3", + "Kuartal ke-4", + } + }, + { "roc.TimePatterns", + new String[] { + "HH.mm.ss zzzz", + "HH.mm.ss z", + "HH.mm.ss", + "HH.mm", + } + }, + { "roc.long.Eras", + new String[] { + "Sebelum R.O.C.", + "R.O.C.", + } + }, + { "roc.narrow.AmPmMarkers", + new String[] { + "AM", + "PM", + } + }, + { "roc.narrow.Eras", + new String[] { + "Sebelum R.O.C.", + "R.O.C.", + } + }, + { "roc.short.Eras", + new String[] { + "Sebelum R.O.C.", + "R.O.C.", + } + }, + }; + } +} diff --git a/src/share/classes/sun/text/resources/lt/JavaTimeSupplementary_lt.java b/src/share/classes/sun/text/resources/lt/JavaTimeSupplementary_lt.java index bebc6b13c37c1377dc77da8c368b28c0977e045d..8a8fe8eed5f32fba590a985e557a33b295919faa 100644 --- a/src/share/classes/sun/text/resources/lt/JavaTimeSupplementary_lt.java +++ b/src/share/classes/sun/text/resources/lt/JavaTimeSupplementary_lt.java @@ -137,6 +137,26 @@ public class JavaTimeSupplementary_lt extends OpenListResourceBundle { "GGGGG yyyy-MM-dd", } }, + { "java.time.japanese.long.Eras", + new String[] { + "po Kristaus", + "Meid\u017ei", + "Tai\u0161o", + "\u0160ova", + "Heisei", + "Reiwa", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "po Kr.", + "Meid\u017ei", + "Tai\u0161o", + "\u0160ova", + "Heisei", + "Reiwa", + } + }, { "java.time.long.Eras", new String[] { "prie\u0161 Krist\u0173", diff --git a/src/share/classes/sun/text/resources/nl/JavaTimeSupplementary_nl.java b/src/share/classes/sun/text/resources/nl/JavaTimeSupplementary_nl.java index 8b111fa4a5a9716eb9a8b4f8bea8da49c00a4b0c..9841d36e5271645451cdaa41db26cd61e9b08ee1 100644 --- a/src/share/classes/sun/text/resources/nl/JavaTimeSupplementary_nl.java +++ b/src/share/classes/sun/text/resources/nl/JavaTimeSupplementary_nl.java @@ -207,6 +207,26 @@ public class JavaTimeSupplementary_nl extends OpenListResourceBundle { "dd-MM-yy GGGGG", } }, + { "java.time.japanese.long.Eras", + new String[] { + "na Christus", + "Meiji", + "Taish\u014d", + "Sh\u014dwa", + "Heisei", + "Reiwa", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "n.Chr.", + "Meiji", + "Taish\u014d", + "Sh\u014dwa", + "Heisei", + "Reiwa", + } + }, { "java.time.long.Eras", new String[] { "Voor Christus", diff --git a/src/share/classes/sun/text/resources/no/JavaTimeSupplementary_no.java b/src/share/classes/sun/text/resources/no/JavaTimeSupplementary_no.java index 2ed407fcaf32cab81d150509695fd4d3eacaec9c..058c96487f2c59e81a040622bed9f214ab59858f 100644 --- a/src/share/classes/sun/text/resources/no/JavaTimeSupplementary_no.java +++ b/src/share/classes/sun/text/resources/no/JavaTimeSupplementary_no.java @@ -189,6 +189,26 @@ public class JavaTimeSupplementary_no extends OpenListResourceBundle { "d.M y GGGG", } }, + { "java.time.japanese.long.Eras", + new String[] { + "etter Kristus", + "Meiji", + "Taish\u014d", + "Sh\u014dwa", + "Heisei", + "Reiwa", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "e.Kr.", + "M", + "T", + "S", + "H", + "R", + } + }, }; } } diff --git a/src/share/classes/sun/text/resources/sr/JavaTimeSupplementary_sr_Latn.java b/src/share/classes/sun/text/resources/sr/JavaTimeSupplementary_sr_Latn.java index 2109447b27e8a37d0f21869228ae3583fb6e669f..7d84dc8b6a9c11c5af814d77bb6599d473760f11 100644 --- a/src/share/classes/sun/text/resources/sr/JavaTimeSupplementary_sr_Latn.java +++ b/src/share/classes/sun/text/resources/sr/JavaTimeSupplementary_sr_Latn.java @@ -145,6 +145,26 @@ public class JavaTimeSupplementary_sr_Latn extends OpenListResourceBundle { "RK", } }, + { "java.time.japanese.long.Eras", + new String[] { + "nove ere", + "Mei\u0111i", + "Tai\u0161o", + "\u0160ova", + "Haisei", + "Reiva", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "n. e.", + "Mei\u0111i", + "Tai\u0161o", + "\u0160ova", + "Haisei", + "Reiva", + } + }, }; } } diff --git a/src/share/classes/sun/text/resources/sv/JavaTimeSupplementary_sv.java b/src/share/classes/sun/text/resources/sv/JavaTimeSupplementary_sv.java index f54fbceaadd0f9fd929a108e5b2e6a43ee3743dc..3c9581d392992513b15c97b827b69f7322dbcc56 100644 --- a/src/share/classes/sun/text/resources/sv/JavaTimeSupplementary_sv.java +++ b/src/share/classes/sun/text/resources/sv/JavaTimeSupplementary_sv.java @@ -170,6 +170,26 @@ public class JavaTimeSupplementary_sv extends OpenListResourceBundle { "G y-MM-dd", } }, + { "java.time.japanese.long.Eras", + new String[] { + "efter Kristus", + "Meiji", + "Taish\u014d", + "Sh\u014dwa", + "Heisei", + "Reiwa", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "e.Kr.", + "Meiji", + "Taish\u014d", + "Sh\u014dwa", + "Heisei", + "Reiwa", + } + }, { "java.time.long.Eras", new String[] { "f\u00f6re Kristus", diff --git a/src/share/classes/sun/tools/jconsole/Worker.java b/src/share/classes/sun/tools/jconsole/Worker.java index 891adb747d2e84c4224e133ede11a05971da6d87..d9d235ecf0ff92d5d4bef06cb37fc304a3da2ec6 100644 --- a/src/share/classes/sun/tools/jconsole/Worker.java +++ b/src/share/classes/sun/tools/jconsole/Worker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2020 Oracle and/or its affiliates. All rights reserved. * 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 @@ import java.util.*; public class Worker extends Thread { ArrayList jobs = new ArrayList(); - private boolean stopped = false; + private volatile boolean stopped = false; public Worker(String name) { super("Worker-"+name); @@ -38,17 +38,17 @@ public class Worker extends Thread { } public void run() { - while (!isStopped()) { + while (!stopped) { Runnable job; synchronized(jobs) { - while (!isStopped() && jobs.size() == 0) { + while (!stopped && jobs.size() == 0) { try { jobs.wait(); } catch (InterruptedException ex) { } } - if(isStopped()) break; + if(stopped) break; job = jobs.remove(0); } @@ -56,11 +56,7 @@ public class Worker extends Thread { } } - private synchronized boolean isStopped() { - return stopped; - } - - public synchronized void stopWorker() { + public void stopWorker() { stopped = true; synchronized(jobs) { jobs.notify(); diff --git a/src/share/classes/sun/util/resources/TimeZoneNames.java b/src/share/classes/sun/util/resources/TimeZoneNames.java index 2c4b56da7e70b5ae1abe820a2149c63ed6a4418e..2a0bea8d71b2c27d4d16c98e8014ec0a28da79b6 100644 --- a/src/share/classes/sun/util/resources/TimeZoneNames.java +++ b/src/share/classes/sun/util/resources/TimeZoneNames.java @@ -242,6 +242,9 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { String TMT[] = new String[] {"Turkmenistan Time", "TMT", "Turkmenistan Summer Time", "TMST", "Turkmenistan Time", "TMT"}; + String TRT[] = new String[] {"Turkey Time", "TRT", + "Turkey Summer Time", "TRST", + "Turkey Time", "TRT"}; String ULAT[]= new String[] {"Ulaanbaatar Time", "ULAT", "Ulaanbaatar Summer Time", "ULAST", "Ulaanbaatar Time", "ULAT"}; @@ -269,6 +272,9 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { String VICTORIA[] = new String[] {"Australian Eastern Standard Time (Victoria)", "AEST", "Australian Eastern Daylight Time (Victoria)", "AEDT", "Australian Eastern Time (Victoria)", "AET"}; + String WGT[] = new String[] {"Western Greenland Time", "WGT", + "Western Greenland Summer Time", "WGST", + "Western Greenland Time", "WGT"}; String UTC[] = new String[] {"Coordinated Universal Time", "UTC", "Coordinated Universal Time", "UTC", "Coordinated Universal Time", "UTC"}; @@ -429,7 +435,7 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { {"America/Cuiaba", AMT}, {"America/Curacao", AST}, {"America/Danmarkshavn", GMT}, - {"America/Dawson", PST}, + {"America/Dawson", MST}, {"America/Dawson_Creek", MST}, {"America/Detroit", EST}, {"America/Dominica", AST}, @@ -441,9 +447,7 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { {"America/Fort_Wayne", EST}, {"America/Fortaleza", BRT}, {"America/Glace_Bay", AST}, - {"America/Godthab", new String[] {"Western Greenland Time", "WGT", - "Western Greenland Summer Time", "WGST", - "Western Greenland Time", "WGT"}}, + {"America/Godthab", WGT}, {"America/Goose_Bay", AST}, {"America/Grand_Turk", EST}, {"America/Grenada", AST}, @@ -511,6 +515,7 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { {"America/North_Dakota/Beulah", CST}, {"America/North_Dakota/Center", CST}, {"America/North_Dakota/New_Salem", CST}, + {"America/Nuuk", WGT}, {"America/Ojinaga", MST}, {"America/Panama", EST}, {"America/Pangnirtung", EST}, @@ -550,7 +555,7 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { {"America/Tortola", AST}, {"America/Vancouver", PST}, {"America/Virgin", AST}, - {"America/Whitehorse", PST}, + {"America/Whitehorse", MST}, {"America/Winnipeg", CST}, {"America/Yakutat", AKST}, {"America/Yellowknife", MST}, @@ -639,7 +644,7 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { "Hovd Summer Time", "HOVST", "Hovd Time", "HOVT"}}, {"Asia/Irkutsk", IRKT}, - {"Asia/Istanbul", EET}, + {"Asia/Istanbul", TRT}, {"Asia/Jakarta", WIT}, {"Asia/Jayapura", new String[] {"East Indonesia Time", "WIT", "East Indonesia Summer Time", "EIST", @@ -784,7 +789,7 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { {"Canada/Mountain", MST}, {"Canada/Newfoundland", NST}, {"Canada/Pacific", PST}, - {"Canada/Yukon", PST}, + {"Canada/Yukon", MST}, {"Canada/Saskatchewan", CST}, {"CAT", CAT}, {"CET", CET}, @@ -819,7 +824,7 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { {"Europe/Guernsey", GMTBST}, {"Europe/Helsinki", EET}, {"Europe/Isle_of_Man", GMTBST}, - {"Europe/Istanbul", EET}, + {"Europe/Istanbul", TRT}, {"Europe/Jersey", GMTBST}, {"Europe/Kaliningrad", EET}, {"Europe/Kiev", EET}, @@ -1021,7 +1026,7 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { {"SystemV/PST8PDT", PST}, {"SystemV/YST9", AKST}, {"SystemV/YST9YDT", AKST}, - {"Turkey", EET}, + {"Turkey", TRT}, {"UCT", UTC}, {"Universal", UTC}, {"US/Alaska", AKST}, diff --git a/src/share/classes/sun/util/resources/de/TimeZoneNames_de.java b/src/share/classes/sun/util/resources/de/TimeZoneNames_de.java index e258618c9db62bc37fa4cd8e317e4229fc726c16..cb2d725d1fd4c0b7bf35a71c01732200cef5e98c 100644 --- a/src/share/classes/sun/util/resources/de/TimeZoneNames_de.java +++ b/src/share/classes/sun/util/resources/de/TimeZoneNames_de.java @@ -252,6 +252,9 @@ public final class TimeZoneNames_de extends TimeZoneNamesBundle { String WET[] = new String[] {"Westeurop\u00e4ische Zeit", "WEZ", "Westeurop\u00e4ische Sommerzeit", "WESZ", "Westeurop\u00E4ische Zeit", "WEZ"}; + String WGT[] = new String[] {"Westgr\u00f6nl\u00e4ndische Zeit", "WGT", + "Westgr\u00f6nl\u00e4ndische Sommerzeit", "WGST", + "Westgr\u00F6nl\u00E4ndische Zeit", "WGT"}; String WIT[] = new String[] {"Westindonesische Zeit", "WIB", "Westindonesische Sommerzeit", "WIST", "Westindonesische Zeit", "WIB"}; @@ -430,7 +433,7 @@ public final class TimeZoneNames_de extends TimeZoneNamesBundle { {"America/Cuiaba", AMT}, {"America/Curacao", AST}, {"America/Danmarkshavn", GMT}, - {"America/Dawson", PST}, + {"America/Dawson", MST}, {"America/Dawson_Creek", MST}, {"America/Detroit", EST}, {"America/Dominica", AST}, @@ -442,9 +445,7 @@ public final class TimeZoneNames_de extends TimeZoneNamesBundle { {"America/Fort_Wayne", EST}, {"America/Fortaleza", BRT}, {"America/Glace_Bay", AST}, - {"America/Godthab", new String[] {"Westgr\u00f6nl\u00e4ndische Zeit", "WGT", - "Westgr\u00f6nl\u00e4ndische Sommerzeit", "WGST", - "Westgr\u00F6nl\u00E4ndische Zeit", "WGT"}}, + {"America/Godthab", WGT}, {"America/Goose_Bay", AST}, {"America/Grand_Turk", EST}, {"America/Grenada", AST}, @@ -512,6 +513,7 @@ public final class TimeZoneNames_de extends TimeZoneNamesBundle { {"America/North_Dakota/Beulah", CST}, {"America/North_Dakota/Center", CST}, {"America/North_Dakota/New_Salem", CST}, + {"America/Nuuk", WGT}, {"America/Ojinaga", MST}, {"America/Panama", EST}, {"America/Pangnirtung", EST}, @@ -551,7 +553,7 @@ public final class TimeZoneNames_de extends TimeZoneNamesBundle { {"America/Tortola", AST}, {"America/Vancouver", PST}, {"America/Virgin", AST}, - {"America/Whitehorse", PST}, + {"America/Whitehorse", MST}, {"America/Winnipeg", CST}, {"America/Yakutat", AKST}, {"America/Yellowknife", MST}, @@ -782,7 +784,7 @@ public final class TimeZoneNames_de extends TimeZoneNamesBundle { {"Canada/Mountain", MST}, {"Canada/Newfoundland", NST}, {"Canada/Pacific", PST}, - {"Canada/Yukon", PST}, + {"Canada/Yukon", MST}, {"Canada/Saskatchewan", CST}, {"CAT", CAT}, {"CET", CET}, diff --git a/src/share/classes/sun/util/resources/es/TimeZoneNames_es.java b/src/share/classes/sun/util/resources/es/TimeZoneNames_es.java index ea8887e1395bee795218d23a50df78cb9a23a4ca..17b28bae38ccfb3bb395cad48997ee1dc0f0e751 100644 --- a/src/share/classes/sun/util/resources/es/TimeZoneNames_es.java +++ b/src/share/classes/sun/util/resources/es/TimeZoneNames_es.java @@ -252,6 +252,9 @@ public final class TimeZoneNames_es extends TimeZoneNamesBundle { String WET[] = new String[] {"Hora de Europa Occidental", "WET", "Hora de verano de Europa Occidental", "WEST", "Hora de Europa Occidental", "WET"}; + String WGT[] = new String[] {"Hora de Groenlandia Occidental", "WGT", + "Hora de verano de Groenlandia Occidental", "WGST", + "Hora de Groenlandia Occidental", "WGT"}; String WIT[] = new String[] {"Hora de Indonesia Occidental", "WIB", "Indonesia Hora de verano de Indonesia Occidental", "WIST", "Hora de Indonesia Occidental", "WIB"}; @@ -430,7 +433,7 @@ public final class TimeZoneNames_es extends TimeZoneNamesBundle { {"America/Cuiaba", AMT}, {"America/Curacao", AST}, {"America/Danmarkshavn", GMT}, - {"America/Dawson", PST}, + {"America/Dawson", MST}, {"America/Dawson_Creek", MST}, {"America/Detroit", EST}, {"America/Dominica", AST}, @@ -442,9 +445,7 @@ public final class TimeZoneNames_es extends TimeZoneNamesBundle { {"America/Fort_Wayne", EST}, {"America/Fortaleza", BRT}, {"America/Glace_Bay", AST}, - {"America/Godthab", new String[] {"Hora de Groenlandia Occidental", "WGT", - "Hora de verano de Groenlandia Occidental", "WGST", - "Hora de Groenlandia Occidental", "WGT"}}, + {"America/Godthab", WGT}, {"America/Goose_Bay", AST}, {"America/Grand_Turk", EST}, {"America/Grenada", AST}, @@ -512,6 +513,7 @@ public final class TimeZoneNames_es extends TimeZoneNamesBundle { {"America/North_Dakota/Beulah", CST}, {"America/North_Dakota/Center", CST}, {"America/North_Dakota/New_Salem", CST}, + {"America/Nuuk", WGT}, {"America/Ojinaga", MST}, {"America/Panama", EST}, {"America/Pangnirtung", EST}, @@ -551,7 +553,7 @@ public final class TimeZoneNames_es extends TimeZoneNamesBundle { {"America/Tortola", AST}, {"America/Vancouver", PST}, {"America/Virgin", AST}, - {"America/Whitehorse", PST}, + {"America/Whitehorse", MST}, {"America/Winnipeg", CST}, {"America/Yakutat", AKST}, {"America/Yellowknife", MST}, @@ -782,7 +784,7 @@ public final class TimeZoneNames_es extends TimeZoneNamesBundle { {"Canada/Mountain", MST}, {"Canada/Newfoundland", NST}, {"Canada/Pacific", PST}, - {"Canada/Yukon", PST}, + {"Canada/Yukon", MST}, {"Canada/Saskatchewan", CST}, {"CAT", CAT}, {"CET", CET}, diff --git a/src/share/classes/sun/util/resources/fr/TimeZoneNames_fr.java b/src/share/classes/sun/util/resources/fr/TimeZoneNames_fr.java index 58891022d3697a1dc683e6cc285645edc999a1aa..15a97b91ea763778a5e919abd0b5786bc983d43e 100644 --- a/src/share/classes/sun/util/resources/fr/TimeZoneNames_fr.java +++ b/src/share/classes/sun/util/resources/fr/TimeZoneNames_fr.java @@ -252,6 +252,9 @@ public final class TimeZoneNames_fr extends TimeZoneNamesBundle { String WET[] = new String[] {"Heure d'Europe de l'Ouest", "WET", "Heure d'\u00e9t\u00e9 d'Europe de l'Ouest", "WEST", "Heure d'Europe de l'Ouest", "WET"} ; + String WGT[] = new String[] {"Heure du Groenland de l'Ouest", "WGT", + "Heure d'\u00e9t\u00e9 du Groenland de l'Ouest", "WGST", + "Heure du Groenland de l'Ouest", "WGT"}; String WIT[] = new String[] {"Heure de l'Indon\u00e9sie occidentale", "WIB", "Heure d'\u00e9t\u00e9 de l'Indon\u00e9sie occidentale", "WIST", "Heure de l'Indon\u00E9sie occidentale", "WIB"}; @@ -430,7 +433,7 @@ public final class TimeZoneNames_fr extends TimeZoneNamesBundle { {"America/Cuiaba", AMT}, {"America/Curacao", AST}, {"America/Danmarkshavn", GMT}, - {"America/Dawson", PST}, + {"America/Dawson", MST}, {"America/Dawson_Creek", MST}, {"America/Detroit", EST}, {"America/Dominica", AST}, @@ -442,9 +445,7 @@ public final class TimeZoneNames_fr extends TimeZoneNamesBundle { {"America/Fort_Wayne", EST}, {"America/Fortaleza", BRT}, {"America/Glace_Bay", AST}, - {"America/Godthab", new String[] {"Heure du Groenland de l'Ouest", "WGT", - "Heure d'\u00e9t\u00e9 du Groenland de l'Ouest", "WGST", - "Heure du Groenland de l'Ouest", "WGT"}}, + {"America/Godthab", WGT}, {"America/Goose_Bay", AST}, {"America/Grand_Turk", EST}, {"America/Grenada", AST}, @@ -512,6 +513,7 @@ public final class TimeZoneNames_fr extends TimeZoneNamesBundle { {"America/North_Dakota/Beulah", CST}, {"America/North_Dakota/Center", CST}, {"America/North_Dakota/New_Salem", CST}, + {"America/Nuuk", WGT}, {"America/Ojinaga", MST}, {"America/Panama", EST}, {"America/Pangnirtung", EST}, @@ -551,7 +553,7 @@ public final class TimeZoneNames_fr extends TimeZoneNamesBundle { {"America/Tortola", AST}, {"America/Vancouver", PST}, {"America/Virgin", AST}, - {"America/Whitehorse", PST}, + {"America/Whitehorse", MST}, {"America/Winnipeg", CST}, {"America/Yakutat", AKST}, {"America/Yellowknife", MST}, @@ -782,7 +784,7 @@ public final class TimeZoneNames_fr extends TimeZoneNamesBundle { {"Canada/Mountain", MST}, {"Canada/Newfoundland", NST}, {"Canada/Pacific", PST}, - {"Canada/Yukon", PST}, + {"Canada/Yukon", MST}, {"Canada/Saskatchewan", CST}, {"CAT", CAT}, {"CET", CET}, diff --git a/src/share/classes/sun/util/resources/it/TimeZoneNames_it.java b/src/share/classes/sun/util/resources/it/TimeZoneNames_it.java index 53ab4a6d7383bc36fcb37fefd4b12310569708b6..5b6f28fd085d92c3d09fad7ee6d8a1b014d79993 100644 --- a/src/share/classes/sun/util/resources/it/TimeZoneNames_it.java +++ b/src/share/classes/sun/util/resources/it/TimeZoneNames_it.java @@ -252,6 +252,9 @@ public final class TimeZoneNames_it extends TimeZoneNamesBundle { String WET[] = new String[] {"Ora dell'Europa occidentale", "WET", "Ora estiva dell'Europa occidentale", "WEST", "Ora dell'Europa occidentale", "WET"}; + String WGT[] = new String[] {"Ora della Groenlandia occidentale", "WGT", + "Ora estiva della Groenlandia occidentale", "WGST", + "Ora della Groenlandia occidentale", "WGT"}; String WIT[] = new String[] {"Ora dell'Indonesia occidentale", "WIB", "Ora estiva dell'Indonesia occidentale", "WIST", "Ora dell'Indonesia occidentale", "WIB"}; @@ -430,7 +433,7 @@ public final class TimeZoneNames_it extends TimeZoneNamesBundle { {"America/Cuiaba", AMT}, {"America/Curacao", AST}, {"America/Danmarkshavn", GMT}, - {"America/Dawson", PST}, + {"America/Dawson", MST}, {"America/Dawson_Creek", MST}, {"America/Detroit", EST}, {"America/Dominica", AST}, @@ -442,9 +445,7 @@ public final class TimeZoneNames_it extends TimeZoneNamesBundle { {"America/Fort_Wayne", EST}, {"America/Fortaleza", BRT}, {"America/Glace_Bay", AST}, - {"America/Godthab", new String[] {"Ora della Groenlandia occidentale", "WGT", - "Ora estiva della Groenlandia occidentale", "WGST", - "Ora della Groenlandia occidentale", "WGT"}}, + {"America/Godthab", WGT}, {"America/Goose_Bay", AST}, {"America/Grand_Turk", EST}, {"America/Grenada", AST}, @@ -512,6 +513,7 @@ public final class TimeZoneNames_it extends TimeZoneNamesBundle { {"America/North_Dakota/Beulah", CST}, {"America/North_Dakota/Center", CST}, {"America/North_Dakota/New_Salem", CST}, + {"America/Nuuk", WGT}, {"America/Ojinaga", MST}, {"America/Panama", EST}, {"America/Pangnirtung", EST}, @@ -551,7 +553,7 @@ public final class TimeZoneNames_it extends TimeZoneNamesBundle { {"America/Tortola", AST}, {"America/Vancouver", PST}, {"America/Virgin", AST}, - {"America/Whitehorse", PST}, + {"America/Whitehorse", MST}, {"America/Winnipeg", CST}, {"America/Yakutat", AKST}, {"America/Yellowknife", MST}, @@ -782,7 +784,7 @@ public final class TimeZoneNames_it extends TimeZoneNamesBundle { {"Canada/Mountain", MST}, {"Canada/Newfoundland", NST}, {"Canada/Pacific", PST}, - {"Canada/Yukon", PST}, + {"Canada/Yukon", MST}, {"Canada/Saskatchewan", CST}, {"CAT", CAT}, {"CET", CET}, diff --git a/src/share/classes/sun/util/resources/ja/TimeZoneNames_ja.java b/src/share/classes/sun/util/resources/ja/TimeZoneNames_ja.java index 8bec0d7db00624b2566addc7c140d93188edf95b..7df275b94f7916da86fcd8cd96b1a46780dd0e74 100644 --- a/src/share/classes/sun/util/resources/ja/TimeZoneNames_ja.java +++ b/src/share/classes/sun/util/resources/ja/TimeZoneNames_ja.java @@ -252,6 +252,9 @@ public final class TimeZoneNames_ja extends TimeZoneNamesBundle { String WET[] = new String[] {"\u897f\u30e8\u30fc\u30ed\u30c3\u30d1\u6642\u9593", "WET", "\u897f\u30e8\u30fc\u30ed\u30c3\u30d1\u590f\u6642\u9593", "WEST", "\u897F\u90E8\u30E8\u30FC\u30ED\u30C3\u30D1\u6642\u9593", "WET"}; + String WGT[] = new String[] {"\u897f\u30b0\u30ea\u30fc\u30f3\u30e9\u30f3\u30c9\u6642\u9593", "WGT", + "\u897f\u30b0\u30ea\u30fc\u30f3\u30e9\u30f3\u30c9\u590f\u6642\u9593", "WGST", + "\u897F\u90E8\u30B0\u30EA\u30FC\u30F3\u30E9\u30F3\u30C9\u6642\u9593", "WGT"}; String WIT[] = new String[] {"\u897f\u30a4\u30f3\u30c9\u30cd\u30b7\u30a2\u6642\u9593", "WIB", "\u897f\u30a4\u30f3\u30c9\u30cd\u30b7\u30a2\u590f\u6642\u9593", "WIST", "\u897F\u90E8\u30A4\u30F3\u30C9\u30CD\u30B7\u30A2\u6642\u9593", "WIB"}; @@ -430,7 +433,7 @@ public final class TimeZoneNames_ja extends TimeZoneNamesBundle { {"America/Cuiaba", AMT}, {"America/Curacao", AST}, {"America/Danmarkshavn", GMT}, - {"America/Dawson", PST}, + {"America/Dawson", MST}, {"America/Dawson_Creek", MST}, {"America/Detroit", EST}, {"America/Dominica", AST}, @@ -442,9 +445,7 @@ public final class TimeZoneNames_ja extends TimeZoneNamesBundle { {"America/Fort_Wayne", EST}, {"America/Fortaleza", BRT}, {"America/Glace_Bay", AST}, - {"America/Godthab", new String[] {"\u897f\u30b0\u30ea\u30fc\u30f3\u30e9\u30f3\u30c9\u6642\u9593", "WGT", - "\u897f\u30b0\u30ea\u30fc\u30f3\u30e9\u30f3\u30c9\u590f\u6642\u9593", "WGST", - "\u897F\u90E8\u30B0\u30EA\u30FC\u30F3\u30E9\u30F3\u30C9\u6642\u9593", "WGT"}}, + {"America/Godthab", WGT}, {"America/Goose_Bay", AST}, {"America/Grand_Turk", EST}, {"America/Grenada", AST}, @@ -512,6 +513,7 @@ public final class TimeZoneNames_ja extends TimeZoneNamesBundle { {"America/North_Dakota/Beulah", CST}, {"America/North_Dakota/Center", CST}, {"America/North_Dakota/New_Salem", CST}, + {"America/Nuuk", WGT}, {"America/Ojinaga", MST}, {"America/Panama", EST}, {"America/Pangnirtung", EST}, @@ -551,7 +553,7 @@ public final class TimeZoneNames_ja extends TimeZoneNamesBundle { {"America/Tortola", AST}, {"America/Vancouver", PST}, {"America/Virgin", AST}, - {"America/Whitehorse", PST}, + {"America/Whitehorse", MST}, {"America/Winnipeg", CST}, {"America/Yakutat", AKST}, {"America/Yellowknife", MST}, @@ -782,7 +784,7 @@ public final class TimeZoneNames_ja extends TimeZoneNamesBundle { {"Canada/Mountain", MST}, {"Canada/Newfoundland", NST}, {"Canada/Pacific", PST}, - {"Canada/Yukon", PST}, + {"Canada/Yukon", MST}, {"Canada/Saskatchewan", CST}, {"CAT", CAT}, {"CET", CET}, diff --git a/src/share/classes/sun/util/resources/ko/TimeZoneNames_ko.java b/src/share/classes/sun/util/resources/ko/TimeZoneNames_ko.java index 7c72073b732a82b99b535bb3250159bd07d4db97..972817a6950e08d0467be571e84e5a28663cfc7e 100644 --- a/src/share/classes/sun/util/resources/ko/TimeZoneNames_ko.java +++ b/src/share/classes/sun/util/resources/ko/TimeZoneNames_ko.java @@ -252,6 +252,9 @@ public final class TimeZoneNames_ko extends TimeZoneNamesBundle { String WET[] = new String[] {"\uc11c\uc720\ub7fd \uc2dc\uac04", "WET", "\uc11c\uc720\ub7fd \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "WEST", "\uC11C\uBD80 \uC720\uB7FD \uD45C\uC900\uC2DC", "WET"}; + String WGT[] = new String[] {"\uc11c\ubd80 \uadf8\ub9b0\ub79c\ub4dc \uc2dc\uac04", "WGT", + "\uc11c\ubd80 \uadf8\ub9b0\ub79c\ub4dc \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "WGST", + "\uC11C\uBD80 \uADF8\uB9B0\uB780\uB4DC \uD45C\uC900\uC2DC", "WGT"}; String WIT[] = new String[] {"\uc11c\uc778\ub3c4\ub124\uc2dc\uc544 \uc2dc\uac04", "WIB", "\uc11c\uc778\ub3c4\ub124\uc2dc\uc544 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "WIST", "\uC11C\uBD80 \uC778\uB3C4\uB124\uC2DC\uC544 \uD45C\uC900\uC2DC", "WIB"}; @@ -430,7 +433,7 @@ public final class TimeZoneNames_ko extends TimeZoneNamesBundle { {"America/Cuiaba", AMT}, {"America/Curacao", AST}, {"America/Danmarkshavn", GMT}, - {"America/Dawson", PST}, + {"America/Dawson", MST}, {"America/Dawson_Creek", MST}, {"America/Detroit", EST}, {"America/Dominica", AST}, @@ -442,9 +445,7 @@ public final class TimeZoneNames_ko extends TimeZoneNamesBundle { {"America/Fort_Wayne", EST}, {"America/Fortaleza", BRT}, {"America/Glace_Bay", AST}, - {"America/Godthab", new String[] {"\uc11c\ubd80 \uadf8\ub9b0\ub79c\ub4dc \uc2dc\uac04", "WGT", - "\uc11c\ubd80 \uadf8\ub9b0\ub79c\ub4dc \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "WGST", - "\uC11C\uBD80 \uADF8\uB9B0\uB780\uB4DC \uD45C\uC900\uC2DC", "WGT"}}, + {"America/Godthab", WGT}, {"America/Goose_Bay", AST}, {"America/Grand_Turk", EST}, {"America/Grenada", AST}, @@ -512,6 +513,7 @@ public final class TimeZoneNames_ko extends TimeZoneNamesBundle { {"America/North_Dakota/Beulah", CST}, {"America/North_Dakota/Center", CST}, {"America/North_Dakota/New_Salem", CST}, + {"America/Nuuk", WGT}, {"America/Ojinaga", MST}, {"America/Panama", EST}, {"America/Pangnirtung", EST}, @@ -551,7 +553,7 @@ public final class TimeZoneNames_ko extends TimeZoneNamesBundle { {"America/Tortola", AST}, {"America/Vancouver", PST}, {"America/Virgin", AST}, - {"America/Whitehorse", PST}, + {"America/Whitehorse", MST}, {"America/Winnipeg", CST}, {"America/Yakutat", AKST}, {"America/Yellowknife", MST}, @@ -782,7 +784,7 @@ public final class TimeZoneNames_ko extends TimeZoneNamesBundle { {"Canada/Mountain", MST}, {"Canada/Newfoundland", NST}, {"Canada/Pacific", PST}, - {"Canada/Yukon", PST}, + {"Canada/Yukon", MST}, {"Canada/Saskatchewan", CST}, {"CAT", CAT}, {"CET", CET}, diff --git a/src/share/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java b/src/share/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java index c65dfa5da752d8ffc1afc4a7237524552f9b9b15..30ee7cdb8e32020da9190e4f692ad7e8cb7c780c 100644 --- a/src/share/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java +++ b/src/share/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java @@ -252,6 +252,9 @@ public final class TimeZoneNames_pt_BR extends TimeZoneNamesBundle { String WET[] = new String[] {"Fuso hor\u00e1rio da Europa Ocidental", "WET", "Fuso hor\u00e1rio de ver\u00e3o da Europa Ocidental", "WEST", "Hor\u00E1rio da Europa Ocidental", "WET"}; + String WGT[] = new String[] {"Fuso hor\u00e1rio da Groenl\u00e2ndia Ocidental", "WGT", + "Fuso hor\u00e1rio de ver\u00e3o da Groenl\u00e2ndia Ocidental", "WGST", + "Hor\u00E1rio da Groenl\u00E2ndia Ocidental", "WGT"}; String WIT[] = new String[] {"Fuso hor\u00e1rio da Indon\u00e9sia Ocidental", "WIB", "Fuso hor\u00e1rio de ver\u00e3o da Indon\u00e9sia Ocidental", "WIST", "Hor\u00E1rio da Indon\u00E9sia Ocidental", "WIB"}; @@ -430,7 +433,7 @@ public final class TimeZoneNames_pt_BR extends TimeZoneNamesBundle { {"America/Cuiaba", AMT}, {"America/Curacao", AST}, {"America/Danmarkshavn", GMT}, - {"America/Dawson", PST}, + {"America/Dawson", MST}, {"America/Dawson_Creek", MST}, {"America/Detroit", EST}, {"America/Dominica", AST}, @@ -442,9 +445,7 @@ public final class TimeZoneNames_pt_BR extends TimeZoneNamesBundle { {"America/Fort_Wayne", EST}, {"America/Fortaleza", BRT}, {"America/Glace_Bay", AST}, - {"America/Godthab", new String[] {"Fuso hor\u00e1rio da Groenl\u00e2ndia Ocidental", "WGT", - "Fuso hor\u00e1rio de ver\u00e3o da Groenl\u00e2ndia Ocidental", "WGST", - "Hor\u00E1rio da Groenl\u00E2ndia Ocidental", "WGT"}}, + {"America/Godthab", WGT}, {"America/Goose_Bay", AST}, {"America/Grand_Turk", EST}, {"America/Grenada", AST}, @@ -512,6 +513,7 @@ public final class TimeZoneNames_pt_BR extends TimeZoneNamesBundle { {"America/North_Dakota/Beulah", CST}, {"America/North_Dakota/Center", CST}, {"America/North_Dakota/New_Salem", CST}, + {"America/Nuuk", WGT}, {"America/Ojinaga", MST}, {"America/Panama", EST}, {"America/Pangnirtung", EST}, @@ -551,7 +553,7 @@ public final class TimeZoneNames_pt_BR extends TimeZoneNamesBundle { {"America/Tortola", AST}, {"America/Vancouver", PST}, {"America/Virgin", AST}, - {"America/Whitehorse", PST}, + {"America/Whitehorse", MST}, {"America/Winnipeg", CST}, {"America/Yakutat", AKST}, {"America/Yellowknife", MST}, @@ -782,7 +784,7 @@ public final class TimeZoneNames_pt_BR extends TimeZoneNamesBundle { {"Canada/Mountain", MST}, {"Canada/Newfoundland", NST}, {"Canada/Pacific", PST}, - {"Canada/Yukon", PST}, + {"Canada/Yukon", MST}, {"Canada/Saskatchewan", CST}, {"CAT", CAT}, {"CET", CET}, diff --git a/src/share/classes/sun/util/resources/sv/TimeZoneNames_sv.java b/src/share/classes/sun/util/resources/sv/TimeZoneNames_sv.java index 6ce81e8011b1e1a3114f765b8c180072c895b35a..e162bb32eb1562c028cbc0c2be334b1db562cf1e 100644 --- a/src/share/classes/sun/util/resources/sv/TimeZoneNames_sv.java +++ b/src/share/classes/sun/util/resources/sv/TimeZoneNames_sv.java @@ -252,6 +252,9 @@ public final class TimeZoneNames_sv extends TimeZoneNamesBundle { String WET[] = new String[] {"V\u00e4steuropeisk tid", "WET", "V\u00e4steuropeisk sommartid", "WEST", "V\u00E4steuropeisk tid", "WET"}; + String WGT[] = new String[] {"V\u00e4stra Gr\u00f6nland, normaltid", "WGT", + "V\u00e4stra Gr\u00f6nland, sommartid", "WGST", + "V\u00E4stgr\u00F6nl\u00E4ndsk tid", "WGT"}; String WIT[] = new String[] {"V\u00e4stindonesisk tid", "WIB", "V\u00e4stindonesisk sommartid", "WIST", "V\u00E4stindonesisk tid", "WIB"}; @@ -430,7 +433,7 @@ public final class TimeZoneNames_sv extends TimeZoneNamesBundle { {"America/Cuiaba", AMT}, {"America/Curacao", AST}, {"America/Danmarkshavn", GMT}, - {"America/Dawson", PST}, + {"America/Dawson", MST}, {"America/Dawson_Creek", MST}, {"America/Detroit", EST}, {"America/Dominica", AST}, @@ -442,9 +445,7 @@ public final class TimeZoneNames_sv extends TimeZoneNamesBundle { {"America/Fort_Wayne", EST}, {"America/Fortaleza", BRT}, {"America/Glace_Bay", AST}, - {"America/Godthab", new String[] {"V\u00e4stra Gr\u00f6nland, normaltid", "WGT", - "V\u00e4stra Gr\u00f6nland, sommartid", "WGST", - "V\u00E4stgr\u00F6nl\u00E4ndsk tid", "WGT"}}, + {"America/Godthab", WGT}, {"America/Goose_Bay", AST}, {"America/Grand_Turk", EST}, {"America/Grenada", AST}, @@ -512,6 +513,7 @@ public final class TimeZoneNames_sv extends TimeZoneNamesBundle { {"America/North_Dakota/Beulah", CST}, {"America/North_Dakota/Center", CST}, {"America/North_Dakota/New_Salem", CST}, + {"America/Nuuk", WGT}, {"America/Ojinaga", MST}, {"America/Panama", EST}, {"America/Pangnirtung", EST}, @@ -551,7 +553,7 @@ public final class TimeZoneNames_sv extends TimeZoneNamesBundle { {"America/Tortola", AST}, {"America/Vancouver", PST}, {"America/Virgin", AST}, - {"America/Whitehorse", PST}, + {"America/Whitehorse", MST}, {"America/Winnipeg", CST}, {"America/Yakutat", AKST}, {"America/Yellowknife", MST}, @@ -782,7 +784,7 @@ public final class TimeZoneNames_sv extends TimeZoneNamesBundle { {"Canada/Mountain", MST}, {"Canada/Newfoundland", NST}, {"Canada/Pacific", PST}, - {"Canada/Yukon", PST}, + {"Canada/Yukon", MST}, {"Canada/Saskatchewan", CST}, {"CAT", CAT}, {"CET", CET}, diff --git a/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java b/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java index 3e81b6b42c0bf3ddbc49113c6de49acfa4cda07c..5c9496248c667107d31c9aeb52dee8f7f519d709 100644 --- a/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java +++ b/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java @@ -252,6 +252,9 @@ public final class TimeZoneNames_zh_CN extends TimeZoneNamesBundle { String WET[] = new String[] {"\u897f\u6b27\u65f6\u95f4", "WET", "\u897f\u6b27\u590f\u4ee4\u65f6", "WEST", "\u897F\u6B27\u65F6\u95F4", "WET"}; + String WGT[] = new String[] {"\u897f\u683c\u6797\u5170\u5c9b\u65f6\u95f4", "WGT", + "\u897f\u683c\u6797\u5170\u5c9b\u590f\u4ee4\u65f6", "WGST", + "\u897F\u683C\u6797\u5170\u5C9B\u65F6\u95F4", "WGT"}; String WIT[] = new String[] {"\u897f\u5370\u5ea6\u5c3c\u897f\u4e9a\u65f6\u95f4", "WIB", "\u897f\u5370\u5ea6\u5c3c\u897f\u4e9a\u590f\u4ee4\u65f6", "WIST", "\u897F\u5370\u5EA6\u5C3C\u897F\u4E9A\u65F6\u95F4", "WIB"}; @@ -430,7 +433,7 @@ public final class TimeZoneNames_zh_CN extends TimeZoneNamesBundle { {"America/Cuiaba", AMT}, {"America/Curacao", AST}, {"America/Danmarkshavn", GMT}, - {"America/Dawson", PST}, + {"America/Dawson", MST}, {"America/Dawson_Creek", MST}, {"America/Detroit", EST}, {"America/Dominica", AST}, @@ -442,9 +445,7 @@ public final class TimeZoneNames_zh_CN extends TimeZoneNamesBundle { {"America/Fort_Wayne", EST}, {"America/Fortaleza", BRT}, {"America/Glace_Bay", AST}, - {"America/Godthab", new String[] {"\u897f\u683c\u6797\u5170\u5c9b\u65f6\u95f4", "WGT", - "\u897f\u683c\u6797\u5170\u5c9b\u590f\u4ee4\u65f6", "WGST", - "\u897F\u683C\u6797\u5170\u5C9B\u65F6\u95F4", "WGT"}}, + {"America/Godthab", WGT}, {"America/Goose_Bay", AST}, {"America/Grand_Turk", EST}, {"America/Grenada", AST}, @@ -512,6 +513,7 @@ public final class TimeZoneNames_zh_CN extends TimeZoneNamesBundle { {"America/North_Dakota/Beulah", CST}, {"America/North_Dakota/Center", CST}, {"America/North_Dakota/New_Salem", CST}, + {"America/Nuuk", WGT}, {"America/Ojinaga", MST}, {"America/Panama", EST}, {"America/Pangnirtung", EST}, @@ -551,7 +553,7 @@ public final class TimeZoneNames_zh_CN extends TimeZoneNamesBundle { {"America/Tortola", AST}, {"America/Vancouver", PST}, {"America/Virgin", AST}, - {"America/Whitehorse", PST}, + {"America/Whitehorse", MST}, {"America/Winnipeg", CST}, {"America/Yakutat", AKST}, {"America/Yellowknife", MST}, @@ -782,7 +784,7 @@ public final class TimeZoneNames_zh_CN extends TimeZoneNamesBundle { {"Canada/Mountain", MST}, {"Canada/Newfoundland", NST}, {"Canada/Pacific", PST}, - {"Canada/Yukon", PST}, + {"Canada/Yukon", MST}, {"Canada/Saskatchewan", CST}, {"CAT", CAT}, {"CET", CET}, diff --git a/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java b/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java index 0233a53f4fcf7084700c2aa23aeee64c46d858ba..080de6d6a426020f2065ba885d2a46e0a8069744 100644 --- a/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java +++ b/src/share/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java @@ -252,6 +252,9 @@ public final class TimeZoneNames_zh_TW extends TimeZoneNamesBundle { String WET[] = new String[] {"\u897f\u6b50\u6642\u9593", "WET", "\u897f\u6b50\u590f\u4ee4\u6642\u9593", "WEST", "\u897F\u6B50\u6642\u9593", "WET"}; + String WGT[] = new String[] {"\u897f\u683c\u6797\u862d\u5cf6\u6642\u9593", "WGT", + "\u897f\u683c\u6797\u862d\u5cf6\u590f\u4ee4\u6642\u9593", "WGST", + "\u897F\u683C\u9675\u862D\u6642\u9593", "WGT"}; String WIT[] = new String[] {"\u897f\u5370\u5c3c\u6642\u9593", "WIB", "\u897f\u5370\u5c3c\u590f\u4ee4\u6642\u9593", "WIST", "\u897F\u5370\u5C3C\u6642\u9593", "WIB"}; @@ -430,7 +433,7 @@ public final class TimeZoneNames_zh_TW extends TimeZoneNamesBundle { {"America/Cuiaba", AMT}, {"America/Curacao", AST}, {"America/Danmarkshavn", GMT}, - {"America/Dawson", PST}, + {"America/Dawson", MST}, {"America/Dawson_Creek", MST}, {"America/Detroit", EST}, {"America/Dominica", AST}, @@ -442,9 +445,7 @@ public final class TimeZoneNames_zh_TW extends TimeZoneNamesBundle { {"America/Fort_Wayne", EST}, {"America/Fortaleza", BRT}, {"America/Glace_Bay", AST}, - {"America/Godthab", new String[] {"\u897f\u683c\u6797\u862d\u5cf6\u6642\u9593", "WGT", - "\u897f\u683c\u6797\u862d\u5cf6\u590f\u4ee4\u6642\u9593", "WGST", - "\u897F\u683C\u9675\u862D\u6642\u9593", "WGT"}}, + {"America/Godthab", WGT}, {"America/Goose_Bay", AST}, {"America/Grand_Turk", EST}, {"America/Grenada", AST}, @@ -512,6 +513,7 @@ public final class TimeZoneNames_zh_TW extends TimeZoneNamesBundle { {"America/North_Dakota/Beulah", CST}, {"America/North_Dakota/Center", CST}, {"America/North_Dakota/New_Salem", CST}, + {"America/Nuuk", WGT}, {"America/Ojinaga", MST}, {"America/Panama", EST}, {"America/Pangnirtung", EST}, @@ -551,7 +553,7 @@ public final class TimeZoneNames_zh_TW extends TimeZoneNamesBundle { {"America/Tortola", AST}, {"America/Vancouver", PST}, {"America/Virgin", AST}, - {"America/Whitehorse", PST}, + {"America/Whitehorse", MST}, {"America/Winnipeg", CST}, {"America/Yakutat", AKST}, {"America/Yellowknife", MST}, @@ -784,7 +786,7 @@ public final class TimeZoneNames_zh_TW extends TimeZoneNamesBundle { {"Canada/Mountain", MST}, {"Canada/Newfoundland", NST}, {"Canada/Pacific", PST}, - {"Canada/Yukon", PST}, + {"Canada/Yukon", MST}, {"Canada/Saskatchewan", CST}, {"CAT", CAT}, {"CET", CET}, diff --git a/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystem.java b/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystem.java index 929361c1de9536ef85dee94615eca7c479185af7..747bf1e63b4cb3fbeb059c34456348b9be9779fa 100644 --- a/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystem.java +++ b/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -289,6 +289,14 @@ public class ZipFileSystem extends FileSystem { def.end(); } + beginWrite(); // lock and sync + try { + // Clear the map so that its keys & values can be garbage collected + inodes = null; + } finally { + endWrite(); + } + IOException ioe = null; synchronized (tmppaths) { for (Path p: tmppaths) { @@ -497,6 +505,7 @@ public class ZipFileSystem extends FileSystem { boolean hasCreateNew = false; boolean hasCreate = false; boolean hasAppend = false; + boolean hasTruncate = false; for (OpenOption opt: options) { if (opt == READ) throw new IllegalArgumentException("READ not allowed"); @@ -506,7 +515,11 @@ public class ZipFileSystem extends FileSystem { hasCreate = true; if (opt == APPEND) hasAppend = true; + if (opt == TRUNCATE_EXISTING) + hasTruncate = true; } + if (hasAppend && hasTruncate) + throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed"); beginRead(); // only need a readlock, the "update()" will try { // try to obtain a writelock when the os is ensureOpen(); // being closed. @@ -558,6 +571,8 @@ public class ZipFileSystem extends FileSystem { if (!(option instanceof StandardOpenOption)) throw new IllegalArgumentException(); } + if (options.contains(APPEND) && options.contains(TRUNCATE_EXISTING)) + throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed"); } // Returns a Writable/ReadByteChannel for now. Might consdier to use @@ -705,15 +720,19 @@ public class ZipFileSystem extends FileSystem { if (forWrite) { checkWritable(); if (e == null) { - if (!options.contains(StandardOpenOption.CREATE_NEW)) - throw new NoSuchFileException(getString(path)); + if (!options.contains(StandardOpenOption.CREATE) && + !options.contains(StandardOpenOption.CREATE_NEW)) { + throw new NoSuchFileException(getString(path)); + } } else { - if (options.contains(StandardOpenOption.CREATE_NEW)) + if (options.contains(StandardOpenOption.CREATE_NEW)) { throw new FileAlreadyExistsException(getString(path)); + } if (e.isDir()) throw new FileAlreadyExistsException("directory <" + getString(path) + "> exists"); } + options = new HashSet<>(options); options.remove(StandardOpenOption.CREATE_NEW); // for tmpfile } else if (e == null || e.isDir()) { throw new NoSuchFileException(getString(path)); @@ -1086,9 +1105,7 @@ public class ZipFileSystem extends FileSystem { // Creates a new empty temporary file in the same directory as the // specified file. A variant of Files.createTempFile. - private Path createTempFileInSameDirectoryAs(Path path) - throws IOException - { + private Path createTempFileInSameDirectoryAs(Path path) throws IOException { Path parent = path.toAbsolutePath().getParent(); Path dir = (parent == null) ? path.getFileSystem().getPath(".") : parent; Path tmpPath = Files.createTempFile(dir, "zipfstmp", null); @@ -1194,6 +1211,7 @@ public class ZipFileSystem extends FileSystem { } if (!hasUpdate) return; + PosixFileAttributes attrs = getPosixAttributes(zfpath); Path tmpFile = createTempFileInSameDirectoryAs(zfpath); try (OutputStream os = new BufferedOutputStream(Files.newOutputStream(tmpFile, WRITE))) { @@ -1294,6 +1312,11 @@ public class ZipFileSystem extends FileSystem { Files.delete(zfpath); } + // Set the POSIX permissions of the original Zip File if available + // before moving the temp file + if (attrs != null) { + Files.setPosixFilePermissions(tmpFile, attrs.permissions()); + } Files.move(tmpFile, zfpath, REPLACE_EXISTING); hasUpdate = false; // clear /* @@ -1305,6 +1328,29 @@ public class ZipFileSystem extends FileSystem { //System.out.printf("->sync(%s) done!%n", toString()); } + /** + * Returns a file's POSIX file attributes. + * @param path The path to the file + * @return The POSIX file attributes for the specified file or + * null if the POSIX attribute view is not available + * @throws IOException If an error occurs obtaining the POSIX attributes for + * the specified file + */ + private PosixFileAttributes getPosixAttributes(Path path) throws IOException { + try { + PosixFileAttributeView view = + Files.getFileAttributeView(path, PosixFileAttributeView.class); + // Return if the attribute view is not supported + if (view == null) { + return null; + } + return view.readAttributes(); + } catch (UnsupportedOperationException e) { + // PosixFileAttributes not available + return null; + } + } + private IndexNode getInode(byte[] path) { if (path == null) throw new NullPointerException("path"); diff --git a/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipPath.java b/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipPath.java index 3527e5de25b2a87f526c75b128f4dafa8a70a00b..ebfe7be7f51388e824eccb77a9abee6d94a294da 100644 --- a/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipPath.java +++ b/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipPath.java @@ -788,7 +788,7 @@ public class ZipPath implements Path { { if (options.length == 0) return zfs.newOutputStream(getResolvedPath(), - CREATE_NEW, WRITE); + CREATE, TRUNCATE_EXISTING, WRITE); return zfs.newOutputStream(getResolvedPath(), options); } diff --git a/src/share/instrument/EncodingSupport.c b/src/share/instrument/EncodingSupport.c index 2e290b721a334809afa384247879ee6d53dc86b0..8261b92acf90ed87b081e45891f4e11a993e9367 100644 --- a/src/share/instrument/EncodingSupport.c +++ b/src/share/instrument/EncodingSupport.c @@ -38,7 +38,11 @@ modifiedUtf8LengthOfUtf8(char* string, int length) { int i; new_length = 0; - for ( i = 0 ; i < length ; i++ ) { + /* + * if length < 0 or new_length becomes < 0 => string is too big + * (handled as error after the cycle). + */ + for ( i = 0 ; i < length && new_length >= 0 ; i++ ) { unsigned byte; byte = (unsigned char)string[i]; diff --git a/src/share/instrument/InvocationAdapter.c b/src/share/instrument/InvocationAdapter.c index f1923d7cc3f4504d9756277d36e7d08680031ac0..5aa189b054634bec239d6a563b0c7655ab94982e 100644 --- a/src/share/instrument/InvocationAdapter.c +++ b/src/share/instrument/InvocationAdapter.c @@ -203,6 +203,19 @@ Agent_OnLoad(JavaVM *vm, char *tail, void * reserved) { */ oldLen = (int)strlen(premainClass); newLen = modifiedUtf8LengthOfUtf8(premainClass, oldLen); + /* + * According to JVMS class name is represented as CONSTANT_Utf8_info, + * so its length is u2 (i.e. must be <= 0xFFFF). + * Negative oldLen or newLen means we got signed integer overflow + * (modifiedUtf8LengthOfUtf8 returns negative value if oldLen is negative). + */ + if (oldLen < 0 || newLen < 0 || newLen > 0xFFFF) { + fprintf(stderr, "-javaagent: Premain-Class value is too big\n"); + free(jarfile); + if (options != NULL) free(options); + freeAttributes(attributes); + return JNI_ERR; + } if (newLen == oldLen) { premainClass = strdup(premainClass); } else { @@ -362,6 +375,19 @@ Agent_OnAttach(JavaVM* vm, char *args, void * reserved) { */ oldLen = strlen(agentClass); newLen = modifiedUtf8LengthOfUtf8(agentClass, oldLen); + /* + * According to JVMS class name is represented as CONSTANT_Utf8_info, + * so its length is u2 (i.e. must be <= 0xFFFF). + * Negative oldLen or newLen means we got signed integer overflow + * (modifiedUtf8LengthOfUtf8 returns negative value if oldLen is negative). + */ + if (oldLen < 0 || newLen < 0 || newLen > 0xFFFF) { + fprintf(stderr, "Agent-Class value is too big\n"); + free(jarfile); + if (options != NULL) free(options); + freeAttributes(attributes); + return AGENT_ERROR_BADJAR; + } if (newLen == oldLen) { agentClass = strdup(agentClass); } else { diff --git a/src/share/javavm/export/jvm.h b/src/share/javavm/export/jvm.h index f1a64d966ed7e142352db6191e7a26760eb903e5..cfcc5d509a093655f9b88fd9fab5da87160be4a9 100644 --- a/src/share/javavm/export/jvm.h +++ b/src/share/javavm/export/jvm.h @@ -131,6 +131,9 @@ JVM_CopySwapMemory(JNIEnv *env, jobject srcObj, jlong srcOffset, JNIEXPORT void JNICALL JVM_Exit(jint code); +JNIEXPORT void JNICALL +JVM_BeforeHalt(); + JNIEXPORT void JNICALL JVM_Halt(jint code); @@ -1516,8 +1519,8 @@ typedef struct { } jvm_version_info; #define JVM_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24) -#define JVM_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16) -#define JVM_VERSION_MICRO(version) ((version & 0x0000FF00) >> 8) +#define JVM_VERSION_MINOR(version) ((version & 0x00FFFF00) >> 8) +#define JVM_VERSION_MICRO(version) 0 /* Build number is available only for RE builds. * It will be zero for internal builds. @@ -1531,9 +1534,9 @@ typedef struct { // Naming convention of RE build version string: n.n.n[_uu[c]][-]-bxx unsigned int jdk_version; /* Consists of major, minor, micro (n.n.n) */ /* and build number (xx) */ - unsigned int update_version : 8; /* Update release version (uu) */ + unsigned int update_version : 16; /* Update release version (uu) */ unsigned int special_update_version : 8; /* Special update release version (c)*/ - unsigned int reserved1 : 16; + unsigned int reserved1 : 8; unsigned int reserved2; /* The following bits represents new JDK supports that VM has dependency on. diff --git a/src/share/lib/security/cacerts b/src/share/lib/security/cacerts deleted file mode 100644 index 2adbd1168cbce6caf2d09aad8bc80833fd3454d2..0000000000000000000000000000000000000000 Binary files a/src/share/lib/security/cacerts and /dev/null differ diff --git a/src/share/lib/security/java.security-aix b/src/share/lib/security/java.security-aix index 6e52f0ef8de6fd735fb19564be3b5fb20dcdd630..e57fd58fe98be0df01b57c6bd9caec92b53b20e9 100644 --- a/src/share/lib/security/java.security-aix +++ b/src/share/lib/security/java.security-aix @@ -223,7 +223,10 @@ package.access=sun.,\ jdk.nashorn.internal.,\ jdk.nashorn.tools.,\ jdk.xml.internal.,\ - com.sun.activation.registries. + com.sun.activation.registries.,\ + jdk.jfr.events.,\ + jdk.jfr.internal.,\ + jdk.management.jfr.internal. # # List of comma-separated packages that start with or equal this string @@ -273,7 +276,10 @@ package.definition=sun.,\ jdk.nashorn.internal.,\ jdk.nashorn.tools.,\ jdk.xml.internal.,\ - com.sun.activation.registries. + com.sun.activation.registries.,\ + jdk.jfr.events.,\ + jdk.jfr.internal.,\ + jdk.management.jfr.internal. # # Determines whether this properties file can be appended to @@ -1002,6 +1008,34 @@ jdk.xml.dsig.secureValidationPolicy=\ jceks.key.serialFilter = java.lang.Enum;java.security.KeyRep;\ java.security.KeyRep$Type;javax.crypto.spec.SecretKeySpec;!* +# The iteration count used for password-based encryption (PBE) in JCEKS +# keystores. Values in the range 10000 to 5000000 are considered valid. +# If the value is out of this range, or is not a number, or is unspecified; +# a default of 200000 is used. +# +# If the system property jdk.jceks.iterationCount is also specified, it +# supersedes the security property value defined here. +# +#jdk.jceks.iterationCount = 200000 + +# +# 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). # diff --git a/src/share/lib/security/java.security-linux b/src/share/lib/security/java.security-linux index 349c6c9d1ddc2247ebf6f65dfa74596306c14f67..0e3e216e15ba0555cc30b5953ee4ec9d88fd95f5 100644 --- a/src/share/lib/security/java.security-linux +++ b/src/share/lib/security/java.security-linux @@ -223,7 +223,10 @@ package.access=sun.,\ jdk.nashorn.internal.,\ jdk.nashorn.tools.,\ jdk.xml.internal.,\ - com.sun.activation.registries. + com.sun.activation.registries.,\ + jdk.jfr.events.,\ + jdk.jfr.internal.,\ + jdk.management.jfr.internal. # # List of comma-separated packages that start with or equal this string @@ -273,7 +276,10 @@ package.definition=sun.,\ jdk.nashorn.internal.,\ jdk.nashorn.tools.,\ jdk.xml.internal.,\ - com.sun.activation.registries. + com.sun.activation.registries.,\ + jdk.jfr.events.,\ + jdk.jfr.internal.,\ + jdk.management.jfr.internal. # # Determines whether this properties file can be appended to @@ -1008,6 +1014,34 @@ jdk.xml.dsig.secureValidationPolicy=\ jceks.key.serialFilter = java.lang.Enum;java.security.KeyRep;\ java.security.KeyRep$Type;javax.crypto.spec.SecretKeySpec;!* +# The iteration count used for password-based encryption (PBE) in JCEKS +# keystores. Values in the range 10000 to 5000000 are considered valid. +# If the value is out of this range, or is not a number, or is unspecified; +# a default of 200000 is used. +# +# If the system property jdk.jceks.iterationCount is also specified, it +# supersedes the security property value defined here. +# +#jdk.jceks.iterationCount = 200000 + +# +# 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). # diff --git a/src/share/lib/security/java.security-macosx b/src/share/lib/security/java.security-macosx index 6404a382ecec87a910514596cb74de8f1cf479b6..7ca95dea57672f02ff0ca6bcecee77e5c2211a2c 100644 --- a/src/share/lib/security/java.security-macosx +++ b/src/share/lib/security/java.security-macosx @@ -225,7 +225,10 @@ package.access=sun.,\ jdk.nashorn.tools.,\ jdk.xml.internal.,\ com.sun.activation.registries.,\ - apple. + apple.,\ + jdk.jfr.events.,\ + jdk.jfr.internal.,\ + jdk.management.jfr.internal. # # List of comma-separated packages that start with or equal this string @@ -276,7 +279,10 @@ package.definition=sun.,\ jdk.nashorn.tools.,\ jdk.xml.internal.,\ com.sun.activation.registries.,\ - apple. + apple.,\ + jdk.jfr.events.,\ + jdk.jfr.internal.,\ + jdk.management.jfr.internal. # # Determines whether this properties file can be appended to @@ -1006,6 +1012,34 @@ jdk.xml.dsig.secureValidationPolicy=\ jceks.key.serialFilter = java.lang.Enum;java.security.KeyRep;\ java.security.KeyRep$Type;javax.crypto.spec.SecretKeySpec;!* +# The iteration count used for password-based encryption (PBE) in JCEKS +# keystores. Values in the range 10000 to 5000000 are considered valid. +# If the value is out of this range, or is not a number, or is unspecified; +# a default of 200000 is used. +# +# If the system property jdk.jceks.iterationCount is also specified, it +# supersedes the security property value defined here. +# +#jdk.jceks.iterationCount = 200000 + +# +# 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). # diff --git a/src/share/lib/security/java.security-solaris b/src/share/lib/security/java.security-solaris index 25c478537d8cc2af6358eaa96b189c24ddc34f46..ef598676b054216dc7c50b44b72ce8af9abda2ba 100644 --- a/src/share/lib/security/java.security-solaris +++ b/src/share/lib/security/java.security-solaris @@ -225,7 +225,10 @@ package.access=sun.,\ jdk.nashorn.internal.,\ jdk.nashorn.tools.,\ jdk.xml.internal.,\ - com.sun.activation.registries. + com.sun.activation.registries.,\ + jdk.jfr.events.,\ + jdk.jfr.internal.,\ + jdk.management.jfr.internal. # # List of comma-separated packages that start with or equal this string @@ -275,8 +278,10 @@ package.definition=sun.,\ jdk.nashorn.internal.,\ jdk.nashorn.tools.,\ jdk.xml.internal.,\ - com.sun.activation.registries. - + com.sun.activation.registries.,\ + jdk.jfr.events.,\ + jdk.jfr.internal.,\ + jdk.management.jfr.internal. # # Determines whether this properties file can be appended to # or overridden on the command line via -Djava.security.properties @@ -1005,6 +1010,34 @@ jdk.xml.dsig.secureValidationPolicy=\ jceks.key.serialFilter = java.lang.Enum;java.security.KeyRep;\ java.security.KeyRep$Type;javax.crypto.spec.SecretKeySpec;!* +# The iteration count used for password-based encryption (PBE) in JCEKS +# keystores. Values in the range 10000 to 5000000 are considered valid. +# If the value is out of this range, or is not a number, or is unspecified; +# a default of 200000 is used. +# +# If the system property jdk.jceks.iterationCount is also specified, it +# supersedes the security property value defined here. +# +#jdk.jceks.iterationCount = 200000 + +# +# 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). # diff --git a/src/share/lib/security/java.security-windows b/src/share/lib/security/java.security-windows index 36122cceee8ee91b071819310b0e3072a311bbae..2bc51072bf67f5bd8872f71db3a4d5178707612b 100644 --- a/src/share/lib/security/java.security-windows +++ b/src/share/lib/security/java.security-windows @@ -225,7 +225,10 @@ package.access=sun.,\ jdk.nashorn.tools.,\ jdk.xml.internal.,\ com.sun.activation.registries.,\ - com.sun.java.accessibility. + com.sun.java.accessibility.,\ + jdk.jfr.events.,\ + jdk.jfr.internal.,\ + jdk.management.jfr.internal. # # List of comma-separated packages that start with or equal this string @@ -276,7 +279,10 @@ package.definition=sun.,\ jdk.nashorn.tools.,\ jdk.xml.internal.,\ com.sun.activation.registries.,\ - com.sun.java.accessibility. + com.sun.java.accessibility.,\ + jdk.jfr.events.,\ + jdk.jfr.internal.,\ + jdk.management.jfr.internal. # # Determines whether this properties file can be appended to @@ -1006,6 +1012,34 @@ jdk.xml.dsig.secureValidationPolicy=\ jceks.key.serialFilter = java.lang.Enum;java.security.KeyRep;\ java.security.KeyRep$Type;javax.crypto.spec.SecretKeySpec;!* +# The iteration count used for password-based encryption (PBE) in JCEKS +# keystores. Values in the range 10000 to 5000000 are considered valid. +# If the value is out of this range, or is not a number, or is unspecified; +# a default of 200000 is used. +# +# If the system property jdk.jceks.iterationCount is also specified, it +# supersedes the security property value defined here. +# +#jdk.jceks.iterationCount = 200000 + +# +# 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). # diff --git a/src/share/native/java/lang/Shutdown.c b/src/share/native/java/lang/Shutdown.c index f131a240f9bb0e9befcf63596e975dc14a26df57..b8f1bd2eaef237ffa418a220f5eac446431c24b3 100644 --- a/src/share/native/java/lang/Shutdown.c +++ b/src/share/native/java/lang/Shutdown.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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,11 @@ #include "java_lang_Shutdown.h" +JNIEXPORT void JNICALL +Java_java_lang_Shutdown_beforeHalt(JNIEnv *env, jclass ignored) +{ + JVM_BeforeHalt(); +} JNIEXPORT void JNICALL Java_java_lang_Shutdown_halt0(JNIEnv *env, jclass ignored, jint code) diff --git a/src/share/native/sun/awt/giflib/dgif_lib.c b/src/share/native/sun/awt/giflib/dgif_lib.c index 0a59e2bcb47faff59e73d1442056fab6d6ae5065..6ddfb46060de4d331d2728d85fc402b09d65ce57 100644 --- a/src/share/native/sun/awt/giflib/dgif_lib.c +++ b/src/share/native/sun/awt/giflib/dgif_lib.c @@ -30,22 +30,21 @@ The functions here and in egif_lib.c are partitioned carefully so that if you only require one of read and write capability, only one of these two modules will be linked. Preserve this property! +SPDX-License-Identifier: MIT + *****************************************************************************/ #include #include #include #include -/** Begin JDK modifications to support building on Windows **/ -#ifndef _WIN32 -#include -#endif -/** End JDK modifications to support building on Windows **/ #include #include #ifdef _WIN32 #include +#else +#include #endif /* _WIN32 */ #include "gif_lib.h" @@ -55,8 +54,7 @@ two modules will be linked. Preserve this property! #define UNSIGNED_LITTLE_ENDIAN(lo, hi) ((lo) | ((hi) << 8)) /* avoid extra function call in case we use fread (TVT) */ -/** JDK modification "inline" is dropped to support c89 **/ -static /**inline**/ int InternalRead(GifFileType *gif, GifByteType *buf, int len) { +static int InternalRead(GifFileType *gif, GifByteType *buf, int len) { //fprintf(stderr, "### Read: %d\n", len); return (((GifFilePrivateType*)gif->Private)->Read ? @@ -969,7 +967,7 @@ DGifDecompressLine(GifFileType *GifFile, GifPixelType *Line, int LineLen) while (StackPtr != 0 && i < LineLen) Line[i++] = Stack[--StackPtr]; } - if (LastCode != NO_SUCH_CODE && Private->RunningCode - 2 < LZ_MAX_CODE && Prefix[Private->RunningCode - 2] == NO_SUCH_CODE) { + if (LastCode != NO_SUCH_CODE && Private->RunningCode - 2 < (LZ_MAX_CODE+1) && Prefix[Private->RunningCode - 2] == NO_SUCH_CODE) { Prefix[Private->RunningCode - 2] = LastCode; if (CrntCode == Private->RunningCode - 2) { diff --git a/src/share/native/sun/awt/giflib/gif_err.c b/src/share/native/sun/awt/giflib/gif_err.c index cbe64068d00379f8d01a6b7a5a5db1bd96be5b58..db08838efff848cd666f1c896696ac8d2b0f4741 100644 --- a/src/share/native/sun/awt/giflib/gif_err.c +++ b/src/share/native/sun/awt/giflib/gif_err.c @@ -26,6 +26,8 @@ gif_err.c - handle error reporting for the GIF library. +SPDX-License-Identifier: MIT + ****************************************************************************/ #include diff --git a/src/share/native/sun/awt/giflib/gif_hash.h b/src/share/native/sun/awt/giflib/gif_hash.h index a2fc081af9edcc7fd0e2ffcb382e63b81e8c1f61..6cabd0866ed1e87144899df5d30a55da1aa8101e 100644 --- a/src/share/native/sun/awt/giflib/gif_hash.h +++ b/src/share/native/sun/awt/giflib/gif_hash.h @@ -26,6 +26,8 @@ gif_hash.h - magfic constants and declarations for GIF LZW +SPDX-License-Identifier: MIT + ******************************************************************************/ #ifndef _GIF_HASH_H_ diff --git a/src/share/native/sun/awt/giflib/gif_lib.h b/src/share/native/sun/awt/giflib/gif_lib.h index 828c1520b465208d457f9bb51a712ef6900128a0..f739b36adfd0f8e9368db80f20cd94c2b8f914df 100644 --- a/src/share/native/sun/awt/giflib/gif_lib.h +++ b/src/share/native/sun/awt/giflib/gif_lib.h @@ -26,6 +26,8 @@ gif_lib.h - service library for decoding and encoding GIF images +SPDX-License-Identifier: MIT + *****************************************************************************/ #ifndef _GIF_LIB_H_ @@ -36,8 +38,8 @@ extern "C" { #endif /* __cplusplus */ #define GIFLIB_MAJOR 5 -#define GIFLIB_MINOR 1 -#define GIFLIB_RELEASE 8 +#define GIFLIB_MINOR 2 +#define GIFLIB_RELEASE 1 #define GIF_ERROR 0 #define GIF_OK 1 @@ -246,15 +248,6 @@ int DGifGetLZCodes(GifFileType *GifFile, int *GifCode); const char *DGifGetGifVersion(GifFileType *GifFile); -/****************************************************************************** - Color table quantization (deprecated) -******************************************************************************/ -int GifQuantizeBuffer(unsigned int Width, unsigned int Height, - int *ColorMapSize, GifByteType * RedInput, - GifByteType * GreenInput, GifByteType * BlueInput, - GifByteType * OutputBuffer, - GifColorType * OutputColorMap); - /****************************************************************************** Error handling and reporting. ******************************************************************************/ diff --git a/src/share/native/sun/awt/giflib/gif_lib_private.h b/src/share/native/sun/awt/giflib/gif_lib_private.h index 21a5f2074e1863e6cf169129c12e6df287bcd77b..4f832676ffcd51b0e1ff0166147e3777e89779f2 100644 --- a/src/share/native/sun/awt/giflib/gif_lib_private.h +++ b/src/share/native/sun/awt/giflib/gif_lib_private.h @@ -26,6 +26,8 @@ gif_lib_private.h - internal giflib routines and structures +SPDX-License-Identifier: MIT + ****************************************************************************/ #ifndef _GIF_LIB_PRIVATE_H diff --git a/src/share/native/sun/awt/giflib/gifalloc.c b/src/share/native/sun/awt/giflib/gifalloc.c index 632458bf2b9ab47bb31d9656e09ff2d4a78e7bc8..75b74b4fba0a2393abb8de625bb40d19f9a3f27e 100644 --- a/src/share/native/sun/awt/giflib/gifalloc.c +++ b/src/share/native/sun/awt/giflib/gifalloc.c @@ -26,6 +26,8 @@ GIF construction tools +SPDX-License-Identifier: MIT + ****************************************************************************/ #include diff --git a/src/share/native/sun/awt/giflib/openbsd-reallocarray.c b/src/share/native/sun/awt/giflib/openbsd-reallocarray.c index fdc07540265982521b5266cf172cd3d7b5c7acf9..452df69d7cd4fb0fc729d4660fd0a575911a7838 100644 --- a/src/share/native/sun/awt/giflib/openbsd-reallocarray.c +++ b/src/share/native/sun/awt/giflib/openbsd-reallocarray.c @@ -25,18 +25,7 @@ /* $OpenBSD: reallocarray.c,v 1.1 2014/05/08 21:43:49 deraadt Exp $ */ /* * Copyright (c) 2008 Otto Moerbeek - * - * 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. + * SPDX-License-Identifier: MIT */ #include diff --git a/src/share/native/sun/awt/image/BufImgSurfaceData.c b/src/share/native/sun/awt/image/BufImgSurfaceData.c index d8f48a7284b7ad59e6a53ce7fb2d3f414c672139..f4782201e1a20d284f0d0d1d60979be587037e00 100644 --- a/src/share/native/sun/awt/image/BufImgSurfaceData.c +++ b/src/share/native/sun/awt/image/BufImgSurfaceData.c @@ -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 @@ -296,6 +296,7 @@ static ColorData *BufImg_SetupICM(JNIEnv *env, cData->img_clr_tbl = initCubemap(pRgb, bisdo->lutsize, 32); if (cData->img_clr_tbl == NULL) { + (*env)->ReleasePrimitiveArrayCritical(env, bisdo->lutarray, pRgb, JNI_ABORT); free(cData); return (ColorData*)NULL; } diff --git a/src/share/native/sun/awt/medialib/awt_ImagingLib.c b/src/share/native/sun/awt/medialib/awt_ImagingLib.c index 2845899749337fa8802d10ce0005c4377066451a..c946debe386f52407dd1a87282d35a87464ec26f 100644 --- a/src/share/native/sun/awt/medialib/awt_ImagingLib.c +++ b/src/share/native/sun/awt/medialib/awt_ImagingLib.c @@ -2418,7 +2418,7 @@ allocateRasterArray(JNIEnv *env, RasterS_t *rasterP, case sun_awt_image_IntegerComponentRaster_TYPE_INT_8BIT_SAMPLES: if (!((rasterP->chanOffsets[0] == 0 || SAFE_TO_ALLOC_2(rasterP->chanOffsets[0], 4)) && SAFE_TO_ALLOC_2(width, 4) && - SAFE_TO_ALLOC_3(height, rasterP->scanlineStride, 4))) + SAFE_TO_ALLOC_3(rasterP->scanlineStride, height, 4))) { return -1; } @@ -2427,7 +2427,7 @@ allocateRasterArray(JNIEnv *env, RasterS_t *rasterP, if (offset < 0 || offset >= dataSize || width > rasterP->scanlineStride || - height * rasterP->scanlineStride * 4 > dataSize - offset) + ((width + (height - 1) * rasterP->scanlineStride) * 4) > dataSize - offset) { // raster data buffer is too short return -1; @@ -2445,7 +2445,7 @@ allocateRasterArray(JNIEnv *env, RasterS_t *rasterP, return 0; case sun_awt_image_IntegerComponentRaster_TYPE_BYTE_SAMPLES: if (!(SAFE_TO_ALLOC_2(width, rasterP->numBands) && - SAFE_TO_ALLOC_2(height, rasterP->scanlineStride))) + SAFE_TO_ALLOC_2(rasterP->scanlineStride, height))) { return -1; } @@ -2454,7 +2454,8 @@ allocateRasterArray(JNIEnv *env, RasterS_t *rasterP, if (offset < 0 || offset >= dataSize || width * rasterP->numBands > rasterP->scanlineStride || - height * rasterP->scanlineStride > dataSize - offset) + ((width * rasterP->numBands) + + (height - 1) * rasterP->scanlineStride) > dataSize - offset) { // raster data buffer is too short return -1; @@ -2473,7 +2474,7 @@ allocateRasterArray(JNIEnv *env, RasterS_t *rasterP, case sun_awt_image_IntegerComponentRaster_TYPE_USHORT_SAMPLES: if (!((rasterP->chanOffsets[0] == 0 || SAFE_TO_ALLOC_2(rasterP->chanOffsets[0], 2)) && SAFE_TO_ALLOC_3(width, rasterP->numBands, 2) && - SAFE_TO_ALLOC_3(height, rasterP->scanlineStride, 2))) + SAFE_TO_ALLOC_3(rasterP->scanlineStride, height, 2))) { return -1; } @@ -2482,7 +2483,8 @@ allocateRasterArray(JNIEnv *env, RasterS_t *rasterP, if (offset < 0 || offset >= dataSize || width * rasterP->numBands > rasterP->scanlineStride || - height * rasterP->scanlineStride * 2 > dataSize - offset) + (((width * rasterP->numBands) + + (height - 1) * rasterP->scanlineStride)) * 2 > dataSize - offset) { // raster data buffer is too short return -1; diff --git a/src/share/native/sun/awt/medialib/mlib_ImageScanPoly.c b/src/share/native/sun/awt/medialib/mlib_ImageScanPoly.c index ccc15728004912758c6ff487b03ef9e38756c147..41f5cfc96e9f2a2f6a6e66d88cd6de9aa1c80b02 100644 --- a/src/share/native/sun/awt/medialib/mlib_ImageScanPoly.c +++ b/src/share/native/sun/awt/medialib/mlib_ImageScanPoly.c @@ -424,7 +424,9 @@ mlib_status mlib_AffineEdges(mlib_affine_param *param, if ((dxs < dxCl) || (dxs >= dwCl) || (dys < dyCl) || (dys >= dhCl)) { dxs += dx; dys += dy; - xLeft++; + if (xLeft < MLIB_S32_MAX) { + xLeft++; + } if ((dxs < dxCl) || (dxs >= dwCl) || (dys < dyCl) || (dys >= dhCl)) xRight = -1; @@ -436,7 +438,9 @@ mlib_status mlib_AffineEdges(mlib_affine_param *param, if ((dxe < dxCl) || (dxe >= dwCl) || (dye < dyCl) || (dye >= dhCl)) { dxe -= dx; dye -= dy; - xRight--; + if (xRight > MLIB_S32_MIN) { + xRight--; + } if ((dxe < dxCl) || (dxe >= dwCl) || (dye < dyCl) || (dye >= dhCl)) xRight = -1; @@ -510,7 +514,9 @@ mlib_status mlib_AffineEdges(mlib_affine_param *param, if ((dxs > dxCl) || (dxs <= dwCl) || (dys > dyCl) || (dys <= dhCl)) { dxs += dx; dys += dy; - xLeft++; + if (xLeft < MLIB_S32_MAX) { + xLeft++; + } if ((dxs > dxCl) || (dxs <= dwCl) || (dys > dyCl) || (dys <= dhCl)) xRight = -1; @@ -522,7 +528,9 @@ mlib_status mlib_AffineEdges(mlib_affine_param *param, if ((dxe > dxCl) || (dxe <= dwCl) || (dye > dyCl) || (dye <= dhCl)) { dxe -= dx; dye -= dy; - xRight--; + if (xRight > MLIB_S32_MIN) { + xRight--; + } if ((dxe > dxCl) || (dxe <= dwCl) || (dye > dyCl) || (dye <= dhCl)) xRight = -1; diff --git a/src/share/native/sun/awt/medialib/safe_alloc.h b/src/share/native/sun/awt/medialib/safe_alloc.h index 1ee99048e9b45bd2495ae3694e7974b37e63a76c..2565d33ac91b8344dba53ec93d1bcc172e604683 100644 --- a/src/share/native/sun/awt/medialib/safe_alloc.h +++ b/src/share/native/sun/awt/medialib/safe_alloc.h @@ -35,10 +35,10 @@ */ #define SAFE_TO_ALLOC_2(c, sz) \ (((c) > 0) && ((sz) > 0) && \ - ((0xffffffffu / ((juint)(c))) > ((juint)(sz)))) + ((0x7fffffff / (c)) > (sz))) #define SAFE_TO_ALLOC_3(w, h, sz) \ (((w) > 0) && ((h) > 0) && ((sz) > 0) && \ - (((0xffffffffu / ((juint)(w))) / ((juint)(h))) > ((juint)(sz)))) + (((0x7fffffff / (w)) / (h)) > (sz))) #endif // __SAFE_ALLOC_H__ diff --git a/src/share/native/sun/awt/splashscreen/splashscreen_gfx_impl.c b/src/share/native/sun/awt/splashscreen/splashscreen_gfx_impl.c index a107e9321ddb881f218b918fd03835c147da8f70..06cc8ffaafad3ab51784224dc030b24dd6b2147e 100644 --- a/src/share/native/sun/awt/splashscreen/splashscreen_gfx_impl.c +++ b/src/share/native/sun/awt/splashscreen/splashscreen_gfx_impl.c @@ -206,7 +206,7 @@ initRect(ImageRect * pRect, int x, int y, int width, int height, int jump, int depthBytes = format->depthBytes; pRect->pBits = pBits; - INCPN(byte_t, pRect->pBits, y * stride + x * depthBytes); + INCPN(byte_t, pRect->pBits, (intptr_t) y * stride + x * depthBytes); pRect->numLines = height; pRect->numSamples = width; pRect->stride = stride * jump; diff --git a/src/share/native/sun/font/freetypeScaler.c b/src/share/native/sun/font/freetypeScaler.c index bc3a905bac1336fcbafcfeb10794ef90f90e08de..30f34e4c2736771cae7fbce6e46d9b7707d4d5b9 100644 --- a/src/share/native/sun/font/freetypeScaler.c +++ b/src/share/native/sun/font/freetypeScaler.c @@ -162,7 +162,7 @@ static unsigned long ReadTTFontFileFunc(FT_Stream stream, */ if (numBytes == 0) { - if (offset >= scalerInfo->fileSize) { + if (offset > scalerInfo->fileSize) { return -1; } else { return 0; diff --git a/src/share/native/sun/java2d/cmm/lcms/cmsps2.c b/src/share/native/sun/java2d/cmm/lcms/cmsps2.c index a3c7b49dbff25792c781a330aa755b260ec7a368..3f373d808f2fa54be0b99188b3166ac7f0712e0e 100644 --- a/src/share/native/sun/java2d/cmm/lcms/cmsps2.c +++ b/src/share/native/sun/java2d/cmm/lcms/cmsps2.c @@ -1443,7 +1443,7 @@ int WriteNamedColorCRD(cmsIOHANDLER* m, cmsHPROFILE hNamedColor, cmsUInt32Number cmsUInt32Number i, nColors, nColorant; cmsUInt32Number OutputFormat; char ColorName[cmsMAX_PATH]; - char Colorant[128]; + char Colorant[512]; cmsNAMEDCOLORLIST* NamedColorList; diff --git a/src/share/native/sun/java2d/opengl/J2D_GL/gl.h b/src/share/native/sun/java2d/opengl/J2D_GL/gl.h index 6d14c932ff88e743f44efd1b14484f43cddd6650..160de408c07fa9a4c5835bd52158ea2a5d7e7c64 100644 --- a/src/share/native/sun/java2d/opengl/J2D_GL/gl.h +++ b/src/share/native/sun/java2d/opengl/J2D_GL/gl.h @@ -22,8 +22,6 @@ * questions. */ -/* $Id: gl.h,v 1.72 2002/10/17 19:39:31 kschultz Exp $ */ - /* * This file is available under and governed by the GNU General Public * License version 2 only, as published by the Free Software Foundation. @@ -31,9 +29,9 @@ * file: * * Mesa 3-D graphics library - * Version: 4.1 * - * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -48,9 +46,10 @@ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. */ @@ -65,36 +64,31 @@ /********************************************************************** * Begin system-specific stuff. */ -#if defined(__BEOS__) -#include /* to get some BeOS-isms */ -#endif - -#if !defined(OPENSTEP) && (defined(NeXT) || defined(NeXT_PDO)) -#define OPENSTEP -#endif #if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) #define __WIN32__ #endif -#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) -# if defined(_MSC_VER) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */ +#if defined(__WIN32__) && !defined(__CYGWIN__) +# if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */ # define GLAPI __declspec(dllexport) -# elif defined(_MSC_VER) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ +# elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ # define GLAPI __declspec(dllimport) # else /* for use with static link lib build of Win32 edition only */ # define GLAPI extern -# endif /* _STATIC_MESA support */ -# define GLAPIENTRY __stdcall -#else -/* non-Windows compilation */ +# endif +# if defined(__MINGW32__) && defined(GL_NO_STDCALL) || defined(UNDER_CE) /* The generated DLLs by MingW with STDCALL are not compatible with the ones done by Microsoft's compilers */ +# define GLAPIENTRY +# else +# define GLAPIENTRY __stdcall +# endif +#elif defined(__CYGWIN__) && defined(USE_OPENGL32) /* use native windows opengl32 */ # define GLAPI extern +# define GLAPIENTRY __stdcall +#elif (defined(__GNUC__) && __GNUC__ >= 4) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +# define GLAPI __attribute__((visibility("default"))) # define GLAPIENTRY -#endif /* WIN32 / CYGWIN bracket */ - -#if (defined(__BEOS__) && defined(__POWERPC__)) || defined(__QUICKDRAW__) -# define PRAGMA_EXPORT_SUPPORTED 1 -#endif +#endif /* WIN32 && !CYGWIN */ /* * WINDOWS: Include windows.h here to define APIENTRY. @@ -105,28 +99,31 @@ * glut.h or gl.h. */ #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 +#endif #include #endif -#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP) && !defined(__CYGWIN__) -#include +#ifndef GLAPI +#define GLAPI extern #endif -#if defined(macintosh) && PRAGMA_IMPORT_SUPPORTED -#pragma import on +#ifndef GLAPIENTRY +#define GLAPIENTRY #endif #ifndef APIENTRY #define APIENTRY GLAPIENTRY #endif -#ifdef CENTERLINE_CLPP -#define signed +/* "P" suffix to be used for a pointer to a function */ +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * #endif -#if defined(PRAGMA_EXPORT_SUPPORTED) -#pragma export on +#ifndef GLAPIENTRYP +#define GLAPIENTRYP GLAPIENTRY * #endif /* @@ -173,8 +170,8 @@ typedef double GLclampd; /* double precision float in [0,1] */ */ /* Boolean values */ -#define GL_FALSE 0x0 -#define GL_TRUE 0x1 +#define GL_FALSE 0 +#define GL_TRUE 1 /* Data types */ #define GL_BYTE 0x1400 @@ -184,10 +181,10 @@ typedef double GLclampd; /* double precision float in [0,1] */ #define GL_INT 0x1404 #define GL_UNSIGNED_INT 0x1405 #define GL_FLOAT 0x1406 -#define GL_DOUBLE 0x140A #define GL_2_BYTES 0x1407 #define GL_3_BYTES 0x1408 #define GL_4_BYTES 0x1409 +#define GL_DOUBLE 0x140A /* Primitives */ #define GL_POINTS 0x0000 @@ -374,8 +371,8 @@ typedef double GLclampd; /* double precision float in [0,1] */ #define GL_BLEND 0x0BE2 #define GL_BLEND_SRC 0x0BE1 #define GL_BLEND_DST 0x0BE0 -#define GL_ZERO 0x0 -#define GL_ONE 0x1 +#define GL_ZERO 0 +#define GL_ONE 1 #define GL_SRC_COLOR 0x0300 #define GL_ONE_MINUS_SRC_COLOR 0x0301 #define GL_SRC_ALPHA 0x0302 @@ -448,16 +445,16 @@ typedef double GLclampd; /* double precision float in [0,1] */ #define GL_OR_INVERTED 0x150D /* Stencil */ -#define GL_STENCIL_TEST 0x0B90 -#define GL_STENCIL_WRITEMASK 0x0B98 #define GL_STENCIL_BITS 0x0D57 +#define GL_STENCIL_TEST 0x0B90 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 #define GL_STENCIL_FUNC 0x0B92 #define GL_STENCIL_VALUE_MASK 0x0B93 -#define GL_STENCIL_REF 0x0B97 #define GL_STENCIL_FAIL 0x0B94 -#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 #define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 -#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_WRITEMASK 0x0B98 #define GL_STENCIL_INDEX 0x1901 #define GL_KEEP 0x1E00 #define GL_REPLACE 0x1E01 @@ -465,7 +462,7 @@ typedef double GLclampd; /* double precision float in [0,1] */ #define GL_DECR 0x1E03 /* Buffers, Pixel Drawing/Reading */ -#define GL_NONE 0x0 +#define GL_NONE 0 #define GL_LEFT 0x0406 #define GL_RIGHT 0x0407 /*GL_FRONT 0x0404 */ @@ -507,16 +504,16 @@ typedef double GLclampd; /* double precision float in [0,1] */ /* Implementation limits */ #define GL_MAX_LIST_NESTING 0x0B31 -#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 -#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 -#define GL_MAX_NAME_STACK_DEPTH 0x0D37 -#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 -#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 #define GL_MAX_EVAL_ORDER 0x0D30 #define GL_MAX_LIGHTS 0x0D31 #define GL_MAX_CLIP_PLANES 0x0D32 #define GL_MAX_TEXTURE_SIZE 0x0D33 #define GL_MAX_PIXEL_MAP_TABLE 0x0D34 +#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 +#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 +#define GL_MAX_NAME_STACK_DEPTH 0x0D37 +#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 +#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 #define GL_MAX_VIEWPORT_DIMS 0x0D3A #define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B @@ -574,22 +571,22 @@ typedef double GLclampd; /* double precision float in [0,1] */ #define GL_MAP2_GRID_DOMAIN 0x0DD2 #define GL_MAP2_GRID_SEGMENTS 0x0DD3 #define GL_COEFF 0x0A00 -#define GL_DOMAIN 0x0A02 #define GL_ORDER 0x0A01 +#define GL_DOMAIN 0x0A02 /* Hints */ -#define GL_FOG_HINT 0x0C54 -#define GL_LINE_SMOOTH_HINT 0x0C52 #define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 #define GL_POINT_SMOOTH_HINT 0x0C51 +#define GL_LINE_SMOOTH_HINT 0x0C52 #define GL_POLYGON_SMOOTH_HINT 0x0C53 +#define GL_FOG_HINT 0x0C54 #define GL_DONT_CARE 0x1100 #define GL_FASTEST 0x1101 #define GL_NICEST 0x1102 /* Scissor box */ -#define GL_SCISSOR_TEST 0x0C11 #define GL_SCISSOR_BOX 0x0C10 +#define GL_SCISSOR_TEST 0x0C11 /* Pixel Mode / Transfer */ #define GL_MAP_COLOR 0x0D10 @@ -653,6 +650,8 @@ typedef double GLclampd; /* double precision float in [0,1] */ #define GL_TEXTURE_ENV_COLOR 0x2201 #define GL_TEXTURE_GEN_S 0x0C60 #define GL_TEXTURE_GEN_T 0x0C61 +#define GL_TEXTURE_GEN_R 0x0C62 +#define GL_TEXTURE_GEN_Q 0x0C63 #define GL_TEXTURE_GEN_MODE 0x2500 #define GL_TEXTURE_BORDER_COLOR 0x1004 #define GL_TEXTURE_WIDTH 0x1000 @@ -683,8 +682,6 @@ typedef double GLclampd; /* double precision float in [0,1] */ #define GL_T 0x2001 #define GL_R 0x2002 #define GL_Q 0x2003 -#define GL_TEXTURE_GEN_R 0x0C62 -#define GL_TEXTURE_GEN_Q 0x0C63 /* Utility */ #define GL_VENDOR 0x1F00 @@ -693,9 +690,9 @@ typedef double GLclampd; /* double precision float in [0,1] */ #define GL_EXTENSIONS 0x1F03 /* Errors */ -#define GL_NO_ERROR 0x0 -#define GL_INVALID_VALUE 0x0501 +#define GL_NO_ERROR 0 #define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 #define GL_INVALID_OPERATION 0x0502 #define GL_STACK_OVERFLOW 0x0503 #define GL_STACK_UNDERFLOW 0x0504 @@ -722,7 +719,7 @@ typedef double GLclampd; /* double precision float in [0,1] */ #define GL_LIST_BIT 0x00020000 #define GL_TEXTURE_BIT 0x00040000 #define GL_SCISSOR_BIT 0x00080000 -#define GL_ALL_ATTRIB_BITS 0x000FFFFF +#define GL_ALL_ATTRIB_BITS 0xFFFFFFFF /* OpenGL 1.1 */ @@ -860,7 +857,7 @@ GLAPI GLint GLAPIENTRY glRenderMode( GLenum mode ); GLAPI GLenum GLAPIENTRY glGetError( void ); -GLAPI const GLubyte* GLAPIENTRY glGetString( GLenum name ); +GLAPI const GLubyte * GLAPIENTRY glGetString( GLenum name ); GLAPI void GLAPIENTRY glFinish( void ); @@ -1228,11 +1225,11 @@ GLAPI void GLAPIENTRY glPixelStorei( GLenum pname, GLint param ); GLAPI void GLAPIENTRY glPixelTransferf( GLenum pname, GLfloat param ); GLAPI void GLAPIENTRY glPixelTransferi( GLenum pname, GLint param ); -GLAPI void GLAPIENTRY glPixelMapfv( GLenum map, GLint mapsize, +GLAPI void GLAPIENTRY glPixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values ); -GLAPI void GLAPIENTRY glPixelMapuiv( GLenum map, GLint mapsize, +GLAPI void GLAPIENTRY glPixelMapuiv( GLenum map, GLsizei mapsize, const GLuint *values ); -GLAPI void GLAPIENTRY glPixelMapusv( GLenum map, GLint mapsize, +GLAPI void GLAPIENTRY glPixelMapusv( GLenum map, GLsizei mapsize, const GLushort *values ); GLAPI void GLAPIENTRY glGetPixelMapfv( GLenum map, GLfloat *values ); @@ -1545,10 +1542,10 @@ GLAPI void GLAPIENTRY glCopyTexSubImage3D( GLenum target, GLint level, GLint y, GLsizei width, GLsizei height ); -typedef void (APIENTRY * PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -typedef void (APIENTRY * PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRY * PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRY * PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); /* @@ -1740,40 +1737,6 @@ GLAPI void GLAPIENTRY glSeparableFilter2D( GLenum target, GLAPI void GLAPIENTRY glGetSeparableFilter( GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span ); -typedef void (APIENTRY * PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -typedef void (APIENTRY * PFNGLBLENDEQUATIONPROC) (GLenum mode); -typedef void (APIENTRY * PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRY * PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRY * PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRY * PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRY * PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRY * PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRY * PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -typedef void (APIENTRY * PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRY * PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRY * PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRY * PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRY * PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRY * PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -typedef void (APIENTRY * PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRY * PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRY * PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRY * PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRY * PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRY * PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRY * PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRY * PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRY * PFNGLRESETHISTOGRAMPROC) (GLenum target); -typedef void (APIENTRY * PFNGLRESETMINMAXPROC) (GLenum target); @@ -1979,52 +1942,17 @@ GLAPI void GLAPIENTRY glMultTransposeMatrixf( const GLfloat m[16] ); GLAPI void GLAPIENTRY glSampleCoverage( GLclampf value, GLboolean invert ); -typedef void (APIENTRY * PFNGLACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRY * PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRY * PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); -typedef void (APIENTRY * PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); -typedef void (APIENTRY * PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); -typedef void (APIENTRY * PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); -typedef void (APIENTRY * PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRY * PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRY * PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRY * PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRY * PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRY * PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRY * PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRY * PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRY * PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRY * PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRY * PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRY * PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRY * PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRY * PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRY * PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRY * PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRY * PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRY * PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, void *img); + +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); + /* @@ -2104,40 +2032,40 @@ GLAPI void GLAPIENTRY glMultiTexCoord4ivARB(GLenum target, const GLint *v); GLAPI void GLAPIENTRY glMultiTexCoord4sARB(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); GLAPI void GLAPIENTRY glMultiTexCoord4svARB(GLenum target, const GLshort *v); -typedef void (APIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRY * PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRY * PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); -typedef void (APIENTRY * PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); -typedef void (APIENTRY * PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); -typedef void (APIENTRY * PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); -typedef void (APIENTRY * PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRY * PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRY * PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRY * PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRY * PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRY * PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRY * PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRY * PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRY * PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRY * PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRY * PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRY * PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRY * PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRY * PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); #endif /* GL_ARB_multitexture */ @@ -2149,479 +2077,17 @@ typedef void (APIENTRY * PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLs */ #if defined(GL_GLEXT_LEGACY) - -/* - * 1. GL_EXT_abgr - */ -#ifndef GL_EXT_abgr -#define GL_EXT_abgr 1 - -#define GL_ABGR_EXT 0x8000 - -#endif /* GL_EXT_abgr */ - - - -/* - * 2. GL_EXT_blend_color - */ -#ifndef GL_EXT_blend_color -#define GL_EXT_blend_color 1 - -#define GL_CONSTANT_COLOR_EXT 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 -#define GL_CONSTANT_ALPHA_EXT 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 -#define GL_BLEND_COLOR_EXT 0x8005 - -GLAPI void GLAPIENTRY glBlendColorEXT( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); - -#endif /* GL_EXT_blend_color */ - - - -/* - * 3. GL_EXT_polygon_offset - */ -#ifndef GL_EXT_polygon_offset -#define GL_EXT_polygon_offset 1 - -#define GL_POLYGON_OFFSET_EXT 0x8037 -#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 -#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 - -GLAPI void GLAPIENTRY glPolygonOffsetEXT( GLfloat factor, GLfloat bias ); - -#endif /* GL_EXT_polygon_offset */ - - - -/* - * 6. GL_EXT_texture3D - */ -#ifndef GL_EXT_texture3D -#define GL_EXT_texture3D 1 - -#define GL_PACK_SKIP_IMAGES_EXT 0x806B -#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C -#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D -#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E -#define GL_TEXTURE_3D_EXT 0x806F -#define GL_PROXY_TEXTURE_3D_EXT 0x8070 -#define GL_TEXTURE_DEPTH_EXT 0x8071 -#define GL_TEXTURE_WRAP_R_EXT 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 -#define GL_TEXTURE_3D_BINDING_EXT 0x806A - -GLAPI void GLAPIENTRY glTexImage3DEXT( GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels ); - -GLAPI void GLAPIENTRY glTexSubImage3DEXT( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); - -GLAPI void GLAPIENTRY glCopyTexSubImage3DEXT( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height ); - -#endif /* GL_EXT_texture3D */ - - - -/* - * 20. GL_EXT_texture_object - */ -#ifndef GL_EXT_texture_object -#define GL_EXT_texture_object 1 - -#define GL_TEXTURE_PRIORITY_EXT 0x8066 -#define GL_TEXTURE_RESIDENT_EXT 0x8067 -#define GL_TEXTURE_1D_BINDING_EXT 0x8068 -#define GL_TEXTURE_2D_BINDING_EXT 0x8069 - -GLAPI void GLAPIENTRY glGenTexturesEXT( GLsizei n, GLuint *textures ); - -GLAPI void GLAPIENTRY glDeleteTexturesEXT( GLsizei n, const GLuint *textures); - -GLAPI void GLAPIENTRY glBindTextureEXT( GLenum target, GLuint texture ); - -GLAPI void GLAPIENTRY glPrioritizeTexturesEXT( GLsizei n, const GLuint *textures, const GLclampf *priorities ); - -GLAPI GLboolean GLAPIENTRY glAreTexturesResidentEXT( GLsizei n, const GLuint *textures, GLboolean *residences ); - -GLAPI GLboolean GLAPIENTRY glIsTextureEXT( GLuint texture ); - -#endif /* GL_EXT_texture_object */ - - - -/* - * 27. GL_EXT_rescale_normal - */ -#ifndef GL_EXT_rescale_normal -#define GL_EXT_rescale_normal 1 - -#define GL_RESCALE_NORMAL_EXT 0x803A - -#endif /* GL_EXT_rescale_normal */ - - - -/* - * 30. GL_EXT_vertex_array - */ -#ifndef GL_EXT_vertex_array -#define GL_EXT_vertex_array 1 - -#define GL_VERTEX_ARRAY_EXT 0x8074 -#define GL_NORMAL_ARRAY_EXT 0x8075 -#define GL_COLOR_ARRAY_EXT 0x8076 -#define GL_INDEX_ARRAY_EXT 0x8077 -#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 -#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 -#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A -#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B -#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C -#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D -#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E -#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F -#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 -#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 -#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 -#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 -#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 -#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 -#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 -#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 -#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A -#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B -#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C -#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D -#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E -#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F -#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 -#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 - -GLAPI void GLAPIENTRY glVertexPointerEXT( GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *ptr ); - -GLAPI void GLAPIENTRY glNormalPointerEXT( GLenum type, GLsizei stride, GLsizei count, const GLvoid *ptr ); - -GLAPI void GLAPIENTRY glColorPointerEXT( GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *ptr ); - -GLAPI void GLAPIENTRY glIndexPointerEXT( GLenum type, GLsizei stride, GLsizei count, const GLvoid *ptr ); - -GLAPI void GLAPIENTRY glTexCoordPointerEXT( GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *ptr ); - -GLAPI void GLAPIENTRY glEdgeFlagPointerEXT( GLsizei stride, GLsizei count, const GLboolean *ptr ); - -GLAPI void GLAPIENTRY glGetPointervEXT( GLenum pname, GLvoid **params ); - -GLAPI void GLAPIENTRY glArrayElementEXT( GLint i ); - -GLAPI void GLAPIENTRY glDrawArraysEXT( GLenum mode, GLint first, GLsizei count ); - -#endif /* GL_EXT_vertex_array */ - - - -/* - * 35. GL_SGIS_texture_edge_clamp - */ -#ifndef GL_SGIS_texture_edge_clamp -#define GL_SGIS_texture_edge_clamp 1 - -#define GL_CLAMP_TO_EDGE_SGIS 0x812F - -#endif /* GL_SGIS_texture_edge_clamp */ - - - -/* - * 37. GL_EXT_blend_minmax - */ -#ifndef GL_EXT_blend_minmax -#define GL_EXT_blend_minmax 1 - -#define GL_FUNC_ADD_EXT 0x8006 -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 -#define GL_BLEND_EQUATION_EXT 0x8009 - -GLAPI void GLAPIENTRY glBlendEquationEXT( GLenum mode ); - -#endif /* GL_EXT_blend_minmax */ - - - -/* - * 38. GL_EXT_blend_subtract (requires GL_EXT_blend_max ) - */ -#ifndef GL_EXT_blend_subtract -#define GL_EXT_blend_subtract 1 - -#define GL_FUNC_SUBTRACT_EXT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B - -#endif /* GL_EXT_blend_subtract */ - - - -/* - * 39. GL_EXT_blend_logic_op - */ -#ifndef GL_EXT_blend_logic_op -#define GL_EXT_blend_logic_op 1 - -/* No new tokens or functions */ - -#endif /* GL_EXT_blend_logic_op */ - - - -/* - * 54. GL_EXT_point_parameters - */ -#ifndef GL_EXT_point_parameters -#define GL_EXT_point_parameters 1 - -#define GL_POINT_SIZE_MIN_EXT 0x8126 -#define GL_POINT_SIZE_MAX_EXT 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 -#define GL_DISTANCE_ATTENUATION_EXT 0x8129 - -GLAPI void GLAPIENTRY glPointParameterfEXT( GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glPointParameterfvEXT( GLenum pname, const GLfloat *params ); -GLAPI void GLAPIENTRY glPointParameterfSGIS(GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glPointParameterfvSGIS(GLenum pname, const GLfloat *params); - -#endif /* GL_EXT_point_parameters */ - - - -/* - * 78. GL_EXT_paletted_texture - */ -#ifndef GL_EXT_paletted_texture -#define GL_EXT_paletted_texture 1 - -#define GL_TABLE_TOO_LARGE_EXT 0x8031 -#define GL_COLOR_TABLE_FORMAT_EXT 0x80D8 -#define GL_COLOR_TABLE_WIDTH_EXT 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE_EXT 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE_EXT 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE_EXT 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE_EXT 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE_EXT 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80DF -#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED -#define GL_COLOR_INDEX1_EXT 0x80E2 -#define GL_COLOR_INDEX2_EXT 0x80E3 -#define GL_COLOR_INDEX4_EXT 0x80E4 -#define GL_COLOR_INDEX8_EXT 0x80E5 -#define GL_COLOR_INDEX12_EXT 0x80E6 -#define GL_COLOR_INDEX16_EXT 0x80E7 - -GLAPI void GLAPIENTRY glColorTableEXT( GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table ); - -GLAPI void GLAPIENTRY glColorSubTableEXT( GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data ); - -GLAPI void GLAPIENTRY glGetColorTableEXT( GLenum target, GLenum format, GLenum type, GLvoid *table ); - -GLAPI void GLAPIENTRY glGetColorTableParameterfvEXT( GLenum target, GLenum pname, GLfloat *params ); - -GLAPI void GLAPIENTRY glGetColorTableParameterivEXT( GLenum target, GLenum pname, GLint *params ); - -#endif /* GL_EXT_paletted_texture */ - - - -/* - * 79. GL_EXT_clip_volume_hint - */ -#ifndef GL_EXT_clip_volume_hint -#define GL_EXT_clip_volume_hint 1 - -#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 - -#endif /* GL_EXT_clip_volume_hint */ - - - -/* - * 97. GL_EXT_compiled_vertex_array - */ -#ifndef GL_EXT_compiled_vertex_array -#define GL_EXT_compiled_vertex_array 1 - -#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 -#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 - -GLAPI void GLAPIENTRY glLockArraysEXT( GLint first, GLsizei count ); -GLAPI void GLAPIENTRY glUnlockArraysEXT( void ); - -#endif /* GL_EXT_compiled_vertex_array */ - -/* - * 137. GL_HP_occlusion_test - */ -#ifndef GL_HP_occlusion_test -#define GL_HP_occlusion_test 1 - -#define GL_OCCLUSION_TEST_HP 0x8165 -#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 - -#endif /* GL_HP_occlusion_test */ - - -/* - * 141. GL_EXT_shared_texture_palette (req's GL_EXT_paletted_texture) - */ -#ifndef GL_EXT_shared_texture_palette -#define GL_EXT_shared_texture_palette 1 - -#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB - -#endif /* GL_EXT_shared_texture_palette */ - - - -/* - * 176. GL_EXT_stencil_wrap - */ -#ifndef GL_EXT_stencil_wrap -#define GL_EXT_stencil_wrap 1 - -#define GL_INCR_WRAP_EXT 0x8507 -#define GL_DECR_WRAP_EXT 0x8508 - -#endif /* GL_EXT_stencil_wrap */ - - - -/* - * 179. GL_NV_texgen_reflection - */ -#ifndef GL_NV_texgen_reflection -#define GL_NV_texgen_reflection 1 - -#define GL_NORMAL_MAP_NV 0x8511 -#define GL_REFLECTION_MAP_NV 0x8512 - -#endif /* GL_NV_texgen_reflection */ - - - -/* - * 185. GL_EXT_texture_env_add - */ -#ifndef GL_EXT_texture_env_add -#define GL_EXT_texture_env_add 1 - -/* No new tokens or functions */ - -#endif /* GL_EXT_texture_env_add */ - - - -/* - * 197. GL_MESA_window_pos - */ -#ifndef GL_MESA_window_pos -#define GL_MESA_window_pos 1 - -GLAPI void GLAPIENTRY glWindowPos2iMESA( GLint x, GLint y ); -GLAPI void GLAPIENTRY glWindowPos2sMESA( GLshort x, GLshort y ); -GLAPI void GLAPIENTRY glWindowPos2fMESA( GLfloat x, GLfloat y ); -GLAPI void GLAPIENTRY glWindowPos2dMESA( GLdouble x, GLdouble y ); -GLAPI void GLAPIENTRY glWindowPos2ivMESA( const GLint *p ); -GLAPI void GLAPIENTRY glWindowPos2svMESA( const GLshort *p ); -GLAPI void GLAPIENTRY glWindowPos2fvMESA( const GLfloat *p ); -GLAPI void GLAPIENTRY glWindowPos2dvMESA( const GLdouble *p ); -GLAPI void GLAPIENTRY glWindowPos3iMESA( GLint x, GLint y, GLint z ); -GLAPI void GLAPIENTRY glWindowPos3sMESA( GLshort x, GLshort y, GLshort z ); -GLAPI void GLAPIENTRY glWindowPos3fMESA( GLfloat x, GLfloat y, GLfloat z ); -GLAPI void GLAPIENTRY glWindowPos3dMESA( GLdouble x, GLdouble y, GLdouble z ); -GLAPI void GLAPIENTRY glWindowPos3ivMESA( const GLint *p ); -GLAPI void GLAPIENTRY glWindowPos3svMESA( const GLshort *p ); -GLAPI void GLAPIENTRY glWindowPos3fvMESA( const GLfloat *p ); -GLAPI void GLAPIENTRY glWindowPos3dvMESA( const GLdouble *p ); -GLAPI void GLAPIENTRY glWindowPos4iMESA( GLint x, GLint y, GLint z, GLint w ); -GLAPI void GLAPIENTRY glWindowPos4sMESA( GLshort x, GLshort y, GLshort z, GLshort w ); -GLAPI void GLAPIENTRY glWindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); -GLAPI void GLAPIENTRY glWindowPos4dMESA( GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void GLAPIENTRY glWindowPos4ivMESA( const GLint *p ); -GLAPI void GLAPIENTRY glWindowPos4svMESA( const GLshort *p ); -GLAPI void GLAPIENTRY glWindowPos4fvMESA( const GLfloat *p ); -GLAPI void GLAPIENTRY glWindowPos4dvMESA( const GLdouble *p ); - -#endif /* GL_MESA_window_pos */ - - - -/* - * 196. GL_MESA_resize_bufffers - */ -#ifndef GL_MESA_resize_bufffers -#define GL_MESA_resize_buffers 1 - -GLAPI void GLAPIENTRY glResizeBuffersMESA( void ); - -#endif /* GL_MESA_resize_bufffers */ - - - -/* - * 220. GL_EXT_texture_env_dot3 - */ -#ifndef GL_EXT_texture_env_dot3 -#define GL_EXT_texture_env_dot3 1 - -#define GL_DOT3_RGB_EXT 0x8740 -#define GL_DOT3_RGBA_EXT 0x8741 - -#endif /* GL_EXT_texture_env_dot3 */ - +/* All extensions that used to be here are now found in glext.h */ #else /* GL_GLEXT_LEGACY */ -/* modified for inclusion in Java 2D source tree */ -/* #include */ +/* JDK modification of include path to be sure to pick up the correct file */ #include "J2D_GL/glext.h" #endif /* GL_GLEXT_LEGACY */ -/* - * ???. GL_MESA_trace - * XXX obsolete - */ -#ifndef GL_MESA_trace -#define GL_MESA_trace 1 - -#define GL_TRACE_ALL_BITS_MESA 0xFFFF -#define GL_TRACE_OPERATIONS_BIT_MESA 0x0001 -#define GL_TRACE_PRIMITIVES_BIT_MESA 0x0002 -#define GL_TRACE_ARRAYS_BIT_MESA 0x0004 -#define GL_TRACE_TEXTURES_BIT_MESA 0x0008 -#define GL_TRACE_PIXELS_BIT_MESA 0x0010 -#define GL_TRACE_ERRORS_BIT_MESA 0x0020 -#define GL_TRACE_MASK_MESA 0x8755 -#define GL_TRACE_NAME_MESA 0x8756 - -GLAPI void GLAPIENTRY glEnableTraceMESA( GLbitfield mask ); -GLAPI void GLAPIENTRY glDisableTraceMESA( GLbitfield mask ); -GLAPI void GLAPIENTRY glNewTraceMESA( GLbitfield mask, const GLubyte * traceName ); -GLAPI void GLAPIENTRY glEndTraceMESA( void ); -GLAPI void GLAPIENTRY glTraceAssertAttribMESA( GLbitfield attribMask ); -GLAPI void GLAPIENTRY glTraceCommentMESA( const GLubyte * comment ); -GLAPI void GLAPIENTRY glTraceTextureMESA( GLuint name, const GLubyte* comment ); -GLAPI void GLAPIENTRY glTraceListMESA( GLuint name, const GLubyte* comment ); -GLAPI void GLAPIENTRY glTracePointerMESA( GLvoid* pointer, const GLubyte* comment ); -GLAPI void GLAPIENTRY glTracePointerRangeMESA( const GLvoid* first, const GLvoid* last, const GLubyte* comment ); - -#endif /* GL_MESA_trace */ - - /* * ???. GL_MESA_packed_depth_stencil * XXX obsolete @@ -2638,59 +2104,38 @@ GLAPI void GLAPIENTRY glTracePointerRangeMESA( const GLvoid* first, const GLvoid #endif /* GL_MESA_packed_depth_stencil */ -#ifndef GL_MESA_ycbcr_texture -#define GL_MESA_ycbcr_texture 1 - -#define GL_YCBCR_MESA 0x8757 -#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA /* same as Apple */ -#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB /* same as Apple */ - -#endif /* GL_MESA_texture_ycbcr */ - - - -#ifndef GL_MESA_pack_invert -#define GL_MESA_pack_invert 1 - -#define GL_PACK_INVERT_MESA 0x8758 +#ifndef GL_ATI_blend_equation_separate +#define GL_ATI_blend_equation_separate 1 -#endif /* GL_MESA_pack_invert */ +#define GL_ALPHA_BLEND_EQUATION_ATI 0x883D +GLAPI void GLAPIENTRY glBlendEquationSeparateATI( GLenum modeRGB, GLenum modeA ); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEATIPROC) (GLenum modeRGB, GLenum modeA); +#endif /* GL_ATI_blend_equation_separate */ -#ifndef GL_APPLE_client_storage -#define GL_APPLE_client_storage 1 -#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 - -#endif /* GL_APPLE_client_storage */ - - - -#ifndef GL_APPLE_ycbcr_422 -#define GL_APPLE_ycbcr_422 1 - -#define GL_YCBCR_422_APPLE 0x85B9 -#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB - -#endif /* GL_APPLE_ycbcr_422 */ - - - -/********************************************************************** - * Begin system-specific stuff - */ -#if defined(PRAGMA_EXPORT_SUPPORTED) -#pragma export off +/* GL_OES_EGL_image */ +#if !defined(GL_OES_EGL_image) && !defined(GL_EXT_EGL_image_storage) +typedef void* GLeglImageOES; #endif -#if defined(macintosh) && PRAGMA_IMPORT_SUPPORTED -#pragma import off +#ifndef GL_OES_EGL_image +#define GL_OES_EGL_image 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image); +GLAPI void APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image); #endif -/* - * End system-specific stuff - **********************************************************************/ +typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image); +typedef void (APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image); +#endif + + +/** + ** NOTE!!!!! If you add new functions to this file, or update + ** glext.h be sure to regenerate the gl_mangle.h file. See comments + ** in that file for details. + **/ #ifdef __cplusplus diff --git a/src/share/native/sun/java2d/opengl/J2D_GL/glext.h b/src/share/native/sun/java2d/opengl/J2D_GL/glext.h index 33185a0e0ab54e2efcd094c61d98379b30b23d31..eeb617e63a1fc650c2f776e4e7b533a7d7c925e2 100644 --- a/src/share/native/sun/java2d/opengl/J2D_GL/glext.h +++ b/src/share/native/sun/java2d/opengl/J2D_GL/glext.h @@ -22,8 +22,8 @@ * questions. */ -#ifndef __glext_h_ -#define __glext_h_ +#ifndef __gl_glext_h_ +#define __gl_glext_h_ 1 #ifdef __cplusplus extern "C" { @@ -35,7 +35,7 @@ extern "C" { ** However, the following notice accompanied the original version of this ** file: ** -** Copyright (c) 2007 The Khronos Group Inc. +** Copyright (c) 2013-2018 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the @@ -56,9 +56,17 @@ extern "C" { ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** https://github.com/KhronosGroup/OpenGL-Registry +*/ #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 +#endif #include #endif @@ -72,20 +80,28 @@ extern "C" { #define GLAPI extern #endif -/*************************************************************/ +#define GL_GLEXT_VERSION 20190611 + +/* JDK modification */ +#include -/* Header file version number, required by OpenGL ABI for Linux */ -/* glext.h last updated 2005/03/17 */ -/* Current version at http://oss.sgi.com/projects/ogl-sample/registry/ */ -#define GL_GLEXT_VERSION 27 +/* Generated C header for: + * API: gl + * Profile: compatibility + * Versions considered: .* + * Versions emitted: 1\.[2-9]|[234]\.[0-9] + * Default extensions included: gl + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ #ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 #define GL_UNSIGNED_BYTE_3_3_2 0x8032 #define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 #define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 #define GL_UNSIGNED_INT_8_8_8_8 0x8035 #define GL_UNSIGNED_INT_10_10_10_2 0x8036 -#define GL_RESCALE_NORMAL 0x803A #define GL_TEXTURE_BINDING_3D 0x806A #define GL_PACK_SKIP_IMAGES 0x806B #define GL_PACK_IMAGE_HEIGHT 0x806C @@ -112,96 +128,30 @@ extern "C" { #define GL_TEXTURE_MAX_LOD 0x813B #define GL_TEXTURE_BASE_LEVEL 0x813C #define GL_TEXTURE_MAX_LEVEL 0x813D -#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 -#define GL_SINGLE_COLOR 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR 0x81FA #define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 #define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 #define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 #define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D #define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_RESCALE_NORMAL 0x803A +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); #endif - -#ifndef GL_ARB_imaging -#define GL_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_BLEND_COLOR 0x8005 -#define GL_FUNC_ADD 0x8006 -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 -#define GL_BLEND_EQUATION 0x8009 -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#define GL_CONVOLUTION_1D 0x8010 -#define GL_CONVOLUTION_2D 0x8011 -#define GL_SEPARABLE_2D 0x8012 -#define GL_CONVOLUTION_BORDER_MODE 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS 0x8015 -#define GL_REDUCE 0x8016 -#define GL_CONVOLUTION_FORMAT 0x8017 -#define GL_CONVOLUTION_WIDTH 0x8018 -#define GL_CONVOLUTION_HEIGHT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 -#define GL_HISTOGRAM 0x8024 -#define GL_PROXY_HISTOGRAM 0x8025 -#define GL_HISTOGRAM_WIDTH 0x8026 -#define GL_HISTOGRAM_FORMAT 0x8027 -#define GL_HISTOGRAM_RED_SIZE 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C -#define GL_HISTOGRAM_SINK 0x802D -#define GL_MINMAX 0x802E -#define GL_MINMAX_FORMAT 0x802F -#define GL_MINMAX_SINK 0x8030 -#define GL_TABLE_TOO_LARGE 0x8031 -#define GL_COLOR_MATRIX 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB -#define GL_COLOR_TABLE 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 -#define GL_PROXY_COLOR_TABLE 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 -#define GL_COLOR_TABLE_SCALE 0x80D6 -#define GL_COLOR_TABLE_BIAS 0x80D7 -#define GL_COLOR_TABLE_FORMAT 0x80D8 -#define GL_COLOR_TABLE_WIDTH 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF -#define GL_CONSTANT_BORDER 0x8151 -#define GL_REPLICATE_BORDER 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR 0x8154 -#endif +#endif /* GL_VERSION_1_2 */ #ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 #define GL_TEXTURE0 0x84C0 #define GL_TEXTURE1 0x84C1 #define GL_TEXTURE2 0x84C2 @@ -235,12 +185,6 @@ extern "C" { #define GL_TEXTURE30 0x84DE #define GL_TEXTURE31 0x84DF #define GL_ACTIVE_TEXTURE 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 -#define GL_MAX_TEXTURE_UNITS 0x84E2 -#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 #define GL_MULTISAMPLE 0x809D #define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E #define GL_SAMPLE_ALPHA_TO_ONE 0x809F @@ -249,9 +193,6 @@ extern "C" { #define GL_SAMPLES 0x80A9 #define GL_SAMPLE_COVERAGE_VALUE 0x80AA #define GL_SAMPLE_COVERAGE_INVERT 0x80AB -#define GL_MULTISAMPLE_BIT 0x20000000 -#define GL_NORMAL_MAP 0x8511 -#define GL_REFLECTION_MAP 0x8512 #define GL_TEXTURE_CUBE_MAP 0x8513 #define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 #define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 @@ -262,10 +203,6 @@ extern "C" { #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A #define GL_PROXY_TEXTURE_CUBE_MAP 0x851B #define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C -#define GL_COMPRESSED_ALPHA 0x84E9 -#define GL_COMPRESSED_LUMINANCE 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB -#define GL_COMPRESSED_INTENSITY 0x84EC #define GL_COMPRESSED_RGB 0x84ED #define GL_COMPRESSED_RGBA 0x84EE #define GL_TEXTURE_COMPRESSION_HINT 0x84EF @@ -274,6 +211,19 @@ extern "C" { #define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 #define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 #define GL_CLAMP_TO_BORDER 0x812D +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC #define GL_COMBINE 0x8570 #define GL_COMBINE_RGB 0x8571 #define GL_COMBINE_ALPHA 0x8572 @@ -298,23 +248,125 @@ extern "C" { #define GL_PREVIOUS 0x8578 #define GL_DOT3_RGB 0x86AE #define GL_DOT3_RGBA 0x86AF -#endif +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, void *img); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum texture); +GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, void *img); +GLAPI void APIENTRY glClientActiveTexture (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); +#endif +#endif /* GL_VERSION_1_3 */ #ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 #define GL_BLEND_DST_RGB 0x80C8 #define GL_BLEND_SRC_RGB 0x80C9 #define GL_BLEND_DST_ALPHA 0x80CA #define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_POINT_SIZE_MIN 0x8126 -#define GL_POINT_SIZE_MAX 0x8127 #define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION 0x8129 -#define GL_GENERATE_MIPMAP 0x8191 -#define GL_GENERATE_MIPMAP_HINT 0x8192 #define GL_DEPTH_COMPONENT16 0x81A5 #define GL_DEPTH_COMPONENT24 0x81A6 #define GL_DEPTH_COMPONENT32 0x81A7 #define GL_MIRRORED_REPEAT 0x8370 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 #define GL_FOG_COORDINATE_SOURCE 0x8450 #define GL_FOG_COORDINATE 0x8451 #define GL_FRAGMENT_DEPTH 0x8452 @@ -330,19 +382,122 @@ extern "C" { #define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C #define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D #define GL_SECONDARY_COLOR_ARRAY 0x845E -#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD #define GL_TEXTURE_FILTER_CONTROL 0x8500 -#define GL_TEXTURE_LOD_BIAS 0x8501 -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 -#define GL_TEXTURE_DEPTH_SIZE 0x884A #define GL_DEPTH_TEXTURE_MODE 0x884B -#define GL_TEXTURE_COMPARE_MODE 0x884C -#define GL_TEXTURE_COMPARE_FUNC 0x884D #define GL_COMPARE_R_TO_TEXTURE 0x884E -#endif +#define GL_BLEND_COLOR 0x8005 +#define GL_BLEND_EQUATION 0x8009 +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_FUNC_ADD 0x8006 +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_FUNC_SUBTRACT 0x800A +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); +GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFogCoordf (GLfloat coord); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord); +GLAPI void APIENTRY glFogCoordd (GLdouble coord); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2iv (const GLint *v); +GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2sv (const GLshort *v); +GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3iv (const GLint *v); +GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3sv (const GLshort *v); +GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI void APIENTRY glBlendEquation (GLenum mode); +#endif +#endif /* GL_VERSION_1_4 */ #ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +typedef khronos_ssize_t GLsizeiptr; +typedef khronos_intptr_t GLintptr; #define GL_BUFFER_SIZE 0x8764 #define GL_BUFFER_USAGE 0x8765 #define GL_QUERY_COUNTER_BITS 0x8864 @@ -353,15 +508,6 @@ extern "C" { #define GL_ELEMENT_ARRAY_BUFFER 0x8893 #define GL_ARRAY_BUFFER_BINDING 0x8894 #define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E #define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F #define GL_READ_ONLY 0x88B8 #define GL_WRITE_ONLY 0x88B9 @@ -379,31 +525,81 @@ extern "C" { #define GL_DYNAMIC_READ 0x88E9 #define GL_DYNAMIC_COPY 0x88EA #define GL_SAMPLES_PASSED 0x8914 -#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE -#define GL_FOG_COORD GL_FOG_COORDINATE -#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE -#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE -#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE -#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER -#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY -#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING -#define GL_SRC0_RGB GL_SOURCE0_RGB -#define GL_SRC1_RGB GL_SOURCE1_RGB -#define GL_SRC2_RGB GL_SOURCE2_RGB -#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA -#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA -#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA -#endif - -#ifndef GL_VERSION_2_0 -#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION +#define GL_SRC1_ALPHA 0x8589 +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_FOG_COORD_SRC 0x8450 +#define GL_FOG_COORD 0x8451 +#define GL_CURRENT_FOG_COORD 0x8453 +#define GL_FOG_COORD_ARRAY_TYPE 0x8454 +#define GL_FOG_COORD_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORD_ARRAY_POINTER 0x8456 +#define GL_FOG_COORD_ARRAY 0x8457 +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D +#define GL_SRC0_RGB 0x8580 +#define GL_SRC1_RGB 0x8581 +#define GL_SRC2_RGB 0x8582 +#define GL_SRC0_ALPHA 0x8588 +#define GL_SRC2_ALPHA 0x858A +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, void *data); +typedef void *(APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQuery (GLuint id); +GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQuery (GLenum target); +GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); +GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, void *data); +GLAPI void *APIENTRY glMapBuffer (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_VERSION_1_5 */ + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +typedef char GLchar; +#define GL_BLEND_EQUATION_RGB 0x8009 #define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 #define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 #define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 #define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 #define GL_CURRENT_VERTEX_ATTRIB 0x8626 #define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 #define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 #define GL_STENCIL_BACK_FUNC 0x8800 #define GL_STENCIL_BACK_FAIL 0x8801 @@ -427,11 +623,8 @@ extern "C" { #define GL_DRAW_BUFFER14 0x8833 #define GL_DRAW_BUFFER15 0x8834 #define GL_BLEND_EQUATION_ALPHA 0x883D -#define GL_POINT_SPRITE 0x8861 -#define GL_COORD_REPLACE 0x8862 #define GL_MAX_VERTEX_ATTRIBS 0x8869 #define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_MAX_TEXTURE_COORDS 0x8871 #define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 #define GL_FRAGMENT_SHADER 0x8B30 #define GL_VERTEX_SHADER 0x8B31 @@ -480,248 +673,2536 @@ extern "C" { #define GL_STENCIL_BACK_REF 0x8CA3 #define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 #define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_TEXTURE_COORDS 0x8871 +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); +GLAPI void APIENTRY glCompileShader (GLuint shader); +GLAPI GLuint APIENTRY glCreateProgram (void); +GLAPI GLuint APIENTRY glCreateShader (GLenum type); +GLAPI void APIENTRY glDeleteProgram (GLuint program); +GLAPI void APIENTRY glDeleteShader (GLuint shader); +GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer); +GLAPI GLboolean APIENTRY glIsProgram (GLuint program); +GLAPI GLboolean APIENTRY glIsShader (GLuint shader); +GLAPI void APIENTRY glLinkProgram (GLuint program); +GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +GLAPI void APIENTRY glUseProgram (GLuint program); +GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glValidateProgram (GLuint program); +GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +#endif +#endif /* GL_VERSION_2_0 */ + +#ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB_ALPHA 0x8C42 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F +#define GL_SLUMINANCE_ALPHA 0x8C44 +#define GL_SLUMINANCE8_ALPHA8 0x8C45 +#define GL_SLUMINANCE 0x8C46 +#define GL_SLUMINANCE8 0x8C47 +#define GL_COMPRESSED_SLUMINANCE 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif +#endif /* GL_VERSION_2_1 */ + +#ifndef GL_VERSION_3_0 +#define GL_VERSION_3_0 1 +typedef khronos_uint16_t GLhalf; +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_CLIP_DISTANCE0 0x3000 +#define GL_CLIP_DISTANCE1 0x3001 +#define GL_CLIP_DISTANCE2 0x3002 +#define GL_CLIP_DISTANCE3 0x3003 +#define GL_CLIP_DISTANCE4 0x3004 +#define GL_CLIP_DISTANCE5 0x3005 +#define GL_CLIP_DISTANCE6 0x3006 +#define GL_CLIP_DISTANCE7 0x3007 +#define GL_MAX_CLIP_DISTANCES 0x0D32 +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_CONTEXT_FLAGS 0x821E +#define GL_COMPRESSED_RED 0x8225 +#define GL_COMPRESSED_RG 0x8226 +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001 +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_CLAMP_READ_COLOR 0x891C +#define GL_FIXED_ONLY 0x891D +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_TEXTURE_1D_ARRAY 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_PRIMITIVES_GENERATED 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_GREEN_INTEGER 0x8D95 +#define GL_BLUE_INTEGER 0x8D96 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_BGR_INTEGER 0x8D9A +#define GL_BGRA_INTEGER 0x8D9B +#define GL_SAMPLER_1D_ARRAY 0x8DC0 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_1D 0x8DC9 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_QUERY_WAIT 0x8E13 +#define GL_QUERY_NO_WAIT 0x8E14 +#define GL_QUERY_BY_REGION_WAIT 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_COLOR_ATTACHMENT16 0x8CF0 +#define GL_COLOR_ATTACHMENT17 0x8CF1 +#define GL_COLOR_ATTACHMENT18 0x8CF2 +#define GL_COLOR_ATTACHMENT19 0x8CF3 +#define GL_COLOR_ATTACHMENT20 0x8CF4 +#define GL_COLOR_ATTACHMENT21 0x8CF5 +#define GL_COLOR_ATTACHMENT22 0x8CF6 +#define GL_COLOR_ATTACHMENT23 0x8CF7 +#define GL_COLOR_ATTACHMENT24 0x8CF8 +#define GL_COLOR_ATTACHMENT25 0x8CF9 +#define GL_COLOR_ATTACHMENT26 0x8CFA +#define GL_COLOR_ATTACHMENT27 0x8CFB +#define GL_COLOR_ATTACHMENT28 0x8CFC +#define GL_COLOR_ATTACHMENT29 0x8CFD +#define GL_COLOR_ATTACHMENT30 0x8CFE +#define GL_COLOR_ATTACHMENT31 0x8CFF +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#define GL_INDEX 0x8222 +#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#define GL_HALF_FLOAT 0x140B +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822A +#define GL_RG8 0x822B +#define GL_RG16 0x822C +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#define GL_CLAMP_VERTEX_COLOR 0x891A +#define GL_CLAMP_FRAGMENT_COLOR 0x891B +#define GL_ALPHA_INTEGER 0x8D97 +typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void *(APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); +GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); +GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedback (void); +GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); +GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRender (void); +GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); +GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); +GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); +GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); +GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GLAPI const GLubyte *APIENTRY glGetStringi (GLenum name, GLuint index); +GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmap (GLenum target); +GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void *APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glBindVertexArray (GLuint array); +GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); +#endif +#endif /* GL_VERSION_3_0 */ + +#ifndef GL_VERSION_3_1 +#define GL_VERSION_3_1 1 +#define GL_SAMPLER_2D_RECT 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 +#define GL_SAMPLER_BUFFER 0x8DC2 +#define GL_INT_SAMPLER_2D_RECT 0x8DCD +#define GL_INT_SAMPLER_BUFFER 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#define GL_TEXTURE_BUFFER 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D +#define GL_TEXTURE_RECTANGLE 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_R16_SNORM 0x8F98 +#define GL_RG16_SNORM 0x8F99 +#define GL_RGB16_SNORM 0x8F9A +#define GL_RGBA16_SNORM 0x8F9B +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART 0x8F9D +#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); +typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); +GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); +GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#endif +#endif /* GL_VERSION_3_1 */ + +#ifndef GL_VERSION_3_2 +#define GL_VERSION_3_2 1 +typedef struct __GLsync *GLsync; +typedef khronos_uint64_t GLuint64; +typedef khronos_int64_t GLint64; +#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 +#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define GL_LINES_ADJACENCY 0x000A +#define GL_LINE_STRIP_ADJACENCY 0x000B +#define GL_TRIANGLES_ADJACENCY 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D +#define GL_PROGRAM_POINT_SIZE 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#define GL_GEOMETRY_SHADER 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT 0x8916 +#define GL_GEOMETRY_INPUT_TYPE 0x8917 +#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_CONTEXT_PROFILE_MASK 0x9126 +#define GL_DEPTH_CLAMP 0x864F +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION 0x8E4D +#define GL_LAST_VERTEX_CONVENTION 0x8E4E +#define GL_PROVOKING_VERTEX 0x8E4F +#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_INTEGER_SAMPLES 0x9110 +typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); +typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); +typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); +typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *data); +typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint maskNumber, GLbitfield mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); +GLAPI void APIENTRY glProvokingVertex (GLenum mode); +GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); +GLAPI GLboolean APIENTRY glIsSync (GLsync sync); +GLAPI void APIENTRY glDeleteSync (GLsync sync); +GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *data); +GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); +GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaski (GLuint maskNumber, GLbitfield mask); +#endif +#endif /* GL_VERSION_3_2 */ + +#ifndef GL_VERSION_3_3 +#define GL_VERSION_3_3 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +#define GL_SRC1_COLOR 0x88F9 +#define GL_ONE_MINUS_SRC1_COLOR 0x88FA +#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#define GL_SAMPLER_BINDING 0x8919 +#define GL_RGB10_A2UI 0x906F +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 +#define GL_TIME_ELAPSED 0x88BF +#define GL_TIMESTAMP 0x8E28 +#define GL_INT_2_10_10_10_REV 0x8D9F +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); +typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); +typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); +GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); +GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); +GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); +GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); +GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); +GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); +GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); +GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); +#endif +#endif /* GL_VERSION_3_3 */ + +#ifndef GL_VERSION_4_0 +#define GL_VERSION_4_0 1 +#define GL_SAMPLE_SHADING 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F +#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F +#define GL_DRAW_INDIRECT_BUFFER 0x8F3F +#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 +#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D +#define GL_MAX_VERTEX_STREAMS 0x8E71 +#define GL_DOUBLE_VEC2 0x8FFC +#define GL_DOUBLE_VEC3 0x8FFD +#define GL_DOUBLE_VEC4 0x8FFE +#define GL_DOUBLE_MAT2 0x8F46 +#define GL_DOUBLE_MAT3 0x8F47 +#define GL_DOUBLE_MAT4 0x8F48 +#define GL_DOUBLE_MAT2x3 0x8F49 +#define GL_DOUBLE_MAT2x4 0x8F4A +#define GL_DOUBLE_MAT3x2 0x8F4B +#define GL_DOUBLE_MAT3x4 0x8F4C +#define GL_DOUBLE_MAT4x2 0x8F4D +#define GL_DOUBLE_MAT4x3 0x8F4E +#define GL_ACTIVE_SUBROUTINES 0x8DE5 +#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 +#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 +#define GL_MAX_SUBROUTINES 0x8DE7 +#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 +#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A +#define GL_COMPATIBLE_SUBROUTINES 0x8E4B +#define GL_PATCHES 0x000E +#define GL_PATCH_VERTICES 0x8E72 +#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 +#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 +#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 +#define GL_TESS_GEN_MODE 0x8E76 +#define GL_TESS_GEN_SPACING 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 +#define GL_TESS_GEN_POINT_MODE 0x8E79 +#define GL_ISOLINES 0x8E7A +#define GL_FRACTIONAL_ODD 0x8E7B +#define GL_FRACTIONAL_EVEN 0x8E7C +#define GL_MAX_PATCH_VERTICES 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 +#define GL_TESS_EVALUATION_SHADER 0x8E87 +#define GL_TESS_CONTROL_SHADER 0x8E88 +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); +typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect); +typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); +typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); +typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); +typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShading (GLfloat value); +GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const void *indirect); +GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect); +GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); +GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); +GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); +GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); +GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); +GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); +GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedback (void); +GLAPI void APIENTRY glResumeTransformFeedback (void); +GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); +GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); +GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); +GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); +GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); +#endif +#endif /* GL_VERSION_4_0 */ + +#ifndef GL_VERSION_4_1 +#define GL_VERSION_4_1 1 +#define GL_FIXED 0x140C +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_RGB565 0x8D62 +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#define GL_VERTEX_SHADER_BIT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT 0x00000002 +#define GL_GEOMETRY_SHADER_BIT 0x00000004 +#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 +#define GL_ALL_SHADER_BITS 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE 0x8258 +#define GL_ACTIVE_PROGRAM 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING 0x825A +#define GL_MAX_VIEWPORTS 0x825B +#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C +#define GL_VIEWPORT_BOUNDS_RANGE 0x825D +#define GL_LAYER_PROVOKING_VERTEX 0x825E +#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F +#define GL_UNDEFINED_VERTEX 0x8260 +typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); +typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); +typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar *const*strings); +typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); +typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f); +typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReleaseShaderCompiler (void); +GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); +GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GLAPI void APIENTRY glDepthRangef (GLfloat n, GLfloat f); +GLAPI void APIENTRY glClearDepthf (GLfloat d); +GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); +GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar *const*strings); +GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); +GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); +GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); +GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); +GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); +GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); +GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f); +GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); +#endif +#endif /* GL_VERSION_4_1 */ + +#ifndef GL_VERSION_4_2 +#define GL_VERSION_4_2 1 +#define GL_COPY_READ_BUFFER_BINDING 0x8F36 +#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 +#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 +#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 +#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 +#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A +#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B +#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C +#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D +#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E +#define GL_NUM_SAMPLE_COUNTS 0x9380 +#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC +#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 +#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 +#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 +#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 +#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB +#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE +#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF +#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 +#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 +#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 +#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 +#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 +#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC +#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 +#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA +#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 +#define GL_COMMAND_BARRIER_BIT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 +#define GL_ALL_BARRIER_BITS 0xFFFFFFFF +#define GL_MAX_IMAGE_UNITS 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 +#define GL_IMAGE_BINDING_NAME 0x8F3A +#define GL_IMAGE_BINDING_LEVEL 0x8F3B +#define GL_IMAGE_BINDING_LAYERED 0x8F3C +#define GL_IMAGE_BINDING_LAYER 0x8F3D +#define GL_IMAGE_BINDING_ACCESS 0x8F3E +#define GL_IMAGE_1D 0x904C +#define GL_IMAGE_2D 0x904D +#define GL_IMAGE_3D 0x904E +#define GL_IMAGE_2D_RECT 0x904F +#define GL_IMAGE_CUBE 0x9050 +#define GL_IMAGE_BUFFER 0x9051 +#define GL_IMAGE_1D_ARRAY 0x9052 +#define GL_IMAGE_2D_ARRAY 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 +#define GL_INT_IMAGE_1D 0x9057 +#define GL_INT_IMAGE_2D 0x9058 +#define GL_INT_IMAGE_3D 0x9059 +#define GL_INT_IMAGE_2D_RECT 0x905A +#define GL_INT_IMAGE_CUBE 0x905B +#define GL_INT_IMAGE_BUFFER 0x905C +#define GL_INT_IMAGE_1D_ARRAY 0x905D +#define GL_INT_IMAGE_2D_ARRAY 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C +#define GL_MAX_IMAGE_SAMPLES 0x906D +#define GL_IMAGE_BINDING_FORMAT 0x906E +#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 +#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA +#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB +#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC +#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD +#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE +#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF +#define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); +typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); +GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount); +GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#endif +#endif /* GL_VERSION_4_2 */ + +#ifndef GL_VERSION_4_3 +#define GL_VERSION_4_3 1 +typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 +#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#define GL_COMPUTE_SHADER 0x91B9 +#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB +#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC +#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD +#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 +#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 +#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 +#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 +#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 +#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB +#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE +#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF +#define GL_COMPUTE_WORK_GROUP_SIZE 0x8267 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED +#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE +#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF +#define GL_COMPUTE_SHADER_BIT 0x00000020 +#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 +#define GL_DEBUG_SOURCE_API 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#define GL_DEBUG_SOURCE_OTHER 0x824B +#define GL_DEBUG_TYPE_ERROR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 +#define GL_DEBUG_TYPE_OTHER 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES 0x9145 +#define GL_DEBUG_SEVERITY_HIGH 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 +#define GL_DEBUG_SEVERITY_LOW 0x9148 +#define GL_DEBUG_TYPE_MARKER 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D +#define GL_BUFFER 0x82E0 +#define GL_SHADER 0x82E1 +#define GL_PROGRAM 0x82E2 +#define GL_QUERY 0x82E3 +#define GL_PROGRAM_PIPELINE 0x82E4 +#define GL_SAMPLER 0x82E6 +#define GL_MAX_LABEL_LENGTH 0x82E8 +#define GL_DEBUG_OUTPUT 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 +#define GL_MAX_UNIFORM_LOCATIONS 0x826E +#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 +#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 +#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 +#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 +#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 +#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 +#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 +#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 +#define GL_INTERNALFORMAT_SUPPORTED 0x826F +#define GL_INTERNALFORMAT_PREFERRED 0x8270 +#define GL_INTERNALFORMAT_RED_SIZE 0x8271 +#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272 +#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273 +#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 +#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 +#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 +#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277 +#define GL_INTERNALFORMAT_RED_TYPE 0x8278 +#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279 +#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A +#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B +#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C +#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D +#define GL_MAX_WIDTH 0x827E +#define GL_MAX_HEIGHT 0x827F +#define GL_MAX_DEPTH 0x8280 +#define GL_MAX_LAYERS 0x8281 +#define GL_MAX_COMBINED_DIMENSIONS 0x8282 +#define GL_COLOR_COMPONENTS 0x8283 +#define GL_DEPTH_COMPONENTS 0x8284 +#define GL_STENCIL_COMPONENTS 0x8285 +#define GL_COLOR_RENDERABLE 0x8286 +#define GL_DEPTH_RENDERABLE 0x8287 +#define GL_STENCIL_RENDERABLE 0x8288 +#define GL_FRAMEBUFFER_RENDERABLE 0x8289 +#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A +#define GL_FRAMEBUFFER_BLEND 0x828B +#define GL_READ_PIXELS 0x828C +#define GL_READ_PIXELS_FORMAT 0x828D +#define GL_READ_PIXELS_TYPE 0x828E +#define GL_TEXTURE_IMAGE_FORMAT 0x828F +#define GL_TEXTURE_IMAGE_TYPE 0x8290 +#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 +#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292 +#define GL_MIPMAP 0x8293 +#define GL_MANUAL_GENERATE_MIPMAP 0x8294 +#define GL_AUTO_GENERATE_MIPMAP 0x8295 +#define GL_COLOR_ENCODING 0x8296 +#define GL_SRGB_READ 0x8297 +#define GL_SRGB_WRITE 0x8298 +#define GL_FILTER 0x829A +#define GL_VERTEX_TEXTURE 0x829B +#define GL_TESS_CONTROL_TEXTURE 0x829C +#define GL_TESS_EVALUATION_TEXTURE 0x829D +#define GL_GEOMETRY_TEXTURE 0x829E +#define GL_FRAGMENT_TEXTURE 0x829F +#define GL_COMPUTE_TEXTURE 0x82A0 +#define GL_TEXTURE_SHADOW 0x82A1 +#define GL_TEXTURE_GATHER 0x82A2 +#define GL_TEXTURE_GATHER_SHADOW 0x82A3 +#define GL_SHADER_IMAGE_LOAD 0x82A4 +#define GL_SHADER_IMAGE_STORE 0x82A5 +#define GL_SHADER_IMAGE_ATOMIC 0x82A6 +#define GL_IMAGE_TEXEL_SIZE 0x82A7 +#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 +#define GL_IMAGE_PIXEL_FORMAT 0x82A9 +#define GL_IMAGE_PIXEL_TYPE 0x82AA +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF +#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 +#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 +#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 +#define GL_CLEAR_BUFFER 0x82B4 +#define GL_TEXTURE_VIEW 0x82B5 +#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6 +#define GL_FULL_SUPPORT 0x82B7 +#define GL_CAVEAT_SUPPORT 0x82B8 +#define GL_IMAGE_CLASS_4_X_32 0x82B9 +#define GL_IMAGE_CLASS_2_X_32 0x82BA +#define GL_IMAGE_CLASS_1_X_32 0x82BB +#define GL_IMAGE_CLASS_4_X_16 0x82BC +#define GL_IMAGE_CLASS_2_X_16 0x82BD +#define GL_IMAGE_CLASS_1_X_16 0x82BE +#define GL_IMAGE_CLASS_4_X_8 0x82BF +#define GL_IMAGE_CLASS_2_X_8 0x82C0 +#define GL_IMAGE_CLASS_1_X_8 0x82C1 +#define GL_IMAGE_CLASS_11_11_10 0x82C2 +#define GL_IMAGE_CLASS_10_10_10_2 0x82C3 +#define GL_VIEW_CLASS_128_BITS 0x82C4 +#define GL_VIEW_CLASS_96_BITS 0x82C5 +#define GL_VIEW_CLASS_64_BITS 0x82C6 +#define GL_VIEW_CLASS_48_BITS 0x82C7 +#define GL_VIEW_CLASS_32_BITS 0x82C8 +#define GL_VIEW_CLASS_24_BITS 0x82C9 +#define GL_VIEW_CLASS_16_BITS 0x82CA +#define GL_VIEW_CLASS_8_BITS 0x82CB +#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC +#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD +#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE +#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF +#define GL_VIEW_CLASS_RGTC1_RED 0x82D0 +#define GL_VIEW_CLASS_RGTC2_RG 0x82D1 +#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2 +#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 +#define GL_UNIFORM 0x92E1 +#define GL_UNIFORM_BLOCK 0x92E2 +#define GL_PROGRAM_INPUT 0x92E3 +#define GL_PROGRAM_OUTPUT 0x92E4 +#define GL_BUFFER_VARIABLE 0x92E5 +#define GL_SHADER_STORAGE_BLOCK 0x92E6 +#define GL_VERTEX_SUBROUTINE 0x92E8 +#define GL_TESS_CONTROL_SUBROUTINE 0x92E9 +#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA +#define GL_GEOMETRY_SUBROUTINE 0x92EB +#define GL_FRAGMENT_SUBROUTINE 0x92EC +#define GL_COMPUTE_SUBROUTINE 0x92ED +#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE +#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF +#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 +#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 +#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 +#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 +#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 +#define GL_ACTIVE_RESOURCES 0x92F5 +#define GL_MAX_NAME_LENGTH 0x92F6 +#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 +#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 +#define GL_NAME_LENGTH 0x92F9 +#define GL_TYPE 0x92FA +#define GL_ARRAY_SIZE 0x92FB +#define GL_OFFSET 0x92FC +#define GL_BLOCK_INDEX 0x92FD +#define GL_ARRAY_STRIDE 0x92FE +#define GL_MATRIX_STRIDE 0x92FF +#define GL_IS_ROW_MAJOR 0x9300 +#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 +#define GL_BUFFER_BINDING 0x9302 +#define GL_BUFFER_DATA_SIZE 0x9303 +#define GL_NUM_ACTIVE_VARIABLES 0x9304 +#define GL_ACTIVE_VARIABLES 0x9305 +#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 +#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 +#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A +#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B +#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C +#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D +#define GL_LOCATION 0x930E +#define GL_LOCATION_INDEX 0x930F +#define GL_IS_PER_PATCH 0x92E7 +#define GL_SHADER_STORAGE_BUFFER 0x90D2 +#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 +#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 +#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 +#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 +#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA +#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB +#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC +#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD +#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE +#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF +#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 +#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 +#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +#define GL_TEXTURE_BUFFER_OFFSET 0x919D +#define GL_TEXTURE_BUFFER_SIZE 0x919E +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F +#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB +#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC +#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD +#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +#define GL_VERTEX_ATTRIB_BINDING 0x82D4 +#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 +#define GL_VERTEX_BINDING_DIVISOR 0x82D6 +#define GL_VERTEX_BINDING_OFFSET 0x82D7 +#define GL_VERTEX_BINDING_STRIDE 0x82D8 +#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 +#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA +#define GL_VERTEX_BINDING_BUFFER 0x8F4F +#define GL_DISPLAY_LIST 0x82E7 +typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); +typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect); +GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level); +GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer); +GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); +GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +GLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +GLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GLAPI void APIENTRY glPopDebugGroup (void); +GLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +#endif /* GL_VERSION_4_3 */ + +#ifndef GL_VERSION_4_4 +#define GL_VERSION_4_4 1 +#define GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5 +#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221 +#define GL_TEXTURE_BUFFER_BINDING 0x8C2A +#define GL_MAP_PERSISTENT_BIT 0x0040 +#define GL_MAP_COHERENT_BIT 0x0080 +#define GL_DYNAMIC_STORAGE_BIT 0x0100 +#define GL_CLIENT_STORAGE_BIT 0x0200 +#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000 +#define GL_BUFFER_IMMUTABLE_STORAGE 0x821F +#define GL_BUFFER_STORAGE_FLAGS 0x8220 +#define GL_CLEAR_TEXTURE 0x9365 +#define GL_LOCATION_COMPONENT 0x934A +#define GL_TRANSFORM_FEEDBACK_BUFFER_INDEX 0x934B +#define GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE 0x934C +#define GL_QUERY_BUFFER 0x9192 +#define GL_QUERY_BUFFER_BARRIER_BIT 0x00008000 +#define GL_QUERY_BUFFER_BINDING 0x9193 +#define GL_QUERY_RESULT_NO_WAIT 0x9194 +#define GL_MIRROR_CLAMP_TO_EDGE 0x8743 +typedef void (APIENTRYP PFNGLBUFFERSTORAGEPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); +typedef void (APIENTRYP PFNGLCLEARTEXIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARTEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLBINDBUFFERSBASEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); +typedef void (APIENTRYP PFNGLBINDBUFFERSRANGEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); +typedef void (APIENTRYP PFNGLBINDTEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); +typedef void (APIENTRYP PFNGLBINDSAMPLERSPROC) (GLuint first, GLsizei count, const GLuint *samplers); +typedef void (APIENTRYP PFNGLBINDIMAGETEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); +typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERSPROC) (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferStorage (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); +GLAPI void APIENTRY glClearTexImage (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glBindBuffersBase (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); +GLAPI void APIENTRY glBindBuffersRange (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); +GLAPI void APIENTRY glBindTextures (GLuint first, GLsizei count, const GLuint *textures); +GLAPI void APIENTRY glBindSamplers (GLuint first, GLsizei count, const GLuint *samplers); +GLAPI void APIENTRY glBindImageTextures (GLuint first, GLsizei count, const GLuint *textures); +GLAPI void APIENTRY glBindVertexBuffers (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +#endif +#endif /* GL_VERSION_4_4 */ + +#ifndef GL_VERSION_4_5 +#define GL_VERSION_4_5 1 +#define GL_CONTEXT_LOST 0x0507 +#define GL_NEGATIVE_ONE_TO_ONE 0x935E +#define GL_ZERO_TO_ONE 0x935F +#define GL_CLIP_ORIGIN 0x935C +#define GL_CLIP_DEPTH_MODE 0x935D +#define GL_QUERY_WAIT_INVERTED 0x8E17 +#define GL_QUERY_NO_WAIT_INVERTED 0x8E18 +#define GL_QUERY_BY_REGION_WAIT_INVERTED 0x8E19 +#define GL_QUERY_BY_REGION_NO_WAIT_INVERTED 0x8E1A +#define GL_MAX_CULL_DISTANCES 0x82F9 +#define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES 0x82FA +#define GL_TEXTURE_TARGET 0x1006 +#define GL_QUERY_TARGET 0x82EA +#define GL_GUILTY_CONTEXT_RESET 0x8253 +#define GL_INNOCENT_CONTEXT_RESET 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY 0x8256 +#define GL_LOSE_CONTEXT_ON_RESET 0x8252 +#define GL_NO_RESET_NOTIFICATION 0x8261 +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT 0x00000004 +#define GL_CONTEXT_RELEASE_BEHAVIOR 0x82FB +#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC +typedef void (APIENTRYP PFNGLCLIPCONTROLPROC) (GLenum origin, GLenum depth); +typedef void (APIENTRYP PFNGLCREATETRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC) (GLuint xfb, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC) (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKIVPROC) (GLuint xfb, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint *param); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI64_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint64 *param); +typedef void (APIENTRYP PFNGLCREATEBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLCOPYNAMEDBUFFERSUBDATAPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERPROC) (GLuint buffer, GLenum access); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERI64VPROC) (GLuint buffer, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVPROC) (GLuint buffer, GLenum pname, void **params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +typedef void (APIENTRYP PFNGLCREATEFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC) (GLuint framebuffer, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC) (GLuint framebuffer, GLenum buf); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC) (GLuint framebuffer, GLenum src); +typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments); +typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFIPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef void (APIENTRYP PFNGLBLITNAMEDFRAMEBUFFERPROC) (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC) (GLuint framebuffer, GLenum target); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC) (GLuint framebuffer, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCREATERENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC) (GLuint renderbuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCREATETEXTURESPROC) (GLenum target, GLsizei n, GLuint *textures); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERPROC) (GLuint texture, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEPROC) (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFPROC) (GLuint texture, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIPROC) (GLuint texture, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLBINDTEXTUREUNITPROC) (GLuint unit, GLuint texture); +typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVPROC) (GLuint texture, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVPROC) (GLuint texture, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCREATEVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLVERTEXARRAYELEMENTBUFFERPROC) (GLuint vaobj, GLuint buffer); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERSPROC) (GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBBINDINGPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBIFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBLFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYBINDINGDIVISORPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYIVPROC) (GLuint vaobj, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXEDIVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXED64IVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint64 *param); +typedef void (APIENTRYP PFNGLCREATESAMPLERSPROC) (GLsizei n, GLuint *samplers); +typedef void (APIENTRYP PFNGLCREATEPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef void (APIENTRYP PFNGLCREATEQUERIESPROC) (GLenum target, GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTI64VPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTIVPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUI64VPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUIVPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLMEMORYBARRIERBYREGIONPROC) (GLbitfield barriers); +typedef void (APIENTRYP PFNGLGETTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels); +typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSPROC) (void); +typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint lod, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETNTEXIMAGEPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETNUNIFORMDVPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMFVPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (APIENTRYP PFNGLREADNPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +typedef void (APIENTRYP PFNGLGETNMAPDVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +typedef void (APIENTRYP PFNGLGETNMAPFVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +typedef void (APIENTRYP PFNGLGETNMAPIVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +typedef void (APIENTRYP PFNGLGETNPIXELMAPFVPROC) (GLenum map, GLsizei bufSize, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVPROC) (GLenum map, GLsizei bufSize, GLuint *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVPROC) (GLenum map, GLsizei bufSize, GLushort *values); +typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEPROC) (GLsizei bufSize, GLubyte *pattern); +typedef void (APIENTRYP PFNGLGETNCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +typedef void (APIENTRYP PFNGLGETNHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +typedef void (APIENTRYP PFNGLGETNMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +typedef void (APIENTRYP PFNGLTEXTUREBARRIERPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClipControl (GLenum origin, GLenum depth); +GLAPI void APIENTRY glCreateTransformFeedbacks (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glTransformFeedbackBufferBase (GLuint xfb, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackBufferRange (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glGetTransformFeedbackiv (GLuint xfb, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetTransformFeedbacki_v (GLuint xfb, GLenum pname, GLuint index, GLint *param); +GLAPI void APIENTRY glGetTransformFeedbacki64_v (GLuint xfb, GLenum pname, GLuint index, GLint64 *param); +GLAPI void APIENTRY glCreateBuffers (GLsizei n, GLuint *buffers); +GLAPI void APIENTRY glNamedBufferStorage (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +GLAPI void APIENTRY glNamedBufferData (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +GLAPI void APIENTRY glNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glCopyNamedBufferSubData (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glClearNamedBufferData (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferSubData (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void *APIENTRY glMapNamedBuffer (GLuint buffer, GLenum access); +GLAPI void *APIENTRY glMapNamedBufferRange (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI GLboolean APIENTRY glUnmapNamedBuffer (GLuint buffer); +GLAPI void APIENTRY glFlushMappedNamedBufferRange (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glGetNamedBufferParameteriv (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedBufferParameteri64v (GLuint buffer, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetNamedBufferPointerv (GLuint buffer, GLenum pname, void **params); +GLAPI void APIENTRY glGetNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +GLAPI void APIENTRY glCreateFramebuffers (GLsizei n, GLuint *framebuffers); +GLAPI void APIENTRY glNamedFramebufferRenderbuffer (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glNamedFramebufferParameteri (GLuint framebuffer, GLenum pname, GLint param); +GLAPI void APIENTRY glNamedFramebufferTexture (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTextureLayer (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glNamedFramebufferDrawBuffer (GLuint framebuffer, GLenum buf); +GLAPI void APIENTRY glNamedFramebufferDrawBuffers (GLuint framebuffer, GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glNamedFramebufferReadBuffer (GLuint framebuffer, GLenum src); +GLAPI void APIENTRY glInvalidateNamedFramebufferData (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments); +GLAPI void APIENTRY glInvalidateNamedFramebufferSubData (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glClearNamedFramebufferiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); +GLAPI void APIENTRY glClearNamedFramebufferuiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); +GLAPI void APIENTRY glClearNamedFramebufferfv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); +GLAPI void APIENTRY glClearNamedFramebufferfi (GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GLAPI void APIENTRY glBlitNamedFramebuffer (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI GLenum APIENTRY glCheckNamedFramebufferStatus (GLuint framebuffer, GLenum target); +GLAPI void APIENTRY glGetNamedFramebufferParameteriv (GLuint framebuffer, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameteriv (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glCreateRenderbuffers (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glNamedRenderbufferStorage (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisample (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetNamedRenderbufferParameteriv (GLuint renderbuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glCreateTextures (GLenum target, GLsizei n, GLuint *textures); +GLAPI void APIENTRY glTextureBuffer (GLuint texture, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glTextureBufferRange (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTextureStorage1D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTextureStorage2D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureStorage3D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glTextureStorage2DMultisample (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage3DMultisample (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCompressedTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCopyTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glCopyTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureParameterf (GLuint texture, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTextureParameterfv (GLuint texture, GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glTextureParameteri (GLuint texture, GLenum pname, GLint param); +GLAPI void APIENTRY glTextureParameterIiv (GLuint texture, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureParameterIuiv (GLuint texture, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glTextureParameteriv (GLuint texture, GLenum pname, const GLint *param); +GLAPI void APIENTRY glGenerateTextureMipmap (GLuint texture); +GLAPI void APIENTRY glBindTextureUnit (GLuint unit, GLuint texture); +GLAPI void APIENTRY glGetTextureImage (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetCompressedTextureImage (GLuint texture, GLint level, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetTextureLevelParameterfv (GLuint texture, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureLevelParameteriv (GLuint texture, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterfv (GLuint texture, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureParameterIiv (GLuint texture, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterIuiv (GLuint texture, GLenum pname, GLuint *params); +GLAPI void APIENTRY glGetTextureParameteriv (GLuint texture, GLenum pname, GLint *params); +GLAPI void APIENTRY glCreateVertexArrays (GLsizei n, GLuint *arrays); +GLAPI void APIENTRY glDisableVertexArrayAttrib (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glEnableVertexArrayAttrib (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glVertexArrayElementBuffer (GLuint vaobj, GLuint buffer); +GLAPI void APIENTRY glVertexArrayVertexBuffer (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexArrayVertexBuffers (GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +GLAPI void APIENTRY glVertexArrayAttribBinding (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexArrayAttribFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayAttribIFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayAttribLFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayBindingDivisor (GLuint vaobj, GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glGetVertexArrayiv (GLuint vaobj, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayIndexediv (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayIndexed64iv (GLuint vaobj, GLuint index, GLenum pname, GLint64 *param); +GLAPI void APIENTRY glCreateSamplers (GLsizei n, GLuint *samplers); +GLAPI void APIENTRY glCreateProgramPipelines (GLsizei n, GLuint *pipelines); +GLAPI void APIENTRY glCreateQueries (GLenum target, GLsizei n, GLuint *ids); +GLAPI void APIENTRY glGetQueryBufferObjecti64v (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glGetQueryBufferObjectiv (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glGetQueryBufferObjectui64v (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glGetQueryBufferObjectuiv (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glMemoryBarrierByRegion (GLbitfield barriers); +GLAPI void APIENTRY glGetTextureSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetCompressedTextureSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels); +GLAPI GLenum APIENTRY glGetGraphicsResetStatus (void); +GLAPI void APIENTRY glGetnCompressedTexImage (GLenum target, GLint lod, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetnTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetnUniformdv (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +GLAPI void APIENTRY glGetnUniformfv (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GLAPI void APIENTRY glGetnUniformiv (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetnUniformuiv (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GLAPI void APIENTRY glReadnPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +GLAPI void APIENTRY glGetnMapdv (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +GLAPI void APIENTRY glGetnMapfv (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +GLAPI void APIENTRY glGetnMapiv (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +GLAPI void APIENTRY glGetnPixelMapfv (GLenum map, GLsizei bufSize, GLfloat *values); +GLAPI void APIENTRY glGetnPixelMapuiv (GLenum map, GLsizei bufSize, GLuint *values); +GLAPI void APIENTRY glGetnPixelMapusv (GLenum map, GLsizei bufSize, GLushort *values); +GLAPI void APIENTRY glGetnPolygonStipple (GLsizei bufSize, GLubyte *pattern); +GLAPI void APIENTRY glGetnColorTable (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +GLAPI void APIENTRY glGetnConvolutionFilter (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +GLAPI void APIENTRY glGetnSeparableFilter (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +GLAPI void APIENTRY glGetnHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +GLAPI void APIENTRY glGetnMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +GLAPI void APIENTRY glTextureBarrier (void); +#endif +#endif /* GL_VERSION_4_5 */ + +#ifndef GL_VERSION_4_6 +#define GL_VERSION_4_6 1 +#define GL_SHADER_BINARY_FORMAT_SPIR_V 0x9551 +#define GL_SPIR_V_BINARY 0x9552 +#define GL_PARAMETER_BUFFER 0x80EE +#define GL_PARAMETER_BUFFER_BINDING 0x80EF +#define GL_CONTEXT_FLAG_NO_ERROR_BIT 0x00000008 +#define GL_VERTICES_SUBMITTED 0x82EE +#define GL_PRIMITIVES_SUBMITTED 0x82EF +#define GL_VERTEX_SHADER_INVOCATIONS 0x82F0 +#define GL_TESS_CONTROL_SHADER_PATCHES 0x82F1 +#define GL_TESS_EVALUATION_SHADER_INVOCATIONS 0x82F2 +#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED 0x82F3 +#define GL_FRAGMENT_SHADER_INVOCATIONS 0x82F4 +#define GL_COMPUTE_SHADER_INVOCATIONS 0x82F5 +#define GL_CLIPPING_INPUT_PRIMITIVES 0x82F6 +#define GL_CLIPPING_OUTPUT_PRIMITIVES 0x82F7 +#define GL_POLYGON_OFFSET_CLAMP 0x8E1B +#define GL_SPIR_V_EXTENSIONS 0x9553 +#define GL_NUM_SPIR_V_EXTENSIONS 0x9554 +#define GL_TEXTURE_MAX_ANISOTROPY 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY 0x84FF +#define GL_TRANSFORM_FEEDBACK_OVERFLOW 0x82EC +#define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW 0x82ED +typedef void (APIENTRYP PFNGLSPECIALIZESHADERPROC) (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLPOLYGONOFFSETCLAMPPROC) (GLfloat factor, GLfloat units, GLfloat clamp); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpecializeShader (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +GLAPI void APIENTRY glMultiDrawArraysIndirectCount (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectCount (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glPolygonOffsetClamp (GLfloat factor, GLfloat units, GLfloat clamp); +#endif +#endif /* GL_VERSION_4_6 */ + +#ifndef GL_ARB_ES2_compatibility +#define GL_ARB_ES2_compatibility 1 +#endif /* GL_ARB_ES2_compatibility */ + +#ifndef GL_ARB_ES3_1_compatibility +#define GL_ARB_ES3_1_compatibility 1 +#endif /* GL_ARB_ES3_1_compatibility */ + +#ifndef GL_ARB_ES3_2_compatibility +#define GL_ARB_ES3_2_compatibility 1 +#define GL_PRIMITIVE_BOUNDING_BOX_ARB 0x92BE +#define GL_MULTISAMPLE_LINE_WIDTH_RANGE_ARB 0x9381 +#define GL_MULTISAMPLE_LINE_WIDTH_GRANULARITY_ARB 0x9382 +typedef void (APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXARBPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveBoundingBoxARB (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#endif +#endif /* GL_ARB_ES3_2_compatibility */ + +#ifndef GL_ARB_ES3_compatibility +#define GL_ARB_ES3_compatibility 1 +#endif /* GL_ARB_ES3_compatibility */ + +#ifndef GL_ARB_arrays_of_arrays +#define GL_ARB_arrays_of_arrays 1 +#endif /* GL_ARB_arrays_of_arrays */ + +#ifndef GL_ARB_base_instance +#define GL_ARB_base_instance 1 +#endif /* GL_ARB_base_instance */ + +#ifndef GL_ARB_bindless_texture +#define GL_ARB_bindless_texture 1 +typedef khronos_uint64_t GLuint64EXT; +#define GL_UNSIGNED_INT64_ARB 0x140F +typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLEARBPROC) (GLuint texture); +typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLEARBPROC) (GLuint texture, GLuint sampler); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC) (GLuint64 handle); +typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLEARBPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle, GLenum access); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTARBPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64ARBPROC) (GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64ARBPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); +typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64ARBPROC) (GLuint index, GLuint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VARBPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VARBPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint64 APIENTRY glGetTextureHandleARB (GLuint texture); +GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleARB (GLuint texture, GLuint sampler); +GLAPI void APIENTRY glMakeTextureHandleResidentARB (GLuint64 handle); +GLAPI void APIENTRY glMakeTextureHandleNonResidentARB (GLuint64 handle); +GLAPI GLuint64 APIENTRY glGetImageHandleARB (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +GLAPI void APIENTRY glMakeImageHandleResidentARB (GLuint64 handle, GLenum access); +GLAPI void APIENTRY glMakeImageHandleNonResidentARB (GLuint64 handle); +GLAPI void APIENTRY glUniformHandleui64ARB (GLint location, GLuint64 value); +GLAPI void APIENTRY glUniformHandleui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniformHandleui64ARB (GLuint program, GLint location, GLuint64 value); +GLAPI void APIENTRY glProgramUniformHandleui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +GLAPI GLboolean APIENTRY glIsTextureHandleResidentARB (GLuint64 handle); +GLAPI GLboolean APIENTRY glIsImageHandleResidentARB (GLuint64 handle); +GLAPI void APIENTRY glVertexAttribL1ui64ARB (GLuint index, GLuint64EXT x); +GLAPI void APIENTRY glVertexAttribL1ui64vARB (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glGetVertexAttribLui64vARB (GLuint index, GLenum pname, GLuint64EXT *params); +#endif +#endif /* GL_ARB_bindless_texture */ + +#ifndef GL_ARB_blend_func_extended +#define GL_ARB_blend_func_extended 1 +#endif /* GL_ARB_blend_func_extended */ + +#ifndef GL_ARB_buffer_storage +#define GL_ARB_buffer_storage 1 +#endif /* GL_ARB_buffer_storage */ + +#ifndef GL_ARB_cl_event +#define GL_ARB_cl_event 1 +struct _cl_context; +struct _cl_event; +#define GL_SYNC_CL_EVENT_ARB 0x8240 +#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 +typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); #endif +#endif /* GL_ARB_cl_event */ -#ifndef GL_ARB_multitexture -#define GL_TEXTURE0_ARB 0x84C0 -#define GL_TEXTURE1_ARB 0x84C1 -#define GL_TEXTURE2_ARB 0x84C2 -#define GL_TEXTURE3_ARB 0x84C3 -#define GL_TEXTURE4_ARB 0x84C4 -#define GL_TEXTURE5_ARB 0x84C5 -#define GL_TEXTURE6_ARB 0x84C6 -#define GL_TEXTURE7_ARB 0x84C7 -#define GL_TEXTURE8_ARB 0x84C8 -#define GL_TEXTURE9_ARB 0x84C9 -#define GL_TEXTURE10_ARB 0x84CA -#define GL_TEXTURE11_ARB 0x84CB -#define GL_TEXTURE12_ARB 0x84CC -#define GL_TEXTURE13_ARB 0x84CD -#define GL_TEXTURE14_ARB 0x84CE -#define GL_TEXTURE15_ARB 0x84CF -#define GL_TEXTURE16_ARB 0x84D0 -#define GL_TEXTURE17_ARB 0x84D1 -#define GL_TEXTURE18_ARB 0x84D2 -#define GL_TEXTURE19_ARB 0x84D3 -#define GL_TEXTURE20_ARB 0x84D4 -#define GL_TEXTURE21_ARB 0x84D5 -#define GL_TEXTURE22_ARB 0x84D6 -#define GL_TEXTURE23_ARB 0x84D7 -#define GL_TEXTURE24_ARB 0x84D8 -#define GL_TEXTURE25_ARB 0x84D9 -#define GL_TEXTURE26_ARB 0x84DA -#define GL_TEXTURE27_ARB 0x84DB -#define GL_TEXTURE28_ARB 0x84DC -#define GL_TEXTURE29_ARB 0x84DD -#define GL_TEXTURE30_ARB 0x84DE -#define GL_TEXTURE31_ARB 0x84DF -#define GL_ACTIVE_TEXTURE_ARB 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 -#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 -#endif +#ifndef GL_ARB_clear_buffer_object +#define GL_ARB_clear_buffer_object 1 +#endif /* GL_ARB_clear_buffer_object */ -#ifndef GL_ARB_transpose_matrix -#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 -#endif +#ifndef GL_ARB_clear_texture +#define GL_ARB_clear_texture 1 +#endif /* GL_ARB_clear_texture */ -#ifndef GL_ARB_multisample -#define GL_MULTISAMPLE_ARB 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F -#define GL_SAMPLE_COVERAGE_ARB 0x80A0 -#define GL_SAMPLE_BUFFERS_ARB 0x80A8 -#define GL_SAMPLES_ARB 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB -#define GL_MULTISAMPLE_BIT_ARB 0x20000000 -#endif +#ifndef GL_ARB_clip_control +#define GL_ARB_clip_control 1 +#endif /* GL_ARB_clip_control */ -#ifndef GL_ARB_texture_env_add +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D +typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); #endif +#endif /* GL_ARB_color_buffer_float */ -#ifndef GL_ARB_texture_cube_map -#define GL_NORMAL_MAP_ARB 0x8511 -#define GL_REFLECTION_MAP_ARB 0x8512 -#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C -#endif +#ifndef GL_ARB_compatibility +#define GL_ARB_compatibility 1 +#endif /* GL_ARB_compatibility */ -#ifndef GL_ARB_texture_compression -#define GL_COMPRESSED_ALPHA_ARB 0x84E9 -#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB -#define GL_COMPRESSED_INTENSITY_ARB 0x84EC -#define GL_COMPRESSED_RGB_ARB 0x84ED -#define GL_COMPRESSED_RGBA_ARB 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 -#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 -#endif +#ifndef GL_ARB_compressed_texture_pixel_storage +#define GL_ARB_compressed_texture_pixel_storage 1 +#endif /* GL_ARB_compressed_texture_pixel_storage */ -#ifndef GL_ARB_texture_border_clamp -#define GL_CLAMP_TO_BORDER_ARB 0x812D -#endif +#ifndef GL_ARB_compute_shader +#define GL_ARB_compute_shader 1 +#endif /* GL_ARB_compute_shader */ -#ifndef GL_ARB_point_parameters -#define GL_POINT_SIZE_MIN_ARB 0x8126 -#define GL_POINT_SIZE_MAX_ARB 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +#ifndef GL_ARB_compute_variable_group_size +#define GL_ARB_compute_variable_group_size 1 +#define GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB 0x9344 +#define GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB 0x90EB +#define GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB 0x9345 +#define GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB 0x91BF +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDispatchComputeGroupSizeARB (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); +#endif +#endif /* GL_ARB_compute_variable_group_size */ + +#ifndef GL_ARB_conditional_render_inverted +#define GL_ARB_conditional_render_inverted 1 +#endif /* GL_ARB_conditional_render_inverted */ + +#ifndef GL_ARB_conservative_depth +#define GL_ARB_conservative_depth 1 +#endif /* GL_ARB_conservative_depth */ + +#ifndef GL_ARB_copy_buffer +#define GL_ARB_copy_buffer 1 +#endif /* GL_ARB_copy_buffer */ + +#ifndef GL_ARB_copy_image +#define GL_ARB_copy_image 1 +#endif /* GL_ARB_copy_image */ + +#ifndef GL_ARB_cull_distance +#define GL_ARB_cull_distance 1 +#endif /* GL_ARB_cull_distance */ + +#ifndef GL_ARB_debug_output +#define GL_ARB_debug_output 1 +typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 +#define GL_DEBUG_SOURCE_API_ARB 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A +#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B +#define GL_DEBUG_TYPE_ERROR_ARB 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 +#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 +#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); #endif +#endif /* GL_ARB_debug_output */ -#ifndef GL_ARB_vertex_blend -#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 -#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 -#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 -#define GL_VERTEX_BLEND_ARB 0x86A7 -#define GL_CURRENT_WEIGHT_ARB 0x86A8 -#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 -#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA -#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB -#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC -#define GL_WEIGHT_ARRAY_ARB 0x86AD -#define GL_MODELVIEW0_ARB 0x1700 -#define GL_MODELVIEW1_ARB 0x850A -#define GL_MODELVIEW2_ARB 0x8722 -#define GL_MODELVIEW3_ARB 0x8723 -#define GL_MODELVIEW4_ARB 0x8724 -#define GL_MODELVIEW5_ARB 0x8725 -#define GL_MODELVIEW6_ARB 0x8726 -#define GL_MODELVIEW7_ARB 0x8727 -#define GL_MODELVIEW8_ARB 0x8728 -#define GL_MODELVIEW9_ARB 0x8729 -#define GL_MODELVIEW10_ARB 0x872A -#define GL_MODELVIEW11_ARB 0x872B -#define GL_MODELVIEW12_ARB 0x872C -#define GL_MODELVIEW13_ARB 0x872D -#define GL_MODELVIEW14_ARB 0x872E -#define GL_MODELVIEW15_ARB 0x872F -#define GL_MODELVIEW16_ARB 0x8730 -#define GL_MODELVIEW17_ARB 0x8731 -#define GL_MODELVIEW18_ARB 0x8732 -#define GL_MODELVIEW19_ARB 0x8733 -#define GL_MODELVIEW20_ARB 0x8734 -#define GL_MODELVIEW21_ARB 0x8735 -#define GL_MODELVIEW22_ARB 0x8736 -#define GL_MODELVIEW23_ARB 0x8737 -#define GL_MODELVIEW24_ARB 0x8738 -#define GL_MODELVIEW25_ARB 0x8739 -#define GL_MODELVIEW26_ARB 0x873A -#define GL_MODELVIEW27_ARB 0x873B -#define GL_MODELVIEW28_ARB 0x873C -#define GL_MODELVIEW29_ARB 0x873D -#define GL_MODELVIEW30_ARB 0x873E -#define GL_MODELVIEW31_ARB 0x873F -#endif - -#ifndef GL_ARB_matrix_palette -#define GL_MATRIX_PALETTE_ARB 0x8840 -#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 -#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 -#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 -#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 -#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 -#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 -#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 -#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 -#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 -#endif - -#ifndef GL_ARB_texture_env_combine -#define GL_COMBINE_ARB 0x8570 -#define GL_COMBINE_RGB_ARB 0x8571 -#define GL_COMBINE_ALPHA_ARB 0x8572 -#define GL_SOURCE0_RGB_ARB 0x8580 -#define GL_SOURCE1_RGB_ARB 0x8581 -#define GL_SOURCE2_RGB_ARB 0x8582 -#define GL_SOURCE0_ALPHA_ARB 0x8588 -#define GL_SOURCE1_ALPHA_ARB 0x8589 -#define GL_SOURCE2_ALPHA_ARB 0x858A -#define GL_OPERAND0_RGB_ARB 0x8590 -#define GL_OPERAND1_RGB_ARB 0x8591 -#define GL_OPERAND2_RGB_ARB 0x8592 -#define GL_OPERAND0_ALPHA_ARB 0x8598 -#define GL_OPERAND1_ALPHA_ARB 0x8599 -#define GL_OPERAND2_ALPHA_ARB 0x859A -#define GL_RGB_SCALE_ARB 0x8573 -#define GL_ADD_SIGNED_ARB 0x8574 -#define GL_INTERPOLATE_ARB 0x8575 -#define GL_SUBTRACT_ARB 0x84E7 -#define GL_CONSTANT_ARB 0x8576 -#define GL_PRIMARY_COLOR_ARB 0x8577 -#define GL_PREVIOUS_ARB 0x8578 -#endif - -#ifndef GL_ARB_texture_env_crossbar -#endif - -#ifndef GL_ARB_texture_env_dot3 -#define GL_DOT3_RGB_ARB 0x86AE -#define GL_DOT3_RGBA_ARB 0x86AF -#endif +#ifndef GL_ARB_depth_buffer_float +#define GL_ARB_depth_buffer_float 1 +#endif /* GL_ARB_depth_buffer_float */ -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_MIRRORED_REPEAT_ARB 0x8370 -#endif +#ifndef GL_ARB_depth_clamp +#define GL_ARB_depth_clamp 1 +#endif /* GL_ARB_depth_clamp */ #ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 #define GL_DEPTH_COMPONENT16_ARB 0x81A5 #define GL_DEPTH_COMPONENT24_ARB 0x81A6 #define GL_DEPTH_COMPONENT32_ARB 0x81A7 #define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A #define GL_DEPTH_TEXTURE_MODE_ARB 0x884B -#endif +#endif /* GL_ARB_depth_texture */ -#ifndef GL_ARB_shadow -#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C -#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D -#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#ifndef GL_ARB_derivative_control +#define GL_ARB_derivative_control 1 +#endif /* GL_ARB_derivative_control */ + +#ifndef GL_ARB_direct_state_access +#define GL_ARB_direct_state_access 1 +#endif /* GL_ARB_direct_state_access */ + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs); #endif +#endif /* GL_ARB_draw_buffers */ -#ifndef GL_ARB_shadow_ambient -#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#ifndef GL_ARB_draw_buffers_blend +#define GL_ARB_draw_buffers_blend 1 +typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); #endif +#endif /* GL_ARB_draw_buffers_blend */ -#ifndef GL_ARB_window_pos +#ifndef GL_ARB_draw_elements_base_vertex +#define GL_ARB_draw_elements_base_vertex 1 +#endif /* GL_ARB_draw_elements_base_vertex */ + +#ifndef GL_ARB_draw_indirect +#define GL_ARB_draw_indirect 1 +#endif /* GL_ARB_draw_indirect */ + +#ifndef GL_ARB_draw_instanced +#define GL_ARB_draw_instanced 1 +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); #endif +#endif /* GL_ARB_draw_instanced */ -#ifndef GL_ARB_vertex_program -#define GL_COLOR_SUM_ARB 0x8458 -#define GL_VERTEX_PROGRAM_ARB 0x8620 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 -#define GL_PROGRAM_LENGTH_ARB 0x8627 -#define GL_PROGRAM_STRING_ARB 0x8628 -#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E -#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F -#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 -#define GL_CURRENT_MATRIX_ARB 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 -#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B -#define GL_PROGRAM_BINDING_ARB 0x8677 -#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A -#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#ifndef GL_ARB_enhanced_layouts +#define GL_ARB_enhanced_layouts 1 +#endif /* GL_ARB_enhanced_layouts */ + +#ifndef GL_ARB_explicit_attrib_location +#define GL_ARB_explicit_attrib_location 1 +#endif /* GL_ARB_explicit_attrib_location */ + +#ifndef GL_ARB_explicit_uniform_location +#define GL_ARB_explicit_uniform_location 1 +#endif /* GL_ARB_explicit_uniform_location */ + +#ifndef GL_ARB_fragment_coord_conventions +#define GL_ARB_fragment_coord_conventions 1 +#endif /* GL_ARB_fragment_coord_conventions */ + +#ifndef GL_ARB_fragment_layer_viewport +#define GL_ARB_fragment_layer_viewport 1 +#endif /* GL_ARB_fragment_layer_viewport */ + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 #define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_LENGTH_ARB 0x8627 #define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_BINDING_ARB 0x8677 #define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 #define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 #define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 @@ -738,14 +3219,31 @@ extern "C" { #define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD #define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE #define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF -#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 -#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 -#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 -#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 #define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 #define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 #define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_CURRENT_MATRIX_ARB 0x8641 #define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 #define GL_MATRIX0_ARB 0x88C0 #define GL_MATRIX1_ARB 0x88C1 #define GL_MATRIX2_ARB 0x88C2 @@ -778,2985 +3276,1435 @@ extern "C" { #define GL_MATRIX29_ARB 0x88DD #define GL_MATRIX30_ARB 0x88DE #define GL_MATRIX31_ARB 0x88DF -#endif +typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const void *string); +typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, void *string); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const void *string); +GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program); +GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, void *string); +GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); +#endif +#endif /* GL_ARB_fragment_program */ -#ifndef GL_ARB_fragment_program -#define GL_FRAGMENT_PROGRAM_ARB 0x8804 -#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 -#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 -#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 -#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 -#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 -#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A -#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B -#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C -#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D -#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E -#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F -#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 -#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 -#endif +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 +#endif /* GL_ARB_fragment_program_shadow */ -#ifndef GL_ARB_vertex_buffer_object -#define GL_BUFFER_SIZE_ARB 0x8764 -#define GL_BUFFER_USAGE_ARB 0x8765 -#define GL_ARRAY_BUFFER_ARB 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 -#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F -#define GL_READ_ONLY_ARB 0x88B8 -#define GL_WRITE_ONLY_ARB 0x88B9 -#define GL_READ_WRITE_ARB 0x88BA -#define GL_BUFFER_ACCESS_ARB 0x88BB -#define GL_BUFFER_MAPPED_ARB 0x88BC -#define GL_BUFFER_MAP_POINTER_ARB 0x88BD -#define GL_STREAM_DRAW_ARB 0x88E0 -#define GL_STREAM_READ_ARB 0x88E1 -#define GL_STREAM_COPY_ARB 0x88E2 -#define GL_STATIC_DRAW_ARB 0x88E4 -#define GL_STATIC_READ_ARB 0x88E5 -#define GL_STATIC_COPY_ARB 0x88E6 -#define GL_DYNAMIC_DRAW_ARB 0x88E8 -#define GL_DYNAMIC_READ_ARB 0x88E9 -#define GL_DYNAMIC_COPY_ARB 0x88EA -#endif +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B +#endif /* GL_ARB_fragment_shader */ + +#ifndef GL_ARB_fragment_shader_interlock +#define GL_ARB_fragment_shader_interlock 1 +#endif /* GL_ARB_fragment_shader_interlock */ + +#ifndef GL_ARB_framebuffer_no_attachments +#define GL_ARB_framebuffer_no_attachments 1 +#endif /* GL_ARB_framebuffer_no_attachments */ + +#ifndef GL_ARB_framebuffer_object +#define GL_ARB_framebuffer_object 1 +#endif /* GL_ARB_framebuffer_object */ + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_ARB_framebuffer_sRGB 1 +#endif /* GL_ARB_framebuffer_sRGB */ + +#ifndef GL_ARB_geometry_shader4 +#define GL_ARB_geometry_shader4 1 +#define GL_LINES_ADJACENCY_ARB 0x000A +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B +#define GL_TRIANGLES_ADJACENCY_ARB 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 +#define GL_GEOMETRY_SHADER_ARB 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif +#endif /* GL_ARB_geometry_shader4 */ + +#ifndef GL_ARB_get_program_binary +#define GL_ARB_get_program_binary 1 +#endif /* GL_ARB_get_program_binary */ + +#ifndef GL_ARB_get_texture_sub_image +#define GL_ARB_get_texture_sub_image 1 +#endif /* GL_ARB_get_texture_sub_image */ + +#ifndef GL_ARB_gl_spirv +#define GL_ARB_gl_spirv 1 +#define GL_SHADER_BINARY_FORMAT_SPIR_V_ARB 0x9551 +#define GL_SPIR_V_BINARY_ARB 0x9552 +typedef void (APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpecializeShaderARB (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +#endif +#endif /* GL_ARB_gl_spirv */ + +#ifndef GL_ARB_gpu_shader5 +#define GL_ARB_gpu_shader5 1 +#endif /* GL_ARB_gpu_shader5 */ + +#ifndef GL_ARB_gpu_shader_fp64 +#define GL_ARB_gpu_shader_fp64 1 +#endif /* GL_ARB_gpu_shader_fp64 */ + +#ifndef GL_ARB_gpu_shader_int64 +#define GL_ARB_gpu_shader_int64 1 +#define GL_INT64_ARB 0x140E +#define GL_INT64_VEC2_ARB 0x8FE9 +#define GL_INT64_VEC3_ARB 0x8FEA +#define GL_INT64_VEC4_ARB 0x8FEB +#define GL_UNSIGNED_INT64_VEC2_ARB 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_ARB 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_ARB 0x8FF7 +typedef void (APIENTRYP PFNGLUNIFORM1I64ARBPROC) (GLint location, GLint64 x); +typedef void (APIENTRYP PFNGLUNIFORM2I64ARBPROC) (GLint location, GLint64 x, GLint64 y); +typedef void (APIENTRYP PFNGLUNIFORM3I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z); +typedef void (APIENTRYP PFNGLUNIFORM4I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +typedef void (APIENTRYP PFNGLUNIFORM1I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM2I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM3I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM4I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM1UI64ARBPROC) (GLint location, GLuint64 x); +typedef void (APIENTRYP PFNGLUNIFORM2UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y); +typedef void (APIENTRYP PFNGLUNIFORM3UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +typedef void (APIENTRYP PFNGLUNIFORM4UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +typedef void (APIENTRYP PFNGLUNIFORM1UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM2UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM3UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM4UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLGETUNIFORMI64VARBPROC) (GLuint program, GLint location, GLint64 *params); +typedef void (APIENTRYP PFNGLGETUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLuint64 *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint64 *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint64 *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64ARBPROC) (GLuint program, GLint location, GLint64 x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64ARBPROC) (GLuint program, GLint location, GLuint64 x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1i64ARB (GLint location, GLint64 x); +GLAPI void APIENTRY glUniform2i64ARB (GLint location, GLint64 x, GLint64 y); +GLAPI void APIENTRY glUniform3i64ARB (GLint location, GLint64 x, GLint64 y, GLint64 z); +GLAPI void APIENTRY glUniform4i64ARB (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +GLAPI void APIENTRY glUniform1i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform2i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform3i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform4i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform1ui64ARB (GLint location, GLuint64 x); +GLAPI void APIENTRY glUniform2ui64ARB (GLint location, GLuint64 x, GLuint64 y); +GLAPI void APIENTRY glUniform3ui64ARB (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +GLAPI void APIENTRY glUniform4ui64ARB (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +GLAPI void APIENTRY glUniform1ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glUniform2ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glUniform3ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glUniform4ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glGetUniformi64vARB (GLuint program, GLint location, GLint64 *params); +GLAPI void APIENTRY glGetUniformui64vARB (GLuint program, GLint location, GLuint64 *params); +GLAPI void APIENTRY glGetnUniformi64vARB (GLuint program, GLint location, GLsizei bufSize, GLint64 *params); +GLAPI void APIENTRY glGetnUniformui64vARB (GLuint program, GLint location, GLsizei bufSize, GLuint64 *params); +GLAPI void APIENTRY glProgramUniform1i64ARB (GLuint program, GLint location, GLint64 x); +GLAPI void APIENTRY glProgramUniform2i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y); +GLAPI void APIENTRY glProgramUniform3i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); +GLAPI void APIENTRY glProgramUniform4i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +GLAPI void APIENTRY glProgramUniform1i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform2i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform3i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform4i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform1ui64ARB (GLuint program, GLint location, GLuint64 x); +GLAPI void APIENTRY glProgramUniform2ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y); +GLAPI void APIENTRY glProgramUniform3ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +GLAPI void APIENTRY glProgramUniform4ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +GLAPI void APIENTRY glProgramUniform1ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniform2ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniform3ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniform4ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +#endif +#endif /* GL_ARB_gpu_shader_int64 */ -#ifndef GL_ARB_occlusion_query -#define GL_QUERY_COUNTER_BITS_ARB 0x8864 -#define GL_CURRENT_QUERY_ARB 0x8865 -#define GL_QUERY_RESULT_ARB 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 -#define GL_SAMPLES_PASSED_ARB 0x8914 -#endif - -#ifndef GL_ARB_shader_objects -#define GL_PROGRAM_OBJECT_ARB 0x8B40 -#define GL_SHADER_OBJECT_ARB 0x8B48 -#define GL_OBJECT_TYPE_ARB 0x8B4E -#define GL_OBJECT_SUBTYPE_ARB 0x8B4F -#define GL_FLOAT_VEC2_ARB 0x8B50 -#define GL_FLOAT_VEC3_ARB 0x8B51 -#define GL_FLOAT_VEC4_ARB 0x8B52 -#define GL_INT_VEC2_ARB 0x8B53 -#define GL_INT_VEC3_ARB 0x8B54 -#define GL_INT_VEC4_ARB 0x8B55 -#define GL_BOOL_ARB 0x8B56 -#define GL_BOOL_VEC2_ARB 0x8B57 -#define GL_BOOL_VEC3_ARB 0x8B58 -#define GL_BOOL_VEC4_ARB 0x8B59 -#define GL_FLOAT_MAT2_ARB 0x8B5A -#define GL_FLOAT_MAT3_ARB 0x8B5B -#define GL_FLOAT_MAT4_ARB 0x8B5C -#define GL_SAMPLER_1D_ARB 0x8B5D -#define GL_SAMPLER_2D_ARB 0x8B5E -#define GL_SAMPLER_3D_ARB 0x8B5F -#define GL_SAMPLER_CUBE_ARB 0x8B60 -#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 -#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 -#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 -#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 -#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 -#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 -#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 -#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 -#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 -#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 -#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 -#endif - -#ifndef GL_ARB_vertex_shader -#define GL_VERTEX_SHADER_ARB 0x8B31 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A -#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D -#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 -#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A -#endif - -#ifndef GL_ARB_fragment_shader -#define GL_FRAGMENT_SHADER_ARB 0x8B30 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B -#endif - -#ifndef GL_ARB_shading_language_100 -#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C -#endif - -#ifndef GL_ARB_texture_non_power_of_two -#endif - -#ifndef GL_ARB_point_sprite -#define GL_POINT_SPRITE_ARB 0x8861 -#define GL_COORD_REPLACE_ARB 0x8862 -#endif - -#ifndef GL_ARB_fragment_program_shadow -#endif +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 +typedef khronos_uint16_t GLhalfARB; +#define GL_HALF_FLOAT_ARB 0x140B +#endif /* GL_ARB_half_float_pixel */ -#ifndef GL_ARB_draw_buffers -#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 -#define GL_DRAW_BUFFER0_ARB 0x8825 -#define GL_DRAW_BUFFER1_ARB 0x8826 -#define GL_DRAW_BUFFER2_ARB 0x8827 -#define GL_DRAW_BUFFER3_ARB 0x8828 -#define GL_DRAW_BUFFER4_ARB 0x8829 -#define GL_DRAW_BUFFER5_ARB 0x882A -#define GL_DRAW_BUFFER6_ARB 0x882B -#define GL_DRAW_BUFFER7_ARB 0x882C -#define GL_DRAW_BUFFER8_ARB 0x882D -#define GL_DRAW_BUFFER9_ARB 0x882E -#define GL_DRAW_BUFFER10_ARB 0x882F -#define GL_DRAW_BUFFER11_ARB 0x8830 -#define GL_DRAW_BUFFER12_ARB 0x8831 -#define GL_DRAW_BUFFER13_ARB 0x8832 -#define GL_DRAW_BUFFER14_ARB 0x8833 -#define GL_DRAW_BUFFER15_ARB 0x8834 -#endif +#ifndef GL_ARB_half_float_vertex +#define GL_ARB_half_float_vertex 1 +#endif /* GL_ARB_half_float_vertex */ -#ifndef GL_ARB_texture_rectangle -#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#ifndef GL_ARB_imaging +#define GL_ARB_imaging 1 +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, void *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, void *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, void *table); +GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, void *image); +GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogram (GLenum target); +GLAPI void APIENTRY glResetMinmax (GLenum target); +#endif +#endif /* GL_ARB_imaging */ + +#ifndef GL_ARB_indirect_parameters +#define GL_ARB_indirect_parameters 1 +#define GL_PARAMETER_BUFFER_ARB 0x80EE +#define GL_PARAMETER_BUFFER_BINDING_ARB 0x80EF +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectCountARB (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); #endif +#endif /* GL_ARB_indirect_parameters */ -#ifndef GL_ARB_color_buffer_float -#define GL_RGBA_FLOAT_MODE_ARB 0x8820 -#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A -#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B -#define GL_CLAMP_READ_COLOR_ARB 0x891C -#define GL_FIXED_ONLY_ARB 0x891D -#endif +#ifndef GL_ARB_instanced_arrays +#define GL_ARB_instanced_arrays 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); +#endif +#endif /* GL_ARB_instanced_arrays */ + +#ifndef GL_ARB_internalformat_query +#define GL_ARB_internalformat_query 1 +#endif /* GL_ARB_internalformat_query */ + +#ifndef GL_ARB_internalformat_query2 +#define GL_ARB_internalformat_query2 1 +#define GL_SRGB_DECODE_ARB 0x8299 +#define GL_VIEW_CLASS_EAC_R11 0x9383 +#define GL_VIEW_CLASS_EAC_RG11 0x9384 +#define GL_VIEW_CLASS_ETC2_RGB 0x9385 +#define GL_VIEW_CLASS_ETC2_RGBA 0x9386 +#define GL_VIEW_CLASS_ETC2_EAC_RGBA 0x9387 +#define GL_VIEW_CLASS_ASTC_4x4_RGBA 0x9388 +#define GL_VIEW_CLASS_ASTC_5x4_RGBA 0x9389 +#define GL_VIEW_CLASS_ASTC_5x5_RGBA 0x938A +#define GL_VIEW_CLASS_ASTC_6x5_RGBA 0x938B +#define GL_VIEW_CLASS_ASTC_6x6_RGBA 0x938C +#define GL_VIEW_CLASS_ASTC_8x5_RGBA 0x938D +#define GL_VIEW_CLASS_ASTC_8x6_RGBA 0x938E +#define GL_VIEW_CLASS_ASTC_8x8_RGBA 0x938F +#define GL_VIEW_CLASS_ASTC_10x5_RGBA 0x9390 +#define GL_VIEW_CLASS_ASTC_10x6_RGBA 0x9391 +#define GL_VIEW_CLASS_ASTC_10x8_RGBA 0x9392 +#define GL_VIEW_CLASS_ASTC_10x10_RGBA 0x9393 +#define GL_VIEW_CLASS_ASTC_12x10_RGBA 0x9394 +#define GL_VIEW_CLASS_ASTC_12x12_RGBA 0x9395 +#endif /* GL_ARB_internalformat_query2 */ + +#ifndef GL_ARB_invalidate_subdata +#define GL_ARB_invalidate_subdata 1 +#endif /* GL_ARB_invalidate_subdata */ + +#ifndef GL_ARB_map_buffer_alignment +#define GL_ARB_map_buffer_alignment 1 +#endif /* GL_ARB_map_buffer_alignment */ + +#ifndef GL_ARB_map_buffer_range +#define GL_ARB_map_buffer_range 1 +#endif /* GL_ARB_map_buffer_range */ -#ifndef GL_ARB_half_float_pixel -#define GL_HALF_FLOAT_ARB 0x140B +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 +typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index); +GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices); +GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices); +GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices); +GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer); #endif +#endif /* GL_ARB_matrix_palette */ -#ifndef GL_ARB_texture_float -#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 -#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 -#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 -#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 -#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 -#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 -#define GL_RGBA32F_ARB 0x8814 -#define GL_RGB32F_ARB 0x8815 -#define GL_ALPHA32F_ARB 0x8816 -#define GL_INTENSITY32F_ARB 0x8817 -#define GL_LUMINANCE32F_ARB 0x8818 -#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 -#define GL_RGBA16F_ARB 0x881A -#define GL_RGB16F_ARB 0x881B -#define GL_ALPHA16F_ARB 0x881C -#define GL_INTENSITY16F_ARB 0x881D -#define GL_LUMINANCE16F_ARB 0x881E -#define GL_LUMINANCE_ALPHA16F_ARB 0x881F -#endif +#ifndef GL_ARB_multi_bind +#define GL_ARB_multi_bind 1 +#endif /* GL_ARB_multi_bind */ -#ifndef GL_ARB_pixel_buffer_object -#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF -#endif +#ifndef GL_ARB_multi_draw_indirect +#define GL_ARB_multi_draw_indirect 1 +#endif /* GL_ARB_multi_draw_indirect */ -#ifndef GL_EXT_abgr -#define GL_ABGR_EXT 0x8000 +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLfloat value, GLboolean invert); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleCoverageARB (GLfloat value, GLboolean invert); #endif +#endif /* GL_ARB_multisample */ -#ifndef GL_EXT_blend_color -#define GL_CONSTANT_COLOR_EXT 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 -#define GL_CONSTANT_ALPHA_EXT 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 -#define GL_BLEND_COLOR_EXT 0x8005 -#endif +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v); +#endif +#endif /* GL_ARB_multitexture */ -#ifndef GL_EXT_polygon_offset -#define GL_POLYGON_OFFSET_EXT 0x8037 -#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 -#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 -#endif +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 +typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id); +GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQueryARB (GLenum target); +GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params); +#endif +#endif /* GL_ARB_occlusion_query */ + +#ifndef GL_ARB_occlusion_query2 +#define GL_ARB_occlusion_query2 1 +#endif /* GL_ARB_occlusion_query2 */ + +#ifndef GL_ARB_parallel_shader_compile +#define GL_ARB_parallel_shader_compile 1 +#define GL_MAX_SHADER_COMPILER_THREADS_ARB 0x91B0 +#define GL_COMPLETION_STATUS_ARB 0x91B1 +typedef void (APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSARBPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMaxShaderCompilerThreadsARB (GLuint count); +#endif +#endif /* GL_ARB_parallel_shader_compile */ + +#ifndef GL_ARB_pipeline_statistics_query +#define GL_ARB_pipeline_statistics_query 1 +#define GL_VERTICES_SUBMITTED_ARB 0x82EE +#define GL_PRIMITIVES_SUBMITTED_ARB 0x82EF +#define GL_VERTEX_SHADER_INVOCATIONS_ARB 0x82F0 +#define GL_TESS_CONTROL_SHADER_PATCHES_ARB 0x82F1 +#define GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB 0x82F2 +#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB 0x82F3 +#define GL_FRAGMENT_SHADER_INVOCATIONS_ARB 0x82F4 +#define GL_COMPUTE_SHADER_INVOCATIONS_ARB 0x82F5 +#define GL_CLIPPING_INPUT_PRIMITIVES_ARB 0x82F6 +#define GL_CLIPPING_OUTPUT_PRIMITIVES_ARB 0x82F7 +#endif /* GL_ARB_pipeline_statistics_query */ -#ifndef GL_EXT_texture -#define GL_ALPHA4_EXT 0x803B -#define GL_ALPHA8_EXT 0x803C -#define GL_ALPHA12_EXT 0x803D -#define GL_ALPHA16_EXT 0x803E -#define GL_LUMINANCE4_EXT 0x803F -#define GL_LUMINANCE8_EXT 0x8040 -#define GL_LUMINANCE12_EXT 0x8041 -#define GL_LUMINANCE16_EXT 0x8042 -#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 -#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 -#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 -#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 -#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 -#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 -#define GL_INTENSITY_EXT 0x8049 -#define GL_INTENSITY4_EXT 0x804A -#define GL_INTENSITY8_EXT 0x804B -#define GL_INTENSITY12_EXT 0x804C -#define GL_INTENSITY16_EXT 0x804D -#define GL_RGB2_EXT 0x804E -#define GL_RGB4_EXT 0x804F -#define GL_RGB5_EXT 0x8050 -#define GL_RGB8_EXT 0x8051 -#define GL_RGB10_EXT 0x8052 -#define GL_RGB12_EXT 0x8053 -#define GL_RGB16_EXT 0x8054 -#define GL_RGBA2_EXT 0x8055 -#define GL_RGBA4_EXT 0x8056 -#define GL_RGB5_A1_EXT 0x8057 -#define GL_RGBA8_EXT 0x8058 -#define GL_RGB10_A2_EXT 0x8059 -#define GL_RGBA12_EXT 0x805A -#define GL_RGBA16_EXT 0x805B -#define GL_TEXTURE_RED_SIZE_EXT 0x805C -#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D -#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E -#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F -#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 -#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 -#define GL_REPLACE_EXT 0x8062 -#define GL_PROXY_TEXTURE_1D_EXT 0x8063 -#define GL_PROXY_TEXTURE_2D_EXT 0x8064 -#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 -#endif +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif /* GL_ARB_pixel_buffer_object */ -#ifndef GL_EXT_texture3D -#define GL_PACK_SKIP_IMAGES_EXT 0x806B -#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C -#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D -#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E -#define GL_TEXTURE_3D_EXT 0x806F -#define GL_PROXY_TEXTURE_3D_EXT 0x8070 -#define GL_TEXTURE_DEPTH_EXT 0x8071 -#define GL_TEXTURE_WRAP_R_EXT 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); #endif +#endif /* GL_ARB_point_parameters */ -#ifndef GL_SGIS_texture_filter4 -#define GL_FILTER4_SGIS 0x8146 -#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif /* GL_ARB_point_sprite */ + +#ifndef GL_ARB_polygon_offset_clamp +#define GL_ARB_polygon_offset_clamp 1 +#endif /* GL_ARB_polygon_offset_clamp */ + +#ifndef GL_ARB_post_depth_coverage +#define GL_ARB_post_depth_coverage 1 +#endif /* GL_ARB_post_depth_coverage */ + +#ifndef GL_ARB_program_interface_query +#define GL_ARB_program_interface_query 1 +#endif /* GL_ARB_program_interface_query */ + +#ifndef GL_ARB_provoking_vertex +#define GL_ARB_provoking_vertex 1 +#endif /* GL_ARB_provoking_vertex */ + +#ifndef GL_ARB_query_buffer_object +#define GL_ARB_query_buffer_object 1 +#endif /* GL_ARB_query_buffer_object */ + +#ifndef GL_ARB_robust_buffer_access_behavior +#define GL_ARB_robust_buffer_access_behavior 1 +#endif /* GL_ARB_robust_buffer_access_behavior */ + +#ifndef GL_ARB_robustness +#define GL_ARB_robustness 1 +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 +typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); +typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); +typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, void *img); +typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); +typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); +typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); +GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); +GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, void *img); +GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); +GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); +GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); +GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); +GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +#endif +#endif /* GL_ARB_robustness */ + +#ifndef GL_ARB_robustness_isolation +#define GL_ARB_robustness_isolation 1 +#endif /* GL_ARB_robustness_isolation */ + +#ifndef GL_ARB_sample_locations +#define GL_ARB_sample_locations 1 +#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB 0x933D +#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB 0x933E +#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB 0x933F +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB 0x9340 +#define GL_SAMPLE_LOCATION_ARB 0x8E50 +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_ARB 0x9341 +#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_ARB 0x9342 +#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_ARB 0x9343 +typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLEVALUATEDEPTHVALUESARBPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferSampleLocationsfvARB (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glNamedFramebufferSampleLocationsfvARB (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glEvaluateDepthValuesARB (void); #endif +#endif /* GL_ARB_sample_locations */ -#ifndef GL_EXT_subtexture +#ifndef GL_ARB_sample_shading +#define GL_ARB_sample_shading 1 +#define GL_SAMPLE_SHADING_ARB 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); #endif +#endif /* GL_ARB_sample_shading */ -#ifndef GL_EXT_copy_texture -#endif +#ifndef GL_ARB_sampler_objects +#define GL_ARB_sampler_objects 1 +#endif /* GL_ARB_sampler_objects */ -#ifndef GL_EXT_histogram -#define GL_HISTOGRAM_EXT 0x8024 -#define GL_PROXY_HISTOGRAM_EXT 0x8025 -#define GL_HISTOGRAM_WIDTH_EXT 0x8026 -#define GL_HISTOGRAM_FORMAT_EXT 0x8027 -#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C -#define GL_HISTOGRAM_SINK_EXT 0x802D -#define GL_MINMAX_EXT 0x802E -#define GL_MINMAX_FORMAT_EXT 0x802F -#define GL_MINMAX_SINK_EXT 0x8030 -#define GL_TABLE_TOO_LARGE_EXT 0x8031 -#endif +#ifndef GL_ARB_seamless_cube_map +#define GL_ARB_seamless_cube_map 1 +#endif /* GL_ARB_seamless_cube_map */ -#ifndef GL_EXT_convolution -#define GL_CONVOLUTION_1D_EXT 0x8010 -#define GL_CONVOLUTION_2D_EXT 0x8011 -#define GL_SEPARABLE_2D_EXT 0x8012 -#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 -#define GL_REDUCE_EXT 0x8016 -#define GL_CONVOLUTION_FORMAT_EXT 0x8017 -#define GL_CONVOLUTION_WIDTH_EXT 0x8018 -#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 -#endif +#ifndef GL_ARB_seamless_cubemap_per_texture +#define GL_ARB_seamless_cubemap_per_texture 1 +#endif /* GL_ARB_seamless_cubemap_per_texture */ -#ifndef GL_SGI_color_matrix -#define GL_COLOR_MATRIX_SGI 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB -#endif +#ifndef GL_ARB_separate_shader_objects +#define GL_ARB_separate_shader_objects 1 +#endif /* GL_ARB_separate_shader_objects */ -#ifndef GL_SGI_color_table -#define GL_COLOR_TABLE_SGI 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 -#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 -#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 -#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 -#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 -#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF -#endif +#ifndef GL_ARB_shader_atomic_counter_ops +#define GL_ARB_shader_atomic_counter_ops 1 +#endif /* GL_ARB_shader_atomic_counter_ops */ -#ifndef GL_SGIS_pixel_texture -#define GL_PIXEL_TEXTURE_SGIS 0x8353 -#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 -#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 -#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 -#endif - -#ifndef GL_SGIX_pixel_texture -#define GL_PIXEL_TEX_GEN_SGIX 0x8139 -#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B -#endif - -#ifndef GL_SGIS_texture4D -#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 -#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 -#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 -#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 -#define GL_TEXTURE_4D_SGIS 0x8134 -#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 -#define GL_TEXTURE_4DSIZE_SGIS 0x8136 -#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 -#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 -#define GL_TEXTURE_4D_BINDING_SGIS 0x814F -#endif - -#ifndef GL_SGI_texture_color_table -#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC -#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD -#endif - -#ifndef GL_EXT_cmyka -#define GL_CMYK_EXT 0x800C -#define GL_CMYKA_EXT 0x800D -#define GL_PACK_CMYK_HINT_EXT 0x800E -#define GL_UNPACK_CMYK_HINT_EXT 0x800F -#endif - -#ifndef GL_EXT_texture_object -#define GL_TEXTURE_PRIORITY_EXT 0x8066 -#define GL_TEXTURE_RESIDENT_EXT 0x8067 -#define GL_TEXTURE_1D_BINDING_EXT 0x8068 -#define GL_TEXTURE_2D_BINDING_EXT 0x8069 -#define GL_TEXTURE_3D_BINDING_EXT 0x806A -#endif - -#ifndef GL_SGIS_detail_texture -#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 -#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 -#define GL_LINEAR_DETAIL_SGIS 0x8097 -#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 -#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 -#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A -#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B -#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C -#endif - -#ifndef GL_SGIS_sharpen_texture -#define GL_LINEAR_SHARPEN_SGIS 0x80AD -#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE -#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF -#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 -#endif - -#ifndef GL_EXT_packed_pixels -#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 -#endif - -#ifndef GL_SGIS_texture_lod -#define GL_TEXTURE_MIN_LOD_SGIS 0x813A -#define GL_TEXTURE_MAX_LOD_SGIS 0x813B -#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C -#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D -#endif - -#ifndef GL_SGIS_multisample -#define GL_MULTISAMPLE_SGIS 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F -#define GL_SAMPLE_MASK_SGIS 0x80A0 -#define GL_1PASS_SGIS 0x80A1 -#define GL_2PASS_0_SGIS 0x80A2 -#define GL_2PASS_1_SGIS 0x80A3 -#define GL_4PASS_0_SGIS 0x80A4 -#define GL_4PASS_1_SGIS 0x80A5 -#define GL_4PASS_2_SGIS 0x80A6 -#define GL_4PASS_3_SGIS 0x80A7 -#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 -#define GL_SAMPLES_SGIS 0x80A9 -#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA -#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB -#define GL_SAMPLE_PATTERN_SGIS 0x80AC -#endif - -#ifndef GL_EXT_rescale_normal -#define GL_RESCALE_NORMAL_EXT 0x803A -#endif - -#ifndef GL_EXT_vertex_array -#define GL_VERTEX_ARRAY_EXT 0x8074 -#define GL_NORMAL_ARRAY_EXT 0x8075 -#define GL_COLOR_ARRAY_EXT 0x8076 -#define GL_INDEX_ARRAY_EXT 0x8077 -#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 -#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 -#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A -#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B -#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C -#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D -#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E -#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F -#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 -#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 -#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 -#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 -#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 -#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 -#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 -#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 -#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A -#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B -#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C -#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D -#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E -#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F -#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 -#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 -#endif - -#ifndef GL_EXT_misc_attribute -#endif - -#ifndef GL_SGIS_generate_mipmap -#define GL_GENERATE_MIPMAP_SGIS 0x8191 -#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 -#endif - -#ifndef GL_SGIX_clipmap -#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 -#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 -#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 -#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 -#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 -#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 -#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 -#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 -#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 -#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D -#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E -#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F -#endif - -#ifndef GL_SGIX_shadow -#define GL_TEXTURE_COMPARE_SGIX 0x819A -#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B -#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C -#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D -#endif +#ifndef GL_ARB_shader_atomic_counters +#define GL_ARB_shader_atomic_counters 1 +#endif /* GL_ARB_shader_atomic_counters */ -#ifndef GL_SGIS_texture_edge_clamp -#define GL_CLAMP_TO_EDGE_SGIS 0x812F -#endif - -#ifndef GL_SGIS_texture_border_clamp -#define GL_CLAMP_TO_BORDER_SGIS 0x812D -#endif - -#ifndef GL_EXT_blend_minmax -#define GL_FUNC_ADD_EXT 0x8006 -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 -#define GL_BLEND_EQUATION_EXT 0x8009 -#endif - -#ifndef GL_EXT_blend_subtract -#define GL_FUNC_SUBTRACT_EXT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B -#endif - -#ifndef GL_EXT_blend_logic_op -#endif - -#ifndef GL_SGIX_interlace -#define GL_INTERLACE_SGIX 0x8094 -#endif +#ifndef GL_ARB_shader_ballot +#define GL_ARB_shader_ballot 1 +#endif /* GL_ARB_shader_ballot */ -#ifndef GL_SGIX_pixel_tiles -#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E -#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F -#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 -#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 -#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 -#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 -#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 -#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 -#endif +#ifndef GL_ARB_shader_bit_encoding +#define GL_ARB_shader_bit_encoding 1 +#endif /* GL_ARB_shader_bit_encoding */ -#ifndef GL_SGIS_texture_select -#define GL_DUAL_ALPHA4_SGIS 0x8110 -#define GL_DUAL_ALPHA8_SGIS 0x8111 -#define GL_DUAL_ALPHA12_SGIS 0x8112 -#define GL_DUAL_ALPHA16_SGIS 0x8113 -#define GL_DUAL_LUMINANCE4_SGIS 0x8114 -#define GL_DUAL_LUMINANCE8_SGIS 0x8115 -#define GL_DUAL_LUMINANCE12_SGIS 0x8116 -#define GL_DUAL_LUMINANCE16_SGIS 0x8117 -#define GL_DUAL_INTENSITY4_SGIS 0x8118 -#define GL_DUAL_INTENSITY8_SGIS 0x8119 -#define GL_DUAL_INTENSITY12_SGIS 0x811A -#define GL_DUAL_INTENSITY16_SGIS 0x811B -#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C -#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D -#define GL_QUAD_ALPHA4_SGIS 0x811E -#define GL_QUAD_ALPHA8_SGIS 0x811F -#define GL_QUAD_LUMINANCE4_SGIS 0x8120 -#define GL_QUAD_LUMINANCE8_SGIS 0x8121 -#define GL_QUAD_INTENSITY4_SGIS 0x8122 -#define GL_QUAD_INTENSITY8_SGIS 0x8123 -#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 -#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 -#endif +#ifndef GL_ARB_shader_clock +#define GL_ARB_shader_clock 1 +#endif /* GL_ARB_shader_clock */ -#ifndef GL_SGIX_sprite -#define GL_SPRITE_SGIX 0x8148 -#define GL_SPRITE_MODE_SGIX 0x8149 -#define GL_SPRITE_AXIS_SGIX 0x814A -#define GL_SPRITE_TRANSLATION_SGIX 0x814B -#define GL_SPRITE_AXIAL_SGIX 0x814C -#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D -#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E -#endif +#ifndef GL_ARB_shader_draw_parameters +#define GL_ARB_shader_draw_parameters 1 +#endif /* GL_ARB_shader_draw_parameters */ -#ifndef GL_SGIX_texture_multi_buffer -#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E -#endif +#ifndef GL_ARB_shader_group_vote +#define GL_ARB_shader_group_vote 1 +#endif /* GL_ARB_shader_group_vote */ -#ifndef GL_EXT_point_parameters -#define GL_POINT_SIZE_MIN_EXT 0x8126 -#define GL_POINT_SIZE_MAX_EXT 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 -#define GL_DISTANCE_ATTENUATION_EXT 0x8129 -#endif +#ifndef GL_ARB_shader_image_load_store +#define GL_ARB_shader_image_load_store 1 +#endif /* GL_ARB_shader_image_load_store */ -#ifndef GL_SGIS_point_parameters -#define GL_POINT_SIZE_MIN_SGIS 0x8126 -#define GL_POINT_SIZE_MAX_SGIS 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 -#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 -#endif +#ifndef GL_ARB_shader_image_size +#define GL_ARB_shader_image_size 1 +#endif /* GL_ARB_shader_image_size */ -#ifndef GL_SGIX_instruments -#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 -#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +#ifdef __APPLE__ +#ifdef BUILDING_MESA +/* Avoid uint <-> void* warnings */ +typedef unsigned long GLhandleARB; +#else +typedef void *GLhandleARB; #endif - -#ifndef GL_SGIX_texture_scale_bias -#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 -#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A -#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B -#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C -#endif - -#ifndef GL_SGIX_framezoom -#define GL_FRAMEZOOM_SGIX 0x818B -#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C -#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D -#endif - -#ifndef GL_SGIX_tag_sample_buffer -#endif - -#ifndef GL_FfdMaskSGIX -#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 -#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 -#endif - -#ifndef GL_SGIX_polynomial_ffd -#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 -#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 -#define GL_DEFORMATIONS_MASK_SGIX 0x8196 -#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 -#endif - -#ifndef GL_SGIX_reference_plane -#define GL_REFERENCE_PLANE_SGIX 0x817D -#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E -#endif - -#ifndef GL_SGIX_flush_raster -#endif - -#ifndef GL_SGIX_depth_texture -#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 -#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 -#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 -#endif - -#ifndef GL_SGIS_fog_function -#define GL_FOG_FUNC_SGIS 0x812A -#define GL_FOG_FUNC_POINTS_SGIS 0x812B -#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C -#endif - -#ifndef GL_SGIX_fog_offset -#define GL_FOG_OFFSET_SGIX 0x8198 -#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 -#endif - -#ifndef GL_HP_image_transform -#define GL_IMAGE_SCALE_X_HP 0x8155 -#define GL_IMAGE_SCALE_Y_HP 0x8156 -#define GL_IMAGE_TRANSLATE_X_HP 0x8157 -#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 -#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 -#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A -#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B -#define GL_IMAGE_MAG_FILTER_HP 0x815C -#define GL_IMAGE_MIN_FILTER_HP 0x815D -#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E -#define GL_CUBIC_HP 0x815F -#define GL_AVERAGE_HP 0x8160 -#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 -#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 -#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 -#endif - -#ifndef GL_HP_convolution_border_modes -#define GL_IGNORE_BORDER_HP 0x8150 -#define GL_CONSTANT_BORDER_HP 0x8151 -#define GL_REPLICATE_BORDER_HP 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 -#endif - -#ifndef GL_INGR_palette_buffer -#endif - -#ifndef GL_SGIX_texture_add_env -#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE -#endif - -#ifndef GL_EXT_color_subtable -#endif - -#ifndef GL_PGI_vertex_hints -#define GL_VERTEX_DATA_HINT_PGI 0x1A22A -#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B -#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C -#define GL_MAX_VERTEX_HINT_PGI 0x1A22D -#define GL_COLOR3_BIT_PGI 0x00010000 -#define GL_COLOR4_BIT_PGI 0x00020000 -#define GL_EDGEFLAG_BIT_PGI 0x00040000 -#define GL_INDEX_BIT_PGI 0x00080000 -#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 -#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 -#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 -#define GL_MAT_EMISSION_BIT_PGI 0x00800000 -#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 -#define GL_MAT_SHININESS_BIT_PGI 0x02000000 -#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 -#define GL_NORMAL_BIT_PGI 0x08000000 -#define GL_TEXCOORD1_BIT_PGI 0x10000000 -#define GL_TEXCOORD2_BIT_PGI 0x20000000 -#define GL_TEXCOORD3_BIT_PGI 0x40000000 -#define GL_TEXCOORD4_BIT_PGI 0x80000000 -#define GL_VERTEX23_BIT_PGI 0x00000004 -#define GL_VERTEX4_BIT_PGI 0x00000008 -#endif - -#ifndef GL_PGI_misc_hints -#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 -#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD -#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE -#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 -#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 -#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 -#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C -#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D -#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E -#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F -#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 -#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 -#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 -#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 -#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 -#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 -#define GL_CLIP_NEAR_HINT_PGI 0x1A220 -#define GL_CLIP_FAR_HINT_PGI 0x1A221 -#define GL_WIDE_LINE_HINT_PGI 0x1A222 -#define GL_BACK_NORMALS_HINT_PGI 0x1A223 -#endif - -#ifndef GL_EXT_paletted_texture -#define GL_COLOR_INDEX1_EXT 0x80E2 -#define GL_COLOR_INDEX2_EXT 0x80E3 -#define GL_COLOR_INDEX4_EXT 0x80E4 -#define GL_COLOR_INDEX8_EXT 0x80E5 -#define GL_COLOR_INDEX12_EXT 0x80E6 -#define GL_COLOR_INDEX16_EXT 0x80E7 -#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED -#endif - -#ifndef GL_EXT_clip_volume_hint -#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 -#endif - -#ifndef GL_SGIX_list_priority -#define GL_LIST_PRIORITY_SGIX 0x8182 -#endif - -#ifndef GL_SGIX_ir_instrument1 -#define GL_IR_INSTRUMENT1_SGIX 0x817F -#endif - -#ifndef GL_SGIX_calligraphic_fragment -#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 -#endif - -#ifndef GL_SGIX_texture_lod_bias -#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E -#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F -#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 -#endif - -#ifndef GL_SGIX_shadow_ambient -#define GL_SHADOW_AMBIENT_SGIX 0x80BF -#endif - -#ifndef GL_EXT_index_texture -#endif - -#ifndef GL_EXT_index_material -#define GL_INDEX_MATERIAL_EXT 0x81B8 -#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 -#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA -#endif - -#ifndef GL_EXT_index_func -#define GL_INDEX_TEST_EXT 0x81B5 -#define GL_INDEX_TEST_FUNC_EXT 0x81B6 -#define GL_INDEX_TEST_REF_EXT 0x81B7 -#endif - -#ifndef GL_EXT_index_array_formats -#define GL_IUI_V2F_EXT 0x81AD -#define GL_IUI_V3F_EXT 0x81AE -#define GL_IUI_N3F_V2F_EXT 0x81AF -#define GL_IUI_N3F_V3F_EXT 0x81B0 -#define GL_T2F_IUI_V2F_EXT 0x81B1 -#define GL_T2F_IUI_V3F_EXT 0x81B2 -#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 -#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 -#endif - -#ifndef GL_EXT_compiled_vertex_array -#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 -#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 -#endif - -#ifndef GL_EXT_cull_vertex -#define GL_CULL_VERTEX_EXT 0x81AA -#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB -#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC -#endif - -#ifndef GL_SGIX_ycrcb -#define GL_YCRCB_422_SGIX 0x81BB -#define GL_YCRCB_444_SGIX 0x81BC -#endif - -#ifndef GL_SGIX_fragment_lighting -#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 -#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 -#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 -#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 -#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 -#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 -#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 -#define GL_LIGHT_ENV_MODE_SGIX 0x8407 -#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 -#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 -#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A -#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B -#define GL_FRAGMENT_LIGHT0_SGIX 0x840C -#define GL_FRAGMENT_LIGHT1_SGIX 0x840D -#define GL_FRAGMENT_LIGHT2_SGIX 0x840E -#define GL_FRAGMENT_LIGHT3_SGIX 0x840F -#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 -#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 -#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 -#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 -#endif - -#ifndef GL_IBM_rasterpos_clip -#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 -#endif - -#ifndef GL_HP_texture_lighting -#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 -#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 -#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 -#endif - -#ifndef GL_EXT_draw_range_elements -#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 -#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 -#endif - -#ifndef GL_WIN_phong_shading -#define GL_PHONG_WIN 0x80EA -#define GL_PHONG_HINT_WIN 0x80EB -#endif - -#ifndef GL_WIN_specular_fog -#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC -#endif - -#ifndef GL_EXT_light_texture -#define GL_FRAGMENT_MATERIAL_EXT 0x8349 -#define GL_FRAGMENT_NORMAL_EXT 0x834A -#define GL_FRAGMENT_COLOR_EXT 0x834C -#define GL_ATTENUATION_EXT 0x834D -#define GL_SHADOW_ATTENUATION_EXT 0x834E -#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F -#define GL_TEXTURE_LIGHT_EXT 0x8350 -#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 -#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 -/* reuse GL_FRAGMENT_DEPTH_EXT */ -#endif - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_ALPHA_MIN_SGIX 0x8320 -#define GL_ALPHA_MAX_SGIX 0x8321 -#endif - -#ifndef GL_SGIX_impact_pixel_texture -#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 -#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 -#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 -#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 -#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 -#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 -#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A -#endif - -#ifndef GL_EXT_bgra -#define GL_BGR_EXT 0x80E0 -#define GL_BGRA_EXT 0x80E1 -#endif - -#ifndef GL_SGIX_async -#define GL_ASYNC_MARKER_SGIX 0x8329 -#endif - -#ifndef GL_SGIX_async_pixel -#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C -#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D -#define GL_ASYNC_READ_PIXELS_SGIX 0x835E -#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F -#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 -#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 -#endif - -#ifndef GL_SGIX_async_histogram -#define GL_ASYNC_HISTOGRAM_SGIX 0x832C -#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D -#endif - -#ifndef GL_INTEL_texture_scissor -#endif - -#ifndef GL_INTEL_parallel_arrays -#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 -#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 -#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 -#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 -#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 -#endif - -#ifndef GL_HP_occlusion_test -#define GL_OCCLUSION_TEST_HP 0x8165 -#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 -#endif - -#ifndef GL_EXT_pixel_transform -#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 -#define GL_PIXEL_MAG_FILTER_EXT 0x8331 -#define GL_PIXEL_MIN_FILTER_EXT 0x8332 -#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 -#define GL_CUBIC_EXT 0x8334 -#define GL_AVERAGE_EXT 0x8335 -#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 -#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 -#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 -#endif - -#ifndef GL_EXT_pixel_transform_color_table -#endif - -#ifndef GL_EXT_shared_texture_palette -#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB -#endif - -#ifndef GL_EXT_separate_specular_color -#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 -#define GL_SINGLE_COLOR_EXT 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA -#endif - -#ifndef GL_EXT_secondary_color -#define GL_COLOR_SUM_EXT 0x8458 -#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D -#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E -#endif - -#ifndef GL_EXT_texture_perturb_normal -#define GL_PERTURB_EXT 0x85AE -#define GL_TEXTURE_NORMAL_EXT 0x85AF -#endif - -#ifndef GL_EXT_multi_draw_arrays -#endif - -#ifndef GL_EXT_fog_coord -#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 -#define GL_FOG_COORDINATE_EXT 0x8451 -#define GL_FRAGMENT_DEPTH_EXT 0x8452 -#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 -#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 -#endif - -#ifndef GL_REND_screen_coordinates -#define GL_SCREEN_COORDINATES_REND 0x8490 -#define GL_INVERTED_SCREEN_W_REND 0x8491 -#endif - -#ifndef GL_EXT_coordinate_frame -#define GL_TANGENT_ARRAY_EXT 0x8439 -#define GL_BINORMAL_ARRAY_EXT 0x843A -#define GL_CURRENT_TANGENT_EXT 0x843B -#define GL_CURRENT_BINORMAL_EXT 0x843C -#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E -#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F -#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 -#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 -#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 -#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 -#define GL_MAP1_TANGENT_EXT 0x8444 -#define GL_MAP2_TANGENT_EXT 0x8445 -#define GL_MAP1_BINORMAL_EXT 0x8446 -#define GL_MAP2_BINORMAL_EXT 0x8447 -#endif - -#ifndef GL_EXT_texture_env_combine -#define GL_COMBINE_EXT 0x8570 -#define GL_COMBINE_RGB_EXT 0x8571 -#define GL_COMBINE_ALPHA_EXT 0x8572 -#define GL_RGB_SCALE_EXT 0x8573 -#define GL_ADD_SIGNED_EXT 0x8574 -#define GL_INTERPOLATE_EXT 0x8575 -#define GL_CONSTANT_EXT 0x8576 -#define GL_PRIMARY_COLOR_EXT 0x8577 -#define GL_PREVIOUS_EXT 0x8578 -#define GL_SOURCE0_RGB_EXT 0x8580 -#define GL_SOURCE1_RGB_EXT 0x8581 -#define GL_SOURCE2_RGB_EXT 0x8582 -#define GL_SOURCE0_ALPHA_EXT 0x8588 -#define GL_SOURCE1_ALPHA_EXT 0x8589 -#define GL_SOURCE2_ALPHA_EXT 0x858A -#define GL_OPERAND0_RGB_EXT 0x8590 -#define GL_OPERAND1_RGB_EXT 0x8591 -#define GL_OPERAND2_RGB_EXT 0x8592 -#define GL_OPERAND0_ALPHA_EXT 0x8598 -#define GL_OPERAND1_ALPHA_EXT 0x8599 -#define GL_OPERAND2_ALPHA_EXT 0x859A -#endif - -#ifndef GL_APPLE_specular_vector -#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 -#endif - -#ifndef GL_APPLE_transform_hint -#define GL_TRANSFORM_HINT_APPLE 0x85B1 -#endif - -#ifndef GL_SGIX_fog_scale -#define GL_FOG_SCALE_SGIX 0x81FC -#define GL_FOG_SCALE_VALUE_SGIX 0x81FD -#endif - -#ifndef GL_SUNX_constant_data -#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 -#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 -#endif - -#ifndef GL_SUN_global_alpha -#define GL_GLOBAL_ALPHA_SUN 0x81D9 -#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA -#endif - -#ifndef GL_SUN_triangle_list -#define GL_RESTART_SUN 0x0001 -#define GL_REPLACE_MIDDLE_SUN 0x0002 -#define GL_REPLACE_OLDEST_SUN 0x0003 -#define GL_TRIANGLE_LIST_SUN 0x81D7 -#define GL_REPLACEMENT_CODE_SUN 0x81D8 -#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 -#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 -#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 -#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 -#define GL_R1UI_V3F_SUN 0x85C4 -#define GL_R1UI_C4UB_V3F_SUN 0x85C5 -#define GL_R1UI_C3F_V3F_SUN 0x85C6 -#define GL_R1UI_N3F_V3F_SUN 0x85C7 -#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 -#define GL_R1UI_T2F_V3F_SUN 0x85C9 -#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA -#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB -#endif - -#ifndef GL_SUN_vertex -#endif - -#ifndef GL_EXT_blend_func_separate -#define GL_BLEND_DST_RGB_EXT 0x80C8 -#define GL_BLEND_SRC_RGB_EXT 0x80C9 -#define GL_BLEND_DST_ALPHA_EXT 0x80CA -#define GL_BLEND_SRC_ALPHA_EXT 0x80CB -#endif - -#ifndef GL_INGR_color_clamp -#define GL_RED_MIN_CLAMP_INGR 0x8560 -#define GL_GREEN_MIN_CLAMP_INGR 0x8561 -#define GL_BLUE_MIN_CLAMP_INGR 0x8562 -#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 -#define GL_RED_MAX_CLAMP_INGR 0x8564 -#define GL_GREEN_MAX_CLAMP_INGR 0x8565 -#define GL_BLUE_MAX_CLAMP_INGR 0x8566 -#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 -#endif - -#ifndef GL_INGR_interlace_read -#define GL_INTERLACE_READ_INGR 0x8568 -#endif - -#ifndef GL_EXT_stencil_wrap -#define GL_INCR_WRAP_EXT 0x8507 -#define GL_DECR_WRAP_EXT 0x8508 -#endif - -#ifndef GL_EXT_422_pixels -#define GL_422_EXT 0x80CC -#define GL_422_REV_EXT 0x80CD -#define GL_422_AVERAGE_EXT 0x80CE -#define GL_422_REV_AVERAGE_EXT 0x80CF -#endif - -#ifndef GL_NV_texgen_reflection -#define GL_NORMAL_MAP_NV 0x8511 -#define GL_REFLECTION_MAP_NV 0x8512 -#endif - -#ifndef GL_EXT_texture_cube_map -#define GL_NORMAL_MAP_EXT 0x8511 -#define GL_REFLECTION_MAP_EXT 0x8512 -#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C -#endif - -#ifndef GL_SUN_convolution_border_modes -#define GL_WRAP_BORDER_SUN 0x81D4 -#endif - -#ifndef GL_EXT_texture_env_add -#endif - -#ifndef GL_EXT_texture_lod_bias -#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD -#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 -#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 -#endif - -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#endif - -#ifndef GL_EXT_vertex_weighting -#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH -#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 -#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX -#define GL_MODELVIEW1_MATRIX_EXT 0x8506 -#define GL_VERTEX_WEIGHTING_EXT 0x8509 -#define GL_MODELVIEW0_EXT GL_MODELVIEW -#define GL_MODELVIEW1_EXT 0x850A -#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B -#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C -#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D -#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E -#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F -#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 -#endif - -#ifndef GL_NV_light_max_exponent -#define GL_MAX_SHININESS_NV 0x8504 -#define GL_MAX_SPOT_EXPONENT_NV 0x8505 -#endif - -#ifndef GL_NV_vertex_array_range -#define GL_VERTEX_ARRAY_RANGE_NV 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E -#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F -#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 -#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 -#endif - -#ifndef GL_NV_register_combiners -#define GL_REGISTER_COMBINERS_NV 0x8522 -#define GL_VARIABLE_A_NV 0x8523 -#define GL_VARIABLE_B_NV 0x8524 -#define GL_VARIABLE_C_NV 0x8525 -#define GL_VARIABLE_D_NV 0x8526 -#define GL_VARIABLE_E_NV 0x8527 -#define GL_VARIABLE_F_NV 0x8528 -#define GL_VARIABLE_G_NV 0x8529 -#define GL_CONSTANT_COLOR0_NV 0x852A -#define GL_CONSTANT_COLOR1_NV 0x852B -#define GL_PRIMARY_COLOR_NV 0x852C -#define GL_SECONDARY_COLOR_NV 0x852D -#define GL_SPARE0_NV 0x852E -#define GL_SPARE1_NV 0x852F -#define GL_DISCARD_NV 0x8530 -#define GL_E_TIMES_F_NV 0x8531 -#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 -#define GL_UNSIGNED_IDENTITY_NV 0x8536 -#define GL_UNSIGNED_INVERT_NV 0x8537 -#define GL_EXPAND_NORMAL_NV 0x8538 -#define GL_EXPAND_NEGATE_NV 0x8539 -#define GL_HALF_BIAS_NORMAL_NV 0x853A -#define GL_HALF_BIAS_NEGATE_NV 0x853B -#define GL_SIGNED_IDENTITY_NV 0x853C -#define GL_SIGNED_NEGATE_NV 0x853D -#define GL_SCALE_BY_TWO_NV 0x853E -#define GL_SCALE_BY_FOUR_NV 0x853F -#define GL_SCALE_BY_ONE_HALF_NV 0x8540 -#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 -#define GL_COMBINER_INPUT_NV 0x8542 -#define GL_COMBINER_MAPPING_NV 0x8543 -#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 -#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 -#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 -#define GL_COMBINER_MUX_SUM_NV 0x8547 -#define GL_COMBINER_SCALE_NV 0x8548 -#define GL_COMBINER_BIAS_NV 0x8549 -#define GL_COMBINER_AB_OUTPUT_NV 0x854A -#define GL_COMBINER_CD_OUTPUT_NV 0x854B -#define GL_COMBINER_SUM_OUTPUT_NV 0x854C -#define GL_MAX_GENERAL_COMBINERS_NV 0x854D -#define GL_NUM_GENERAL_COMBINERS_NV 0x854E -#define GL_COLOR_SUM_CLAMP_NV 0x854F -#define GL_COMBINER0_NV 0x8550 -#define GL_COMBINER1_NV 0x8551 -#define GL_COMBINER2_NV 0x8552 -#define GL_COMBINER3_NV 0x8553 -#define GL_COMBINER4_NV 0x8554 -#define GL_COMBINER5_NV 0x8555 -#define GL_COMBINER6_NV 0x8556 -#define GL_COMBINER7_NV 0x8557 -/* reuse GL_TEXTURE0_ARB */ -/* reuse GL_TEXTURE1_ARB */ -/* reuse GL_ZERO */ -/* reuse GL_NONE */ -/* reuse GL_FOG */ -#endif - -#ifndef GL_NV_fog_distance -#define GL_FOG_DISTANCE_MODE_NV 0x855A -#define GL_EYE_RADIAL_NV 0x855B -#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C -/* reuse GL_EYE_PLANE */ -#endif - -#ifndef GL_NV_texgen_emboss -#define GL_EMBOSS_LIGHT_NV 0x855D -#define GL_EMBOSS_CONSTANT_NV 0x855E -#define GL_EMBOSS_MAP_NV 0x855F -#endif - -#ifndef GL_NV_blend_square -#endif - -#ifndef GL_NV_texture_env_combine4 -#define GL_COMBINE4_NV 0x8503 -#define GL_SOURCE3_RGB_NV 0x8583 -#define GL_SOURCE3_ALPHA_NV 0x858B -#define GL_OPERAND3_RGB_NV 0x8593 -#define GL_OPERAND3_ALPHA_NV 0x859B -#endif - -#ifndef GL_MESA_resize_buffers -#endif - -#ifndef GL_MESA_window_pos -#endif - -#ifndef GL_EXT_texture_compression_s3tc -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 -#endif - -#ifndef GL_IBM_cull_vertex -#define GL_CULL_VERTEX_IBM 103050 -#endif - -#ifndef GL_IBM_multimode_draw_arrays -#endif - -#ifndef GL_IBM_vertex_array_lists -#define GL_VERTEX_ARRAY_LIST_IBM 103070 -#define GL_NORMAL_ARRAY_LIST_IBM 103071 -#define GL_COLOR_ARRAY_LIST_IBM 103072 -#define GL_INDEX_ARRAY_LIST_IBM 103073 -#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 -#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 -#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 -#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 -#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 -#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 -#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 -#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 -#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 -#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 -#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 -#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 -#endif - -#ifndef GL_SGIX_subsample -#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 -#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 -#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 -#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 -#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 -#endif - -#ifndef GL_SGIX_ycrcb_subsample -#endif - -#ifndef GL_SGIX_ycrcba -#define GL_YCRCB_SGIX 0x8318 -#define GL_YCRCBA_SGIX 0x8319 -#endif - -#ifndef GL_SGI_depth_pass_instrument -#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 -#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 -#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 -#endif - -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 -#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 -#endif - -#ifndef GL_3DFX_multisample -#define GL_MULTISAMPLE_3DFX 0x86B2 -#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 -#define GL_SAMPLES_3DFX 0x86B4 -#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 -#endif - -#ifndef GL_3DFX_tbuffer -#endif - -#ifndef GL_EXT_multisample -#define GL_MULTISAMPLE_EXT 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F -#define GL_SAMPLE_MASK_EXT 0x80A0 -#define GL_1PASS_EXT 0x80A1 -#define GL_2PASS_0_EXT 0x80A2 -#define GL_2PASS_1_EXT 0x80A3 -#define GL_4PASS_0_EXT 0x80A4 -#define GL_4PASS_1_EXT 0x80A5 -#define GL_4PASS_2_EXT 0x80A6 -#define GL_4PASS_3_EXT 0x80A7 -#define GL_SAMPLE_BUFFERS_EXT 0x80A8 -#define GL_SAMPLES_EXT 0x80A9 -#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA -#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB -#define GL_SAMPLE_PATTERN_EXT 0x80AC -#define GL_MULTISAMPLE_BIT_EXT 0x20000000 -#endif - -#ifndef GL_SGIX_vertex_preclip -#define GL_VERTEX_PRECLIP_SGIX 0x83EE -#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF -#endif - -#ifndef GL_SGIX_convolution_accuracy -#define GL_CONVOLUTION_HINT_SGIX 0x8316 -#endif - -#ifndef GL_SGIX_resample -#define GL_PACK_RESAMPLE_SGIX 0x842C -#define GL_UNPACK_RESAMPLE_SGIX 0x842D -#define GL_RESAMPLE_REPLICATE_SGIX 0x842E -#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F -#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 -#endif - -#ifndef GL_SGIS_point_line_texgen -#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 -#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 -#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 -#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 -#define GL_EYE_POINT_SGIS 0x81F4 -#define GL_OBJECT_POINT_SGIS 0x81F5 -#define GL_EYE_LINE_SGIS 0x81F6 -#define GL_OBJECT_LINE_SGIS 0x81F7 -#endif - -#ifndef GL_SGIS_texture_color_mask -#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF -#endif - -#ifndef GL_EXT_texture_env_dot3 -#define GL_DOT3_RGB_EXT 0x8740 -#define GL_DOT3_RGBA_EXT 0x8741 -#endif - -#ifndef GL_ATI_texture_mirror_once -#define GL_MIRROR_CLAMP_ATI 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 -#endif - -#ifndef GL_NV_fence -#define GL_ALL_COMPLETED_NV 0x84F2 -#define GL_FENCE_STATUS_NV 0x84F3 -#define GL_FENCE_CONDITION_NV 0x84F4 -#endif - -#ifndef GL_IBM_texture_mirrored_repeat -#define GL_MIRRORED_REPEAT_IBM 0x8370 -#endif - -#ifndef GL_NV_evaluators -#define GL_EVAL_2D_NV 0x86C0 -#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 -#define GL_MAP_TESSELLATION_NV 0x86C2 -#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 -#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 -#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 -#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 -#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 -#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 -#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 -#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA -#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB -#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC -#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD -#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE -#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF -#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 -#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 -#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 -#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 -#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 -#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 -#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 -#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 -#endif - -#ifndef GL_NV_packed_depth_stencil -#define GL_DEPTH_STENCIL_NV 0x84F9 -#define GL_UNSIGNED_INT_24_8_NV 0x84FA -#endif - -#ifndef GL_NV_register_combiners2 -#define GL_PER_STAGE_CONSTANTS_NV 0x8535 -#endif - -#ifndef GL_NV_texture_compression_vtc -#endif - -#ifndef GL_NV_texture_rectangle -#define GL_TEXTURE_RECTANGLE_NV 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 -#endif - -#ifndef GL_NV_texture_shader -#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C -#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D -#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E -#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 -#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA -#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB -#define GL_DSDT_MAG_INTENSITY_NV 0x86DC -#define GL_SHADER_CONSISTENT_NV 0x86DD -#define GL_TEXTURE_SHADER_NV 0x86DE -#define GL_SHADER_OPERATION_NV 0x86DF -#define GL_CULL_MODES_NV 0x86E0 -#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 -#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV -#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV -#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV -#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 -#define GL_CONST_EYE_NV 0x86E5 -#define GL_PASS_THROUGH_NV 0x86E6 -#define GL_CULL_FRAGMENT_NV 0x86E7 -#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 -#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 -#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA -#define GL_DOT_PRODUCT_NV 0x86EC -#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED -#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE -#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 -#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 -#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 -#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 -#define GL_HILO_NV 0x86F4 -#define GL_DSDT_NV 0x86F5 -#define GL_DSDT_MAG_NV 0x86F6 -#define GL_DSDT_MAG_VIB_NV 0x86F7 -#define GL_HILO16_NV 0x86F8 -#define GL_SIGNED_HILO_NV 0x86F9 -#define GL_SIGNED_HILO16_NV 0x86FA -#define GL_SIGNED_RGBA_NV 0x86FB -#define GL_SIGNED_RGBA8_NV 0x86FC -#define GL_SIGNED_RGB_NV 0x86FE -#define GL_SIGNED_RGB8_NV 0x86FF -#define GL_SIGNED_LUMINANCE_NV 0x8701 -#define GL_SIGNED_LUMINANCE8_NV 0x8702 -#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 -#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 -#define GL_SIGNED_ALPHA_NV 0x8705 -#define GL_SIGNED_ALPHA8_NV 0x8706 -#define GL_SIGNED_INTENSITY_NV 0x8707 -#define GL_SIGNED_INTENSITY8_NV 0x8708 -#define GL_DSDT8_NV 0x8709 -#define GL_DSDT8_MAG8_NV 0x870A -#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B -#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C -#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D -#define GL_HI_SCALE_NV 0x870E -#define GL_LO_SCALE_NV 0x870F -#define GL_DS_SCALE_NV 0x8710 -#define GL_DT_SCALE_NV 0x8711 -#define GL_MAGNITUDE_SCALE_NV 0x8712 -#define GL_VIBRANCE_SCALE_NV 0x8713 -#define GL_HI_BIAS_NV 0x8714 -#define GL_LO_BIAS_NV 0x8715 -#define GL_DS_BIAS_NV 0x8716 -#define GL_DT_BIAS_NV 0x8717 -#define GL_MAGNITUDE_BIAS_NV 0x8718 -#define GL_VIBRANCE_BIAS_NV 0x8719 -#define GL_TEXTURE_BORDER_VALUES_NV 0x871A -#define GL_TEXTURE_HI_SIZE_NV 0x871B -#define GL_TEXTURE_LO_SIZE_NV 0x871C -#define GL_TEXTURE_DS_SIZE_NV 0x871D -#define GL_TEXTURE_DT_SIZE_NV 0x871E -#define GL_TEXTURE_MAG_SIZE_NV 0x871F -#endif - -#ifndef GL_NV_texture_shader2 -#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF -#endif - -#ifndef GL_NV_vertex_array_range2 -#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 -#endif - -#ifndef GL_NV_vertex_program -#define GL_VERTEX_PROGRAM_NV 0x8620 -#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 -#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 -#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 -#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 -#define GL_CURRENT_ATTRIB_NV 0x8626 -#define GL_PROGRAM_LENGTH_NV 0x8627 -#define GL_PROGRAM_STRING_NV 0x8628 -#define GL_MODELVIEW_PROJECTION_NV 0x8629 -#define GL_IDENTITY_NV 0x862A -#define GL_INVERSE_NV 0x862B -#define GL_TRANSPOSE_NV 0x862C -#define GL_INVERSE_TRANSPOSE_NV 0x862D -#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E -#define GL_MAX_TRACK_MATRICES_NV 0x862F -#define GL_MATRIX0_NV 0x8630 -#define GL_MATRIX1_NV 0x8631 -#define GL_MATRIX2_NV 0x8632 -#define GL_MATRIX3_NV 0x8633 -#define GL_MATRIX4_NV 0x8634 -#define GL_MATRIX5_NV 0x8635 -#define GL_MATRIX6_NV 0x8636 -#define GL_MATRIX7_NV 0x8637 -#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 -#define GL_CURRENT_MATRIX_NV 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 -#define GL_PROGRAM_PARAMETER_NV 0x8644 -#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 -#define GL_PROGRAM_TARGET_NV 0x8646 -#define GL_PROGRAM_RESIDENT_NV 0x8647 -#define GL_TRACK_MATRIX_NV 0x8648 -#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 -#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A -#define GL_PROGRAM_ERROR_POSITION_NV 0x864B -#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 -#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 -#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 -#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 -#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 -#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 -#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 -#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 -#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 -#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 -#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A -#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B -#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C -#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D -#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E -#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F -#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 -#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 -#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 -#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 -#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 -#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 -#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 -#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 -#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 -#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 -#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A -#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B -#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C -#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D -#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E -#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F -#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 -#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 -#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 -#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 -#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 -#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 -#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 -#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 -#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 -#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 -#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A -#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B -#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C -#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D -#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E -#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F -#endif - -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 -#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A -#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B -#endif - -#ifndef GL_SGIX_scalebias_hint -#define GL_SCALEBIAS_HINT_SGIX 0x8322 -#endif - -#ifndef GL_OML_interlace -#define GL_INTERLACE_OML 0x8980 -#define GL_INTERLACE_READ_OML 0x8981 -#endif - -#ifndef GL_OML_subsample -#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 -#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 -#endif - -#ifndef GL_OML_resample -#define GL_PACK_RESAMPLE_OML 0x8984 -#define GL_UNPACK_RESAMPLE_OML 0x8985 -#define GL_RESAMPLE_REPLICATE_OML 0x8986 -#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 -#define GL_RESAMPLE_AVERAGE_OML 0x8988 -#define GL_RESAMPLE_DECIMATE_OML 0x8989 -#endif - -#ifndef GL_NV_copy_depth_to_color -#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E -#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F -#endif - -#ifndef GL_ATI_envmap_bumpmap -#define GL_BUMP_ROT_MATRIX_ATI 0x8775 -#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 -#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 -#define GL_BUMP_TEX_UNITS_ATI 0x8778 -#define GL_DUDV_ATI 0x8779 -#define GL_DU8DV8_ATI 0x877A -#define GL_BUMP_ENVMAP_ATI 0x877B -#define GL_BUMP_TARGET_ATI 0x877C -#endif - -#ifndef GL_ATI_fragment_shader -#define GL_FRAGMENT_SHADER_ATI 0x8920 -#define GL_REG_0_ATI 0x8921 -#define GL_REG_1_ATI 0x8922 -#define GL_REG_2_ATI 0x8923 -#define GL_REG_3_ATI 0x8924 -#define GL_REG_4_ATI 0x8925 -#define GL_REG_5_ATI 0x8926 -#define GL_REG_6_ATI 0x8927 -#define GL_REG_7_ATI 0x8928 -#define GL_REG_8_ATI 0x8929 -#define GL_REG_9_ATI 0x892A -#define GL_REG_10_ATI 0x892B -#define GL_REG_11_ATI 0x892C -#define GL_REG_12_ATI 0x892D -#define GL_REG_13_ATI 0x892E -#define GL_REG_14_ATI 0x892F -#define GL_REG_15_ATI 0x8930 -#define GL_REG_16_ATI 0x8931 -#define GL_REG_17_ATI 0x8932 -#define GL_REG_18_ATI 0x8933 -#define GL_REG_19_ATI 0x8934 -#define GL_REG_20_ATI 0x8935 -#define GL_REG_21_ATI 0x8936 -#define GL_REG_22_ATI 0x8937 -#define GL_REG_23_ATI 0x8938 -#define GL_REG_24_ATI 0x8939 -#define GL_REG_25_ATI 0x893A -#define GL_REG_26_ATI 0x893B -#define GL_REG_27_ATI 0x893C -#define GL_REG_28_ATI 0x893D -#define GL_REG_29_ATI 0x893E -#define GL_REG_30_ATI 0x893F -#define GL_REG_31_ATI 0x8940 -#define GL_CON_0_ATI 0x8941 -#define GL_CON_1_ATI 0x8942 -#define GL_CON_2_ATI 0x8943 -#define GL_CON_3_ATI 0x8944 -#define GL_CON_4_ATI 0x8945 -#define GL_CON_5_ATI 0x8946 -#define GL_CON_6_ATI 0x8947 -#define GL_CON_7_ATI 0x8948 -#define GL_CON_8_ATI 0x8949 -#define GL_CON_9_ATI 0x894A -#define GL_CON_10_ATI 0x894B -#define GL_CON_11_ATI 0x894C -#define GL_CON_12_ATI 0x894D -#define GL_CON_13_ATI 0x894E -#define GL_CON_14_ATI 0x894F -#define GL_CON_15_ATI 0x8950 -#define GL_CON_16_ATI 0x8951 -#define GL_CON_17_ATI 0x8952 -#define GL_CON_18_ATI 0x8953 -#define GL_CON_19_ATI 0x8954 -#define GL_CON_20_ATI 0x8955 -#define GL_CON_21_ATI 0x8956 -#define GL_CON_22_ATI 0x8957 -#define GL_CON_23_ATI 0x8958 -#define GL_CON_24_ATI 0x8959 -#define GL_CON_25_ATI 0x895A -#define GL_CON_26_ATI 0x895B -#define GL_CON_27_ATI 0x895C -#define GL_CON_28_ATI 0x895D -#define GL_CON_29_ATI 0x895E -#define GL_CON_30_ATI 0x895F -#define GL_CON_31_ATI 0x8960 -#define GL_MOV_ATI 0x8961 -#define GL_ADD_ATI 0x8963 -#define GL_MUL_ATI 0x8964 -#define GL_SUB_ATI 0x8965 -#define GL_DOT3_ATI 0x8966 -#define GL_DOT4_ATI 0x8967 -#define GL_MAD_ATI 0x8968 -#define GL_LERP_ATI 0x8969 -#define GL_CND_ATI 0x896A -#define GL_CND0_ATI 0x896B -#define GL_DOT2_ADD_ATI 0x896C -#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D -#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E -#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F -#define GL_NUM_PASSES_ATI 0x8970 -#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 -#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 -#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 -#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 -#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 -#define GL_SWIZZLE_STR_ATI 0x8976 -#define GL_SWIZZLE_STQ_ATI 0x8977 -#define GL_SWIZZLE_STR_DR_ATI 0x8978 -#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 -#define GL_SWIZZLE_STRQ_ATI 0x897A -#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B -#define GL_RED_BIT_ATI 0x00000001 -#define GL_GREEN_BIT_ATI 0x00000002 -#define GL_BLUE_BIT_ATI 0x00000004 -#define GL_2X_BIT_ATI 0x00000001 -#define GL_4X_BIT_ATI 0x00000002 -#define GL_8X_BIT_ATI 0x00000004 -#define GL_HALF_BIT_ATI 0x00000008 -#define GL_QUARTER_BIT_ATI 0x00000010 -#define GL_EIGHTH_BIT_ATI 0x00000020 -#define GL_SATURATE_BIT_ATI 0x00000040 -#define GL_COMP_BIT_ATI 0x00000002 -#define GL_NEGATE_BIT_ATI 0x00000004 -#define GL_BIAS_BIT_ATI 0x00000008 -#endif - -#ifndef GL_ATI_pn_triangles -#define GL_PN_TRIANGLES_ATI 0x87F0 -#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 -#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 -#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 -#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 -#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 -#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 -#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 -#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 -#endif - -#ifndef GL_ATI_vertex_array_object -#define GL_STATIC_ATI 0x8760 -#define GL_DYNAMIC_ATI 0x8761 -#define GL_PRESERVE_ATI 0x8762 -#define GL_DISCARD_ATI 0x8763 -#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 -#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 -#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 -#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 -#endif - -#ifndef GL_EXT_vertex_shader -#define GL_VERTEX_SHADER_EXT 0x8780 -#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 -#define GL_OP_INDEX_EXT 0x8782 -#define GL_OP_NEGATE_EXT 0x8783 -#define GL_OP_DOT3_EXT 0x8784 -#define GL_OP_DOT4_EXT 0x8785 -#define GL_OP_MUL_EXT 0x8786 -#define GL_OP_ADD_EXT 0x8787 -#define GL_OP_MADD_EXT 0x8788 -#define GL_OP_FRAC_EXT 0x8789 -#define GL_OP_MAX_EXT 0x878A -#define GL_OP_MIN_EXT 0x878B -#define GL_OP_SET_GE_EXT 0x878C -#define GL_OP_SET_LT_EXT 0x878D -#define GL_OP_CLAMP_EXT 0x878E -#define GL_OP_FLOOR_EXT 0x878F -#define GL_OP_ROUND_EXT 0x8790 -#define GL_OP_EXP_BASE_2_EXT 0x8791 -#define GL_OP_LOG_BASE_2_EXT 0x8792 -#define GL_OP_POWER_EXT 0x8793 -#define GL_OP_RECIP_EXT 0x8794 -#define GL_OP_RECIP_SQRT_EXT 0x8795 -#define GL_OP_SUB_EXT 0x8796 -#define GL_OP_CROSS_PRODUCT_EXT 0x8797 -#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 -#define GL_OP_MOV_EXT 0x8799 -#define GL_OUTPUT_VERTEX_EXT 0x879A -#define GL_OUTPUT_COLOR0_EXT 0x879B -#define GL_OUTPUT_COLOR1_EXT 0x879C -#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D -#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E -#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F -#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 -#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 -#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 -#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 -#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 -#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 -#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 -#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 -#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 -#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 -#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA -#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB -#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC -#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD -#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE -#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF -#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 -#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 -#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 -#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 -#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 -#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 -#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 -#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 -#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 -#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 -#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA -#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB -#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC -#define GL_OUTPUT_FOG_EXT 0x87BD -#define GL_SCALAR_EXT 0x87BE -#define GL_VECTOR_EXT 0x87BF -#define GL_MATRIX_EXT 0x87C0 -#define GL_VARIANT_EXT 0x87C1 -#define GL_INVARIANT_EXT 0x87C2 -#define GL_LOCAL_CONSTANT_EXT 0x87C3 -#define GL_LOCAL_EXT 0x87C4 -#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 -#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 -#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 -#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 -#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE -#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF -#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 -#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 -#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 -#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 -#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 -#define GL_X_EXT 0x87D5 -#define GL_Y_EXT 0x87D6 -#define GL_Z_EXT 0x87D7 -#define GL_W_EXT 0x87D8 -#define GL_NEGATIVE_X_EXT 0x87D9 -#define GL_NEGATIVE_Y_EXT 0x87DA -#define GL_NEGATIVE_Z_EXT 0x87DB -#define GL_NEGATIVE_W_EXT 0x87DC -#define GL_ZERO_EXT 0x87DD -#define GL_ONE_EXT 0x87DE -#define GL_NEGATIVE_ONE_EXT 0x87DF -#define GL_NORMALIZED_RANGE_EXT 0x87E0 -#define GL_FULL_RANGE_EXT 0x87E1 -#define GL_CURRENT_VERTEX_EXT 0x87E2 -#define GL_MVP_MATRIX_EXT 0x87E3 -#define GL_VARIANT_VALUE_EXT 0x87E4 -#define GL_VARIANT_DATATYPE_EXT 0x87E5 -#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 -#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 -#define GL_VARIANT_ARRAY_EXT 0x87E8 -#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 -#define GL_INVARIANT_VALUE_EXT 0x87EA -#define GL_INVARIANT_DATATYPE_EXT 0x87EB -#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC -#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED -#endif - -#ifndef GL_ATI_vertex_streams -#define GL_MAX_VERTEX_STREAMS_ATI 0x876B -#define GL_VERTEX_STREAM0_ATI 0x876C -#define GL_VERTEX_STREAM1_ATI 0x876D -#define GL_VERTEX_STREAM2_ATI 0x876E -#define GL_VERTEX_STREAM3_ATI 0x876F -#define GL_VERTEX_STREAM4_ATI 0x8770 -#define GL_VERTEX_STREAM5_ATI 0x8771 -#define GL_VERTEX_STREAM6_ATI 0x8772 -#define GL_VERTEX_STREAM7_ATI 0x8773 -#define GL_VERTEX_SOURCE_ATI 0x8774 -#endif - -#ifndef GL_ATI_element_array -#define GL_ELEMENT_ARRAY_ATI 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A -#endif - -#ifndef GL_SUN_mesh_array -#define GL_QUAD_MESH_SUN 0x8614 -#define GL_TRIANGLE_MESH_SUN 0x8615 -#endif - -#ifndef GL_SUN_slice_accum -#define GL_SLICE_ACCUM_SUN 0x85CC -#endif - -#ifndef GL_NV_multisample_filter_hint -#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 -#endif - -#ifndef GL_NV_depth_clamp -#define GL_DEPTH_CLAMP_NV 0x864F -#endif - -#ifndef GL_NV_occlusion_query -#define GL_PIXEL_COUNTER_BITS_NV 0x8864 -#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 -#define GL_PIXEL_COUNT_NV 0x8866 -#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 -#endif - -#ifndef GL_NV_point_sprite -#define GL_POINT_SPRITE_NV 0x8861 -#define GL_COORD_REPLACE_NV 0x8862 -#define GL_POINT_SPRITE_R_MODE_NV 0x8863 -#endif - -#ifndef GL_NV_texture_shader3 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 -#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 -#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 -#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 -#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 -#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A -#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B -#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C -#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D -#define GL_HILO8_NV 0x885E -#define GL_SIGNED_HILO8_NV 0x885F -#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 -#endif - -#ifndef GL_NV_vertex_program1_1 -#endif - -#ifndef GL_EXT_shadow_funcs -#endif - -#ifndef GL_EXT_stencil_two_side -#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 -#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 -#endif - -#ifndef GL_ATI_text_fragment_shader -#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 -#endif - -#ifndef GL_APPLE_client_storage -#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 -#endif - -#ifndef GL_APPLE_element_array -#define GL_ELEMENT_ARRAY_APPLE 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A -#endif - -#ifndef GL_APPLE_fence -#define GL_DRAW_PIXELS_APPLE 0x8A0A -#define GL_FENCE_APPLE 0x8A0B -#endif - -#ifndef GL_APPLE_vertex_array_object -#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 -#endif - -#ifndef GL_APPLE_vertex_array_range -#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E -#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F -#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 -#define GL_STORAGE_CACHED_APPLE 0x85BE -#define GL_STORAGE_SHARED_APPLE 0x85BF -#endif - -#ifndef GL_APPLE_ycbcr_422 -#define GL_YCBCR_422_APPLE 0x85B9 -#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB -#endif - -#ifndef GL_S3_s3tc -#define GL_RGB_S3TC 0x83A0 -#define GL_RGB4_S3TC 0x83A1 -#define GL_RGBA_S3TC 0x83A2 -#define GL_RGBA4_S3TC 0x83A3 -#endif - -#ifndef GL_ATI_draw_buffers -#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 -#define GL_DRAW_BUFFER0_ATI 0x8825 -#define GL_DRAW_BUFFER1_ATI 0x8826 -#define GL_DRAW_BUFFER2_ATI 0x8827 -#define GL_DRAW_BUFFER3_ATI 0x8828 -#define GL_DRAW_BUFFER4_ATI 0x8829 -#define GL_DRAW_BUFFER5_ATI 0x882A -#define GL_DRAW_BUFFER6_ATI 0x882B -#define GL_DRAW_BUFFER7_ATI 0x882C -#define GL_DRAW_BUFFER8_ATI 0x882D -#define GL_DRAW_BUFFER9_ATI 0x882E -#define GL_DRAW_BUFFER10_ATI 0x882F -#define GL_DRAW_BUFFER11_ATI 0x8830 -#define GL_DRAW_BUFFER12_ATI 0x8831 -#define GL_DRAW_BUFFER13_ATI 0x8832 -#define GL_DRAW_BUFFER14_ATI 0x8833 -#define GL_DRAW_BUFFER15_ATI 0x8834 -#endif - -#ifndef GL_ATI_pixel_format_float -#define GL_TYPE_RGBA_FLOAT_ATI 0x8820 -#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 -#endif - -#ifndef GL_ATI_texture_env_combine3 -#define GL_MODULATE_ADD_ATI 0x8744 -#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 -#define GL_MODULATE_SUBTRACT_ATI 0x8746 -#endif - -#ifndef GL_ATI_texture_float -#define GL_RGBA_FLOAT32_ATI 0x8814 -#define GL_RGB_FLOAT32_ATI 0x8815 -#define GL_ALPHA_FLOAT32_ATI 0x8816 -#define GL_INTENSITY_FLOAT32_ATI 0x8817 -#define GL_LUMINANCE_FLOAT32_ATI 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 -#define GL_RGBA_FLOAT16_ATI 0x881A -#define GL_RGB_FLOAT16_ATI 0x881B -#define GL_ALPHA_FLOAT16_ATI 0x881C -#define GL_INTENSITY_FLOAT16_ATI 0x881D -#define GL_LUMINANCE_FLOAT16_ATI 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F -#endif - -#ifndef GL_NV_float_buffer -#define GL_FLOAT_R_NV 0x8880 -#define GL_FLOAT_RG_NV 0x8881 -#define GL_FLOAT_RGB_NV 0x8882 -#define GL_FLOAT_RGBA_NV 0x8883 -#define GL_FLOAT_R16_NV 0x8884 -#define GL_FLOAT_R32_NV 0x8885 -#define GL_FLOAT_RG16_NV 0x8886 -#define GL_FLOAT_RG32_NV 0x8887 -#define GL_FLOAT_RGB16_NV 0x8888 -#define GL_FLOAT_RGB32_NV 0x8889 -#define GL_FLOAT_RGBA16_NV 0x888A -#define GL_FLOAT_RGBA32_NV 0x888B -#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C -#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D -#define GL_FLOAT_RGBA_MODE_NV 0x888E -#endif - -#ifndef GL_NV_fragment_program -#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 -#define GL_FRAGMENT_PROGRAM_NV 0x8870 -#define GL_MAX_TEXTURE_COORDS_NV 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 -#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 -#define GL_PROGRAM_ERROR_STRING_NV 0x8874 -#endif - -#ifndef GL_NV_half_float -#define GL_HALF_FLOAT_NV 0x140B -#endif - -#ifndef GL_NV_pixel_data_range -#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 -#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 -#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A -#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B -#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C -#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D -#endif - -#ifndef GL_NV_primitive_restart -#define GL_PRIMITIVE_RESTART_NV 0x8558 -#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 -#endif - -#ifndef GL_NV_texture_expand_normal -#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F -#endif - -#ifndef GL_NV_vertex_program2 -#endif - -#ifndef GL_ATI_map_object_buffer -#endif - -#ifndef GL_ATI_separate_stencil -#define GL_STENCIL_BACK_FUNC_ATI 0x8800 -#define GL_STENCIL_BACK_FAIL_ATI 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 -#endif - -#ifndef GL_ATI_vertex_attrib_array_object -#endif - -#ifndef GL_OES_read_format -#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B -#endif - -#ifndef GL_EXT_depth_bounds_test -#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 -#define GL_DEPTH_BOUNDS_EXT 0x8891 -#endif - -#ifndef GL_EXT_texture_mirror_clamp -#define GL_MIRROR_CLAMP_EXT 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 -#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 -#endif - -#ifndef GL_EXT_blend_equation_separate -#define GL_BLEND_EQUATION_RGB_EXT GL_BLEND_EQUATION -#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D -#endif - -#ifndef GL_MESA_pack_invert -#define GL_PACK_INVERT_MESA 0x8758 -#endif - -#ifndef GL_MESA_ycbcr_texture -#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB -#define GL_YCBCR_MESA 0x8757 -#endif - -#ifndef GL_EXT_pixel_buffer_object -#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF -#endif - -#ifndef GL_NV_fragment_program_option -#endif - -#ifndef GL_NV_fragment_program2 -#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 -#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 -#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 -#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 -#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 -#endif - -#ifndef GL_NV_vertex_program2_option -/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ -/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */ -#endif - -#ifndef GL_NV_vertex_program3 -/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ -#endif - -#ifndef GL_EXT_framebuffer_object -#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 -#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 -#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENTS_EXT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT 0x8CD8 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 -#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD -#define GL_FRAMEBUFFER_STATUS_ERROR_EXT 0x8CDE -#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF -#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 -#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 -#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 -#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 -#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 -#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 -#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 -#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 -#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 -#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 -#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA -#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB -#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC -#define GL_COLOR_ATTACHMENT13_EXT 0x8CED -#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE -#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF -#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 -#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 -#define GL_FRAMEBUFFER_EXT 0x8D40 -#define GL_RENDERBUFFER_EXT 0x8D41 -#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 -#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 -#define GL_STENCIL_INDEX_EXT 0x8D45 -#define GL_STENCIL_INDEX1_EXT 0x8D46 -#define GL_STENCIL_INDEX4_EXT 0x8D47 -#define GL_STENCIL_INDEX8_EXT 0x8D48 -#define GL_STENCIL_INDEX16_EXT 0x8D49 -#endif - -#ifndef GL_GREMEDY_string_marker -#endif - - -/*************************************************************/ - -#include -#ifndef GL_VERSION_2_0 -/* GL type for program/shader text */ -typedef char GLchar; /* native character */ -#endif - -#ifndef GL_VERSION_1_5 -/* GL types for handling large vertex buffer objects */ -typedef ptrdiff_t GLintptr; -typedef ptrdiff_t GLsizeiptr; -#endif - -#ifndef GL_ARB_vertex_buffer_object -/* GL types for handling large vertex buffer objects */ -typedef ptrdiff_t GLintptrARB; -typedef ptrdiff_t GLsizeiptrARB; -#endif - -#ifndef GL_ARB_shader_objects -/* GL types for handling shader object handles and program/shader text */ -typedef char GLcharARB; /* native character */ -typedef unsigned int GLhandleARB; /* shader object handle */ -#endif - -/* GL types for "half" precision (s10e5) float data in host memory */ -#ifndef GL_ARB_half_float_pixel -typedef unsigned short GLhalfARB; -#endif - -#ifndef GL_NV_half_float -typedef unsigned short GLhalfNV; -#endif - -#ifndef GL_VERSION_1_2 -#define GL_VERSION_1_2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf); -GLAPI void APIENTRY glBlendEquation (GLenum); -GLAPI void APIENTRY glDrawRangeElements (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); -GLAPI void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glColorTableParameterfv (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glColorTableParameteriv (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyColorTable (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glGetColorTable (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetColorTableParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetColorTableParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glColorSubTable (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyColorSubTable (GLenum, GLsizei, GLint, GLint, GLsizei); -GLAPI void APIENTRY glConvolutionFilter1D (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionParameterf (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glConvolutionParameterfv (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glConvolutionParameteri (GLenum, GLenum, GLint); -GLAPI void APIENTRY glConvolutionParameteriv (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glGetConvolutionFilter (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetSeparableFilter (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); -GLAPI void APIENTRY glSeparableFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); -GLAPI void APIENTRY glGetHistogram (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetHistogramParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetHistogramParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMinmax (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glHistogram (GLenum, GLsizei, GLenum, GLboolean); -GLAPI void APIENTRY glMinmax (GLenum, GLenum, GLboolean); -GLAPI void APIENTRY glResetHistogram (GLenum); -GLAPI void APIENTRY glResetMinmax (GLenum); -GLAPI void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); -typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_VERSION_1_3 -#define GL_VERSION_1_3 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTexture (GLenum); -GLAPI void APIENTRY glClientActiveTexture (GLenum); -GLAPI void APIENTRY glMultiTexCoord1d (GLenum, GLdouble); -GLAPI void APIENTRY glMultiTexCoord1dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord1f (GLenum, GLfloat); -GLAPI void APIENTRY glMultiTexCoord1fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord1i (GLenum, GLint); -GLAPI void APIENTRY glMultiTexCoord1iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord1s (GLenum, GLshort); -GLAPI void APIENTRY glMultiTexCoord1sv (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord2d (GLenum, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord2dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord2f (GLenum, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord2fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord2i (GLenum, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord2iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord2s (GLenum, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord2sv (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord3d (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord3dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord3f (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord3fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord3i (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord3iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord3s (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord3sv (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord4d (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord4dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord4f (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord4fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord4i (GLenum, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord4iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord4s (GLenum, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord4sv (GLenum, const GLshort *); -GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *); -GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *); -GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *); -GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *); -GLAPI void APIENTRY glSampleCoverage (GLclampf, GLboolean); -GLAPI void APIENTRY glCompressedTexImage3D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage2D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage1D (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glGetCompressedTexImage (GLenum, GLint, GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); -#endif - -#ifndef GL_VERSION_1_4 -#define GL_VERSION_1_4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparate (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glFogCoordf (GLfloat); -GLAPI void APIENTRY glFogCoordfv (const GLfloat *); -GLAPI void APIENTRY glFogCoordd (GLdouble); -GLAPI void APIENTRY glFogCoorddv (const GLdouble *); -GLAPI void APIENTRY glFogCoordPointer (GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glMultiDrawArrays (GLenum, GLint *, GLsizei *, GLsizei); -GLAPI void APIENTRY glMultiDrawElements (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); -GLAPI void APIENTRY glPointParameterf (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfv (GLenum, const GLfloat *); -GLAPI void APIENTRY glPointParameteri (GLenum, GLint); -GLAPI void APIENTRY glPointParameteriv (GLenum, const GLint *); -GLAPI void APIENTRY glSecondaryColor3b (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *); -GLAPI void APIENTRY glSecondaryColor3d (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *); -GLAPI void APIENTRY glSecondaryColor3f (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *); -GLAPI void APIENTRY glSecondaryColor3i (GLint, GLint, GLint); -GLAPI void APIENTRY glSecondaryColor3iv (const GLint *); -GLAPI void APIENTRY glSecondaryColor3s (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *); -GLAPI void APIENTRY glSecondaryColor3ub (GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *); -GLAPI void APIENTRY glSecondaryColor3ui (GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *); -GLAPI void APIENTRY glSecondaryColor3us (GLushort, GLushort, GLushort); -GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *); -GLAPI void APIENTRY glSecondaryColorPointer (GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glWindowPos2d (GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos2dv (const GLdouble *); -GLAPI void APIENTRY glWindowPos2f (GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos2fv (const GLfloat *); -GLAPI void APIENTRY glWindowPos2i (GLint, GLint); -GLAPI void APIENTRY glWindowPos2iv (const GLint *); -GLAPI void APIENTRY glWindowPos2s (GLshort, GLshort); -GLAPI void APIENTRY glWindowPos2sv (const GLshort *); -GLAPI void APIENTRY glWindowPos3d (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos3dv (const GLdouble *); -GLAPI void APIENTRY glWindowPos3f (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos3fv (const GLfloat *); -GLAPI void APIENTRY glWindowPos3i (GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos3iv (const GLint *); -GLAPI void APIENTRY glWindowPos3s (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos3sv (const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); -#endif - -#ifndef GL_VERSION_1_5 -#define GL_VERSION_1_5 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueries (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteQueries (GLsizei, const GLuint *); -GLAPI GLboolean APIENTRY glIsQuery (GLuint); -GLAPI void APIENTRY glBeginQuery (GLenum, GLuint); -GLAPI void APIENTRY glEndQuery (GLenum); -GLAPI void APIENTRY glGetQueryiv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectuiv (GLuint, GLenum, GLuint *); -GLAPI void APIENTRY glBindBuffer (GLenum, GLuint); -GLAPI void APIENTRY glDeleteBuffers (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenBuffers (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsBuffer (GLuint); -GLAPI void APIENTRY glBufferData (GLenum, GLsizeiptr, const GLvoid *, GLenum); -GLAPI void APIENTRY glBufferSubData (GLenum, GLintptr, GLsizeiptr, const GLvoid *); -GLAPI void APIENTRY glGetBufferSubData (GLenum, GLintptr, GLsizeiptr, GLvoid *); -GLAPI GLvoid* APIENTRY glMapBuffer (GLenum, GLenum); -GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum); -GLAPI void APIENTRY glGetBufferParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetBufferPointerv (GLenum, GLenum, GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_VERSION_2_0 -#define GL_VERSION_2_0 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparate (GLenum, GLenum); -GLAPI void APIENTRY glDrawBuffers (GLsizei, const GLenum *); -GLAPI void APIENTRY glStencilOpSeparate (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glStencilFuncSeparate (GLenum, GLenum, GLint, GLuint); -GLAPI void APIENTRY glStencilMaskSeparate (GLenum, GLuint); -GLAPI void APIENTRY glAttachShader (GLuint, GLuint); -GLAPI void APIENTRY glBindAttribLocation (GLuint, GLuint, const GLchar *); -GLAPI void APIENTRY glCompileShader (GLuint); -GLAPI GLuint APIENTRY glCreateProgram (void); -GLAPI GLuint APIENTRY glCreateShader (GLenum); -GLAPI void APIENTRY glDeleteProgram (GLuint); -GLAPI void APIENTRY glDeleteShader (GLuint); -GLAPI void APIENTRY glDetachShader (GLuint, GLuint); -GLAPI void APIENTRY glDisableVertexAttribArray (GLuint); -GLAPI void APIENTRY glEnableVertexAttribArray (GLuint); -GLAPI void APIENTRY glGetActiveAttrib (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); -GLAPI void APIENTRY glGetActiveUniform (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); -GLAPI void APIENTRY glGetAttachedShaders (GLuint, GLsizei, GLsizei *, GLuint *); -GLAPI GLint APIENTRY glGetAttribLocation (GLuint, const GLchar *); -GLAPI void APIENTRY glGetProgramiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetProgramInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); -GLAPI void APIENTRY glGetShaderiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetShaderInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); -GLAPI void APIENTRY glGetShaderSource (GLuint, GLsizei, GLsizei *, GLchar *); -GLAPI GLint APIENTRY glGetUniformLocation (GLuint, const GLchar *); -GLAPI void APIENTRY glGetUniformfv (GLuint, GLint, GLfloat *); -GLAPI void APIENTRY glGetUniformiv (GLuint, GLint, GLint *); -GLAPI void APIENTRY glGetVertexAttribdv (GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetVertexAttribfv (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint, GLenum, GLvoid* *); -GLAPI GLboolean APIENTRY glIsProgram (GLuint); -GLAPI GLboolean APIENTRY glIsShader (GLuint); -GLAPI void APIENTRY glLinkProgram (GLuint); -GLAPI void APIENTRY glShaderSource (GLuint, GLsizei, const GLchar* *, const GLint *); -GLAPI void APIENTRY glUseProgram (GLuint); -GLAPI void APIENTRY glUniform1f (GLint, GLfloat); -GLAPI void APIENTRY glUniform2f (GLint, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform3f (GLint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform4f (GLint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform1i (GLint, GLint); -GLAPI void APIENTRY glUniform2i (GLint, GLint, GLint); -GLAPI void APIENTRY glUniform3i (GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform4i (GLint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform1fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform2fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform3fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform4fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform1iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform2iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform3iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform4iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniformMatrix2fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix3fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix4fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glValidateProgram (GLuint); -GLAPI void APIENTRY glVertexAttrib1d (GLuint, GLdouble); -GLAPI void APIENTRY glVertexAttrib1dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib1f (GLuint, GLfloat); -GLAPI void APIENTRY glVertexAttrib1fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib1s (GLuint, GLshort); -GLAPI void APIENTRY glVertexAttrib1sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib2d (GLuint, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib2dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib2f (GLuint, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib2fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib2s (GLuint, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib2sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib3d (GLuint, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib3dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib3f (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib3fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib3s (GLuint, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib3sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4Niv (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4Nub (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttrib4bv (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4d (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib4dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib4f (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib4fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib4iv (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4s (GLuint, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib4sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4ubv (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4uiv (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4usv (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttribPointer (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); -typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); -typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); -typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); -typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +#else +typedef unsigned int GLhandleARB; #endif +typedef char GLcharARB; +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 +typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj); +GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname); +GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj); +GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType); +GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); +GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj); +GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); +GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj); +GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj); +GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params); +GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif +#endif /* GL_ARB_shader_objects */ + +#ifndef GL_ARB_shader_precision +#define GL_ARB_shader_precision 1 +#endif /* GL_ARB_shader_precision */ + +#ifndef GL_ARB_shader_stencil_export +#define GL_ARB_shader_stencil_export 1 +#endif /* GL_ARB_shader_stencil_export */ + +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_ARB_shader_storage_buffer_object 1 +#endif /* GL_ARB_shader_storage_buffer_object */ + +#ifndef GL_ARB_shader_subroutine +#define GL_ARB_shader_subroutine 1 +#endif /* GL_ARB_shader_subroutine */ + +#ifndef GL_ARB_shader_texture_image_samples +#define GL_ARB_shader_texture_image_samples 1 +#endif /* GL_ARB_shader_texture_image_samples */ + +#ifndef GL_ARB_shader_texture_lod +#define GL_ARB_shader_texture_lod 1 +#endif /* GL_ARB_shader_texture_lod */ + +#ifndef GL_ARB_shader_viewport_layer_array +#define GL_ARB_shader_viewport_layer_array 1 +#endif /* GL_ARB_shader_viewport_layer_array */ -#ifndef GL_ARB_multitexture -#define GL_ARB_multitexture 1 +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C +#endif /* GL_ARB_shading_language_100 */ + +#ifndef GL_ARB_shading_language_420pack +#define GL_ARB_shading_language_420pack 1 +#endif /* GL_ARB_shading_language_420pack */ + +#ifndef GL_ARB_shading_language_include +#define GL_ARB_shading_language_include 1 +#define GL_SHADER_INCLUDE_ARB 0x8DAE +#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 +#define GL_NAMED_STRING_TYPE_ARB 0x8DEA +typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); +typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTextureARB (GLenum); -GLAPI void APIENTRY glClientActiveTextureARB (GLenum); -GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble); -GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat); -GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum, GLint); -GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort); -GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); +GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); #endif +#endif /* GL_ARB_shading_language_include */ -#ifndef GL_ARB_transpose_matrix -#define GL_ARB_transpose_matrix 1 +#ifndef GL_ARB_shading_language_packing +#define GL_ARB_shading_language_packing 1 +#endif /* GL_ARB_shading_language_packing */ + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif /* GL_ARB_shadow */ + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif /* GL_ARB_shadow_ambient */ + +#ifndef GL_ARB_sparse_buffer +#define GL_ARB_sparse_buffer 1 +#define GL_SPARSE_STORAGE_BIT_ARB 0x0400 +#define GL_SPARSE_BUFFER_PAGE_SIZE_ARB 0x82F8 +typedef void (APIENTRYP PFNGLBUFFERPAGECOMMITMENTARBPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLboolean commit); +typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTARBPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *); -GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *); -GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *); -GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +GLAPI void APIENTRY glBufferPageCommitmentARB (GLenum target, GLintptr offset, GLsizeiptr size, GLboolean commit); +GLAPI void APIENTRY glNamedBufferPageCommitmentEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +GLAPI void APIENTRY glNamedBufferPageCommitmentARB (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +#endif +#endif /* GL_ARB_sparse_buffer */ + +#ifndef GL_ARB_sparse_texture +#define GL_ARB_sparse_texture 1 +#define GL_TEXTURE_SPARSE_ARB 0x91A6 +#define GL_VIRTUAL_PAGE_SIZE_INDEX_ARB 0x91A7 +#define GL_NUM_SPARSE_LEVELS_ARB 0x91AA +#define GL_NUM_VIRTUAL_PAGE_SIZES_ARB 0x91A8 +#define GL_VIRTUAL_PAGE_SIZE_X_ARB 0x9195 +#define GL_VIRTUAL_PAGE_SIZE_Y_ARB 0x9196 +#define GL_VIRTUAL_PAGE_SIZE_Z_ARB 0x9197 +#define GL_MAX_SPARSE_TEXTURE_SIZE_ARB 0x9198 +#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB 0x9199 +#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB 0x919A +#define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB 0x91A9 +typedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); #endif +#endif /* GL_ARB_sparse_texture */ -#ifndef GL_ARB_multisample -#define GL_ARB_multisample 1 +#ifndef GL_ARB_sparse_texture2 +#define GL_ARB_sparse_texture2 1 +#endif /* GL_ARB_sparse_texture2 */ + +#ifndef GL_ARB_sparse_texture_clamp +#define GL_ARB_sparse_texture_clamp 1 +#endif /* GL_ARB_sparse_texture_clamp */ + +#ifndef GL_ARB_spirv_extensions +#define GL_ARB_spirv_extensions 1 +#endif /* GL_ARB_spirv_extensions */ + +#ifndef GL_ARB_stencil_texturing +#define GL_ARB_stencil_texturing 1 +#endif /* GL_ARB_stencil_texturing */ + +#ifndef GL_ARB_sync +#define GL_ARB_sync 1 +#endif /* GL_ARB_sync */ + +#ifndef GL_ARB_tessellation_shader +#define GL_ARB_tessellation_shader 1 +#endif /* GL_ARB_tessellation_shader */ + +#ifndef GL_ARB_texture_barrier +#define GL_ARB_texture_barrier 1 +#endif /* GL_ARB_texture_barrier */ + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif /* GL_ARB_texture_border_clamp */ + +#ifndef GL_ARB_texture_buffer_object +#define GL_ARB_texture_buffer_object 1 +#define GL_TEXTURE_BUFFER_ARB 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E +typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleCoverageARB (GLclampf, GLboolean); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); #endif +#endif /* GL_ARB_texture_buffer_object */ -#ifndef GL_ARB_texture_env_add -#define GL_ARB_texture_env_add 1 -#endif +#ifndef GL_ARB_texture_buffer_object_rgb32 +#define GL_ARB_texture_buffer_object_rgb32 1 +#endif /* GL_ARB_texture_buffer_object_rgb32 */ -#ifndef GL_ARB_texture_cube_map -#define GL_ARB_texture_cube_map 1 -#endif +#ifndef GL_ARB_texture_buffer_range +#define GL_ARB_texture_buffer_range 1 +#endif /* GL_ARB_texture_buffer_range */ #ifndef GL_ARB_texture_compression #define GL_ARB_texture_compression 1 +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, void *img); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum, GLint, GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); -#endif +GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, void *img); +#endif +#endif /* GL_ARB_texture_compression */ + +#ifndef GL_ARB_texture_compression_bptc +#define GL_ARB_texture_compression_bptc 1 +#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F +#endif /* GL_ARB_texture_compression_bptc */ + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_ARB_texture_compression_rgtc 1 +#endif /* GL_ARB_texture_compression_rgtc */ -#ifndef GL_ARB_texture_border_clamp -#define GL_ARB_texture_border_clamp 1 -#endif +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +#endif /* GL_ARB_texture_cube_map */ + +#ifndef GL_ARB_texture_cube_map_array +#define GL_ARB_texture_cube_map_array 1 +#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F +#endif /* GL_ARB_texture_cube_map_array */ -#ifndef GL_ARB_point_parameters -#define GL_ARB_point_parameters 1 +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 +#endif /* GL_ARB_texture_env_add */ + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif /* GL_ARB_texture_env_combine */ + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif /* GL_ARB_texture_env_crossbar */ + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif /* GL_ARB_texture_env_dot3 */ + +#ifndef GL_ARB_texture_filter_anisotropic +#define GL_ARB_texture_filter_anisotropic 1 +#endif /* GL_ARB_texture_filter_anisotropic */ + +#ifndef GL_ARB_texture_filter_minmax +#define GL_ARB_texture_filter_minmax 1 +#define GL_TEXTURE_REDUCTION_MODE_ARB 0x9366 +#define GL_WEIGHTED_AVERAGE_ARB 0x9367 +#endif /* GL_ARB_texture_filter_minmax */ + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif /* GL_ARB_texture_float */ + +#ifndef GL_ARB_texture_gather +#define GL_ARB_texture_gather 1 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F +#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F +#endif /* GL_ARB_texture_gather */ + +#ifndef GL_ARB_texture_mirror_clamp_to_edge +#define GL_ARB_texture_mirror_clamp_to_edge 1 +#endif /* GL_ARB_texture_mirror_clamp_to_edge */ + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif /* GL_ARB_texture_mirrored_repeat */ + +#ifndef GL_ARB_texture_multisample +#define GL_ARB_texture_multisample 1 +#endif /* GL_ARB_texture_multisample */ + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif /* GL_ARB_texture_non_power_of_two */ + +#ifndef GL_ARB_texture_query_levels +#define GL_ARB_texture_query_levels 1 +#endif /* GL_ARB_texture_query_levels */ + +#ifndef GL_ARB_texture_query_lod +#define GL_ARB_texture_query_lod 1 +#endif /* GL_ARB_texture_query_lod */ + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#endif /* GL_ARB_texture_rectangle */ + +#ifndef GL_ARB_texture_rg +#define GL_ARB_texture_rg 1 +#endif /* GL_ARB_texture_rg */ + +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_ARB_texture_rgb10_a2ui 1 +#endif /* GL_ARB_texture_rgb10_a2ui */ + +#ifndef GL_ARB_texture_stencil8 +#define GL_ARB_texture_stencil8 1 +#endif /* GL_ARB_texture_stencil8 */ + +#ifndef GL_ARB_texture_storage +#define GL_ARB_texture_storage 1 +#endif /* GL_ARB_texture_storage */ + +#ifndef GL_ARB_texture_storage_multisample +#define GL_ARB_texture_storage_multisample 1 +#endif /* GL_ARB_texture_storage_multisample */ + +#ifndef GL_ARB_texture_swizzle +#define GL_ARB_texture_swizzle 1 +#endif /* GL_ARB_texture_swizzle */ + +#ifndef GL_ARB_texture_view +#define GL_ARB_texture_view 1 +#endif /* GL_ARB_texture_view */ + +#ifndef GL_ARB_timer_query +#define GL_ARB_timer_query 1 +#endif /* GL_ARB_timer_query */ + +#ifndef GL_ARB_transform_feedback2 +#define GL_ARB_transform_feedback2 1 +#endif /* GL_ARB_transform_feedback2 */ + +#ifndef GL_ARB_transform_feedback3 +#define GL_ARB_transform_feedback3 1 +#endif /* GL_ARB_transform_feedback3 */ + +#ifndef GL_ARB_transform_feedback_instanced +#define GL_ARB_transform_feedback_instanced 1 +#endif /* GL_ARB_transform_feedback_instanced */ + +#ifndef GL_ARB_transform_feedback_overflow_query +#define GL_ARB_transform_feedback_overflow_query 1 +#define GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB 0x82EC +#define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB 0x82ED +#endif /* GL_ARB_transform_feedback_overflow_query */ + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfARB (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfvARB (GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m); #endif +#endif /* GL_ARB_transpose_matrix */ + +#ifndef GL_ARB_uniform_buffer_object +#define GL_ARB_uniform_buffer_object 1 +#endif /* GL_ARB_uniform_buffer_object */ + +#ifndef GL_ARB_vertex_array_bgra +#define GL_ARB_vertex_array_bgra 1 +#endif /* GL_ARB_vertex_array_bgra */ + +#ifndef GL_ARB_vertex_array_object +#define GL_ARB_vertex_array_object 1 +#endif /* GL_ARB_vertex_array_object */ + +#ifndef GL_ARB_vertex_attrib_64bit +#define GL_ARB_vertex_attrib_64bit 1 +#endif /* GL_ARB_vertex_attrib_64bit */ + +#ifndef GL_ARB_vertex_attrib_binding +#define GL_ARB_vertex_attrib_binding 1 +#endif /* GL_ARB_vertex_attrib_binding */ #ifndef GL_ARB_vertex_blend #define GL_ARB_vertex_blend 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWeightbvARB (GLint, const GLbyte *); -GLAPI void APIENTRY glWeightsvARB (GLint, const GLshort *); -GLAPI void APIENTRY glWeightivARB (GLint, const GLint *); -GLAPI void APIENTRY glWeightfvARB (GLint, const GLfloat *); -GLAPI void APIENTRY glWeightdvARB (GLint, const GLdouble *); -GLAPI void APIENTRY glWeightubvARB (GLint, const GLubyte *); -GLAPI void APIENTRY glWeightusvARB (GLint, const GLushort *); -GLAPI void APIENTRY glWeightuivARB (GLint, const GLuint *); -GLAPI void APIENTRY glWeightPointerARB (GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glVertexBlendARB (GLint); -#endif /* GL_GLEXT_PROTOTYPES */ +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); @@ -3765,158 +4713,101 @@ typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weigh typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); -typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); -#endif - -#ifndef GL_ARB_matrix_palette -#define GL_ARB_matrix_palette 1 #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint); -GLAPI void APIENTRY glMatrixIndexubvARB (GLint, const GLubyte *); -GLAPI void APIENTRY glMatrixIndexusvARB (GLint, const GLushort *); -GLAPI void APIENTRY glMatrixIndexuivARB (GLint, const GLuint *); -GLAPI void APIENTRY glMatrixIndexPointerARB (GLint, GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); -typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_ARB_texture_env_combine -#define GL_ARB_texture_env_combine 1 -#endif - -#ifndef GL_ARB_texture_env_crossbar -#define GL_ARB_texture_env_crossbar 1 -#endif - -#ifndef GL_ARB_texture_env_dot3 -#define GL_ARB_texture_env_dot3 1 -#endif - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_ARB_texture_mirrored_repeat 1 -#endif - -#ifndef GL_ARB_depth_texture -#define GL_ARB_depth_texture 1 -#endif +GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights); +GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights); +GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights); +GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights); +GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights); +GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights); +GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights); +GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights); +GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glVertexBlendARB (GLint count); +#endif +#endif /* GL_ARB_vertex_blend */ -#ifndef GL_ARB_shadow -#define GL_ARB_shadow 1 -#endif - -#ifndef GL_ARB_shadow_ambient -#define GL_ARB_shadow_ambient 1 -#endif - -#ifndef GL_ARB_window_pos -#define GL_ARB_window_pos 1 +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +typedef khronos_ssize_t GLsizeiptrARB; +typedef khronos_intptr_t GLintptrARB; +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA +typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); +typedef void *(APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, void **params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dARB (GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *); -GLAPI void APIENTRY glWindowPos2fARB (GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *); -GLAPI void APIENTRY glWindowPos2iARB (GLint, GLint); -GLAPI void APIENTRY glWindowPos2ivARB (const GLint *); -GLAPI void APIENTRY glWindowPos2sARB (GLshort, GLshort); -GLAPI void APIENTRY glWindowPos2svARB (const GLshort *); -GLAPI void APIENTRY glWindowPos3dARB (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *); -GLAPI void APIENTRY glWindowPos3fARB (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *); -GLAPI void APIENTRY glWindowPos3iARB (GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos3ivARB (const GLint *); -GLAPI void APIENTRY glWindowPos3sARB (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos3svARB (const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); -#endif +GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); +GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); +GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); +GLAPI void *APIENTRY glMapBufferARB (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); +GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_ARB_vertex_buffer_object */ #ifndef GL_ARB_vertex_program #define GL_ARB_vertex_program 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttrib1dARB (GLuint, GLdouble); -GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib1fARB (GLuint, GLfloat); -GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib1sARB (GLuint, GLshort); -GLAPI void APIENTRY glVertexAttrib1svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib2dARB (GLuint, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib2fARB (GLuint, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib2sARB (GLuint, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib2svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib3dARB (GLuint, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib3fARB (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib3sARB (GLuint, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib3svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4dARB (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib4fARB (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4sARB (GLuint, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib4svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttribPointerARB (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); -GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint); -GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint); -GLAPI void APIENTRY glProgramStringARB (GLenum, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glBindProgramARB (GLenum, GLuint); -GLAPI void APIENTRY glDeleteProgramsARB (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenProgramsARB (GLsizei, GLuint *); -GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum, GLuint, GLdouble *); -GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum, GLuint, GLfloat *); -GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum, GLuint, GLdouble *); -GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum, GLuint, GLfloat *); -GLAPI void APIENTRY glGetProgramivARB (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetProgramStringARB (GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribivARB (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint, GLenum, GLvoid* *); -GLAPI GLboolean APIENTRY glIsProgramARB (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); @@ -3953,1439 +4844,4487 @@ typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshor typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); -typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, void **pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, void **pointer); +#endif +#endif /* GL_ARB_vertex_program */ + +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name); +#endif +#endif /* GL_ARB_vertex_shader */ + +#ifndef GL_ARB_vertex_type_10f_11f_11f_rev +#define GL_ARB_vertex_type_10f_11f_11f_rev 1 +#endif /* GL_ARB_vertex_type_10f_11f_11f_rev */ + +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +#define GL_ARB_vertex_type_2_10_10_10_rev 1 +#endif /* GL_ARB_vertex_type_2_10_10_10_rev */ + +#ifndef GL_ARB_viewport_array +#define GL_ARB_viewport_array 1 +#endif /* GL_ARB_viewport_array */ + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 +typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); +#endif +#endif /* GL_ARB_window_pos */ + +#ifndef GL_KHR_blend_equation_advanced +#define GL_KHR_blend_equation_advanced 1 +#define GL_MULTIPLY_KHR 0x9294 +#define GL_SCREEN_KHR 0x9295 +#define GL_OVERLAY_KHR 0x9296 +#define GL_DARKEN_KHR 0x9297 +#define GL_LIGHTEN_KHR 0x9298 +#define GL_COLORDODGE_KHR 0x9299 +#define GL_COLORBURN_KHR 0x929A +#define GL_HARDLIGHT_KHR 0x929B +#define GL_SOFTLIGHT_KHR 0x929C +#define GL_DIFFERENCE_KHR 0x929E +#define GL_EXCLUSION_KHR 0x92A0 +#define GL_HSL_HUE_KHR 0x92AD +#define GL_HSL_SATURATION_KHR 0x92AE +#define GL_HSL_COLOR_KHR 0x92AF +#define GL_HSL_LUMINOSITY_KHR 0x92B0 +typedef void (APIENTRYP PFNGLBLENDBARRIERKHRPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendBarrierKHR (void); +#endif +#endif /* GL_KHR_blend_equation_advanced */ + +#ifndef GL_KHR_blend_equation_advanced_coherent +#define GL_KHR_blend_equation_advanced_coherent 1 +#define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285 +#endif /* GL_KHR_blend_equation_advanced_coherent */ + +#ifndef GL_KHR_context_flush_control +#define GL_KHR_context_flush_control 1 +#endif /* GL_KHR_context_flush_control */ + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +#endif /* GL_KHR_debug */ + +#ifndef GL_KHR_no_error +#define GL_KHR_no_error 1 +#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 +#endif /* GL_KHR_no_error */ + +#ifndef GL_KHR_parallel_shader_compile +#define GL_KHR_parallel_shader_compile 1 +#define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0 +#define GL_COMPLETION_STATUS_KHR 0x91B1 +typedef void (APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSKHRPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMaxShaderCompilerThreadsKHR (GLuint count); +#endif +#endif /* GL_KHR_parallel_shader_compile */ + +#ifndef GL_KHR_robust_buffer_access_behavior +#define GL_KHR_robust_buffer_access_behavior 1 +#endif /* GL_KHR_robust_buffer_access_behavior */ + +#ifndef GL_KHR_robustness +#define GL_KHR_robustness 1 +#define GL_CONTEXT_ROBUST_ACCESS 0x90F3 +#endif /* GL_KHR_robustness */ + +#ifndef GL_KHR_texture_compression_astc_hdr +#define GL_KHR_texture_compression_astc_hdr 1 +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif /* GL_KHR_texture_compression_astc_hdr */ + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#endif /* GL_KHR_texture_compression_astc_ldr */ + +#ifndef GL_KHR_texture_compression_astc_sliced_3d +#define GL_KHR_texture_compression_astc_sliced_3d 1 +#endif /* GL_KHR_texture_compression_astc_sliced_3d */ + +#ifndef GL_OES_byte_coordinates +#define GL_OES_byte_coordinates 1 +typedef void (APIENTRYP PFNGLMULTITEXCOORD1BOESPROC) (GLenum texture, GLbyte s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2BOESPROC) (GLenum texture, GLbyte s, GLbyte t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD1BOESPROC) (GLbyte s); +typedef void (APIENTRYP PFNGLTEXCOORD1BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD2BOESPROC) (GLbyte s, GLbyte t); +typedef void (APIENTRYP PFNGLTEXCOORD2BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD3BOESPROC) (GLbyte s, GLbyte t, GLbyte r); +typedef void (APIENTRYP PFNGLTEXCOORD3BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD4BOESPROC) (GLbyte s, GLbyte t, GLbyte r, GLbyte q); +typedef void (APIENTRYP PFNGLTEXCOORD4BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX2BOESPROC) (GLbyte x, GLbyte y); +typedef void (APIENTRYP PFNGLVERTEX2BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX3BOESPROC) (GLbyte x, GLbyte y, GLbyte z); +typedef void (APIENTRYP PFNGLVERTEX3BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX4BOESPROC) (GLbyte x, GLbyte y, GLbyte z, GLbyte w); +typedef void (APIENTRYP PFNGLVERTEX4BVOESPROC) (const GLbyte *coords); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiTexCoord1bOES (GLenum texture, GLbyte s); +GLAPI void APIENTRY glMultiTexCoord1bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord2bOES (GLenum texture, GLbyte s, GLbyte t); +GLAPI void APIENTRY glMultiTexCoord2bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord3bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r); +GLAPI void APIENTRY glMultiTexCoord3bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord4bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); +GLAPI void APIENTRY glMultiTexCoord4bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glTexCoord1bOES (GLbyte s); +GLAPI void APIENTRY glTexCoord1bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord2bOES (GLbyte s, GLbyte t); +GLAPI void APIENTRY glTexCoord2bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord3bOES (GLbyte s, GLbyte t, GLbyte r); +GLAPI void APIENTRY glTexCoord3bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord4bOES (GLbyte s, GLbyte t, GLbyte r, GLbyte q); +GLAPI void APIENTRY glTexCoord4bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex2bOES (GLbyte x, GLbyte y); +GLAPI void APIENTRY glVertex2bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex3bOES (GLbyte x, GLbyte y, GLbyte z); +GLAPI void APIENTRY glVertex3bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex4bOES (GLbyte x, GLbyte y, GLbyte z, GLbyte w); +GLAPI void APIENTRY glVertex4bvOES (const GLbyte *coords); +#endif +#endif /* GL_OES_byte_coordinates */ + +#ifndef GL_OES_compressed_paletted_texture +#define GL_OES_compressed_paletted_texture 1 +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#endif /* GL_OES_compressed_paletted_texture */ + +#ifndef GL_OES_fixed_point +#define GL_OES_fixed_point 1 +typedef khronos_int32_t GLfixed; +#define GL_FIXED_OES 0x140C +typedef void (APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLfixed ref); +typedef void (APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCLEARDEPTHXOESPROC) (GLfixed depth); +typedef void (APIENTRYP PFNGLCLIPPLANEXOESPROC) (GLenum plane, const GLfixed *equation); +typedef void (APIENTRYP PFNGLCOLOR4XOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLDEPTHRANGEXOESPROC) (GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLFOGXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLFOGXVOESPROC) (GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLFRUSTUMXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLGETCLIPPLANEXOESPROC) (GLenum plane, GLfixed *equation); +typedef void (APIENTRYP PFNGLGETFIXEDVOESPROC) (GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXENVXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLLIGHTMODELXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLLIGHTMODELXVOESPROC) (GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLLIGHTXVOESPROC) (GLenum light, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLLINEWIDTHXOESPROC) (GLfixed width); +typedef void (APIENTRYP PFNGLLOADMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLMATERIALXVOESPROC) (GLenum face, GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLMULTMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +typedef void (APIENTRYP PFNGLNORMAL3XOESPROC) (GLfixed nx, GLfixed ny, GLfixed nz); +typedef void (APIENTRYP PFNGLORTHOXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size); +typedef void (APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units); +typedef void (APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLTRANSLATEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLACCUMXOESPROC) (GLenum op, GLfixed value); +typedef void (APIENTRYP PFNGLBITMAPXOESPROC) (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); +typedef void (APIENTRYP PFNGLBLENDCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCLEARACCUMXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCOLOR3XOESPROC) (GLfixed red, GLfixed green, GLfixed blue); +typedef void (APIENTRYP PFNGLCOLOR3XVOESPROC) (const GLfixed *components); +typedef void (APIENTRYP PFNGLCOLOR4XVOESPROC) (const GLfixed *components); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLEVALCOORD1XOESPROC) (GLfixed u); +typedef void (APIENTRYP PFNGLEVALCOORD1XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLEVALCOORD2XOESPROC) (GLfixed u, GLfixed v); +typedef void (APIENTRYP PFNGLEVALCOORD2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLFEEDBACKBUFFERXOESPROC) (GLsizei n, GLenum type, const GLfixed *buffer); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETMAPXVOESPROC) (GLenum target, GLenum query, GLfixed *v); +typedef void (APIENTRYP PFNGLGETMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLGETPIXELMAPXVPROC) (GLenum map, GLint size, GLfixed *values); +typedef void (APIENTRYP PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERXVOESPROC) (GLenum target, GLint level, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLINDEXXOESPROC) (GLfixed component); +typedef void (APIENTRYP PFNGLINDEXXVOESPROC) (const GLfixed *component); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMAP1XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); +typedef void (APIENTRYP PFNGLMAP2XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); +typedef void (APIENTRYP PFNGLMAPGRID1XOESPROC) (GLint n, GLfixed u1, GLfixed u2); +typedef void (APIENTRYP PFNGLMAPGRID2XOESPROC) (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1XOESPROC) (GLenum texture, GLfixed s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2XOESPROC) (GLenum texture, GLfixed s, GLfixed t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLNORMAL3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLPASSTHROUGHXOESPROC) (GLfixed token); +typedef void (APIENTRYP PFNGLPIXELMAPXPROC) (GLenum map, GLint size, const GLfixed *values); +typedef void (APIENTRYP PFNGLPIXELSTOREXPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLPIXELTRANSFERXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLPIXELZOOMXOESPROC) (GLfixed xfactor, GLfixed yfactor); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESXOESPROC) (GLsizei n, const GLuint *textures, const GLfixed *priorities); +typedef void (APIENTRYP PFNGLRASTERPOS2XOESPROC) (GLfixed x, GLfixed y); +typedef void (APIENTRYP PFNGLRASTERPOS2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRASTERPOS3XOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLRASTERPOS3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRASTERPOS4XOESPROC) (GLfixed x, GLfixed y, GLfixed z, GLfixed w); +typedef void (APIENTRYP PFNGLRASTERPOS4XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRECTXOESPROC) (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); +typedef void (APIENTRYP PFNGLRECTXVOESPROC) (const GLfixed *v1, const GLfixed *v2); +typedef void (APIENTRYP PFNGLTEXCOORD1XOESPROC) (GLfixed s); +typedef void (APIENTRYP PFNGLTEXCOORD1XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD2XOESPROC) (GLfixed s, GLfixed t); +typedef void (APIENTRYP PFNGLTEXCOORD2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD3XOESPROC) (GLfixed s, GLfixed t, GLfixed r); +typedef void (APIENTRYP PFNGLTEXCOORD3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD4XOESPROC) (GLfixed s, GLfixed t, GLfixed r, GLfixed q); +typedef void (APIENTRYP PFNGLTEXCOORD4XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLVERTEX2XOESPROC) (GLfixed x); +typedef void (APIENTRYP PFNGLVERTEX2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLVERTEX3XOESPROC) (GLfixed x, GLfixed y); +typedef void (APIENTRYP PFNGLVERTEX3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLVERTEX4XOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLVERTEX4XVOESPROC) (const GLfixed *coords); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAlphaFuncxOES (GLenum func, GLfixed ref); +GLAPI void APIENTRY glClearColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glClearDepthxOES (GLfixed depth); +GLAPI void APIENTRY glClipPlanexOES (GLenum plane, const GLfixed *equation); +GLAPI void APIENTRY glColor4xOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glDepthRangexOES (GLfixed n, GLfixed f); +GLAPI void APIENTRY glFogxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glFogxvOES (GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glFrustumxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +GLAPI void APIENTRY glGetClipPlanexOES (GLenum plane, GLfixed *equation); +GLAPI void APIENTRY glGetFixedvOES (GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexEnvxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glLightModelxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glLightModelxvOES (GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glLightxOES (GLenum light, GLenum pname, GLfixed param); +GLAPI void APIENTRY glLightxvOES (GLenum light, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glLineWidthxOES (GLfixed width); +GLAPI void APIENTRY glLoadMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMaterialxOES (GLenum face, GLenum pname, GLfixed param); +GLAPI void APIENTRY glMaterialxvOES (GLenum face, GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glMultMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMultiTexCoord4xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +GLAPI void APIENTRY glNormal3xOES (GLfixed nx, GLfixed ny, GLfixed nz); +GLAPI void APIENTRY glOrthoxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +GLAPI void APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glPointSizexOES (GLfixed size); +GLAPI void APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units); +GLAPI void APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glTexParameterxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glTranslatexOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glAccumxOES (GLenum op, GLfixed value); +GLAPI void APIENTRY glBitmapxOES (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); +GLAPI void APIENTRY glBlendColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glClearAccumxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glColor3xOES (GLfixed red, GLfixed green, GLfixed blue); +GLAPI void APIENTRY glColor3xvOES (const GLfixed *components); +GLAPI void APIENTRY glColor4xvOES (const GLfixed *components); +GLAPI void APIENTRY glConvolutionParameterxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glConvolutionParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glEvalCoord1xOES (GLfixed u); +GLAPI void APIENTRY glEvalCoord1xvOES (const GLfixed *coords); +GLAPI void APIENTRY glEvalCoord2xOES (GLfixed u, GLfixed v); +GLAPI void APIENTRY glEvalCoord2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glFeedbackBufferxOES (GLsizei n, GLenum type, const GLfixed *buffer); +GLAPI void APIENTRY glGetConvolutionParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetHistogramParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetLightxOES (GLenum light, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetMapxvOES (GLenum target, GLenum query, GLfixed *v); +GLAPI void APIENTRY glGetMaterialxOES (GLenum face, GLenum pname, GLfixed param); +GLAPI void APIENTRY glGetPixelMapxv (GLenum map, GLint size, GLfixed *values); +GLAPI void APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexLevelParameterxvOES (GLenum target, GLint level, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glIndexxOES (GLfixed component); +GLAPI void APIENTRY glIndexxvOES (const GLfixed *component); +GLAPI void APIENTRY glLoadTransposeMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMap1xOES (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); +GLAPI void APIENTRY glMap2xOES (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); +GLAPI void APIENTRY glMapGrid1xOES (GLint n, GLfixed u1, GLfixed u2); +GLAPI void APIENTRY glMapGrid2xOES (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); +GLAPI void APIENTRY glMultTransposeMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMultiTexCoord1xOES (GLenum texture, GLfixed s); +GLAPI void APIENTRY glMultiTexCoord1xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord2xOES (GLenum texture, GLfixed s, GLfixed t); +GLAPI void APIENTRY glMultiTexCoord2xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord3xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r); +GLAPI void APIENTRY glMultiTexCoord3xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord4xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glNormal3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glPassThroughxOES (GLfixed token); +GLAPI void APIENTRY glPixelMapx (GLenum map, GLint size, const GLfixed *values); +GLAPI void APIENTRY glPixelStorex (GLenum pname, GLfixed param); +GLAPI void APIENTRY glPixelTransferxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glPixelZoomxOES (GLfixed xfactor, GLfixed yfactor); +GLAPI void APIENTRY glPrioritizeTexturesxOES (GLsizei n, const GLuint *textures, const GLfixed *priorities); +GLAPI void APIENTRY glRasterPos2xOES (GLfixed x, GLfixed y); +GLAPI void APIENTRY glRasterPos2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRasterPos3xOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glRasterPos3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRasterPos4xOES (GLfixed x, GLfixed y, GLfixed z, GLfixed w); +GLAPI void APIENTRY glRasterPos4xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRectxOES (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); +GLAPI void APIENTRY glRectxvOES (const GLfixed *v1, const GLfixed *v2); +GLAPI void APIENTRY glTexCoord1xOES (GLfixed s); +GLAPI void APIENTRY glTexCoord1xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord2xOES (GLfixed s, GLfixed t); +GLAPI void APIENTRY glTexCoord2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord3xOES (GLfixed s, GLfixed t, GLfixed r); +GLAPI void APIENTRY glTexCoord3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord4xOES (GLfixed s, GLfixed t, GLfixed r, GLfixed q); +GLAPI void APIENTRY glTexCoord4xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glVertex2xOES (GLfixed x); +GLAPI void APIENTRY glVertex2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glVertex3xOES (GLfixed x, GLfixed y); +GLAPI void APIENTRY glVertex3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glVertex4xOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glVertex4xvOES (const GLfixed *coords); +#endif +#endif /* GL_OES_fixed_point */ + +#ifndef GL_OES_query_matrix +#define GL_OES_query_matrix 1 +typedef GLbitfield (APIENTRYP PFNGLQUERYMATRIXXOESPROC) (GLfixed *mantissa, GLint *exponent); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLbitfield APIENTRY glQueryMatrixxOES (GLfixed *mantissa, GLint *exponent); +#endif +#endif /* GL_OES_query_matrix */ + +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B +#endif /* GL_OES_read_format */ + +#ifndef GL_OES_single_precision +#define GL_OES_single_precision 1 +typedef void (APIENTRYP PFNGLCLEARDEPTHFOESPROC) (GLclampf depth); +typedef void (APIENTRYP PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat *equation); +typedef void (APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f); +typedef void (APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat *equation); +typedef void (APIENTRYP PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearDepthfOES (GLclampf depth); +GLAPI void APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation); +GLAPI void APIENTRY glDepthRangefOES (GLclampf n, GLclampf f); +GLAPI void APIENTRY glFrustumfOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +GLAPI void APIENTRY glGetClipPlanefOES (GLenum plane, GLfloat *equation); +GLAPI void APIENTRY glOrthofOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +#endif +#endif /* GL_OES_single_precision */ + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 +#endif /* GL_3DFX_multisample */ + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 +typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask); +#endif +#endif /* GL_3DFX_tbuffer */ + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif /* GL_3DFX_texture_compression_FXT1 */ + +#ifndef GL_AMD_blend_minmax_factor +#define GL_AMD_blend_minmax_factor 1 +#define GL_FACTOR_MIN_AMD 0x901C +#define GL_FACTOR_MAX_AMD 0x901D +#endif /* GL_AMD_blend_minmax_factor */ + +#ifndef GL_AMD_conservative_depth +#define GL_AMD_conservative_depth 1 +#endif /* GL_AMD_conservative_depth */ + +#ifndef GL_AMD_debug_output +#define GL_AMD_debug_output 1 +typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam); +#define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 +#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 +#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 +#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A +#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B +#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C +#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D +#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E +#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F +#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 +typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#endif +#endif /* GL_AMD_debug_output */ + +#ifndef GL_AMD_depth_clamp_separate +#define GL_AMD_depth_clamp_separate 1 +#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E +#define GL_DEPTH_CLAMP_FAR_AMD 0x901F +#endif /* GL_AMD_depth_clamp_separate */ + +#ifndef GL_AMD_draw_buffers_blend +#define GL_AMD_draw_buffers_blend 1 +typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#endif +#endif /* GL_AMD_draw_buffers_blend */ + +#ifndef GL_AMD_framebuffer_multisample_advanced +#define GL_AMD_framebuffer_multisample_advanced 1 +#define GL_RENDERBUFFER_STORAGE_SAMPLES_AMD 0x91B2 +#define GL_MAX_COLOR_FRAMEBUFFER_SAMPLES_AMD 0x91B3 +#define GL_MAX_COLOR_FRAMEBUFFER_STORAGE_SAMPLES_AMD 0x91B4 +#define GL_MAX_DEPTH_STENCIL_FRAMEBUFFER_SAMPLES_AMD 0x91B5 +#define GL_NUM_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B6 +#define GL_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B7 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleAdvancedAMD (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleAdvancedAMD (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_AMD_framebuffer_multisample_advanced */ + +#ifndef GL_AMD_framebuffer_sample_positions +#define GL_AMD_framebuffer_sample_positions 1 +#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F +#define GL_PIXELS_PER_SAMPLE_PATTERN_X_AMD 0x91AE +#define GL_PIXELS_PER_SAMPLE_PATTERN_Y_AMD 0x91AF +#define GL_ALL_PIXELS_AMD 0xFFFFFFFF +typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLEPOSITIONSFVAMDPROC) (GLenum target, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLEPOSITIONSFVAMDPROC) (GLuint framebuffer, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERFVAMDPROC) (GLenum target, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERFVAMDPROC) (GLuint framebuffer, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferSamplePositionsfvAMD (GLenum target, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +GLAPI void APIENTRY glNamedFramebufferSamplePositionsfvAMD (GLuint framebuffer, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +GLAPI void APIENTRY glGetFramebufferParameterfvAMD (GLenum target, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +GLAPI void APIENTRY glGetNamedFramebufferParameterfvAMD (GLuint framebuffer, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +#endif +#endif /* GL_AMD_framebuffer_sample_positions */ + +#ifndef GL_AMD_gcn_shader +#define GL_AMD_gcn_shader 1 +#endif /* GL_AMD_gcn_shader */ + +#ifndef GL_AMD_gpu_shader_half_float +#define GL_AMD_gpu_shader_half_float 1 +#define GL_FLOAT16_NV 0x8FF8 +#define GL_FLOAT16_VEC2_NV 0x8FF9 +#define GL_FLOAT16_VEC3_NV 0x8FFA +#define GL_FLOAT16_VEC4_NV 0x8FFB +#define GL_FLOAT16_MAT2_AMD 0x91C5 +#define GL_FLOAT16_MAT3_AMD 0x91C6 +#define GL_FLOAT16_MAT4_AMD 0x91C7 +#define GL_FLOAT16_MAT2x3_AMD 0x91C8 +#define GL_FLOAT16_MAT2x4_AMD 0x91C9 +#define GL_FLOAT16_MAT3x2_AMD 0x91CA +#define GL_FLOAT16_MAT3x4_AMD 0x91CB +#define GL_FLOAT16_MAT4x2_AMD 0x91CC +#define GL_FLOAT16_MAT4x3_AMD 0x91CD +#endif /* GL_AMD_gpu_shader_half_float */ + +#ifndef GL_AMD_gpu_shader_int16 +#define GL_AMD_gpu_shader_int16 1 +#endif /* GL_AMD_gpu_shader_int16 */ + +#ifndef GL_AMD_gpu_shader_int64 +#define GL_AMD_gpu_shader_int64 1 +typedef khronos_int64_t GLint64EXT; +#define GL_INT64_NV 0x140E +#define GL_UNSIGNED_INT64_NV 0x140F +#define GL_INT8_NV 0x8FE0 +#define GL_INT8_VEC2_NV 0x8FE1 +#define GL_INT8_VEC3_NV 0x8FE2 +#define GL_INT8_VEC4_NV 0x8FE3 +#define GL_INT16_NV 0x8FE4 +#define GL_INT16_VEC2_NV 0x8FE5 +#define GL_INT16_VEC3_NV 0x8FE6 +#define GL_INT16_VEC4_NV 0x8FE7 +#define GL_INT64_VEC2_NV 0x8FE9 +#define GL_INT64_VEC3_NV 0x8FEA +#define GL_INT64_VEC4_NV 0x8FEB +#define GL_UNSIGNED_INT8_NV 0x8FEC +#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED +#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE +#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF +#define GL_UNSIGNED_INT16_NV 0x8FF0 +#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 +#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 +#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 +#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 +typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); +GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); +GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); +GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); +GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); +GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); +GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_AMD_gpu_shader_int64 */ + +#ifndef GL_AMD_interleaved_elements +#define GL_AMD_interleaved_elements 1 +#define GL_VERTEX_ELEMENT_SWIZZLE_AMD 0x91A4 +#define GL_VERTEX_ID_SWIZZLE_AMD 0x91A5 +typedef void (APIENTRYP PFNGLVERTEXATTRIBPARAMETERIAMDPROC) (GLuint index, GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribParameteriAMD (GLuint index, GLenum pname, GLint param); +#endif +#endif /* GL_AMD_interleaved_elements */ + +#ifndef GL_AMD_multi_draw_indirect +#define GL_AMD_multi_draw_indirect 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); +#endif +#endif /* GL_AMD_multi_draw_indirect */ + +#ifndef GL_AMD_name_gen_delete +#define GL_AMD_name_gen_delete 1 +#define GL_DATA_BUFFER_AMD 0x9151 +#define GL_PERFORMANCE_MONITOR_AMD 0x9152 +#define GL_QUERY_OBJECT_AMD 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 +#define GL_SAMPLER_OBJECT_AMD 0x9155 +typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names); +typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names); +typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names); +GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names); +GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name); +#endif +#endif /* GL_AMD_name_gen_delete */ + +#ifndef GL_AMD_occlusion_query_event +#define GL_AMD_occlusion_query_event 1 +#define GL_OCCLUSION_QUERY_EVENT_MASK_AMD 0x874F +#define GL_QUERY_DEPTH_PASS_EVENT_BIT_AMD 0x00000001 +#define GL_QUERY_DEPTH_FAIL_EVENT_BIT_AMD 0x00000002 +#define GL_QUERY_STENCIL_FAIL_EVENT_BIT_AMD 0x00000004 +#define GL_QUERY_DEPTH_BOUNDS_FAIL_EVENT_BIT_AMD 0x00000008 +#define GL_QUERY_ALL_EVENT_BITS_AMD 0xFFFFFFFF +typedef void (APIENTRYP PFNGLQUERYOBJECTPARAMETERUIAMDPROC) (GLenum target, GLuint id, GLenum pname, GLuint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glQueryObjectParameteruiAMD (GLenum target, GLuint id, GLenum pname, GLuint param); +#endif +#endif /* GL_AMD_occlusion_query_event */ + +#ifndef GL_AMD_performance_monitor +#define GL_AMD_performance_monitor 1 +#define GL_COUNTER_TYPE_AMD 0x8BC0 +#define GL_COUNTER_RANGE_AMD 0x8BC1 +#define GL_UNSIGNED_INT64_AMD 0x8BC2 +#define GL_PERCENTAGE_AMD 0x8BC3 +#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 +#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 +#define GL_PERFMON_RESULT_AMD 0x8BC6 +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data); +typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, void *data); +GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif +#endif /* GL_AMD_performance_monitor */ + +#ifndef GL_AMD_pinned_memory +#define GL_AMD_pinned_memory 1 +#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 +#endif /* GL_AMD_pinned_memory */ + +#ifndef GL_AMD_query_buffer_object +#define GL_AMD_query_buffer_object 1 +#define GL_QUERY_BUFFER_AMD 0x9192 +#define GL_QUERY_BUFFER_BINDING_AMD 0x9193 +#define GL_QUERY_RESULT_NO_WAIT_AMD 0x9194 +#endif /* GL_AMD_query_buffer_object */ + +#ifndef GL_AMD_sample_positions +#define GL_AMD_sample_positions 1 +typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); +#endif +#endif /* GL_AMD_sample_positions */ + +#ifndef GL_AMD_seamless_cubemap_per_texture +#define GL_AMD_seamless_cubemap_per_texture 1 +#endif /* GL_AMD_seamless_cubemap_per_texture */ + +#ifndef GL_AMD_shader_atomic_counter_ops +#define GL_AMD_shader_atomic_counter_ops 1 +#endif /* GL_AMD_shader_atomic_counter_ops */ + +#ifndef GL_AMD_shader_ballot +#define GL_AMD_shader_ballot 1 +#endif /* GL_AMD_shader_ballot */ + +#ifndef GL_AMD_shader_explicit_vertex_parameter +#define GL_AMD_shader_explicit_vertex_parameter 1 +#endif /* GL_AMD_shader_explicit_vertex_parameter */ + +#ifndef GL_AMD_shader_gpu_shader_half_float_fetch +#define GL_AMD_shader_gpu_shader_half_float_fetch 1 +#endif /* GL_AMD_shader_gpu_shader_half_float_fetch */ + +#ifndef GL_AMD_shader_image_load_store_lod +#define GL_AMD_shader_image_load_store_lod 1 +#endif /* GL_AMD_shader_image_load_store_lod */ + +#ifndef GL_AMD_shader_stencil_export +#define GL_AMD_shader_stencil_export 1 +#endif /* GL_AMD_shader_stencil_export */ + +#ifndef GL_AMD_shader_trinary_minmax +#define GL_AMD_shader_trinary_minmax 1 +#endif /* GL_AMD_shader_trinary_minmax */ + +#ifndef GL_AMD_sparse_texture +#define GL_AMD_sparse_texture 1 +#define GL_VIRTUAL_PAGE_SIZE_X_AMD 0x9195 +#define GL_VIRTUAL_PAGE_SIZE_Y_AMD 0x9196 +#define GL_VIRTUAL_PAGE_SIZE_Z_AMD 0x9197 +#define GL_MAX_SPARSE_TEXTURE_SIZE_AMD 0x9198 +#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD 0x9199 +#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS 0x919A +#define GL_MIN_SPARSE_LEVEL_AMD 0x919B +#define GL_MIN_LOD_WARNING_AMD 0x919C +#define GL_TEXTURE_STORAGE_SPARSE_BIT_AMD 0x00000001 +typedef void (APIENTRYP PFNGLTEXSTORAGESPARSEAMDPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +typedef void (APIENTRYP PFNGLTEXTURESTORAGESPARSEAMDPROC) (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexStorageSparseAMD (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +GLAPI void APIENTRY glTextureStorageSparseAMD (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +#endif +#endif /* GL_AMD_sparse_texture */ + +#ifndef GL_AMD_stencil_operation_extended +#define GL_AMD_stencil_operation_extended 1 +#define GL_SET_AMD 0x874A +#define GL_REPLACE_VALUE_AMD 0x874B +#define GL_STENCIL_OP_VALUE_AMD 0x874C +#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D +typedef void (APIENTRYP PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); +#endif +#endif /* GL_AMD_stencil_operation_extended */ + +#ifndef GL_AMD_texture_gather_bias_lod +#define GL_AMD_texture_gather_bias_lod 1 +#endif /* GL_AMD_texture_gather_bias_lod */ + +#ifndef GL_AMD_texture_texture4 +#define GL_AMD_texture_texture4 1 +#endif /* GL_AMD_texture_texture4 */ + +#ifndef GL_AMD_transform_feedback3_lines_triangles +#define GL_AMD_transform_feedback3_lines_triangles 1 +#endif /* GL_AMD_transform_feedback3_lines_triangles */ + +#ifndef GL_AMD_transform_feedback4 +#define GL_AMD_transform_feedback4 1 +#define GL_STREAM_RASTERIZATION_AMD 0x91A0 +#endif /* GL_AMD_transform_feedback4 */ + +#ifndef GL_AMD_vertex_shader_layer +#define GL_AMD_vertex_shader_layer 1 +#endif /* GL_AMD_vertex_shader_layer */ + +#ifndef GL_AMD_vertex_shader_tessellator +#define GL_AMD_vertex_shader_tessellator 1 +#define GL_SAMPLER_BUFFER_AMD 0x9001 +#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 +#define GL_TESSELLATION_MODE_AMD 0x9004 +#define GL_TESSELLATION_FACTOR_AMD 0x9005 +#define GL_DISCRETE_AMD 0x9006 +#define GL_CONTINUOUS_AMD 0x9007 +typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor); +GLAPI void APIENTRY glTessellationModeAMD (GLenum mode); +#endif +#endif /* GL_AMD_vertex_shader_tessellator */ + +#ifndef GL_AMD_vertex_shader_viewport_index +#define GL_AMD_vertex_shader_viewport_index 1 +#endif /* GL_AMD_vertex_shader_viewport_index */ + +#ifndef GL_APPLE_aux_depth_stencil +#define GL_APPLE_aux_depth_stencil 1 +#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 +#endif /* GL_APPLE_aux_depth_stencil */ + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif /* GL_APPLE_client_storage */ + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#define GL_ELEMENT_ARRAY_APPLE 0x8A0C +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E +typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const void *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const void *pointer); +GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif +#endif /* GL_APPLE_element_array */ + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B +typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); +typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); +typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences); +GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence); +GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name); +GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name); +#endif +#endif /* GL_APPLE_fence */ + +#ifndef GL_APPLE_float_pixels +#define GL_APPLE_float_pixels 1 +#define GL_HALF_APPLE 0x140B +#define GL_RGBA_FLOAT32_APPLE 0x8814 +#define GL_RGB_FLOAT32_APPLE 0x8815 +#define GL_ALPHA_FLOAT32_APPLE 0x8816 +#define GL_INTENSITY_FLOAT32_APPLE 0x8817 +#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 +#define GL_RGBA_FLOAT16_APPLE 0x881A +#define GL_RGB_FLOAT16_APPLE 0x881B +#define GL_ALPHA_FLOAT16_APPLE 0x881C +#define GL_INTENSITY_FLOAT16_APPLE 0x881D +#define GL_LUMINANCE_FLOAT16_APPLE 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F +#define GL_COLOR_FLOAT_APPLE 0x8A0F +#endif /* GL_APPLE_float_pixels */ + +#ifndef GL_APPLE_flush_buffer_range +#define GL_APPLE_flush_buffer_range 1 +#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 +#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 +typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size); +#endif +#endif /* GL_APPLE_flush_buffer_range */ + +#ifndef GL_APPLE_object_purgeable +#define GL_APPLE_object_purgeable 1 +#define GL_BUFFER_OBJECT_APPLE 0x85B3 +#define GL_RELEASED_APPLE 0x8A19 +#define GL_VOLATILE_APPLE 0x8A1A +#define GL_RETAINED_APPLE 0x8A1B +#define GL_UNDEFINED_APPLE 0x8A1C +#define GL_PURGEABLE_APPLE 0x8A1D +typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params); #endif +#endif /* GL_APPLE_object_purgeable */ -#ifndef GL_ARB_fragment_program -#define GL_ARB_fragment_program 1 -/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#define GL_RGB_422_APPLE 0x8A1F +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#define GL_RGB_RAW_422_APPLE 0x8A51 +#endif /* GL_APPLE_rgb_422 */ + +#ifndef GL_APPLE_row_bytes +#define GL_APPLE_row_bytes 1 +#define GL_PACK_ROW_BYTES_APPLE 0x8A15 +#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 +#endif /* GL_APPLE_row_bytes */ + +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 +#endif /* GL_APPLE_specular_vector */ + +#ifndef GL_APPLE_texture_range +#define GL_APPLE_texture_range 1 +#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 +#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 +#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC +#define GL_STORAGE_PRIVATE_APPLE 0x85BD +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF +typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const void *pointer); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const void *pointer); +GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, void **params); #endif +#endif /* GL_APPLE_texture_range */ -#ifndef GL_ARB_vertex_buffer_object -#define GL_ARB_vertex_buffer_object 1 +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 +#define GL_TRANSFORM_HINT_APPLE 0x85B1 +#endif /* GL_APPLE_transform_hint */ + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindBufferARB (GLenum, GLuint); -GLAPI void APIENTRY glDeleteBuffersARB (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenBuffersARB (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsBufferARB (GLuint); -GLAPI void APIENTRY glBufferDataARB (GLenum, GLsizeiptrARB, const GLvoid *, GLenum); -GLAPI void APIENTRY glBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *); -GLAPI void APIENTRY glGetBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *); -GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum, GLenum); -GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum); -GLAPI void APIENTRY glGetBufferParameterivARB (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetBufferPointervARB (GLenum, GLenum, GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); +GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array); +GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array); #endif +#endif /* GL_APPLE_vertex_array_object */ -#ifndef GL_ARB_occlusion_query -#define GL_ARB_occlusion_query 1 +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CLIENT_APPLE 0x85B4 +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); +typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueriesARB (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteQueriesARB (GLsizei, const GLuint *); -GLAPI GLboolean APIENTRY glIsQueryARB (GLuint); -GLAPI void APIENTRY glBeginQueryARB (GLenum, GLuint); -GLAPI void APIENTRY glEndQueryARB (GLenum); -GLAPI void APIENTRY glGetQueryivARB (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectivARB (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint, GLenum, GLuint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, void *pointer); +GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, void *pointer); +GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param); +#endif +#endif /* GL_APPLE_vertex_array_range */ + +#ifndef GL_APPLE_vertex_program_evaluators +#define GL_APPLE_vertex_program_evaluators 1 +#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 +#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 +#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 +#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 +#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 +#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 +#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 +#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 +#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 +#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); #endif +#endif /* GL_APPLE_vertex_program_evaluators */ -#ifndef GL_ARB_shader_objects -#define GL_ARB_shader_objects 1 +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#define GL_YCBCR_422_APPLE 0x85B9 +#endif /* GL_APPLE_ycbcr_422 */ + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 +typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB); -GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum); -GLAPI void APIENTRY glDetachObjectARB (GLhandleARB, GLhandleARB); -GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum); -GLAPI void APIENTRY glShaderSourceARB (GLhandleARB, GLsizei, const GLcharARB* *, const GLint *); -GLAPI void APIENTRY glCompileShaderARB (GLhandleARB); -GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); -GLAPI void APIENTRY glAttachObjectARB (GLhandleARB, GLhandleARB); -GLAPI void APIENTRY glLinkProgramARB (GLhandleARB); -GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB); -GLAPI void APIENTRY glValidateProgramARB (GLhandleARB); -GLAPI void APIENTRY glUniform1fARB (GLint, GLfloat); -GLAPI void APIENTRY glUniform2fARB (GLint, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform3fARB (GLint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform4fARB (GLint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform1iARB (GLint, GLint); -GLAPI void APIENTRY glUniform2iARB (GLint, GLint, GLint); -GLAPI void APIENTRY glUniform3iARB (GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform4iARB (GLint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform1fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform2fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform3fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform4fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform1ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform2ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform3ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform4ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniformMatrix2fvARB (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix3fvARB (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix4fvARB (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB, GLenum, GLfloat *); -GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB, GLenum, GLint *); -GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); -GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); -GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB, const GLcharARB *); -GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); -GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB, GLint, GLfloat *); -GLAPI void APIENTRY glGetUniformivARB (GLhandleARB, GLint, GLint *); -GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); -typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); -typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); -typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); -typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); -typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); -typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs); +#endif +#endif /* GL_ATI_draw_buffers */ + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A +typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const void *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerATI (GLenum type, const void *pointer); +GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif +#endif /* GL_ATI_element_array */ + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param); +GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param); +GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param); #endif +#endif /* GL_ATI_envmap_bumpmap */ + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range); +GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glBeginFragmentShaderATI (void); +GLAPI void APIENTRY glEndFragmentShaderATI (void); +GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle); +GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle); +GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value); +#endif +#endif /* GL_ATI_fragment_shader */ -#ifndef GL_ARB_vertex_shader -#define GL_ARB_vertex_shader 1 +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 +typedef void *(APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB, GLuint, const GLcharARB *); -GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); -GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB, const GLcharARB *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +GLAPI void *APIENTRY glMapObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer); #endif +#endif /* GL_ATI_map_object_buffer */ -#ifndef GL_ARB_fragment_shader -#define GL_ARB_fragment_shader 1 -#endif +#ifndef GL_ATI_meminfo +#define GL_ATI_meminfo 1 +#define GL_VBO_FREE_MEMORY_ATI 0x87FB +#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC +#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD +#endif /* GL_ATI_meminfo */ -#ifndef GL_ARB_shading_language_100 -#define GL_ARB_shading_language_100 1 -#endif +#ifndef GL_ATI_pixel_format_float +#define GL_ATI_pixel_format_float 1 +#define GL_RGBA_FLOAT_MODE_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 +#endif /* GL_ATI_pixel_format_float */ -#ifndef GL_ARB_texture_non_power_of_two -#define GL_ARB_texture_non_power_of_two 1 +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 +typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param); +GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param); #endif +#endif /* GL_ATI_pn_triangles */ -#ifndef GL_ARB_point_sprite -#define GL_ARB_point_sprite 1 +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); #endif +#endif /* GL_ATI_separate_stencil */ -#ifndef GL_ARB_fragment_program_shadow -#define GL_ARB_fragment_program_shadow 1 -#endif +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif /* GL_ATI_text_fragment_shader */ -#ifndef GL_ARB_draw_buffers -#define GL_ARB_draw_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersARB (GLsizei, const GLenum *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); -#endif +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif /* GL_ATI_texture_env_combine3 */ -#ifndef GL_ARB_texture_rectangle -#define GL_ARB_texture_rectangle 1 -#endif +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif /* GL_ATI_texture_float */ -#ifndef GL_ARB_color_buffer_float -#define GL_ARB_color_buffer_float 1 +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif /* GL_ATI_texture_mirror_once */ + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 +typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const void *pointer, GLenum usage); +typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClampColorARB (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); -#endif +GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const void *pointer, GLenum usage); +GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); +GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params); +GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params); +#endif +#endif /* GL_ATI_vertex_array_object */ -#ifndef GL_ARB_half_float_pixel -#define GL_ARB_half_float_pixel 1 +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 +typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params); #endif +#endif /* GL_ATI_vertex_attrib_array_object */ -#ifndef GL_ARB_texture_float -#define GL_ARB_texture_float 1 -#endif +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x); +GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x); +GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x); +GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x); +GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y); +GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords); +GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz); +GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream); +GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param); +GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); +#endif +#endif /* GL_ATI_vertex_streams */ -#ifndef GL_ARB_pixel_buffer_object -#define GL_ARB_pixel_buffer_object 1 +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF +#endif /* GL_EXT_422_pixels */ + +#ifndef GL_EXT_EGL_image_storage +#define GL_EXT_EGL_image_storage 1 +typedef void *GLeglImageOES; +typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC) (GLenum target, GLeglImageOES image, const GLint* attrib_list); +typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC) (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEGLImageTargetTexStorageEXT (GLenum target, GLeglImageOES image, const GLint* attrib_list); +GLAPI void APIENTRY glEGLImageTargetTextureStorageEXT (GLuint texture, GLeglImageOES image, const GLint* attrib_list); #endif +#endif /* GL_EXT_EGL_image_storage */ #ifndef GL_EXT_abgr #define GL_EXT_abgr 1 +#define GL_ABGR_EXT 0x8000 +#endif /* GL_EXT_abgr */ + +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 +#endif /* GL_EXT_bgra */ + +#ifndef GL_EXT_bindable_uniform +#define GL_EXT_bindable_uniform 1 +#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 +#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 +#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 +#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED +#define GL_UNIFORM_BUFFER_EXT 0x8DEE +#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF +typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); +typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); +typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer); +GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location); +GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location); #endif +#endif /* GL_EXT_bindable_uniform */ #ifndef GL_EXT_blend_color #define GL_EXT_blend_color 1 +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 +typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColorEXT (GLclampf, GLclampf, GLclampf, GLclampf); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +GLAPI void APIENTRY glBlendColorEXT (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); #endif +#endif /* GL_EXT_blend_color */ -#ifndef GL_EXT_polygon_offset -#define GL_EXT_polygon_offset 1 +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 +#define GL_BLEND_EQUATION_RGB_EXT 0x8009 +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat, GLfloat); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha); #endif +#endif /* GL_EXT_blend_equation_separate */ -#ifndef GL_EXT_texture -#define GL_EXT_texture 1 +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); #endif +#endif /* GL_EXT_blend_func_separate */ -#ifndef GL_EXT_texture3D -#define GL_EXT_texture3D 1 +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 +#endif /* GL_EXT_blend_logic_op */ + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_BLEND_EQUATION_EXT 0x8009 +typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationEXT (GLenum mode); +#endif +#endif /* GL_EXT_blend_minmax */ + +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B +#endif /* GL_EXT_blend_subtract */ + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 +#endif /* GL_EXT_clip_volume_hint */ + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F +#endif /* GL_EXT_cmyka */ + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 +typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage3DEXT (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); #endif +#endif /* GL_EXT_color_subtable */ -#ifndef GL_SGIS_texture_filter4 -#define GL_SGIS_texture_filter4 1 +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 +#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 +#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 +typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum, GLenum, GLsizei, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); -typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count); +GLAPI void APIENTRY glUnlockArraysEXT (void); #endif +#endif /* GL_EXT_compiled_vertex_array */ -#ifndef GL_EXT_subtexture -#define GL_EXT_subtexture 1 +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexSubImage1DEXT (GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -#endif +GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, void *image); +GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +#endif +#endif /* GL_EXT_convolution */ + +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 +typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); +typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); +typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); +typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); +typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); +typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); +typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); +typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); +typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); +typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); +typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz); +GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz); +GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz); +GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz); +GLAPI void APIENTRY glTangent3ivEXT (const GLint *v); +GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz); +GLAPI void APIENTRY glTangent3svEXT (const GLshort *v); +GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz); +GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz); +GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz); +GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz); +GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v); +GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz); +GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v); +GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_coordinate_frame */ #ifndef GL_EXT_copy_texture #define GL_EXT_copy_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); -GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); -GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei); -GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); #endif +#endif /* GL_EXT_copy_texture */ -#ifndef GL_EXT_histogram -#define GL_EXT_histogram 1 +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC +typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetHistogramEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMinmaxEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glHistogramEXT (GLenum, GLsizei, GLenum, GLboolean); -GLAPI void APIENTRY glMinmaxEXT (GLenum, GLenum, GLboolean); -GLAPI void APIENTRY glResetHistogramEXT (GLenum); -GLAPI void APIENTRY glResetMinmaxEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); +GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params); +GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_cull_vertex */ + +#ifndef GL_EXT_debug_label +#define GL_EXT_debug_label 1 +#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F +#define GL_PROGRAM_OBJECT_EXT 0x8B40 +#define GL_SHADER_OBJECT_EXT 0x8B48 +#define GL_BUFFER_OBJECT_EXT 0x9151 +#define GL_QUERY_OBJECT_EXT 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 +typedef void (APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); #endif +#endif /* GL_EXT_debug_label */ -#ifndef GL_EXT_convolution -#define GL_EXT_convolution 1 +#ifndef GL_EXT_debug_marker +#define GL_EXT_debug_marker 1 +typedef void (APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum, GLenum, GLint); -GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); -GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +GLAPI void APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker); +GLAPI void APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker); +GLAPI void APIENTRY glPopGroupMarkerEXT (void); #endif +#endif /* GL_EXT_debug_marker */ -#ifndef GL_EXT_color_matrix -#define GL_EXT_color_matrix 1 +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 +typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax); +#endif +#endif /* GL_EXT_depth_bounds_test */ + +#ifndef GL_EXT_direct_state_access +#define GL_EXT_direct_state_access 1 +#define GL_PROGRAM_MATRIX_EXT 0x8E2D +#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E +#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F +typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); +typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, void **data); +typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, void *img); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, void *img); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, void **params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, void **params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, void *string); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); +typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYINDEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYNORMALOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERVEXTPROC) (GLuint vaobj, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERVEXTPROC) (GLuint vaobj, GLenum pname, void **param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, void **param); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLTEXTUREPAGECOMMITMENTEXTPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBDIVISOREXTPROC) (GLuint vaobj, GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); +GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); +GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); +GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); +GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); +GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, void **data); +GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, void *img); +GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, void *img); +GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void *APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); +GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); +GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, void **params); +GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glEnableClientStateiEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateiEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glGetFloati_vEXT (GLenum pname, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetDoublei_vEXT (GLenum pname, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetPointeri_vEXT (GLenum pname, GLuint index, void **params); +GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); +GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, void *string); +GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); +GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); +GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); +GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glVertexArrayVertexOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayEdgeFlagOffsetEXT (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayIndexOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayNormalOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayMultiTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayFogCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArraySecondaryColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayVertexAttribOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayVertexAttribIOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glEnableVertexArrayEXT (GLuint vaobj, GLenum array); +GLAPI void APIENTRY glDisableVertexArrayEXT (GLuint vaobj, GLenum array); +GLAPI void APIENTRY glEnableVertexArrayAttribEXT (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glDisableVertexArrayAttribEXT (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glGetVertexArrayIntegervEXT (GLuint vaobj, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayPointervEXT (GLuint vaobj, GLenum pname, void **param); +GLAPI void APIENTRY glGetVertexArrayIntegeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayPointeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, void **param); +GLAPI void *APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glNamedBufferStorageEXT (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param); +GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); +GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glTexturePageCommitmentEXT (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +GLAPI void APIENTRY glVertexArrayVertexAttribDivisorEXT (GLuint vaobj, GLuint index, GLuint divisor); +#endif +#endif /* GL_EXT_direct_state_access */ + +#ifndef GL_EXT_draw_buffers2 +#define GL_EXT_draw_buffers2 1 +typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); #endif +#endif /* GL_EXT_draw_buffers2 */ -#ifndef GL_SGI_color_table -#define GL_SGI_color_table 1 +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableSGI (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glColorTableParameterivSGI (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyColorTableSGI (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glGetColorTableSGI (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); #endif +#endif /* GL_EXT_draw_instanced */ -#ifndef GL_SGIX_pixel_texture -#define GL_SGIX_pixel_texture 1 +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenSGIX (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); +GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); #endif +#endif /* GL_EXT_draw_range_elements */ -#ifndef GL_SGIS_pixel_texture -#define GL_SGIS_pixel_texture 1 +#ifndef GL_EXT_external_buffer +#define GL_EXT_external_buffer 1 +typedef void *GLeglClientBufferEXT; +typedef void (APIENTRYP PFNGLBUFFERSTORAGEEXTERNALEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum, GLint); -GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum, const GLint *); -GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum, GLfloat); -GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum, const GLfloat *); -GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum, GLint *); -GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); +GLAPI void APIENTRY glBufferStorageExternalEXT (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +GLAPI void APIENTRY glNamedBufferStorageExternalEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); #endif +#endif /* GL_EXT_external_buffer */ -#ifndef GL_SGIS_texture4D -#define GL_SGIS_texture4D 1 +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage4DSGIS (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord); +GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord); +GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord); +GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_fog_coord */ + +#ifndef GL_EXT_framebuffer_blit +#define GL_EXT_framebuffer_blit 1 +#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); #endif +#endif /* GL_EXT_framebuffer_blit */ -#ifndef GL_SGI_texture_color_table -#define GL_SGI_texture_color_table 1 +#ifndef GL_EXT_framebuffer_multisample +#define GL_EXT_framebuffer_multisample 1 +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); #endif +#endif /* GL_EXT_framebuffer_multisample */ -#ifndef GL_EXT_cmyka -#define GL_EXT_cmyka 1 +#ifndef GL_EXT_framebuffer_multisample_blit_scaled +#define GL_EXT_framebuffer_multisample_blit_scaled 1 +#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA +#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB +#endif /* GL_EXT_framebuffer_multisample_blit_scaled */ + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target); +#endif +#endif /* GL_EXT_framebuffer_object */ + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_EXT_framebuffer_sRGB 1 +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA +#endif /* GL_EXT_framebuffer_sRGB */ + +#ifndef GL_EXT_geometry_shader4 +#define GL_EXT_geometry_shader4 1 +#define GL_GEOMETRY_SHADER_EXT 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE +#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 +#define GL_LINES_ADJACENCY_EXT 0x000A +#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B +#define GL_TRIANGLES_ADJACENCY_EXT 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 +#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); #endif +#endif /* GL_EXT_geometry_shader4 */ -#ifndef GL_EXT_texture_object -#define GL_EXT_texture_object 1 +#ifndef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 1 +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#endif +#endif /* GL_EXT_gpu_program_parameters */ + +#ifndef GL_EXT_gpu_shader4 +#define GL_EXT_gpu_shader4 1 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD +#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 +#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 +#define GL_SAMPLER_BUFFER_EXT 0x8DC2 +#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 +#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 +#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 +#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 +#define GL_INT_SAMPLER_1D_EXT 0x8DC9 +#define GL_INT_SAMPLER_2D_EXT 0x8DCA +#define GL_INT_SAMPLER_3D_EXT 0x8DCB +#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC +#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD +#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF +#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_EXT 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_EXT 0x8905 +typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value); +#endif +#endif /* GL_EXT_gpu_shader4 */ + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 +#define GL_TABLE_TOO_LARGE_EXT 0x8031 +typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); #ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei, const GLuint *, GLboolean *); -GLAPI void APIENTRY glBindTextureEXT (GLenum, GLuint); -GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenTexturesEXT (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint); -GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei, const GLuint *, const GLclampf *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); -typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); -typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); -typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); -#endif +GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogramEXT (GLenum target); +GLAPI void APIENTRY glResetMinmaxEXT (GLenum target); +#endif +#endif /* GL_EXT_histogram */ -#ifndef GL_SGIS_detail_texture -#define GL_SGIS_detail_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum, GLsizei, const GLfloat *); -GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#endif +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 +#endif /* GL_EXT_index_array_formats */ -#ifndef GL_SGIS_sharpen_texture -#define GL_SGIS_sharpen_texture 1 +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 +typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum, GLsizei, const GLfloat *); -GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#endif - -#ifndef GL_EXT_packed_pixels -#define GL_EXT_packed_pixels 1 +GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref); #endif +#endif /* GL_EXT_index_func */ -#ifndef GL_SGIS_texture_lod -#define GL_SGIS_texture_lod 1 -#endif - -#ifndef GL_SGIS_multisample -#define GL_SGIS_multisample 1 +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA +typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskSGIS (GLclampf, GLboolean); -GLAPI void APIENTRY glSamplePatternSGIS (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); +GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode); #endif +#endif /* GL_EXT_index_material */ -#ifndef GL_EXT_rescale_normal -#define GL_EXT_rescale_normal 1 -#endif +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 +#endif /* GL_EXT_index_texture */ -#ifndef GL_EXT_vertex_array -#define GL_EXT_vertex_array 1 +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glArrayElementEXT (GLint); -GLAPI void APIENTRY glColorPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glDrawArraysEXT (GLenum, GLint, GLsizei); -GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei, GLsizei, const GLboolean *); -GLAPI void APIENTRY glGetPointervEXT (GLenum, GLvoid* *); -GLAPI void APIENTRY glIndexPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glNormalPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glTexCoordPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glVertexPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); -typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); -typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); -typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glApplyTextureEXT (GLenum mode); +GLAPI void APIENTRY glTextureLightEXT (GLenum pname); +GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); +#endif +#endif /* GL_EXT_light_texture */ + +#ifndef GL_EXT_memory_object +#define GL_EXT_memory_object 1 +#define GL_TEXTURE_TILING_EXT 0x9580 +#define GL_DEDICATED_MEMORY_OBJECT_EXT 0x9581 +#define GL_PROTECTED_MEMORY_OBJECT_EXT 0x959B +#define GL_NUM_TILING_TYPES_EXT 0x9582 +#define GL_TILING_TYPES_EXT 0x9583 +#define GL_OPTIMAL_TILING_EXT 0x9584 +#define GL_LINEAR_TILING_EXT 0x9585 +#define GL_NUM_DEVICE_UUIDS_EXT 0x9596 +#define GL_DEVICE_UUID_EXT 0x9597 +#define GL_DRIVER_UUID_EXT 0x9598 +#define GL_UUID_SIZE_EXT 16 +typedef void (APIENTRYP PFNGLGETUNSIGNEDBYTEVEXTPROC) (GLenum pname, GLubyte *data); +typedef void (APIENTRYP PFNGLGETUNSIGNEDBYTEI_VEXTPROC) (GLenum target, GLuint index, GLubyte *data); +typedef void (APIENTRYP PFNGLDELETEMEMORYOBJECTSEXTPROC) (GLsizei n, const GLuint *memoryObjects); +typedef GLboolean (APIENTRYP PFNGLISMEMORYOBJECTEXTPROC) (GLuint memoryObject); +typedef void (APIENTRYP PFNGLCREATEMEMORYOBJECTSEXTPROC) (GLsizei n, GLuint *memoryObjects); +typedef void (APIENTRYP PFNGLMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLBUFFERSTORAGEMEMEXTPROC) (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM2DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM3DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC) (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM1DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUnsignedBytevEXT (GLenum pname, GLubyte *data); +GLAPI void APIENTRY glGetUnsignedBytei_vEXT (GLenum target, GLuint index, GLubyte *data); +GLAPI void APIENTRY glDeleteMemoryObjectsEXT (GLsizei n, const GLuint *memoryObjects); +GLAPI GLboolean APIENTRY glIsMemoryObjectEXT (GLuint memoryObject); +GLAPI void APIENTRY glCreateMemoryObjectsEXT (GLsizei n, GLuint *memoryObjects); +GLAPI void APIENTRY glMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, GLint *params); +GLAPI void APIENTRY glTexStorageMem2DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem2DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem3DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem3DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glBufferStorageMemEXT (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem2DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem2DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem3DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem3DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glNamedBufferStorageMemEXT (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem1DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem1DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +#endif +#endif /* GL_EXT_memory_object */ + +#ifndef GL_EXT_memory_object_fd +#define GL_EXT_memory_object_fd 1 +#define GL_HANDLE_TYPE_OPAQUE_FD_EXT 0x9586 +typedef void (APIENTRYP PFNGLIMPORTMEMORYFDEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportMemoryFdEXT (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); +#endif +#endif /* GL_EXT_memory_object_fd */ + +#ifndef GL_EXT_memory_object_win32 +#define GL_EXT_memory_object_win32 1 +#define GL_HANDLE_TYPE_OPAQUE_WIN32_EXT 0x9587 +#define GL_HANDLE_TYPE_OPAQUE_WIN32_KMT_EXT 0x9588 +#define GL_DEVICE_LUID_EXT 0x9599 +#define GL_DEVICE_NODE_MASK_EXT 0x959A +#define GL_LUID_SIZE_EXT 8 +#define GL_HANDLE_TYPE_D3D12_TILEPOOL_EXT 0x9589 +#define GL_HANDLE_TYPE_D3D12_RESOURCE_EXT 0x958A +#define GL_HANDLE_TYPE_D3D11_IMAGE_EXT 0x958B +#define GL_HANDLE_TYPE_D3D11_IMAGE_KMT_EXT 0x958C +typedef void (APIENTRYP PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, void *handle); +typedef void (APIENTRYP PFNGLIMPORTMEMORYWIN32NAMEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, const void *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportMemoryWin32HandleEXT (GLuint memory, GLuint64 size, GLenum handleType, void *handle); +GLAPI void APIENTRY glImportMemoryWin32NameEXT (GLuint memory, GLuint64 size, GLenum handleType, const void *name); #endif +#endif /* GL_EXT_memory_object_win32 */ #ifndef GL_EXT_misc_attribute #define GL_EXT_misc_attribute 1 -#endif - -#ifndef GL_SGIS_generate_mipmap -#define GL_SGIS_generate_mipmap 1 -#endif - -#ifndef GL_SGIX_clipmap -#define GL_SGIX_clipmap 1 -#endif - -#ifndef GL_SGIX_shadow -#define GL_SGIX_shadow 1 -#endif - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_SGIS_texture_edge_clamp 1 -#endif - -#ifndef GL_SGIS_texture_border_clamp -#define GL_SGIS_texture_border_clamp 1 -#endif +#endif /* GL_EXT_misc_attribute */ -#ifndef GL_EXT_blend_minmax -#define GL_EXT_blend_minmax 1 +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); -#endif - -#ifndef GL_EXT_blend_subtract -#define GL_EXT_blend_subtract 1 +GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); #endif +#endif /* GL_EXT_multi_draw_arrays */ -#ifndef GL_EXT_blend_logic_op -#define GL_EXT_blend_logic_op 1 -#endif +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 +typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern); +#endif +#endif /* GL_EXT_multisample */ + +#ifndef GL_EXT_multiview_tessellation_geometry_shader +#define GL_EXT_multiview_tessellation_geometry_shader 1 +#endif /* GL_EXT_multiview_tessellation_geometry_shader */ + +#ifndef GL_EXT_multiview_texture_multisample +#define GL_EXT_multiview_texture_multisample 1 +#endif /* GL_EXT_multiview_texture_multisample */ + +#ifndef GL_EXT_multiview_timer_query +#define GL_EXT_multiview_timer_query 1 +#endif /* GL_EXT_multiview_timer_query */ + +#ifndef GL_EXT_packed_depth_stencil +#define GL_EXT_packed_depth_stencil 1 +#define GL_DEPTH_STENCIL_EXT 0x84F9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84FA +#define GL_DEPTH24_STENCIL8_EXT 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 +#endif /* GL_EXT_packed_depth_stencil */ + +#ifndef GL_EXT_packed_float +#define GL_EXT_packed_float 1 +#define GL_R11F_G11F_B10F_EXT 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B +#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C +#endif /* GL_EXT_packed_float */ -#ifndef GL_SGIX_interlace -#define GL_SGIX_interlace 1 -#endif +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 +#endif /* GL_EXT_packed_pixels */ -#ifndef GL_SGIX_pixel_tiles -#define GL_SGIX_pixel_tiles 1 +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, void *data); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table); +GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, void *data); +GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); #endif +#endif /* GL_EXT_paletted_texture */ -#ifndef GL_SGIX_texture_select -#define GL_SGIX_texture_select 1 -#endif +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF +#endif /* GL_EXT_pixel_buffer_object */ -#ifndef GL_SGIX_sprite -#define GL_SGIX_sprite 1 +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum, GLfloat); -GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum, const GLfloat *); -GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum, GLint); -GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum, const GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTransformParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTransformParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); #endif +#endif /* GL_EXT_pixel_transform */ -#ifndef GL_SGIX_texture_multi_buffer -#define GL_SGIX_texture_multi_buffer 1 -#endif +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 +#endif /* GL_EXT_pixel_transform_color_table */ #ifndef GL_EXT_point_parameters #define GL_EXT_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfEXT (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfvEXT (GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_SGIS_point_parameters -#define GL_SGIS_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfSGIS (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfvSGIS (GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_SGIX_instruments -#define GL_SGIX_instruments 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); -GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei, GLint *); -GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *); -GLAPI void APIENTRY glReadInstrumentsSGIX (GLint); -GLAPI void APIENTRY glStartInstrumentsSGIX (void); -GLAPI void APIENTRY glStopInstrumentsSGIX (GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); -typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); -typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); -typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); -#endif - -#ifndef GL_SGIX_texture_scale_bias -#define GL_SGIX_texture_scale_bias 1 -#endif - -#ifndef GL_SGIX_framezoom -#define GL_SGIX_framezoom 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFrameZoomSGIX (GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); -#endif - -#ifndef GL_SGIX_tag_sample_buffer -#define GL_SGIX_tag_sample_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTagSampleBufferSGIX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); -#endif - -#ifndef GL_SGIX_polynomial_ffd -#define GL_SGIX_polynomial_ffd 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *); -GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *); -GLAPI void APIENTRY glDeformSGIX (GLbitfield); -GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); -typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); -#endif - -#ifndef GL_SGIX_reference_plane -#define GL_SGIX_reference_plane 1 #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); -#endif - -#ifndef GL_SGIX_flush_raster -#define GL_SGIX_flush_raster 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushRasterSGIX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); +GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params); #endif +#endif /* GL_EXT_point_parameters */ -#ifndef GL_SGIX_depth_texture -#define GL_SGIX_depth_texture 1 +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 +typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias); #endif +#endif /* GL_EXT_polygon_offset */ -#ifndef GL_SGIS_fog_function -#define GL_SGIS_fog_function 1 +#ifndef GL_EXT_polygon_offset_clamp +#define GL_EXT_polygon_offset_clamp 1 +#define GL_POLYGON_OFFSET_CLAMP_EXT 0x8E1B +typedef void (APIENTRYP PFNGLPOLYGONOFFSETCLAMPEXTPROC) (GLfloat factor, GLfloat units, GLfloat clamp); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogFuncSGIS (GLsizei, const GLfloat *); -GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); +GLAPI void APIENTRY glPolygonOffsetClampEXT (GLfloat factor, GLfloat units, GLfloat clamp); #endif +#endif /* GL_EXT_polygon_offset_clamp */ -#ifndef GL_SGIX_fog_offset -#define GL_SGIX_fog_offset 1 -#endif +#ifndef GL_EXT_post_depth_coverage +#define GL_EXT_post_depth_coverage 1 +#endif /* GL_EXT_post_depth_coverage */ -#ifndef GL_HP_image_transform -#define GL_HP_image_transform 1 +#ifndef GL_EXT_provoking_vertex +#define GL_EXT_provoking_vertex 1 +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D +#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E +#define GL_PROVOKING_VERTEX_EXT 0x8E4F +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glImageTransformParameteriHP (GLenum, GLenum, GLint); -GLAPI void APIENTRY glImageTransformParameterfHP (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glImageTransformParameterivHP (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_HP_convolution_border_modes -#define GL_HP_convolution_border_modes 1 +GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode); +#endif +#endif /* GL_EXT_provoking_vertex */ + +#ifndef GL_EXT_raster_multisample +#define GL_EXT_raster_multisample 1 +#define GL_RASTER_MULTISAMPLE_EXT 0x9327 +#define GL_RASTER_SAMPLES_EXT 0x9328 +#define GL_MAX_RASTER_SAMPLES_EXT 0x9329 +#define GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A +#define GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B +#define GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C +typedef void (APIENTRYP PFNGLRASTERSAMPLESEXTPROC) (GLuint samples, GLboolean fixedsamplelocations); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRasterSamplesEXT (GLuint samples, GLboolean fixedsamplelocations); #endif +#endif /* GL_EXT_raster_multisample */ -#ifndef GL_SGIX_texture_add_env -#define GL_SGIX_texture_add_env 1 -#endif +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 +#define GL_RESCALE_NORMAL_EXT 0x803A +#endif /* GL_EXT_rescale_normal */ -#ifndef GL_EXT_color_subtable -#define GL_EXT_color_subtable 1 +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum, GLsizei, GLint, GLint, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -#endif - -#ifndef GL_PGI_vertex_hints -#define GL_PGI_vertex_hints 1 +GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_secondary_color */ + +#ifndef GL_EXT_semaphore +#define GL_EXT_semaphore 1 +#define GL_LAYOUT_GENERAL_EXT 0x958D +#define GL_LAYOUT_COLOR_ATTACHMENT_EXT 0x958E +#define GL_LAYOUT_DEPTH_STENCIL_ATTACHMENT_EXT 0x958F +#define GL_LAYOUT_DEPTH_STENCIL_READ_ONLY_EXT 0x9590 +#define GL_LAYOUT_SHADER_READ_ONLY_EXT 0x9591 +#define GL_LAYOUT_TRANSFER_SRC_EXT 0x9592 +#define GL_LAYOUT_TRANSFER_DST_EXT 0x9593 +#define GL_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_EXT 0x9530 +#define GL_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_EXT 0x9531 +typedef void (APIENTRYP PFNGLGENSEMAPHORESEXTPROC) (GLsizei n, GLuint *semaphores); +typedef void (APIENTRYP PFNGLDELETESEMAPHORESEXTPROC) (GLsizei n, const GLuint *semaphores); +typedef GLboolean (APIENTRYP PFNGLISSEMAPHOREEXTPROC) (GLuint semaphore); +typedef void (APIENTRYP PFNGLSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, const GLuint64 *params); +typedef void (APIENTRYP PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, GLuint64 *params); +typedef void (APIENTRYP PFNGLWAITSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); +typedef void (APIENTRYP PFNGLSIGNALSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenSemaphoresEXT (GLsizei n, GLuint *semaphores); +GLAPI void APIENTRY glDeleteSemaphoresEXT (GLsizei n, const GLuint *semaphores); +GLAPI GLboolean APIENTRY glIsSemaphoreEXT (GLuint semaphore); +GLAPI void APIENTRY glSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, const GLuint64 *params); +GLAPI void APIENTRY glGetSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, GLuint64 *params); +GLAPI void APIENTRY glWaitSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); +GLAPI void APIENTRY glSignalSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); +#endif +#endif /* GL_EXT_semaphore */ + +#ifndef GL_EXT_semaphore_fd +#define GL_EXT_semaphore_fd 1 +typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREFDEXTPROC) (GLuint semaphore, GLenum handleType, GLint fd); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportSemaphoreFdEXT (GLuint semaphore, GLenum handleType, GLint fd); #endif +#endif /* GL_EXT_semaphore_fd */ -#ifndef GL_PGI_misc_hints -#define GL_PGI_misc_hints 1 +#ifndef GL_EXT_semaphore_win32 +#define GL_EXT_semaphore_win32 1 +#define GL_HANDLE_TYPE_D3D12_FENCE_EXT 0x9594 +#define GL_D3D12_FENCE_VALUE_EXT 0x9595 +typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC) (GLuint semaphore, GLenum handleType, void *handle); +typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC) (GLuint semaphore, GLenum handleType, const void *name); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glHintPGI (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); +GLAPI void APIENTRY glImportSemaphoreWin32HandleEXT (GLuint semaphore, GLenum handleType, void *handle); +GLAPI void APIENTRY glImportSemaphoreWin32NameEXT (GLuint semaphore, GLenum handleType, const void *name); #endif +#endif /* GL_EXT_semaphore_win32 */ -#ifndef GL_EXT_paletted_texture -#define GL_EXT_paletted_texture 1 +#ifndef GL_EXT_separate_shader_objects +#define GL_EXT_separate_shader_objects 1 +#define GL_ACTIVE_PROGRAM_EXT 0x8B8D +typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); +typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glGetColorTableEXT (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); +GLAPI void APIENTRY glActiveProgramEXT (GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); #endif +#endif /* GL_EXT_separate_shader_objects */ -#ifndef GL_EXT_clip_volume_hint -#define GL_EXT_clip_volume_hint 1 -#endif +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA +#endif /* GL_EXT_separate_specular_color */ -#ifndef GL_SGIX_list_priority -#define GL_SGIX_list_priority 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetListParameterivSGIX (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glListParameterfSGIX (GLuint, GLenum, GLfloat); -GLAPI void APIENTRY glListParameterfvSGIX (GLuint, GLenum, const GLfloat *); -GLAPI void APIENTRY glListParameteriSGIX (GLuint, GLenum, GLint); -GLAPI void APIENTRY glListParameterivSGIX (GLuint, GLenum, const GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); -#endif +#ifndef GL_EXT_shader_framebuffer_fetch +#define GL_EXT_shader_framebuffer_fetch 1 +#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 +#endif /* GL_EXT_shader_framebuffer_fetch */ -#ifndef GL_SGIX_ir_instrument1 -#define GL_SGIX_ir_instrument1 1 +#ifndef GL_EXT_shader_framebuffer_fetch_non_coherent +#define GL_EXT_shader_framebuffer_fetch_non_coherent 1 +typedef void (APIENTRYP PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferFetchBarrierEXT (void); +#endif +#endif /* GL_EXT_shader_framebuffer_fetch_non_coherent */ + +#ifndef GL_EXT_shader_image_load_formatted +#define GL_EXT_shader_image_load_formatted 1 +#endif /* GL_EXT_shader_image_load_formatted */ + +#ifndef GL_EXT_shader_image_load_store +#define GL_EXT_shader_image_load_store 1 +#define GL_MAX_IMAGE_UNITS_EXT 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 +#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A +#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B +#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C +#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D +#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E +#define GL_IMAGE_1D_EXT 0x904C +#define GL_IMAGE_2D_EXT 0x904D +#define GL_IMAGE_3D_EXT 0x904E +#define GL_IMAGE_2D_RECT_EXT 0x904F +#define GL_IMAGE_CUBE_EXT 0x9050 +#define GL_IMAGE_BUFFER_EXT 0x9051 +#define GL_IMAGE_1D_ARRAY_EXT 0x9052 +#define GL_IMAGE_2D_ARRAY_EXT 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 +#define GL_INT_IMAGE_1D_EXT 0x9057 +#define GL_INT_IMAGE_2D_EXT 0x9058 +#define GL_INT_IMAGE_3D_EXT 0x9059 +#define GL_INT_IMAGE_2D_RECT_EXT 0x905A +#define GL_INT_IMAGE_CUBE_EXT 0x905B +#define GL_INT_IMAGE_BUFFER_EXT 0x905C +#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D +#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C +#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D +#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 +#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 +#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers); #endif +#endif /* GL_EXT_shader_image_load_store */ -#ifndef GL_SGIX_calligraphic_fragment -#define GL_SGIX_calligraphic_fragment 1 -#endif +#ifndef GL_EXT_shader_integer_mix +#define GL_EXT_shader_integer_mix 1 +#endif /* GL_EXT_shader_integer_mix */ -#ifndef GL_SGIX_texture_lod_bias -#define GL_SGIX_texture_lod_bias 1 -#endif +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif /* GL_EXT_shadow_funcs */ -#ifndef GL_SGIX_shadow_ambient -#define GL_SGIX_shadow_ambient 1 -#endif +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif /* GL_EXT_shared_texture_palette */ -#ifndef GL_EXT_index_texture -#define GL_EXT_index_texture 1 -#endif +#ifndef GL_EXT_sparse_texture2 +#define GL_EXT_sparse_texture2 1 +#endif /* GL_EXT_sparse_texture2 */ -#ifndef GL_EXT_index_material -#define GL_EXT_index_material 1 +#ifndef GL_EXT_stencil_clear_tag +#define GL_EXT_stencil_clear_tag 1 +#define GL_STENCIL_TAG_BITS_EXT 0x88F2 +#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 +typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexMaterialEXT (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag); #endif +#endif /* GL_EXT_stencil_clear_tag */ -#ifndef GL_EXT_index_func -#define GL_EXT_index_func 1 +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexFuncEXT (GLenum, GLclampf); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face); #endif +#endif /* GL_EXT_stencil_two_side */ -#ifndef GL_EXT_index_array_formats -#define GL_EXT_index_array_formats 1 -#endif +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif /* GL_EXT_stencil_wrap */ -#ifndef GL_EXT_compiled_vertex_array -#define GL_EXT_compiled_vertex_array 1 +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLockArraysEXT (GLint, GLsizei); -GLAPI void APIENTRY glUnlockArraysEXT (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); +GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); #endif +#endif /* GL_EXT_subtexture */ -#ifndef GL_EXT_cull_vertex -#define GL_EXT_cull_vertex 1 +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 +#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +#endif /* GL_EXT_texture */ + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCullParameterdvEXT (GLenum, GLdouble *); -GLAPI void APIENTRY glCullParameterfvEXT (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); -#endif +GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +#endif +#endif /* GL_EXT_texture3D */ + +#ifndef GL_EXT_texture_array +#define GL_EXT_texture_array 1 +#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 +#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D +#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF +#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#endif +#endif /* GL_EXT_texture_array */ + +#ifndef GL_EXT_texture_buffer_object +#define GL_EXT_texture_buffer_object 1 +#define GL_TEXTURE_BUFFER_EXT 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E +typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); +#endif +#endif /* GL_EXT_texture_buffer_object */ + +#ifndef GL_EXT_texture_compression_latc +#define GL_EXT_texture_compression_latc 1 +#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 +#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 +#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 +#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 +#endif /* GL_EXT_texture_compression_latc */ + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE +#endif /* GL_EXT_texture_compression_rgtc */ -#ifndef GL_SGIX_ycrcb -#define GL_SGIX_ycrcb 1 -#endif +#ifndef GL_EXT_texture_compression_s3tc +#define GL_EXT_texture_compression_s3tc 1 +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif /* GL_EXT_texture_compression_s3tc */ -#ifndef GL_SGIX_fragment_lighting -#define GL_SGIX_fragment_lighting 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum, GLenum); -GLAPI void APIENTRY glFragmentLightfSGIX (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glFragmentLightiSGIX (GLenum, GLenum, GLint); -GLAPI void APIENTRY glFragmentLightivSGIX (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum, GLfloat); -GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum, const GLfloat *); -GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum, GLint); -GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum, const GLint *); -GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum, GLenum, GLint); -GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glLightEnviSGIX (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); -#endif +#ifndef GL_EXT_texture_cube_map +#define GL_EXT_texture_cube_map 1 +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C +#endif /* GL_EXT_texture_cube_map */ -#ifndef GL_IBM_rasterpos_clip -#define GL_IBM_rasterpos_clip 1 -#endif +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 +#endif /* GL_EXT_texture_env_add */ + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A +#endif /* GL_EXT_texture_env_combine */ -#ifndef GL_HP_texture_lighting -#define GL_HP_texture_lighting 1 -#endif +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif /* GL_EXT_texture_env_dot3 */ -#ifndef GL_EXT_draw_range_elements -#define GL_EXT_draw_range_elements 1 +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif /* GL_EXT_texture_filter_anisotropic */ + +#ifndef GL_EXT_texture_filter_minmax +#define GL_EXT_texture_filter_minmax 1 +#define GL_TEXTURE_REDUCTION_MODE_EXT 0x9366 +#define GL_WEIGHTED_AVERAGE_EXT 0x9367 +#endif /* GL_EXT_texture_filter_minmax */ + +#ifndef GL_EXT_texture_integer +#define GL_EXT_texture_integer 1 +#define GL_RGBA32UI_EXT 0x8D70 +#define GL_RGB32UI_EXT 0x8D71 +#define GL_ALPHA32UI_EXT 0x8D72 +#define GL_INTENSITY32UI_EXT 0x8D73 +#define GL_LUMINANCE32UI_EXT 0x8D74 +#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 +#define GL_RGBA16UI_EXT 0x8D76 +#define GL_RGB16UI_EXT 0x8D77 +#define GL_ALPHA16UI_EXT 0x8D78 +#define GL_INTENSITY16UI_EXT 0x8D79 +#define GL_LUMINANCE16UI_EXT 0x8D7A +#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B +#define GL_RGBA8UI_EXT 0x8D7C +#define GL_RGB8UI_EXT 0x8D7D +#define GL_ALPHA8UI_EXT 0x8D7E +#define GL_INTENSITY8UI_EXT 0x8D7F +#define GL_LUMINANCE8UI_EXT 0x8D80 +#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 +#define GL_RGBA32I_EXT 0x8D82 +#define GL_RGB32I_EXT 0x8D83 +#define GL_ALPHA32I_EXT 0x8D84 +#define GL_INTENSITY32I_EXT 0x8D85 +#define GL_LUMINANCE32I_EXT 0x8D86 +#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 +#define GL_RGBA16I_EXT 0x8D88 +#define GL_RGB16I_EXT 0x8D89 +#define GL_ALPHA16I_EXT 0x8D8A +#define GL_INTENSITY16I_EXT 0x8D8B +#define GL_LUMINANCE16I_EXT 0x8D8C +#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D +#define GL_RGBA8I_EXT 0x8D8E +#define GL_RGB8I_EXT 0x8D8F +#define GL_ALPHA8I_EXT 0x8D90 +#define GL_INTENSITY8I_EXT 0x8D91 +#define GL_LUMINANCE8I_EXT 0x8D92 +#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 +#define GL_RED_INTEGER_EXT 0x8D94 +#define GL_GREEN_INTEGER_EXT 0x8D95 +#define GL_BLUE_INTEGER_EXT 0x8D96 +#define GL_ALPHA_INTEGER_EXT 0x8D97 +#define GL_RGB_INTEGER_EXT 0x8D98 +#define GL_RGBA_INTEGER_EXT 0x8D99 +#define GL_BGR_INTEGER_EXT 0x8D9A +#define GL_BGRA_INTEGER_EXT 0x8D9B +#define GL_LUMINANCE_INTEGER_EXT 0x8D9C +#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D +#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); +typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha); +GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha); #endif +#endif /* GL_EXT_texture_integer */ -#ifndef GL_WIN_phong_shading -#define GL_WIN_phong_shading 1 -#endif +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif /* GL_EXT_texture_lod_bias */ -#ifndef GL_WIN_specular_fog -#define GL_WIN_specular_fog 1 -#endif +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif /* GL_EXT_texture_mirror_clamp */ -#ifndef GL_EXT_light_texture -#define GL_EXT_light_texture 1 +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glApplyTextureEXT (GLenum); -GLAPI void APIENTRY glTextureLightEXT (GLenum); -GLAPI void APIENTRY glTextureMaterialEXT (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences); +GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture); +GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures); +GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures); +GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture); +GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities); #endif +#endif /* GL_EXT_texture_object */ -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_SGIX_blend_alpha_minmax 1 +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF +typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); +#endif +#endif /* GL_EXT_texture_perturb_normal */ + +#ifndef GL_EXT_texture_sRGB +#define GL_EXT_texture_sRGB 1 +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif /* GL_EXT_texture_sRGB */ + +#ifndef GL_EXT_texture_sRGB_R8 +#define GL_EXT_texture_sRGB_R8 1 +#define GL_SR8_EXT 0x8FBD +#endif /* GL_EXT_texture_sRGB_R8 */ + +#ifndef GL_EXT_texture_sRGB_decode +#define GL_EXT_texture_sRGB_decode 1 +#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 +#define GL_DECODE_EXT 0x8A49 +#define GL_SKIP_DECODE_EXT 0x8A4A +#endif /* GL_EXT_texture_sRGB_decode */ + +#ifndef GL_EXT_texture_shadow_lod +#define GL_EXT_texture_shadow_lod 1 +#endif /* GL_EXT_texture_shadow_lod */ + +#ifndef GL_EXT_texture_shared_exponent +#define GL_EXT_texture_shared_exponent 1 +#define GL_RGB9_E5_EXT 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E +#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F +#endif /* GL_EXT_texture_shared_exponent */ + +#ifndef GL_EXT_texture_snorm +#define GL_EXT_texture_snorm 1 +#define GL_ALPHA_SNORM 0x9010 +#define GL_LUMINANCE_SNORM 0x9011 +#define GL_LUMINANCE_ALPHA_SNORM 0x9012 +#define GL_INTENSITY_SNORM 0x9013 +#define GL_ALPHA8_SNORM 0x9014 +#define GL_LUMINANCE8_SNORM 0x9015 +#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 +#define GL_INTENSITY8_SNORM 0x9017 +#define GL_ALPHA16_SNORM 0x9018 +#define GL_LUMINANCE16_SNORM 0x9019 +#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A +#define GL_INTENSITY16_SNORM 0x901B +#define GL_RED_SNORM 0x8F90 +#define GL_RG_SNORM 0x8F91 +#define GL_RGB_SNORM 0x8F92 +#define GL_RGBA_SNORM 0x8F93 +#endif /* GL_EXT_texture_snorm */ + +#ifndef GL_EXT_texture_swizzle +#define GL_EXT_texture_swizzle 1 +#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 +#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 +#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 +#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 +#endif /* GL_EXT_texture_swizzle */ + +#ifndef GL_EXT_timer_query +#define GL_EXT_timer_query 1 +#define GL_TIME_ELAPSED_EXT 0x88BF +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params); +#endif +#endif /* GL_EXT_timer_query */ + +#ifndef GL_EXT_transform_feedback +#define GL_EXT_transform_feedback 1 +#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F +#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C +#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D +#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 +#define GL_RASTERIZER_DISCARD_EXT 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackEXT (void); +GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); #endif +#endif /* GL_EXT_transform_feedback */ -#ifndef GL_EXT_bgra -#define GL_EXT_bgra 1 -#endif +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 +typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); +typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, void **params); +typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glArrayElementEXT (GLint i); +GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer); +GLAPI void APIENTRY glGetPointervEXT (GLenum pname, void **params); +GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +#endif +#endif /* GL_EXT_vertex_array */ + +#ifndef GL_EXT_vertex_array_bgra +#define GL_EXT_vertex_array_bgra 1 +#endif /* GL_EXT_vertex_array_bgra */ + +#ifndef GL_EXT_vertex_attrib_64bit +#define GL_EXT_vertex_attrib_64bit 1 +#define GL_DOUBLE_VEC2_EXT 0x8FFC +#define GL_DOUBLE_VEC3_EXT 0x8FFD +#define GL_DOUBLE_VEC4_EXT 0x8FFE +#define GL_DOUBLE_MAT2_EXT 0x8F46 +#define GL_DOUBLE_MAT3_EXT 0x8F47 +#define GL_DOUBLE_MAT4_EXT 0x8F48 +#define GL_DOUBLE_MAT2x3_EXT 0x8F49 +#define GL_DOUBLE_MAT2x4_EXT 0x8F4A +#define GL_DOUBLE_MAT3x2_EXT 0x8F4B +#define GL_DOUBLE_MAT3x4_EXT 0x8F4C +#define GL_DOUBLE_MAT4x2_EXT 0x8F4D +#define GL_DOUBLE_MAT4x3_EXT 0x8F4E +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params); +#endif +#endif /* GL_EXT_vertex_attrib_64bit */ -#ifndef GL_SGIX_async -#define GL_SGIX_async 1 +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED +typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const void *addr); +typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const void *addr); +typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); +typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); +typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); +typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); +typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); +typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); +typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); +typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); +typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const void *addr); +typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, void **data); +typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint); -GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *); -GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *); -GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei); -GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint, GLsizei); -GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); -typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); -typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); -typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); -typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); -typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); -#endif - -#ifndef GL_SGIX_async_pixel -#define GL_SGIX_async_pixel 1 -#endif - -#ifndef GL_SGIX_async_histogram -#define GL_SGIX_async_histogram 1 -#endif +GLAPI void APIENTRY glBeginVertexShaderEXT (void); +GLAPI void APIENTRY glEndVertexShaderEXT (void); +GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id); +GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range); +GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id); +GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1); +GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const void *addr); +GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const void *addr); +GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr); +GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr); +GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr); +GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr); +GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr); +GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr); +GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr); +GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr); +GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const void *addr); +GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id); +GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id); +GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value); +GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value); +GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value); +GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value); +GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value); +GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap); +GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, void **data); +GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +#endif +#endif /* GL_EXT_vertex_shader */ -#ifndef GL_INTEL_parallel_arrays -#define GL_INTEL_parallel_arrays 1 +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 +#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6 +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW0_EXT 0x1700 +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexPointervINTEL (GLint, GLenum, const GLvoid* *); -GLAPI void APIENTRY glNormalPointervINTEL (GLenum, const GLvoid* *); -GLAPI void APIENTRY glColorPointervINTEL (GLint, GLenum, const GLvoid* *); -GLAPI void APIENTRY glTexCoordPointervINTEL (GLint, GLenum, const GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight); +GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer); #endif +#endif /* GL_EXT_vertex_weighting */ -#ifndef GL_HP_occlusion_test -#define GL_HP_occlusion_test 1 -#endif - -#ifndef GL_EXT_pixel_transform -#define GL_EXT_pixel_transform 1 +#ifndef GL_EXT_win32_keyed_mutex +#define GL_EXT_win32_keyed_mutex 1 +typedef GLboolean (APIENTRYP PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key, GLuint timeout); +typedef GLboolean (APIENTRYP PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum, GLenum, GLint); -GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum, GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_EXT_pixel_transform_color_table -#define GL_EXT_pixel_transform_color_table 1 -#endif - -#ifndef GL_EXT_shared_texture_palette -#define GL_EXT_shared_texture_palette 1 -#endif - -#ifndef GL_EXT_separate_specular_color -#define GL_EXT_separate_specular_color 1 -#endif - -#ifndef GL_EXT_secondary_color -#define GL_EXT_secondary_color 1 +GLAPI GLboolean APIENTRY glAcquireKeyedMutexWin32EXT (GLuint memory, GLuint64 key, GLuint timeout); +GLAPI GLboolean APIENTRY glReleaseKeyedMutexWin32EXT (GLuint memory, GLuint64 key); +#endif +#endif /* GL_EXT_win32_keyed_mutex */ + +#ifndef GL_EXT_window_rectangles +#define GL_EXT_window_rectangles 1 +#define GL_INCLUSIVE_EXT 0x8F10 +#define GL_EXCLUSIVE_EXT 0x8F11 +#define GL_WINDOW_RECTANGLE_EXT 0x8F12 +#define GL_WINDOW_RECTANGLE_MODE_EXT 0x8F13 +#define GL_MAX_WINDOW_RECTANGLES_EXT 0x8F14 +#define GL_NUM_WINDOW_RECTANGLES_EXT 0x8F15 +typedef void (APIENTRYP PFNGLWINDOWRECTANGLESEXTPROC) (GLenum mode, GLsizei count, const GLint *box); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *); -GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *); -GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *); -GLAPI void APIENTRY glSecondaryColor3iEXT (GLint, GLint, GLint); -GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *); -GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *); -GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *); -GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *); -GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort, GLushort, GLushort); -GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *); -GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint, GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glWindowRectanglesEXT (GLenum mode, GLsizei count, const GLint *box); #endif +#endif /* GL_EXT_window_rectangles */ -#ifndef GL_EXT_texture_perturb_normal -#define GL_EXT_texture_perturb_normal 1 +#ifndef GL_EXT_x11_sync_object +#define GL_EXT_x11_sync_object 1 +#define GL_SYNC_X11_FENCE_EXT 0x90E1 +typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureNormalEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); #endif +#endif /* GL_EXT_x11_sync_object */ -#ifndef GL_EXT_multi_draw_arrays -#define GL_EXT_multi_draw_arrays 1 +#ifndef GL_GREMEDY_frame_terminator +#define GL_GREMEDY_frame_terminator 1 +typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); -GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); #endif +#endif /* GL_GREMEDY_frame_terminator */ -#ifndef GL_EXT_fog_coord -#define GL_EXT_fog_coord 1 +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 +typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const void *string); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogCoordfEXT (GLfloat); -GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *); -GLAPI void APIENTRY glFogCoorddEXT (GLdouble); -GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *); -GLAPI void APIENTRY glFogCoordPointerEXT (GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const void *string); #endif +#endif /* GL_GREMEDY_string_marker */ -#ifndef GL_REND_screen_coordinates -#define GL_REND_screen_coordinates 1 -#endif +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 +#endif /* GL_HP_convolution_border_modes */ -#ifndef GL_EXT_coordinate_frame -#define GL_EXT_coordinate_frame 1 +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTangent3bEXT (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *); -GLAPI void APIENTRY glTangent3dEXT (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *); -GLAPI void APIENTRY glTangent3fEXT (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *); -GLAPI void APIENTRY glTangent3iEXT (GLint, GLint, GLint); -GLAPI void APIENTRY glTangent3ivEXT (const GLint *); -GLAPI void APIENTRY glTangent3sEXT (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glTangent3svEXT (const GLshort *); -GLAPI void APIENTRY glBinormal3bEXT (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *); -GLAPI void APIENTRY glBinormal3dEXT (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *); -GLAPI void APIENTRY glBinormal3fEXT (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *); -GLAPI void APIENTRY glBinormal3iEXT (GLint, GLint, GLint); -GLAPI void APIENTRY glBinormal3ivEXT (const GLint *); -GLAPI void APIENTRY glBinormal3sEXT (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glBinormal3svEXT (const GLshort *); -GLAPI void APIENTRY glTangentPointerEXT (GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glBinormalPointerEXT (GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); -typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); -typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); -typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); -typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); -typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); -typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); -typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); -typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); -typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); -typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_texture_env_combine -#define GL_EXT_texture_env_combine 1 -#endif - -#ifndef GL_APPLE_specular_vector -#define GL_APPLE_specular_vector 1 -#endif - -#ifndef GL_APPLE_transform_hint -#define GL_APPLE_transform_hint 1 -#endif - -#ifndef GL_SGIX_fog_scale -#define GL_SGIX_fog_scale 1 +GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params); #endif +#endif /* GL_HP_image_transform */ -#ifndef GL_SUNX_constant_data -#define GL_SUNX_constant_data 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFinishTextureSUNX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); -#endif +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 +#endif /* GL_HP_occlusion_test */ -#ifndef GL_SUN_global_alpha -#define GL_SUN_global_alpha 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte); -GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort); -GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint); -GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat); -GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble); -GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte); -GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort); -GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); -#endif +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 +#endif /* GL_HP_texture_lighting */ -#ifndef GL_SUN_triangle_list -#define GL_SUN_triangle_list 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint); -GLAPI void APIENTRY glReplacementCodeusSUN (GLushort); -GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte); -GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *); -GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *); -GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *); -GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum, GLsizei, const GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); -#endif +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 +#define GL_CULL_VERTEX_IBM 103050 +#endif /* GL_IBM_cull_vertex */ -#ifndef GL_SUN_vertex -#define GL_SUN_vertex 1 +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 +typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat); -GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat, GLfloat, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *, const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *, const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride); #endif +#endif /* GL_IBM_multimode_draw_arrays */ -#ifndef GL_EXT_blend_func_separate -#define GL_EXT_blend_func_separate 1 +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif /* GL_IBM_rasterpos_clip */ + +#ifndef GL_IBM_static_data +#define GL_IBM_static_data 1 +#define GL_ALL_STATIC_DATA_IBM 103060 +#define GL_STATIC_VERTEX_ARRAY_IBM 103061 +typedef void (APIENTRYP PFNGLFLUSHSTATICDATAIBMPROC) (GLenum target); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum, GLenum, GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GLAPI void APIENTRY glFlushStaticDataIBM (GLenum target); +#endif +#endif /* GL_IBM_static_data */ + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_IBM_texture_mirrored_repeat 1 +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif /* GL_IBM_texture_mirrored_repeat */ + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 +typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean **pointer, GLint ptrstride); +GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); #endif +#endif /* GL_IBM_vertex_array_lists */ #ifndef GL_INGR_blend_func_separate #define GL_INGR_blend_func_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum, GLenum, GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); #endif +#endif /* GL_INGR_blend_func_separate */ #ifndef GL_INGR_color_clamp #define GL_INGR_color_clamp 1 -#endif +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#endif /* GL_INGR_color_clamp */ #ifndef GL_INGR_interlace_read #define GL_INGR_interlace_read 1 -#endif - -#ifndef GL_EXT_stencil_wrap -#define GL_EXT_stencil_wrap 1 -#endif - -#ifndef GL_EXT_422_pixels -#define GL_EXT_422_pixels 1 -#endif - -#ifndef GL_NV_texgen_reflection -#define GL_NV_texgen_reflection 1 -#endif - -#ifndef GL_SUN_convolution_border_modes -#define GL_SUN_convolution_border_modes 1 -#endif +#define GL_INTERLACE_READ_INGR 0x8568 +#endif /* GL_INGR_interlace_read */ -#ifndef GL_EXT_texture_env_add -#define GL_EXT_texture_env_add 1 -#endif +#ifndef GL_INTEL_blackhole_render +#define GL_INTEL_blackhole_render 1 +#define GL_BLACKHOLE_RENDER_INTEL 0x83FC +#endif /* GL_INTEL_blackhole_render */ -#ifndef GL_EXT_texture_lod_bias -#define GL_EXT_texture_lod_bias 1 -#endif +#ifndef GL_INTEL_conservative_rasterization +#define GL_INTEL_conservative_rasterization 1 +#define GL_CONSERVATIVE_RASTERIZATION_INTEL 0x83FE +#endif /* GL_INTEL_conservative_rasterization */ -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 -#endif +#ifndef GL_INTEL_fragment_shader_ordering +#define GL_INTEL_fragment_shader_ordering 1 +#endif /* GL_INTEL_fragment_shader_ordering */ -#ifndef GL_EXT_vertex_weighting -#define GL_EXT_vertex_weighting 1 +#ifndef GL_INTEL_framebuffer_CMAA +#define GL_INTEL_framebuffer_CMAA 1 +typedef void (APIENTRYP PFNGLAPPLYFRAMEBUFFERATTACHMENTCMAAINTELPROC) (void); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexWeightfEXT (GLfloat); -GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *); -GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei, GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_NV_light_max_exponent -#define GL_NV_light_max_exponent 1 -#endif - -#ifndef GL_NV_vertex_array_range -#define GL_NV_vertex_array_range 1 +GLAPI void APIENTRY glApplyFramebufferAttachmentCMAAINTEL (void); +#endif +#endif /* GL_INTEL_framebuffer_CMAA */ + +#ifndef GL_INTEL_map_texture +#define GL_INTEL_map_texture 1 +#define GL_TEXTURE_MEMORY_LAYOUT_INTEL 0x83FF +#define GL_LAYOUT_DEFAULT_INTEL 0 +#define GL_LAYOUT_LINEAR_INTEL 1 +#define GL_LAYOUT_LINEAR_CPU_CACHED_INTEL 2 +typedef void (APIENTRYP PFNGLSYNCTEXTUREINTELPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLUNMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level); +typedef void *(APIENTRYP PFNGLMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); -GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); +GLAPI void APIENTRY glSyncTextureINTEL (GLuint texture); +GLAPI void APIENTRY glUnmapTexture2DINTEL (GLuint texture, GLint level); +GLAPI void *APIENTRY glMapTexture2DINTEL (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout); #endif +#endif /* GL_INTEL_map_texture */ -#ifndef GL_NV_register_combiners -#define GL_NV_register_combiners 1 +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 +typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const void **pointer); +typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *); -GLAPI void APIENTRY glCombinerParameterfNV (GLenum, GLfloat); -GLAPI void APIENTRY glCombinerParameterivNV (GLenum, const GLint *); -GLAPI void APIENTRY glCombinerParameteriNV (GLenum, GLint); -GLAPI void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean); -GLAPI void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); -#endif - -#ifndef GL_NV_fog_distance -#define GL_NV_fog_distance 1 -#endif - -#ifndef GL_NV_texgen_emboss -#define GL_NV_texgen_emboss 1 -#endif +GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const void **pointer); +GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const void **pointer); +GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const void **pointer); +GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const void **pointer); +#endif +#endif /* GL_INTEL_parallel_arrays */ + +#ifndef GL_INTEL_performance_query +#define GL_INTEL_performance_query 1 +#define GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x00000000 +#define GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x00000001 +#define GL_PERFQUERY_WAIT_INTEL 0x83FB +#define GL_PERFQUERY_FLUSH_INTEL 0x83FA +#define GL_PERFQUERY_DONOT_FLUSH_INTEL 0x83F9 +#define GL_PERFQUERY_COUNTER_EVENT_INTEL 0x94F0 +#define GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1 +#define GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2 +#define GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3 +#define GL_PERFQUERY_COUNTER_RAW_INTEL 0x94F4 +#define GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5 +#define GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8 +#define GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9 +#define GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA +#define GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB +#define GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC +#define GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD +#define GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE +#define GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF +#define GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500 +typedef void (APIENTRYP PFNGLBEGINPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLCREATEPERFQUERYINTELPROC) (GLuint queryId, GLuint *queryHandle); +typedef void (APIENTRYP PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId); +typedef void (APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId); +typedef void (APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); +typedef void (APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); +typedef void (APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId); +typedef void (APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginPerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glCreatePerfQueryINTEL (GLuint queryId, GLuint *queryHandle); +GLAPI void APIENTRY glDeletePerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glEndPerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId); +GLAPI void APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId); +GLAPI void APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); +GLAPI void APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); +GLAPI void APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId); +GLAPI void APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#endif +#endif /* GL_INTEL_performance_query */ + +#ifndef GL_MESAX_texture_stack +#define GL_MESAX_texture_stack 1 +#define GL_TEXTURE_1D_STACK_MESAX 0x8759 +#define GL_TEXTURE_2D_STACK_MESAX 0x875A +#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B +#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C +#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D +#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E +#endif /* GL_MESAX_texture_stack */ -#ifndef GL_NV_blend_square -#define GL_NV_blend_square 1 -#endif +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 +#define GL_PACK_INVERT_MESA 0x8758 +#endif /* GL_MESA_pack_invert */ -#ifndef GL_NV_texture_env_combine4 -#define GL_NV_texture_env_combine4 1 -#endif +#ifndef GL_MESA_program_binary_formats +#define GL_MESA_program_binary_formats 1 +#define GL_PROGRAM_BINARY_FORMAT_MESA 0x875F +#endif /* GL_MESA_program_binary_formats */ #ifndef GL_MESA_resize_buffers #define GL_MESA_resize_buffers 1 +typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glResizeBuffersMESA (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); #endif +#endif /* GL_MESA_resize_buffers */ + +#ifndef GL_MESA_shader_integer_functions +#define GL_MESA_shader_integer_functions 1 +#endif /* GL_MESA_shader_integer_functions */ + +#ifndef GL_MESA_tile_raster_order +#define GL_MESA_tile_raster_order 1 +#define GL_TILE_RASTER_ORDER_FIXED_MESA 0x8BB8 +#define GL_TILE_RASTER_ORDER_INCREASING_X_MESA 0x8BB9 +#define GL_TILE_RASTER_ORDER_INCREASING_Y_MESA 0x8BBA +#endif /* GL_MESA_tile_raster_order */ #ifndef GL_MESA_window_pos #define GL_MESA_window_pos 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dMESA (GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *); -GLAPI void APIENTRY glWindowPos2fMESA (GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *); -GLAPI void APIENTRY glWindowPos2iMESA (GLint, GLint); -GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *); -GLAPI void APIENTRY glWindowPos2sMESA (GLshort, GLshort); -GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *); -GLAPI void APIENTRY glWindowPos3dMESA (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *); -GLAPI void APIENTRY glWindowPos3fMESA (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *); -GLAPI void APIENTRY glWindowPos3iMESA (GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *); -GLAPI void APIENTRY glWindowPos3sMESA (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *); -GLAPI void APIENTRY glWindowPos4dMESA (GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *); -GLAPI void APIENTRY glWindowPos4fMESA (GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *); -GLAPI void APIENTRY glWindowPos4iMESA (GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *); -GLAPI void APIENTRY glWindowPos4sMESA (GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); @@ -5410,272 +9349,2203 @@ typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GL typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); +#endif +#endif /* GL_MESA_window_pos */ + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 +#endif /* GL_MESA_ycbcr_texture */ + +#ifndef GL_NVX_blend_equation_advanced_multi_draw_buffers +#define GL_NVX_blend_equation_advanced_multi_draw_buffers 1 +#endif /* GL_NVX_blend_equation_advanced_multi_draw_buffers */ + +#ifndef GL_NVX_conditional_render +#define GL_NVX_conditional_render 1 +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVXPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNVX (GLuint id); +GLAPI void APIENTRY glEndConditionalRenderNVX (void); +#endif +#endif /* GL_NVX_conditional_render */ + +#ifndef GL_NVX_gpu_memory_info +#define GL_NVX_gpu_memory_info 1 +#define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047 +#define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048 +#define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049 +#define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A +#define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B +#endif /* GL_NVX_gpu_memory_info */ + +#ifndef GL_NVX_linked_gpu_multicast +#define GL_NVX_linked_gpu_multicast 1 +#define GL_LGPU_SEPARATE_STORAGE_BIT_NVX 0x0800 +#define GL_MAX_LGPU_GPUS_NVX 0x92BA +typedef void (APIENTRYP PFNGLLGPUNAMEDBUFFERSUBDATANVXPROC) (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLLGPUCOPYIMAGESUBDATANVXPROC) (GLuint sourceGpu, GLbitfield destinationGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srxY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLLGPUINTERLOCKNVXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLGPUNamedBufferSubDataNVX (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glLGPUCopyImageSubDataNVX (GLuint sourceGpu, GLbitfield destinationGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srxY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glLGPUInterlockNVX (void); +#endif +#endif /* GL_NVX_linked_gpu_multicast */ + +#ifndef GL_NV_alpha_to_coverage_dither_control +#define GL_NV_alpha_to_coverage_dither_control 1 +#define GL_ALPHA_TO_COVERAGE_DITHER_DEFAULT_NV 0x934D +#define GL_ALPHA_TO_COVERAGE_DITHER_ENABLE_NV 0x934E +#define GL_ALPHA_TO_COVERAGE_DITHER_DISABLE_NV 0x934F +#define GL_ALPHA_TO_COVERAGE_DITHER_MODE_NV 0x92BF +typedef void (APIENTRYP PFNGLALPHATOCOVERAGEDITHERCONTROLNVPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAlphaToCoverageDitherControlNV (GLenum mode); #endif +#endif /* GL_NV_alpha_to_coverage_dither_control */ -#ifndef GL_IBM_cull_vertex -#define GL_IBM_cull_vertex 1 +#ifndef GL_NV_bindless_multi_draw_indirect +#define GL_NV_bindless_multi_draw_indirect 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); #endif +#endif /* GL_NV_bindless_multi_draw_indirect */ -#ifndef GL_IBM_multimode_draw_arrays -#define GL_IBM_multimode_draw_arrays 1 +#ifndef GL_NV_bindless_multi_draw_indirect_count +#define GL_NV_bindless_multi_draw_indirect_count 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *, const GLint *, const GLsizei *, GLsizei, GLint); -GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *, const GLsizei *, GLenum, const GLvoid* const *, GLsizei, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); -typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); +GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessCountNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessCountNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +#endif +#endif /* GL_NV_bindless_multi_draw_indirect_count */ + +#ifndef GL_NV_bindless_texture +#define GL_NV_bindless_texture 1 +typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); +typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint64 APIENTRY glGetTextureHandleNV (GLuint texture); +GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); +GLAPI void APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); +GLAPI void APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); +GLAPI GLuint64 APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +GLAPI void APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); +GLAPI void APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); +GLAPI void APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); +GLAPI void APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); +GLAPI void APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +GLAPI GLboolean APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); +GLAPI GLboolean APIENTRY glIsImageHandleResidentNV (GLuint64 handle); +#endif +#endif /* GL_NV_bindless_texture */ + +#ifndef GL_NV_blend_equation_advanced +#define GL_NV_blend_equation_advanced 1 +#define GL_BLEND_OVERLAP_NV 0x9281 +#define GL_BLEND_PREMULTIPLIED_SRC_NV 0x9280 +#define GL_BLUE_NV 0x1905 +#define GL_COLORBURN_NV 0x929A +#define GL_COLORDODGE_NV 0x9299 +#define GL_CONJOINT_NV 0x9284 +#define GL_CONTRAST_NV 0x92A1 +#define GL_DARKEN_NV 0x9297 +#define GL_DIFFERENCE_NV 0x929E +#define GL_DISJOINT_NV 0x9283 +#define GL_DST_ATOP_NV 0x928F +#define GL_DST_IN_NV 0x928B +#define GL_DST_NV 0x9287 +#define GL_DST_OUT_NV 0x928D +#define GL_DST_OVER_NV 0x9289 +#define GL_EXCLUSION_NV 0x92A0 +#define GL_GREEN_NV 0x1904 +#define GL_HARDLIGHT_NV 0x929B +#define GL_HARDMIX_NV 0x92A9 +#define GL_HSL_COLOR_NV 0x92AF +#define GL_HSL_HUE_NV 0x92AD +#define GL_HSL_LUMINOSITY_NV 0x92B0 +#define GL_HSL_SATURATION_NV 0x92AE +#define GL_INVERT_OVG_NV 0x92B4 +#define GL_INVERT_RGB_NV 0x92A3 +#define GL_LIGHTEN_NV 0x9298 +#define GL_LINEARBURN_NV 0x92A5 +#define GL_LINEARDODGE_NV 0x92A4 +#define GL_LINEARLIGHT_NV 0x92A7 +#define GL_MINUS_CLAMPED_NV 0x92B3 +#define GL_MINUS_NV 0x929F +#define GL_MULTIPLY_NV 0x9294 +#define GL_OVERLAY_NV 0x9296 +#define GL_PINLIGHT_NV 0x92A8 +#define GL_PLUS_CLAMPED_ALPHA_NV 0x92B2 +#define GL_PLUS_CLAMPED_NV 0x92B1 +#define GL_PLUS_DARKER_NV 0x9292 +#define GL_PLUS_NV 0x9291 +#define GL_RED_NV 0x1903 +#define GL_SCREEN_NV 0x9295 +#define GL_SOFTLIGHT_NV 0x929C +#define GL_SRC_ATOP_NV 0x928E +#define GL_SRC_IN_NV 0x928A +#define GL_SRC_NV 0x9286 +#define GL_SRC_OUT_NV 0x928C +#define GL_SRC_OVER_NV 0x9288 +#define GL_UNCORRELATED_NV 0x9282 +#define GL_VIVIDLIGHT_NV 0x92A6 +#define GL_XOR_NV 0x1506 +typedef void (APIENTRYP PFNGLBLENDPARAMETERINVPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLBLENDBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendParameteriNV (GLenum pname, GLint value); +GLAPI void APIENTRY glBlendBarrierNV (void); #endif +#endif /* GL_NV_blend_equation_advanced */ -#ifndef GL_IBM_vertex_array_lists -#define GL_IBM_vertex_array_lists 1 +#ifndef GL_NV_blend_equation_advanced_coherent +#define GL_NV_blend_equation_advanced_coherent 1 +#define GL_BLEND_ADVANCED_COHERENT_NV 0x9285 +#endif /* GL_NV_blend_equation_advanced_coherent */ + +#ifndef GL_NV_blend_minmax_factor +#define GL_NV_blend_minmax_factor 1 +#endif /* GL_NV_blend_minmax_factor */ + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 +#endif /* GL_NV_blend_square */ + +#ifndef GL_NV_clip_space_w_scaling +#define GL_NV_clip_space_w_scaling 1 +#define GL_VIEWPORT_POSITION_W_SCALE_NV 0x937C +#define GL_VIEWPORT_POSITION_W_SCALE_X_COEFF_NV 0x937D +#define GL_VIEWPORT_POSITION_W_SCALE_Y_COEFF_NV 0x937E +typedef void (APIENTRYP PFNGLVIEWPORTPOSITIONWSCALENVPROC) (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glViewportPositionWScaleNV (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#endif +#endif /* GL_NV_clip_space_w_scaling */ + +#ifndef GL_NV_command_list +#define GL_NV_command_list 1 +#define GL_TERMINATE_SEQUENCE_COMMAND_NV 0x0000 +#define GL_NOP_COMMAND_NV 0x0001 +#define GL_DRAW_ELEMENTS_COMMAND_NV 0x0002 +#define GL_DRAW_ARRAYS_COMMAND_NV 0x0003 +#define GL_DRAW_ELEMENTS_STRIP_COMMAND_NV 0x0004 +#define GL_DRAW_ARRAYS_STRIP_COMMAND_NV 0x0005 +#define GL_DRAW_ELEMENTS_INSTANCED_COMMAND_NV 0x0006 +#define GL_DRAW_ARRAYS_INSTANCED_COMMAND_NV 0x0007 +#define GL_ELEMENT_ADDRESS_COMMAND_NV 0x0008 +#define GL_ATTRIBUTE_ADDRESS_COMMAND_NV 0x0009 +#define GL_UNIFORM_ADDRESS_COMMAND_NV 0x000A +#define GL_BLEND_COLOR_COMMAND_NV 0x000B +#define GL_STENCIL_REF_COMMAND_NV 0x000C +#define GL_LINE_WIDTH_COMMAND_NV 0x000D +#define GL_POLYGON_OFFSET_COMMAND_NV 0x000E +#define GL_ALPHA_REF_COMMAND_NV 0x000F +#define GL_VIEWPORT_COMMAND_NV 0x0010 +#define GL_SCISSOR_COMMAND_NV 0x0011 +#define GL_FRONT_FACE_COMMAND_NV 0x0012 +typedef void (APIENTRYP PFNGLCREATESTATESNVPROC) (GLsizei n, GLuint *states); +typedef void (APIENTRYP PFNGLDELETESTATESNVPROC) (GLsizei n, const GLuint *states); +typedef GLboolean (APIENTRYP PFNGLISSTATENVPROC) (GLuint state); +typedef void (APIENTRYP PFNGLSTATECAPTURENVPROC) (GLuint state, GLenum mode); +typedef GLuint (APIENTRYP PFNGLGETCOMMANDHEADERNVPROC) (GLenum tokenID, GLuint size); +typedef GLushort (APIENTRYP PFNGLGETSTAGEINDEXNVPROC) (GLenum shadertype); +typedef void (APIENTRYP PFNGLDRAWCOMMANDSNVPROC) (GLenum primitiveMode, GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, GLuint count); +typedef void (APIENTRYP PFNGLDRAWCOMMANDSADDRESSNVPROC) (GLenum primitiveMode, const GLuint64 *indirects, const GLsizei *sizes, GLuint count); +typedef void (APIENTRYP PFNGLDRAWCOMMANDSSTATESNVPROC) (GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +typedef void (APIENTRYP PFNGLDRAWCOMMANDSSTATESADDRESSNVPROC) (const GLuint64 *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +typedef void (APIENTRYP PFNGLCREATECOMMANDLISTSNVPROC) (GLsizei n, GLuint *lists); +typedef void (APIENTRYP PFNGLDELETECOMMANDLISTSNVPROC) (GLsizei n, const GLuint *lists); +typedef GLboolean (APIENTRYP PFNGLISCOMMANDLISTNVPROC) (GLuint list); +typedef void (APIENTRYP PFNGLLISTDRAWCOMMANDSSTATESCLIENTNVPROC) (GLuint list, GLuint segment, const void **indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +typedef void (APIENTRYP PFNGLCOMMANDLISTSEGMENTSNVPROC) (GLuint list, GLuint segments); +typedef void (APIENTRYP PFNGLCOMPILECOMMANDLISTNVPROC) (GLuint list); +typedef void (APIENTRYP PFNGLCALLCOMMANDLISTNVPROC) (GLuint list); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint, const GLboolean* *, GLint); -GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glIndexPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glNormalPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glTexCoordPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glVertexPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glCreateStatesNV (GLsizei n, GLuint *states); +GLAPI void APIENTRY glDeleteStatesNV (GLsizei n, const GLuint *states); +GLAPI GLboolean APIENTRY glIsStateNV (GLuint state); +GLAPI void APIENTRY glStateCaptureNV (GLuint state, GLenum mode); +GLAPI GLuint APIENTRY glGetCommandHeaderNV (GLenum tokenID, GLuint size); +GLAPI GLushort APIENTRY glGetStageIndexNV (GLenum shadertype); +GLAPI void APIENTRY glDrawCommandsNV (GLenum primitiveMode, GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, GLuint count); +GLAPI void APIENTRY glDrawCommandsAddressNV (GLenum primitiveMode, const GLuint64 *indirects, const GLsizei *sizes, GLuint count); +GLAPI void APIENTRY glDrawCommandsStatesNV (GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +GLAPI void APIENTRY glDrawCommandsStatesAddressNV (const GLuint64 *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +GLAPI void APIENTRY glCreateCommandListsNV (GLsizei n, GLuint *lists); +GLAPI void APIENTRY glDeleteCommandListsNV (GLsizei n, const GLuint *lists); +GLAPI GLboolean APIENTRY glIsCommandListNV (GLuint list); +GLAPI void APIENTRY glListDrawCommandsStatesClientNV (GLuint list, GLuint segment, const void **indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +GLAPI void APIENTRY glCommandListSegmentsNV (GLuint list, GLuint segments); +GLAPI void APIENTRY glCompileCommandListNV (GLuint list); +GLAPI void APIENTRY glCallCommandListNV (GLuint list); +#endif +#endif /* GL_NV_command_list */ + +#ifndef GL_NV_compute_program5 +#define GL_NV_compute_program5 1 +#define GL_COMPUTE_PROGRAM_NV 0x90FB +#define GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90FC +#endif /* GL_NV_compute_program5 */ + +#ifndef GL_NV_compute_shader_derivatives +#define GL_NV_compute_shader_derivatives 1 +#endif /* GL_NV_compute_shader_derivatives */ + +#ifndef GL_NV_conditional_render +#define GL_NV_conditional_render 1 +#define GL_QUERY_WAIT_NV 0x8E13 +#define GL_QUERY_NO_WAIT_NV 0x8E14 +#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRenderNV (void); +#endif +#endif /* GL_NV_conditional_render */ + +#ifndef GL_NV_conservative_raster +#define GL_NV_conservative_raster 1 +#define GL_CONSERVATIVE_RASTERIZATION_NV 0x9346 +#define GL_SUBPIXEL_PRECISION_BIAS_X_BITS_NV 0x9347 +#define GL_SUBPIXEL_PRECISION_BIAS_Y_BITS_NV 0x9348 +#define GL_MAX_SUBPIXEL_PRECISION_BIAS_BITS_NV 0x9349 +typedef void (APIENTRYP PFNGLSUBPIXELPRECISIONBIASNVPROC) (GLuint xbits, GLuint ybits); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSubpixelPrecisionBiasNV (GLuint xbits, GLuint ybits); #endif +#endif /* GL_NV_conservative_raster */ -#ifndef GL_SGIX_subsample -#define GL_SGIX_subsample 1 +#ifndef GL_NV_conservative_raster_dilate +#define GL_NV_conservative_raster_dilate 1 +#define GL_CONSERVATIVE_RASTER_DILATE_NV 0x9379 +#define GL_CONSERVATIVE_RASTER_DILATE_RANGE_NV 0x937A +#define GL_CONSERVATIVE_RASTER_DILATE_GRANULARITY_NV 0x937B +typedef void (APIENTRYP PFNGLCONSERVATIVERASTERPARAMETERFNVPROC) (GLenum pname, GLfloat value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConservativeRasterParameterfNV (GLenum pname, GLfloat value); #endif +#endif /* GL_NV_conservative_raster_dilate */ -#ifndef GL_SGIX_ycrcba -#define GL_SGIX_ycrcba 1 +#ifndef GL_NV_conservative_raster_pre_snap +#define GL_NV_conservative_raster_pre_snap 1 +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_NV 0x9550 +#endif /* GL_NV_conservative_raster_pre_snap */ + +#ifndef GL_NV_conservative_raster_pre_snap_triangles +#define GL_NV_conservative_raster_pre_snap_triangles 1 +#define GL_CONSERVATIVE_RASTER_MODE_NV 0x954D +#define GL_CONSERVATIVE_RASTER_MODE_POST_SNAP_NV 0x954E +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV 0x954F +typedef void (APIENTRYP PFNGLCONSERVATIVERASTERPARAMETERINVPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConservativeRasterParameteriNV (GLenum pname, GLint param); +#endif +#endif /* GL_NV_conservative_raster_pre_snap_triangles */ + +#ifndef GL_NV_conservative_raster_underestimation +#define GL_NV_conservative_raster_underestimation 1 +#endif /* GL_NV_conservative_raster_underestimation */ + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif /* GL_NV_copy_depth_to_color */ + +#ifndef GL_NV_copy_image +#define GL_NV_copy_image 1 +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* GL_NV_copy_image */ + +#ifndef GL_NV_deep_texture3D +#define GL_NV_deep_texture3D 1 +#define GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV 0x90D0 +#define GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV 0x90D1 +#endif /* GL_NV_deep_texture3D */ + +#ifndef GL_NV_depth_buffer_float +#define GL_NV_depth_buffer_float 1 +#define GL_DEPTH_COMPONENT32F_NV 0x8DAB +#define GL_DEPTH32F_STENCIL8_NV 0x8DAC +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD +#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF +typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); +typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); +GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); +#endif +#endif /* GL_NV_depth_buffer_float */ + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#define GL_DEPTH_CLAMP_NV 0x864F +#endif /* GL_NV_depth_clamp */ + +#ifndef GL_NV_draw_texture +#define GL_NV_draw_texture 1 +typedef void (APIENTRYP PFNGLDRAWTEXTURENVPROC) (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawTextureNV (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +#endif +#endif /* GL_NV_draw_texture */ + +#ifndef GL_NV_draw_vulkan_image +#define GL_NV_draw_vulkan_image 1 +typedef void (APIENTRY *GLVULKANPROCNV)(void); +typedef void (APIENTRYP PFNGLDRAWVKIMAGENVPROC) (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +typedef GLVULKANPROCNV (APIENTRYP PFNGLGETVKPROCADDRNVPROC) (const GLchar *name); +typedef void (APIENTRYP PFNGLWAITVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); +typedef void (APIENTRYP PFNGLSIGNALVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); +typedef void (APIENTRYP PFNGLSIGNALVKFENCENVPROC) (GLuint64 vkFence); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawVkImageNV (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +GLAPI GLVULKANPROCNV APIENTRY glGetVkProcAddrNV (const GLchar *name); +GLAPI void APIENTRY glWaitVkSemaphoreNV (GLuint64 vkSemaphore); +GLAPI void APIENTRY glSignalVkSemaphoreNV (GLuint64 vkSemaphore); +GLAPI void APIENTRY glSignalVkFenceNV (GLuint64 vkFence); +#endif +#endif /* GL_NV_draw_vulkan_image */ + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 +typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); +typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); +GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); +GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode); +#endif +#endif /* GL_NV_evaluators */ + +#ifndef GL_NV_explicit_multisample +#define GL_NV_explicit_multisample 1 +#define GL_SAMPLE_POSITION_NV 0x8E50 +#define GL_SAMPLE_MASK_NV 0x8E51 +#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 +#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 +#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 +#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 +#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 +#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 +#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 +#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); +typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask); +GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer); +#endif +#endif /* GL_NV_explicit_multisample */ + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); +GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence); +GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); +GLAPI void APIENTRY glFinishFenceNV (GLuint fence); +GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); #endif +#endif /* GL_NV_fence */ + +#ifndef GL_NV_fill_rectangle +#define GL_NV_fill_rectangle 1 +#define GL_FILL_RECTANGLE_NV 0x933C +#endif /* GL_NV_fill_rectangle */ + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif /* GL_NV_float_buffer */ + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +#endif /* GL_NV_fog_distance */ -#ifndef GL_SGIX_ycrcb_subsample -#define GL_SGIX_ycrcb_subsample 1 +#ifndef GL_NV_fragment_coverage_to_color +#define GL_NV_fragment_coverage_to_color 1 +#define GL_FRAGMENT_COVERAGE_TO_COLOR_NV 0x92DD +#define GL_FRAGMENT_COVERAGE_COLOR_NV 0x92DE +typedef void (APIENTRYP PFNGLFRAGMENTCOVERAGECOLORNVPROC) (GLuint color); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentCoverageColorNV (GLuint color); #endif +#endif /* GL_NV_fragment_coverage_to_color */ -#ifndef GL_SGIX_depth_pass_instrument -#define GL_SGIX_depth_pass_instrument 1 +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); #endif +#endif /* GL_NV_fragment_program */ -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_3DFX_texture_compression_FXT1 1 -#endif +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 +#endif /* GL_NV_fragment_program2 */ -#ifndef GL_3DFX_multisample -#define GL_3DFX_multisample 1 -#endif +#ifndef GL_NV_fragment_program4 +#define GL_NV_fragment_program4 1 +#endif /* GL_NV_fragment_program4 */ -#ifndef GL_3DFX_tbuffer -#define GL_3DFX_tbuffer 1 +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 +#endif /* GL_NV_fragment_program_option */ + +#ifndef GL_NV_fragment_shader_barycentric +#define GL_NV_fragment_shader_barycentric 1 +#endif /* GL_NV_fragment_shader_barycentric */ + +#ifndef GL_NV_fragment_shader_interlock +#define GL_NV_fragment_shader_interlock 1 +#endif /* GL_NV_fragment_shader_interlock */ + +#ifndef GL_NV_framebuffer_mixed_samples +#define GL_NV_framebuffer_mixed_samples 1 +#define GL_COVERAGE_MODULATION_TABLE_NV 0x9331 +#define GL_COLOR_SAMPLES_NV 0x8E20 +#define GL_DEPTH_SAMPLES_NV 0x932D +#define GL_STENCIL_SAMPLES_NV 0x932E +#define GL_MIXED_DEPTH_SAMPLES_SUPPORTED_NV 0x932F +#define GL_MIXED_STENCIL_SAMPLES_SUPPORTED_NV 0x9330 +#define GL_COVERAGE_MODULATION_NV 0x9332 +#define GL_COVERAGE_MODULATION_TABLE_SIZE_NV 0x9333 +typedef void (APIENTRYP PFNGLCOVERAGEMODULATIONTABLENVPROC) (GLsizei n, const GLfloat *v); +typedef void (APIENTRYP PFNGLGETCOVERAGEMODULATIONTABLENVPROC) (GLsizei bufsize, GLfloat *v); +typedef void (APIENTRYP PFNGLCOVERAGEMODULATIONNVPROC) (GLenum components); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTbufferMask3DFX (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); +GLAPI void APIENTRY glCoverageModulationTableNV (GLsizei n, const GLfloat *v); +GLAPI void APIENTRY glGetCoverageModulationTableNV (GLsizei bufsize, GLfloat *v); +GLAPI void APIENTRY glCoverageModulationNV (GLenum components); +#endif +#endif /* GL_NV_framebuffer_mixed_samples */ + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_NV_framebuffer_multisample_coverage 1 +#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB +#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 +#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 +#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_NV_framebuffer_multisample_coverage */ + +#ifndef GL_NV_geometry_program4 +#define GL_NV_geometry_program4 1 +#define GL_GEOMETRY_PROGRAM_NV 0x8C26 +#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 +#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 +typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); +GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif +#endif /* GL_NV_geometry_program4 */ + +#ifndef GL_NV_geometry_shader4 +#define GL_NV_geometry_shader4 1 +#endif /* GL_NV_geometry_shader4 */ + +#ifndef GL_NV_geometry_shader_passthrough +#define GL_NV_geometry_shader_passthrough 1 +#endif /* GL_NV_geometry_shader_passthrough */ + +#ifndef GL_NV_gpu_multicast +#define GL_NV_gpu_multicast 1 +#define GL_PER_GPU_STORAGE_BIT_NV 0x0800 +#define GL_MULTICAST_GPUS_NV 0x92BA +#define GL_RENDER_GPU_MASK_NV 0x9558 +#define GL_PER_GPU_STORAGE_NV 0x9548 +#define GL_MULTICAST_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9549 +typedef void (APIENTRYP PFNGLRENDERGPUMASKNVPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLMULTICASTBUFFERSUBDATANVPROC) (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLMULTICASTCOPYBUFFERSUBDATANVPROC) (GLuint readGpu, GLbitfield writeGpuMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLMULTICASTCOPYIMAGESUBDATANVPROC) (GLuint srcGpu, GLbitfield dstGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +typedef void (APIENTRYP PFNGLMULTICASTBLITFRAMEBUFFERNVPROC) (GLuint srcGpu, GLuint dstGpu, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLMULTICASTFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint gpu, GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTICASTBARRIERNVPROC) (void); +typedef void (APIENTRYP PFNGLMULTICASTWAITSYNCNVPROC) (GLuint signalGpu, GLbitfield waitGpuMask); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTIVNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTUIVNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTI64VNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTUI64VNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLuint64 *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderGpuMaskNV (GLbitfield mask); +GLAPI void APIENTRY glMulticastBufferSubDataNV (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glMulticastCopyBufferSubDataNV (GLuint readGpu, GLbitfield writeGpuMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glMulticastCopyImageSubDataNV (GLuint srcGpu, GLbitfield dstGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +GLAPI void APIENTRY glMulticastBlitFramebufferNV (GLuint srcGpu, GLuint dstGpu, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glMulticastFramebufferSampleLocationsfvNV (GLuint gpu, GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glMulticastBarrierNV (void); +GLAPI void APIENTRY glMulticastWaitSyncNV (GLuint signalGpu, GLbitfield waitGpuMask); +GLAPI void APIENTRY glMulticastGetQueryObjectivNV (GLuint gpu, GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glMulticastGetQueryObjectuivNV (GLuint gpu, GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glMulticastGetQueryObjecti64vNV (GLuint gpu, GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glMulticastGetQueryObjectui64vNV (GLuint gpu, GLuint id, GLenum pname, GLuint64 *params); +#endif +#endif /* GL_NV_gpu_multicast */ + +#ifndef GL_NV_gpu_program4 +#define GL_NV_gpu_program4 1 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 +#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 +#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 +#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 +#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 +#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 +#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params); +#endif +#endif /* GL_NV_gpu_program4 */ + +#ifndef GL_NV_gpu_program5 +#define GL_NV_gpu_program5 1 +#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C +#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F +#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44 +#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45 +typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param); #endif +#endif /* GL_NV_gpu_program5 */ -#ifndef GL_EXT_multisample -#define GL_EXT_multisample 1 +#ifndef GL_NV_gpu_program5_mem_extended +#define GL_NV_gpu_program5_mem_extended 1 +#endif /* GL_NV_gpu_program5_mem_extended */ + +#ifndef GL_NV_gpu_shader5 +#define GL_NV_gpu_shader5 1 +#endif /* GL_NV_gpu_shader5 */ + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +typedef unsigned short GLhalfNV; +#define GL_HALF_FLOAT_NV 0x140B +typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); +typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); +typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskEXT (GLclampf, GLboolean); -GLAPI void APIENTRY glSamplePatternEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s); +GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s); +GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog); +GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog); +GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight); +GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight); +GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x); +GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +#endif +#endif /* GL_NV_half_float */ + +#ifndef GL_NV_internalformat_sample_query +#define GL_NV_internalformat_sample_query 1 +#define GL_MULTISAMPLES_NV 0x9371 +#define GL_SUPERSAMPLE_SCALE_X_NV 0x9372 +#define GL_SUPERSAMPLE_SCALE_Y_NV 0x9373 +#define GL_CONFORMANT_NV 0x9374 +typedef void (APIENTRYP PFNGLGETINTERNALFORMATSAMPLEIVNVPROC) (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei bufSize, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetInternalformatSampleivNV (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei bufSize, GLint *params); #endif +#endif /* GL_NV_internalformat_sample_query */ -#ifndef GL_SGIX_vertex_preclip -#define GL_SGIX_vertex_preclip 1 +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif /* GL_NV_light_max_exponent */ + +#ifndef GL_NV_memory_attachment +#define GL_NV_memory_attachment 1 +#define GL_ATTACHED_MEMORY_OBJECT_NV 0x95A4 +#define GL_ATTACHED_MEMORY_OFFSET_NV 0x95A5 +#define GL_MEMORY_ATTACHABLE_ALIGNMENT_NV 0x95A6 +#define GL_MEMORY_ATTACHABLE_SIZE_NV 0x95A7 +#define GL_MEMORY_ATTACHABLE_NV 0x95A8 +#define GL_DETACHED_MEMORY_INCARNATION_NV 0x95A9 +#define GL_DETACHED_TEXTURES_NV 0x95AA +#define GL_DETACHED_BUFFERS_NV 0x95AB +#define GL_MAX_DETACHED_TEXTURES_NV 0x95AC +#define GL_MAX_DETACHED_BUFFERS_NV 0x95AD +typedef void (APIENTRYP PFNGLGETMEMORYOBJECTDETACHEDRESOURCESUIVNVPROC) (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); +typedef void (APIENTRYP PFNGLRESETMEMORYOBJECTPARAMETERNVPROC) (GLuint memory, GLenum pname); +typedef void (APIENTRYP PFNGLTEXATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLBUFFERATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTUREATTACHMEMORYNVPROC) (GLuint texture, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLNAMEDBUFFERATTACHMEMORYNVPROC) (GLuint buffer, GLuint memory, GLuint64 offset); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetMemoryObjectDetachedResourcesuivNV (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); +GLAPI void APIENTRY glResetMemoryObjectParameterNV (GLuint memory, GLenum pname); +GLAPI void APIENTRY glTexAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glBufferAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureAttachMemoryNV (GLuint texture, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glNamedBufferAttachMemoryNV (GLuint buffer, GLuint memory, GLuint64 offset); +#endif +#endif /* GL_NV_memory_attachment */ + +#ifndef GL_NV_mesh_shader +#define GL_NV_mesh_shader 1 +#define GL_MESH_SHADER_NV 0x9559 +#define GL_TASK_SHADER_NV 0x955A +#define GL_MAX_MESH_UNIFORM_BLOCKS_NV 0x8E60 +#define GL_MAX_MESH_TEXTURE_IMAGE_UNITS_NV 0x8E61 +#define GL_MAX_MESH_IMAGE_UNIFORMS_NV 0x8E62 +#define GL_MAX_MESH_UNIFORM_COMPONENTS_NV 0x8E63 +#define GL_MAX_MESH_ATOMIC_COUNTER_BUFFERS_NV 0x8E64 +#define GL_MAX_MESH_ATOMIC_COUNTERS_NV 0x8E65 +#define GL_MAX_MESH_SHADER_STORAGE_BLOCKS_NV 0x8E66 +#define GL_MAX_COMBINED_MESH_UNIFORM_COMPONENTS_NV 0x8E67 +#define GL_MAX_TASK_UNIFORM_BLOCKS_NV 0x8E68 +#define GL_MAX_TASK_TEXTURE_IMAGE_UNITS_NV 0x8E69 +#define GL_MAX_TASK_IMAGE_UNIFORMS_NV 0x8E6A +#define GL_MAX_TASK_UNIFORM_COMPONENTS_NV 0x8E6B +#define GL_MAX_TASK_ATOMIC_COUNTER_BUFFERS_NV 0x8E6C +#define GL_MAX_TASK_ATOMIC_COUNTERS_NV 0x8E6D +#define GL_MAX_TASK_SHADER_STORAGE_BLOCKS_NV 0x8E6E +#define GL_MAX_COMBINED_TASK_UNIFORM_COMPONENTS_NV 0x8E6F +#define GL_MAX_MESH_WORK_GROUP_INVOCATIONS_NV 0x95A2 +#define GL_MAX_TASK_WORK_GROUP_INVOCATIONS_NV 0x95A3 +#define GL_MAX_MESH_TOTAL_MEMORY_SIZE_NV 0x9536 +#define GL_MAX_TASK_TOTAL_MEMORY_SIZE_NV 0x9537 +#define GL_MAX_MESH_OUTPUT_VERTICES_NV 0x9538 +#define GL_MAX_MESH_OUTPUT_PRIMITIVES_NV 0x9539 +#define GL_MAX_TASK_OUTPUT_COUNT_NV 0x953A +#define GL_MAX_DRAW_MESH_TASKS_COUNT_NV 0x953D +#define GL_MAX_MESH_VIEWS_NV 0x9557 +#define GL_MESH_OUTPUT_PER_VERTEX_GRANULARITY_NV 0x92DF +#define GL_MESH_OUTPUT_PER_PRIMITIVE_GRANULARITY_NV 0x9543 +#define GL_MAX_MESH_WORK_GROUP_SIZE_NV 0x953B +#define GL_MAX_TASK_WORK_GROUP_SIZE_NV 0x953C +#define GL_MESH_WORK_GROUP_SIZE_NV 0x953E +#define GL_TASK_WORK_GROUP_SIZE_NV 0x953F +#define GL_MESH_VERTICES_OUT_NV 0x9579 +#define GL_MESH_PRIMITIVES_OUT_NV 0x957A +#define GL_MESH_OUTPUT_TYPE_NV 0x957B +#define GL_UNIFORM_BLOCK_REFERENCED_BY_MESH_SHADER_NV 0x959C +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TASK_SHADER_NV 0x959D +#define GL_REFERENCED_BY_MESH_SHADER_NV 0x95A0 +#define GL_REFERENCED_BY_TASK_SHADER_NV 0x95A1 +#define GL_MESH_SHADER_BIT_NV 0x00000040 +#define GL_TASK_SHADER_BIT_NV 0x00000080 +#define GL_MESH_SUBROUTINE_NV 0x957C +#define GL_TASK_SUBROUTINE_NV 0x957D +#define GL_MESH_SUBROUTINE_UNIFORM_NV 0x957E +#define GL_TASK_SUBROUTINE_UNIFORM_NV 0x957F +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_MESH_SHADER_NV 0x959E +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TASK_SHADER_NV 0x959F +typedef void (APIENTRYP PFNGLDRAWMESHTASKSNVPROC) (GLuint first, GLuint count); +typedef void (APIENTRYP PFNGLDRAWMESHTASKSINDIRECTNVPROC) (GLintptr indirect); +typedef void (APIENTRYP PFNGLMULTIDRAWMESHTASKSINDIRECTNVPROC) (GLintptr indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWMESHTASKSINDIRECTCOUNTNVPROC) (GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshTasksNV (GLuint first, GLuint count); +GLAPI void APIENTRY glDrawMeshTasksIndirectNV (GLintptr indirect); +GLAPI void APIENTRY glMultiDrawMeshTasksIndirectNV (GLintptr indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawMeshTasksIndirectCountNV (GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); #endif +#endif /* GL_NV_mesh_shader */ -#ifndef GL_SGIX_convolution_accuracy -#define GL_SGIX_convolution_accuracy 1 -#endif +#ifndef GL_NV_multisample_coverage +#define GL_NV_multisample_coverage 1 +#endif /* GL_NV_multisample_coverage */ -#ifndef GL_SGIX_resample -#define GL_SGIX_resample 1 -#endif +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif /* GL_NV_multisample_filter_hint */ -#ifndef GL_SGIS_point_line_texgen -#define GL_SGIS_point_line_texgen 1 +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 +typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glEndOcclusionQueryNV (void); +GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params); #endif +#endif /* GL_NV_occlusion_query */ -#ifndef GL_SGIS_texture_color_mask -#define GL_SGIS_texture_color_mask 1 +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif /* GL_NV_packed_depth_stencil */ + +#ifndef GL_NV_parameter_buffer_object +#define GL_NV_parameter_buffer_object 1 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 +#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 +#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 +#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean, GLboolean, GLboolean, GLboolean); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -#endif +GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); +#endif +#endif /* GL_NV_parameter_buffer_object */ + +#ifndef GL_NV_parameter_buffer_object2 +#define GL_NV_parameter_buffer_object2 1 +#endif /* GL_NV_parameter_buffer_object2 */ + +#ifndef GL_NV_path_rendering +#define GL_NV_path_rendering 1 +#define GL_PATH_FORMAT_SVG_NV 0x9070 +#define GL_PATH_FORMAT_PS_NV 0x9071 +#define GL_STANDARD_FONT_NAME_NV 0x9072 +#define GL_SYSTEM_FONT_NAME_NV 0x9073 +#define GL_FILE_NAME_NV 0x9074 +#define GL_PATH_STROKE_WIDTH_NV 0x9075 +#define GL_PATH_END_CAPS_NV 0x9076 +#define GL_PATH_INITIAL_END_CAP_NV 0x9077 +#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 +#define GL_PATH_JOIN_STYLE_NV 0x9079 +#define GL_PATH_MITER_LIMIT_NV 0x907A +#define GL_PATH_DASH_CAPS_NV 0x907B +#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C +#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D +#define GL_PATH_DASH_OFFSET_NV 0x907E +#define GL_PATH_CLIENT_LENGTH_NV 0x907F +#define GL_PATH_FILL_MODE_NV 0x9080 +#define GL_PATH_FILL_MASK_NV 0x9081 +#define GL_PATH_FILL_COVER_MODE_NV 0x9082 +#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 +#define GL_PATH_STROKE_MASK_NV 0x9084 +#define GL_COUNT_UP_NV 0x9088 +#define GL_COUNT_DOWN_NV 0x9089 +#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A +#define GL_CONVEX_HULL_NV 0x908B +#define GL_BOUNDING_BOX_NV 0x908D +#define GL_TRANSLATE_X_NV 0x908E +#define GL_TRANSLATE_Y_NV 0x908F +#define GL_TRANSLATE_2D_NV 0x9090 +#define GL_TRANSLATE_3D_NV 0x9091 +#define GL_AFFINE_2D_NV 0x9092 +#define GL_AFFINE_3D_NV 0x9094 +#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 +#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 +#define GL_UTF8_NV 0x909A +#define GL_UTF16_NV 0x909B +#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C +#define GL_PATH_COMMAND_COUNT_NV 0x909D +#define GL_PATH_COORD_COUNT_NV 0x909E +#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F +#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 +#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 +#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 +#define GL_SQUARE_NV 0x90A3 +#define GL_ROUND_NV 0x90A4 +#define GL_TRIANGULAR_NV 0x90A5 +#define GL_BEVEL_NV 0x90A6 +#define GL_MITER_REVERT_NV 0x90A7 +#define GL_MITER_TRUNCATE_NV 0x90A8 +#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 +#define GL_USE_MISSING_GLYPH_NV 0x90AA +#define GL_PATH_ERROR_POSITION_NV 0x90AB +#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD +#define GL_ADJACENT_PAIRS_NV 0x90AE +#define GL_FIRST_TO_REST_NV 0x90AF +#define GL_PATH_GEN_MODE_NV 0x90B0 +#define GL_PATH_GEN_COEFF_NV 0x90B1 +#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 +#define GL_PATH_STENCIL_FUNC_NV 0x90B7 +#define GL_PATH_STENCIL_REF_NV 0x90B8 +#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 +#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD +#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE +#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF +#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 +#define GL_MOVE_TO_RESETS_NV 0x90B5 +#define GL_MOVE_TO_CONTINUES_NV 0x90B6 +#define GL_CLOSE_PATH_NV 0x00 +#define GL_MOVE_TO_NV 0x02 +#define GL_RELATIVE_MOVE_TO_NV 0x03 +#define GL_LINE_TO_NV 0x04 +#define GL_RELATIVE_LINE_TO_NV 0x05 +#define GL_HORIZONTAL_LINE_TO_NV 0x06 +#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 +#define GL_VERTICAL_LINE_TO_NV 0x08 +#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 +#define GL_QUADRATIC_CURVE_TO_NV 0x0A +#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B +#define GL_CUBIC_CURVE_TO_NV 0x0C +#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D +#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E +#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F +#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 +#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 +#define GL_SMALL_CCW_ARC_TO_NV 0x12 +#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 +#define GL_SMALL_CW_ARC_TO_NV 0x14 +#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 +#define GL_LARGE_CCW_ARC_TO_NV 0x16 +#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 +#define GL_LARGE_CW_ARC_TO_NV 0x18 +#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 +#define GL_RESTART_PATH_NV 0xF0 +#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 +#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 +#define GL_RECT_NV 0xF6 +#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 +#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA +#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC +#define GL_ARC_TO_NV 0xFE +#define GL_RELATIVE_ARC_TO_NV 0xFF +#define GL_BOLD_BIT_NV 0x01 +#define GL_ITALIC_BIT_NV 0x02 +#define GL_GLYPH_WIDTH_BIT_NV 0x01 +#define GL_GLYPH_HEIGHT_BIT_NV 0x02 +#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 +#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 +#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 +#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 +#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 +#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 +#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 +#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 +#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 +#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 +#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 +#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 +#define GL_FONT_ASCENDER_BIT_NV 0x00200000 +#define GL_FONT_DESCENDER_BIT_NV 0x00400000 +#define GL_FONT_HEIGHT_BIT_NV 0x00800000 +#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 +#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 +#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 +#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 +#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 +#define GL_ROUNDED_RECT_NV 0xE8 +#define GL_RELATIVE_ROUNDED_RECT_NV 0xE9 +#define GL_ROUNDED_RECT2_NV 0xEA +#define GL_RELATIVE_ROUNDED_RECT2_NV 0xEB +#define GL_ROUNDED_RECT4_NV 0xEC +#define GL_RELATIVE_ROUNDED_RECT4_NV 0xED +#define GL_ROUNDED_RECT8_NV 0xEE +#define GL_RELATIVE_ROUNDED_RECT8_NV 0xEF +#define GL_RELATIVE_RECT_NV 0xF7 +#define GL_FONT_GLYPHS_AVAILABLE_NV 0x9368 +#define GL_FONT_TARGET_UNAVAILABLE_NV 0x9369 +#define GL_FONT_UNAVAILABLE_NV 0x936A +#define GL_FONT_UNINTELLIGIBLE_NV 0x936B +#define GL_CONIC_CURVE_TO_NV 0x1A +#define GL_RELATIVE_CONIC_CURVE_TO_NV 0x1B +#define GL_FONT_NUM_GLYPH_INDICES_BIT_NV 0x20000000 +#define GL_STANDARD_FONT_FORMAT_NV 0x936C +#define GL_2_BYTES_NV 0x1407 +#define GL_3_BYTES_NV 0x1408 +#define GL_4_BYTES_NV 0x1409 +#define GL_EYE_LINEAR_NV 0x2400 +#define GL_OBJECT_LINEAR_NV 0x2401 +#define GL_CONSTANT_NV 0x8576 +#define GL_PATH_FOG_GEN_MODE_NV 0x90AC +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 +#define GL_PATH_PROJECTION_NV 0x1701 +#define GL_PATH_MODELVIEW_NV 0x1700 +#define GL_PATH_MODELVIEW_STACK_DEPTH_NV 0x0BA3 +#define GL_PATH_MODELVIEW_MATRIX_NV 0x0BA6 +#define GL_PATH_MAX_MODELVIEW_STACK_DEPTH_NV 0x0D36 +#define GL_PATH_TRANSPOSE_MODELVIEW_MATRIX_NV 0x84E3 +#define GL_PATH_PROJECTION_STACK_DEPTH_NV 0x0BA4 +#define GL_PATH_PROJECTION_MATRIX_NV 0x0BA7 +#define GL_PATH_MAX_PROJECTION_STACK_DEPTH_NV 0x0D38 +#define GL_PATH_TRANSPOSE_PROJECTION_MATRIX_NV 0x84E4 +#define GL_FRAGMENT_INPUT_NV 0x936D +typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path); +typedef void (APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void *pathString); +typedef void (APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +typedef void (APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); +typedef void (APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +typedef void (APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); +typedef void (APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +typedef void (APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); +typedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); +typedef void (APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); +typedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); +typedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); +typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); +typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); +typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +typedef void (APIENTRYP PFNGLMATRIXLOAD3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOAD3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULT3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULT3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask, GLenum coverMode); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef GLenum (APIENTRYP PFNGLPATHGLYPHINDEXRANGENVPROC) (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint baseAndCount[2]); +typedef GLenum (APIENTRYP PFNGLPATHGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef GLenum (APIENTRYP PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC) (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEFVNVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLfloat *params); +typedef void (APIENTRYP PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHFOGGENNVPROC) (GLenum genMode); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range); +GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range); +GLAPI GLboolean APIENTRY glIsPathNV (GLuint path); +GLAPI void APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const void *pathString); +GLAPI void APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +GLAPI void APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); +GLAPI void APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +GLAPI void APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); +GLAPI void APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); +GLAPI void APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); +GLAPI void APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); +GLAPI void APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +GLAPI void APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); +GLAPI void APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); +GLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); +GLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func); +GLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); +GLAPI void APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); +GLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); +GLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); +GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); +GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); +GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +GLAPI void APIENTRY glMatrixLoad3x2fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoad3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoadTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMult3x2fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMult3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glStencilThenCoverFillPathNV (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); +GLAPI void APIENTRY glStencilThenCoverStrokePathNV (GLuint path, GLint reference, GLuint mask, GLenum coverMode); +GLAPI void APIENTRY glStencilThenCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glStencilThenCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI GLenum APIENTRY glPathGlyphIndexRangeNV (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint baseAndCount[2]); +GLAPI GLenum APIENTRY glPathGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI GLenum APIENTRY glPathMemoryGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glProgramPathFragmentInputGenNV (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); +GLAPI void APIENTRY glGetProgramResourcefvNV (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLfloat *params); +GLAPI void APIENTRY glPathColorGenNV (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +GLAPI void APIENTRY glPathTexGenNV (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +GLAPI void APIENTRY glPathFogGenNV (GLenum genMode); +GLAPI void APIENTRY glGetPathColorGenivNV (GLenum color, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathColorGenfvNV (GLenum color, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathTexGenivNV (GLenum texCoordSet, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathTexGenfvNV (GLenum texCoordSet, GLenum pname, GLfloat *value); +#endif +#endif /* GL_NV_path_rendering */ + +#ifndef GL_NV_path_rendering_shared_edge +#define GL_NV_path_rendering_shared_edge 1 +#define GL_SHARED_EDGE_NV 0xC0 +#endif /* GL_NV_path_rendering_shared_edge */ -#ifndef GL_SGIX_igloo_interface -#define GL_SGIX_igloo_interface 1 +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, const void *pointer); +typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); +GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, const void *pointer); +GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); #endif +#endif /* GL_NV_pixel_data_range */ -#ifndef GL_EXT_texture_env_dot3 -#define GL_EXT_texture_env_dot3 1 +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 +typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params); +#endif +#endif /* GL_NV_point_sprite */ + +#ifndef GL_NV_present_video +#define GL_NV_present_video 1 +#define GL_FRAME_NV 0x8E26 +#define GL_FIELDS_NV 0x8E27 +#define GL_CURRENT_TIME_NV 0x8E28 +#define GL_NUM_FILL_STREAMS_NV 0x8E29 +#define GL_PRESENT_TIME_NV 0x8E2A +#define GL_PRESENT_DURATION_NV 0x8E2B +typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params); +GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params); #endif +#endif /* GL_NV_present_video */ -#ifndef GL_ATI_texture_mirror_once -#define GL_ATI_texture_mirror_once 1 +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveRestartNV (void); +GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); +#endif +#endif /* GL_NV_primitive_restart */ + +#ifndef GL_NV_query_resource +#define GL_NV_query_resource 1 +#define GL_QUERY_RESOURCE_TYPE_VIDMEM_ALLOC_NV 0x9540 +#define GL_QUERY_RESOURCE_MEMTYPE_VIDMEM_NV 0x9542 +#define GL_QUERY_RESOURCE_SYS_RESERVED_NV 0x9544 +#define GL_QUERY_RESOURCE_TEXTURE_NV 0x9545 +#define GL_QUERY_RESOURCE_RENDERBUFFER_NV 0x9546 +#define GL_QUERY_RESOURCE_BUFFEROBJECT_NV 0x9547 +typedef GLint (APIENTRYP PFNGLQUERYRESOURCENVPROC) (GLenum queryType, GLint tagId, GLuint bufSize, GLint *buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glQueryResourceNV (GLenum queryType, GLint tagId, GLuint bufSize, GLint *buffer); #endif +#endif /* GL_NV_query_resource */ -#ifndef GL_NV_fence -#define GL_NV_fence 1 +#ifndef GL_NV_query_resource_tag +#define GL_NV_query_resource_tag 1 +typedef void (APIENTRYP PFNGLGENQUERYRESOURCETAGNVPROC) (GLsizei n, GLint *tagIds); +typedef void (APIENTRYP PFNGLDELETEQUERYRESOURCETAGNVPROC) (GLsizei n, const GLint *tagIds); +typedef void (APIENTRYP PFNGLQUERYRESOURCETAGNVPROC) (GLint tagId, const GLchar *tagString); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteFencesNV (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenFencesNV (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsFenceNV (GLuint); -GLAPI GLboolean APIENTRY glTestFenceNV (GLuint); -GLAPI void APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glFinishFenceNV (GLuint); -GLAPI void APIENTRY glSetFenceNV (GLuint, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); -typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +GLAPI void APIENTRY glGenQueryResourceTagNV (GLsizei n, GLint *tagIds); +GLAPI void APIENTRY glDeleteQueryResourceTagNV (GLsizei n, const GLint *tagIds); +GLAPI void APIENTRY glQueryResourceTagNV (GLint tagId, const GLchar *tagString); #endif +#endif /* GL_NV_query_resource_tag */ -#ifndef GL_NV_evaluators -#define GL_NV_evaluators 1 +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLint, GLint, GLboolean, const GLvoid *); -GLAPI void APIENTRY glMapParameterivNV (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glMapParameterfvNV (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glGetMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLboolean, GLvoid *); -GLAPI void APIENTRY glGetMapParameterivNV (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMapParameterfvNV (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum, GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glEvalMapsNV (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); -typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); -#endif - -#ifndef GL_NV_packed_depth_stencil -#define GL_NV_packed_depth_stencil 1 -#endif +GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param); +GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params); +GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params); +#endif +#endif /* GL_NV_register_combiners */ #ifndef GL_NV_register_combiners2 #define GL_NV_register_combiners2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params); +#endif +#endif /* GL_NV_register_combiners2 */ + +#ifndef GL_NV_representative_fragment_test +#define GL_NV_representative_fragment_test 1 +#define GL_REPRESENTATIVE_FRAGMENT_TEST_NV 0x937F +#endif /* GL_NV_representative_fragment_test */ + +#ifndef GL_NV_robustness_video_memory_purge +#define GL_NV_robustness_video_memory_purge 1 +#define GL_PURGED_CONTEXT_RESET_NV 0x92BB +#endif /* GL_NV_robustness_video_memory_purge */ + +#ifndef GL_NV_sample_locations +#define GL_NV_sample_locations 1 +#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_NV 0x933D +#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_NV 0x933E +#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_NV 0x933F +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_NV 0x9340 +#define GL_SAMPLE_LOCATION_NV 0x8E50 +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9341 +#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_NV 0x9342 +#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_NV 0x9343 +typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLRESOLVEDEPTHVALUESNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferSampleLocationsfvNV (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glNamedFramebufferSampleLocationsfvNV (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glResolveDepthValuesNV (void); +#endif +#endif /* GL_NV_sample_locations */ + +#ifndef GL_NV_sample_mask_override_coverage +#define GL_NV_sample_mask_override_coverage 1 +#endif /* GL_NV_sample_mask_override_coverage */ + +#ifndef GL_NV_scissor_exclusive +#define GL_NV_scissor_exclusive 1 +#define GL_SCISSOR_TEST_EXCLUSIVE_NV 0x9555 +#define GL_SCISSOR_BOX_EXCLUSIVE_NV 0x9556 +typedef void (APIENTRYP PFNGLSCISSOREXCLUSIVENVPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLSCISSOREXCLUSIVEARRAYVNVPROC) (GLuint first, GLsizei count, const GLint *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glScissorExclusiveNV (GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glScissorExclusiveArrayvNV (GLuint first, GLsizei count, const GLint *v); +#endif +#endif /* GL_NV_scissor_exclusive */ + +#ifndef GL_NV_shader_atomic_counters +#define GL_NV_shader_atomic_counters 1 +#endif /* GL_NV_shader_atomic_counters */ + +#ifndef GL_NV_shader_atomic_float +#define GL_NV_shader_atomic_float 1 +#endif /* GL_NV_shader_atomic_float */ + +#ifndef GL_NV_shader_atomic_float64 +#define GL_NV_shader_atomic_float64 1 +#endif /* GL_NV_shader_atomic_float64 */ + +#ifndef GL_NV_shader_atomic_fp16_vector +#define GL_NV_shader_atomic_fp16_vector 1 +#endif /* GL_NV_shader_atomic_fp16_vector */ + +#ifndef GL_NV_shader_atomic_int64 +#define GL_NV_shader_atomic_int64 1 +#endif /* GL_NV_shader_atomic_int64 */ + +#ifndef GL_NV_shader_buffer_load +#define GL_NV_shader_buffer_load 1 +#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D +#define GL_GPU_ADDRESS_NV 0x8F34 +#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 +typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); +typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); +typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); +typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); +typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); +GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); +GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); +GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); +GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); +GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); +GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); +GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); +GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); +GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_NV_shader_buffer_load */ + +#ifndef GL_NV_shader_buffer_store +#define GL_NV_shader_buffer_store 1 +#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 +#endif /* GL_NV_shader_buffer_store */ + +#ifndef GL_NV_shader_storage_buffer_object +#define GL_NV_shader_storage_buffer_object 1 +#endif /* GL_NV_shader_storage_buffer_object */ + +#ifndef GL_NV_shader_texture_footprint +#define GL_NV_shader_texture_footprint 1 +#endif /* GL_NV_shader_texture_footprint */ + +#ifndef GL_NV_shader_thread_group +#define GL_NV_shader_thread_group 1 +#define GL_WARP_SIZE_NV 0x9339 +#define GL_WARPS_PER_SM_NV 0x933A +#define GL_SM_COUNT_NV 0x933B +#endif /* GL_NV_shader_thread_group */ + +#ifndef GL_NV_shader_thread_shuffle +#define GL_NV_shader_thread_shuffle 1 +#endif /* GL_NV_shader_thread_shuffle */ + +#ifndef GL_NV_shading_rate_image +#define GL_NV_shading_rate_image 1 +#define GL_SHADING_RATE_IMAGE_NV 0x9563 +#define GL_SHADING_RATE_NO_INVOCATIONS_NV 0x9564 +#define GL_SHADING_RATE_1_INVOCATION_PER_PIXEL_NV 0x9565 +#define GL_SHADING_RATE_1_INVOCATION_PER_1X2_PIXELS_NV 0x9566 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X1_PIXELS_NV 0x9567 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X2_PIXELS_NV 0x9568 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X4_PIXELS_NV 0x9569 +#define GL_SHADING_RATE_1_INVOCATION_PER_4X2_PIXELS_NV 0x956A +#define GL_SHADING_RATE_1_INVOCATION_PER_4X4_PIXELS_NV 0x956B +#define GL_SHADING_RATE_2_INVOCATIONS_PER_PIXEL_NV 0x956C +#define GL_SHADING_RATE_4_INVOCATIONS_PER_PIXEL_NV 0x956D +#define GL_SHADING_RATE_8_INVOCATIONS_PER_PIXEL_NV 0x956E +#define GL_SHADING_RATE_16_INVOCATIONS_PER_PIXEL_NV 0x956F +#define GL_SHADING_RATE_IMAGE_BINDING_NV 0x955B +#define GL_SHADING_RATE_IMAGE_TEXEL_WIDTH_NV 0x955C +#define GL_SHADING_RATE_IMAGE_TEXEL_HEIGHT_NV 0x955D +#define GL_SHADING_RATE_IMAGE_PALETTE_SIZE_NV 0x955E +#define GL_MAX_COARSE_FRAGMENT_SAMPLES_NV 0x955F +#define GL_SHADING_RATE_SAMPLE_ORDER_DEFAULT_NV 0x95AE +#define GL_SHADING_RATE_SAMPLE_ORDER_PIXEL_MAJOR_NV 0x95AF +#define GL_SHADING_RATE_SAMPLE_ORDER_SAMPLE_MAJOR_NV 0x95B0 +typedef void (APIENTRYP PFNGLBINDSHADINGRATEIMAGENVPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLGETSHADINGRATEIMAGEPALETTENVPROC) (GLuint viewport, GLuint entry, GLenum *rate); +typedef void (APIENTRYP PFNGLGETSHADINGRATESAMPLELOCATIONIVNVPROC) (GLenum rate, GLuint samples, GLuint index, GLint *location); +typedef void (APIENTRYP PFNGLSHADINGRATEIMAGEBARRIERNVPROC) (GLboolean synchronize); +typedef void (APIENTRYP PFNGLSHADINGRATEIMAGEPALETTENVPROC) (GLuint viewport, GLuint first, GLsizei count, const GLenum *rates); +typedef void (APIENTRYP PFNGLSHADINGRATESAMPLEORDERNVPROC) (GLenum order); +typedef void (APIENTRYP PFNGLSHADINGRATESAMPLEORDERCUSTOMNVPROC) (GLenum rate, GLuint samples, const GLint *locations); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindShadingRateImageNV (GLuint texture); +GLAPI void APIENTRY glGetShadingRateImagePaletteNV (GLuint viewport, GLuint entry, GLenum *rate); +GLAPI void APIENTRY glGetShadingRateSampleLocationivNV (GLenum rate, GLuint samples, GLuint index, GLint *location); +GLAPI void APIENTRY glShadingRateImageBarrierNV (GLboolean synchronize); +GLAPI void APIENTRY glShadingRateImagePaletteNV (GLuint viewport, GLuint first, GLsizei count, const GLenum *rates); +GLAPI void APIENTRY glShadingRateSampleOrderNV (GLenum order); +GLAPI void APIENTRY glShadingRateSampleOrderCustomNV (GLenum rate, GLuint samples, const GLint *locations); +#endif +#endif /* GL_NV_shading_rate_image */ + +#ifndef GL_NV_stereo_view_rendering +#define GL_NV_stereo_view_rendering 1 +#endif /* GL_NV_stereo_view_rendering */ + +#ifndef GL_NV_tessellation_program5 +#define GL_NV_tessellation_program5 1 +#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 +#define GL_TESS_CONTROL_PROGRAM_NV 0x891E +#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F +#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 +#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 +#endif /* GL_NV_tessellation_program5 */ + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F +#endif /* GL_NV_texgen_emboss */ + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif /* GL_NV_texgen_reflection */ + +#ifndef GL_NV_texture_barrier +#define GL_NV_texture_barrier 1 +typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureBarrierNV (void); #endif +#endif /* GL_NV_texture_barrier */ #ifndef GL_NV_texture_compression_vtc #define GL_NV_texture_compression_vtc 1 +#endif /* GL_NV_texture_compression_vtc */ + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B +#endif /* GL_NV_texture_env_combine4 */ + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif /* GL_NV_texture_expand_normal */ + +#ifndef GL_NV_texture_multisample +#define GL_NV_texture_multisample 1 +#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 +#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); #endif +#endif /* GL_NV_texture_multisample */ #ifndef GL_NV_texture_rectangle #define GL_NV_texture_rectangle 1 -#endif +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif /* GL_NV_texture_rectangle */ + +#ifndef GL_NV_texture_rectangle_compressed +#define GL_NV_texture_rectangle_compressed 1 +#endif /* GL_NV_texture_rectangle_compressed */ #ifndef GL_NV_texture_shader #define GL_NV_texture_shader 1 -#endif +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3 +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif /* GL_NV_texture_shader */ #ifndef GL_NV_texture_shader2 #define GL_NV_texture_shader2 1 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif /* GL_NV_texture_shader2 */ + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif /* GL_NV_texture_shader3 */ + +#ifndef GL_NV_transform_feedback +#define GL_NV_transform_feedback 1 +#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 +#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 +#define GL_TEXTURE_COORD_NV 0x8C79 +#define GL_CLIP_DISTANCE_NV 0x8C7A +#define GL_VERTEX_ID_NV 0x8C7B +#define GL_PRIMITIVE_ID_NV 0x8C7C +#define GL_GENERIC_ATTRIB_NV 0x8C7D +#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 +#define GL_ACTIVE_VARYINGS_NV 0x8C81 +#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 +#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 +#define GL_PRIMITIVES_GENERATED_NV 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 +#define GL_RASTERIZER_DISCARD_NV 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B +#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C +#define GL_SEPARATE_ATTRIBS_NV 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F +#define GL_LAYER_NV 0x8DAA +#define GL_NEXT_BUFFER_NV -2 +#define GL_SKIP_COMPONENTS4_NV -3 +#define GL_SKIP_COMPONENTS3_NV -4 +#define GL_SKIP_COMPONENTS2_NV -5 +#define GL_SKIP_COMPONENTS1_NV -6 +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLenum bufferMode); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackNV (void); +GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLsizei count, const GLint *attribs, GLenum bufferMode); +GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name); +GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location); +GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#endif +#endif /* GL_NV_transform_feedback */ + +#ifndef GL_NV_transform_feedback2 +#define GL_NV_transform_feedback2 1 +#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedbackNV (void); +GLAPI void APIENTRY glResumeTransformFeedbackNV (void); +GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id); +#endif +#endif /* GL_NV_transform_feedback2 */ + +#ifndef GL_NV_uniform_buffer_unified_memory +#define GL_NV_uniform_buffer_unified_memory 1 +#define GL_UNIFORM_BUFFER_UNIFIED_NV 0x936E +#define GL_UNIFORM_BUFFER_ADDRESS_NV 0x936F +#define GL_UNIFORM_BUFFER_LENGTH_NV 0x9370 +#endif /* GL_NV_uniform_buffer_unified_memory */ + +#ifndef GL_NV_vdpau_interop +#define GL_NV_vdpau_interop 1 +typedef GLintptr GLvdpauSurfaceNV; +#define GL_SURFACE_STATE_NV 0x86EB +#define GL_SURFACE_REGISTERED_NV 0x86FD +#define GL_SURFACE_MAPPED_NV 0x8700 +#define GL_WRITE_DISCARD_NV 0x88BE +typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const void *vdpDevice, const void *getProcAddress); +typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef GLboolean (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); +typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVDPAUInitNV (const void *vdpDevice, const void *getProcAddress); +GLAPI void APIENTRY glVDPAUFiniNV (void); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI GLboolean APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access); +GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#endif +#endif /* GL_NV_vdpau_interop */ + +#ifndef GL_NV_vdpau_interop2 +#define GL_NV_vdpau_interop2 1 +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACEWITHPICTURESTRUCTURENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames, GLboolean isFrameStructure); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceWithPictureStructureNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames, GLboolean isFrameStructure); +#endif +#endif /* GL_NV_vdpau_interop2 */ + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); +GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const void *pointer); #endif +#endif /* GL_NV_vertex_array_range */ #ifndef GL_NV_vertex_array_range2 #define GL_NV_vertex_array_range2 1 -#endif +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif /* GL_NV_vertex_array_range2 */ + +#ifndef GL_NV_vertex_attrib_integer_64bit +#define GL_NV_vertex_attrib_integer_64bit 1 +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); +GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); +GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +#endif +#endif /* GL_NV_vertex_attrib_integer_64bit */ + +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_NV_vertex_buffer_unified_memory 1 +#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E +#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F +#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 +#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 +#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 +#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 +#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 +#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 +#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 +#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 +#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 +#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 +#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A +#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B +#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C +#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D +#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E +#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F +#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 +#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 +#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 +#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 +#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 +#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 +#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 +typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); +GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); +#endif +#endif /* GL_NV_vertex_buffer_unified_memory */ #ifndef GL_NV_vertex_program #define GL_NV_vertex_program 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei, const GLuint *, GLboolean *); -GLAPI void APIENTRY glBindProgramNV (GLenum, GLuint); -GLAPI void APIENTRY glDeleteProgramsNV (GLsizei, const GLuint *); -GLAPI void APIENTRY glExecuteProgramNV (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glGenProgramsNV (GLsizei, GLuint *); -GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum, GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetProgramivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetProgramStringNV (GLuint, GLenum, GLubyte *); -GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum, GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint, GLenum, GLvoid* *); -GLAPI GLboolean APIENTRY glIsProgramNV (GLuint); -GLAPI void APIENTRY glLoadProgramNV (GLenum, GLuint, GLsizei, const GLubyte *); -GLAPI void APIENTRY glProgramParameter4dNV (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramParameter4dvNV (GLenum, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramParameter4fNV (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramParameter4fvNV (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glProgramParameters4dvNV (GLenum, GLuint, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramParameters4fvNV (GLenum, GLuint, GLuint, const GLfloat *); -GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei, const GLuint *); -GLAPI void APIENTRY glTrackMatrixNV (GLenum, GLuint, GLenum, GLenum); -GLAPI void APIENTRY glVertexAttribPointerNV (GLuint, GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glVertexAttrib1dNV (GLuint, GLdouble); -GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib1fNV (GLuint, GLfloat); -GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib1sNV (GLuint, GLshort); -GLAPI void APIENTRY glVertexAttrib1svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib2dNV (GLuint, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib2fNV (GLuint, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib2sNV (GLuint, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib2svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib3dNV (GLuint, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib3fNV (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib3sNV (GLuint, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib3svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4dNV (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib4fNV (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib4sNV (GLuint, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib4svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs1svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs2svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs3svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs4svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint, GLsizei, const GLubyte *); -#endif /* GL_GLEXT_PROTOTYPES */ +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); @@ -5689,18 +11559,18 @@ typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint addr typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, void **pointer); typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint count, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint count, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v); typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer); typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); @@ -5740,779 +11610,1181 @@ typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei coun typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); -#endif +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences); +GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params); +GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program); +GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, void **pointer); +GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id); +GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v); +GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v); +GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform); +GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v); +#endif +#endif /* GL_NV_vertex_program */ + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif /* GL_NV_vertex_program1_1 */ -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_SGIX_texture_coordinate_clamp 1 -#endif +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif /* GL_NV_vertex_program2 */ -#ifndef GL_SGIX_scalebias_hint -#define GL_SGIX_scalebias_hint 1 +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 +#endif /* GL_NV_vertex_program2_option */ + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 +#endif /* GL_NV_vertex_program3 */ + +#ifndef GL_NV_vertex_program4 +#define GL_NV_vertex_program4 1 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params); +#endif +#endif /* GL_NV_vertex_program4 */ + +#ifndef GL_NV_video_capture +#define GL_NV_video_capture 1 +#define GL_VIDEO_BUFFER_NV 0x9020 +#define GL_VIDEO_BUFFER_BINDING_NV 0x9021 +#define GL_FIELD_UPPER_NV 0x9022 +#define GL_FIELD_LOWER_NV 0x9023 +#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 +#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 +#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 +#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 +#define GL_VIDEO_BUFFER_PITCH_NV 0x9028 +#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 +#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A +#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B +#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C +#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D +#define GL_PARTIAL_SUCCESS_NV 0x902E +#define GL_SUCCESS_NV 0x902F +#define GL_FAILURE_NV 0x9030 +#define GL_YCBYCR8_422_NV 0x9031 +#define GL_YCBAYCR8A_4224_NV 0x9032 +#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 +#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 +#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 +#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 +#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 +#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 +#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 +#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A +#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B +#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C +typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#endif +#endif /* GL_NV_video_capture */ + +#ifndef GL_NV_viewport_array2 +#define GL_NV_viewport_array2 1 +#endif /* GL_NV_viewport_array2 */ + +#ifndef GL_NV_viewport_swizzle +#define GL_NV_viewport_swizzle 1 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_X_NV 0x9350 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_X_NV 0x9351 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Y_NV 0x9352 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Y_NV 0x9353 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Z_NV 0x9354 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Z_NV 0x9355 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_W_NV 0x9356 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_W_NV 0x9357 +#define GL_VIEWPORT_SWIZZLE_X_NV 0x9358 +#define GL_VIEWPORT_SWIZZLE_Y_NV 0x9359 +#define GL_VIEWPORT_SWIZZLE_Z_NV 0x935A +#define GL_VIEWPORT_SWIZZLE_W_NV 0x935B +typedef void (APIENTRYP PFNGLVIEWPORTSWIZZLENVPROC) (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glViewportSwizzleNV (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); #endif +#endif /* GL_NV_viewport_swizzle */ #ifndef GL_OML_interlace #define GL_OML_interlace 1 -#endif - -#ifndef GL_OML_subsample -#define GL_OML_subsample 1 -#endif +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif /* GL_OML_interlace */ #ifndef GL_OML_resample #define GL_OML_resample 1 -#endif - -#ifndef GL_NV_copy_depth_to_color -#define GL_NV_copy_depth_to_color 1 -#endif +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif /* GL_OML_resample */ -#ifndef GL_ATI_envmap_bumpmap -#define GL_ATI_envmap_bumpmap 1 +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif /* GL_OML_subsample */ + +#ifndef GL_OVR_multiview +#define GL_OVR_multiview 1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR 0x9630 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR 0x9632 +#define GL_MAX_VIEWS_OVR 0x9631 +#define GL_FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR 0x9633 +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBumpParameterivATI (GLenum, const GLint *); -GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum, GLint *); -GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +GLAPI void APIENTRY glFramebufferTextureMultiviewOVR (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); #endif +#endif /* GL_OVR_multiview */ -#ifndef GL_ATI_fragment_shader -#define GL_ATI_fragment_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint); -GLAPI void APIENTRY glBindFragmentShaderATI (GLuint); -GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint); -GLAPI void APIENTRY glBeginFragmentShaderATI (void); -GLAPI void APIENTRY glEndFragmentShaderATI (void); -GLAPI void APIENTRY glPassTexCoordATI (GLuint, GLuint, GLenum); -GLAPI void APIENTRY glSampleMapATI (GLuint, GLuint, GLenum); -GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); -typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); -typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); -#endif +#ifndef GL_OVR_multiview2 +#define GL_OVR_multiview2 1 +#endif /* GL_OVR_multiview2 */ -#ifndef GL_ATI_pn_triangles -#define GL_ATI_pn_triangles 1 +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 +#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD +#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 +#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C +#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E +#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F +#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 +#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 +#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 +#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 +#define GL_CLIP_NEAR_HINT_PGI 0x1A220 +#define GL_CLIP_FAR_HINT_PGI 0x1A221 +#define GL_WIDE_LINE_HINT_PGI 0x1A222 +#define GL_BACK_NORMALS_HINT_PGI 0x1A223 +typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPNTrianglesiATI (GLenum, GLint); -GLAPI void APIENTRY glPNTrianglesfATI (GLenum, GLfloat); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode); #endif +#endif /* GL_PGI_misc_hints */ -#ifndef GL_ATI_vertex_array_object -#define GL_ATI_vertex_array_object 1 +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 +#define GL_VERTEX_DATA_HINT_PGI 0x1A22A +#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B +#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C +#define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#endif /* GL_PGI_vertex_hints */ + +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 +#endif /* GL_REND_screen_coordinates */ + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#define GL_RGBA_DXT5_S3TC 0x83A4 +#define GL_RGBA4_DXT5_S3TC 0x83A5 +#endif /* GL_S3_s3tc */ + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 +#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 +#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 +#define GL_LINEAR_DETAIL_SGIS 0x8097 +#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 +#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 +#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A +#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B +#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C +typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); #ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei, const GLvoid *, GLenum); -GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint); -GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint, GLuint, GLsizei, const GLvoid *, GLenum); -GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetObjectBufferivATI (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glFreeObjectBufferATI (GLuint); -GLAPI void APIENTRY glArrayObjectATI (GLenum, GLint, GLenum, GLsizei, GLuint, GLuint); -GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetArrayObjectivATI (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glVariantArrayObjectATI (GLuint, GLenum, GLsizei, GLuint, GLuint); -GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); -typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points); #endif +#endif /* GL_SGIS_detail_texture */ -#ifndef GL_EXT_vertex_shader -#define GL_EXT_vertex_shader 1 +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C +typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginVertexShaderEXT (void); -GLAPI void APIENTRY glEndVertexShaderEXT (void); -GLAPI void APIENTRY glBindVertexShaderEXT (GLuint); -GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint); -GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint); -GLAPI void APIENTRY glShaderOp1EXT (GLenum, GLuint, GLuint); -GLAPI void APIENTRY glShaderOp2EXT (GLenum, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glShaderOp3EXT (GLenum, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSwizzleEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glWriteMaskEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glInsertComponentEXT (GLuint, GLuint, GLuint); -GLAPI void APIENTRY glExtractComponentEXT (GLuint, GLuint, GLuint); -GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum, GLenum, GLenum, GLuint); -GLAPI void APIENTRY glSetInvariantEXT (GLuint, GLenum, const GLvoid *); -GLAPI void APIENTRY glSetLocalConstantEXT (GLuint, GLenum, const GLvoid *); -GLAPI void APIENTRY glVariantbvEXT (GLuint, const GLbyte *); -GLAPI void APIENTRY glVariantsvEXT (GLuint, const GLshort *); -GLAPI void APIENTRY glVariantivEXT (GLuint, const GLint *); -GLAPI void APIENTRY glVariantfvEXT (GLuint, const GLfloat *); -GLAPI void APIENTRY glVariantdvEXT (GLuint, const GLdouble *); -GLAPI void APIENTRY glVariantubvEXT (GLuint, const GLubyte *); -GLAPI void APIENTRY glVariantusvEXT (GLuint, const GLushort *); -GLAPI void APIENTRY glVariantuivEXT (GLuint, const GLuint *); -GLAPI void APIENTRY glVariantPointerEXT (GLuint, GLenum, GLuint, const GLvoid *); -GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint); -GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint); -GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum, GLenum); -GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum, GLenum); -GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum, GLenum, GLenum); -GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum, GLenum); -GLAPI GLuint APIENTRY glBindParameterEXT (GLenum); -GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint, GLenum); -GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint, GLenum, GLboolean *); -GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVariantPointervEXT (GLuint, GLenum, GLvoid* *); -GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint, GLenum, GLboolean *); -GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint, GLenum, GLboolean *); -GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); -typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); -typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); -typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); -typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); -typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); -typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); -typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); -typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); -typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); -typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); -typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); -typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); -typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); -typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); -typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); -typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); -typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); -typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); -typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points); #endif +#endif /* GL_SGIS_fog_function */ -#ifndef GL_ATI_vertex_streams -#define GL_ATI_vertex_streams 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexStream1sATI (GLenum, GLshort); -GLAPI void APIENTRY glVertexStream1svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream1iATI (GLenum, GLint); -GLAPI void APIENTRY glVertexStream1ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream1fATI (GLenum, GLfloat); -GLAPI void APIENTRY glVertexStream1fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream1dATI (GLenum, GLdouble); -GLAPI void APIENTRY glVertexStream1dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glVertexStream2sATI (GLenum, GLshort, GLshort); -GLAPI void APIENTRY glVertexStream2svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream2iATI (GLenum, GLint, GLint); -GLAPI void APIENTRY glVertexStream2ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream2fATI (GLenum, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexStream2fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream2dATI (GLenum, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexStream2dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glVertexStream3sATI (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexStream3svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream3iATI (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glVertexStream3ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexStream3fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexStream3dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glVertexStream4sATI (GLenum, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexStream4svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream4iATI (GLenum, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glVertexStream4ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream4fATI (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexStream4fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream4dATI (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexStream4dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glNormalStream3bATI (GLenum, GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glNormalStream3bvATI (GLenum, const GLbyte *); -GLAPI void APIENTRY glNormalStream3sATI (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glNormalStream3svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glNormalStream3iATI (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glNormalStream3ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glNormalStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glNormalStream3fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glNormalStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glNormalStream3dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum); -GLAPI void APIENTRY glVertexBlendEnviATI (GLenum, GLint); -GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum, GLfloat); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif /* GL_SGIS_generate_mipmap */ + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern); #endif +#endif /* GL_SGIS_multisample */ -#ifndef GL_ATI_element_array -#define GL_ATI_element_array 1 +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerATI (GLenum, const GLvoid *); -GLAPI void APIENTRY glDrawElementArrayATI (GLenum, GLsizei); -GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum, GLuint, GLuint, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params); #endif +#endif /* GL_SGIS_pixel_texture */ -#ifndef GL_SUN_mesh_array -#define GL_SUN_mesh_array 1 +#ifndef GL_SGIS_point_line_texgen +#define GL_SGIS_point_line_texgen 1 +#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 +#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 +#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 +#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 +#define GL_EYE_POINT_SGIS 0x81F4 +#define GL_OBJECT_POINT_SGIS 0x81F5 +#define GL_EYE_LINE_SGIS 0x81F6 +#define GL_OBJECT_LINE_SGIS 0x81F7 +#endif /* GL_SGIS_point_line_texgen */ + +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 +#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum, GLint, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params); #endif +#endif /* GL_SGIS_point_parameters */ -#ifndef GL_SUN_slice_accum -#define GL_SUN_slice_accum 1 +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 +#define GL_LINEAR_SHARPEN_SGIS 0x80AD +#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE +#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF +#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 +typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points); #endif +#endif /* GL_SGIS_sharpen_texture */ -#ifndef GL_NV_multisample_filter_hint -#define GL_NV_multisample_filter_hint 1 +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F +typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels); #endif +#endif /* GL_SGIS_texture4D */ -#ifndef GL_NV_depth_clamp -#define GL_NV_depth_clamp 1 +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 +#define GL_CLAMP_TO_BORDER_SGIS 0x812D +#endif /* GL_SGIS_texture_border_clamp */ + +#ifndef GL_SGIS_texture_color_mask +#define GL_SGIS_texture_color_mask 1 +#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF +typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); #endif +#endif /* GL_SGIS_texture_color_mask */ -#ifndef GL_NV_occlusion_query -#define GL_NV_occlusion_query 1 +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 +#define GL_CLAMP_TO_EDGE_SGIS 0x812F +#endif /* GL_SGIS_texture_edge_clamp */ + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 +typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); +typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei, const GLuint *); -GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint); -GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint); -GLAPI void APIENTRY glEndOcclusionQueryNV (void); -GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint, GLenum, GLuint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights); +GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); #endif +#endif /* GL_SGIS_texture_filter4 */ -#ifndef GL_NV_point_sprite -#define GL_NV_point_sprite 1 +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D +#endif /* GL_SGIS_texture_lod */ + +#ifndef GL_SGIS_texture_select +#define GL_SGIS_texture_select 1 +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS 0x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 +#endif /* GL_SGIS_texture_select */ + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 +#define GL_ASYNC_MARKER_SGIX 0x8329 +typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); +typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); +typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameteriNV (GLenum, GLint); -GLAPI void APIENTRY glPointParameterivNV (GLenum, const GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker); +GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp); +GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp); +GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range); +GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range); +GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker); #endif +#endif /* GL_SGIX_async */ -#ifndef GL_NV_texture_shader3 -#define GL_NV_texture_shader3 1 +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D +#endif /* GL_SGIX_async_histogram */ + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 +#endif /* GL_SGIX_async_pixel */ + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 +#endif /* GL_SGIX_blend_alpha_minmax */ + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_SGIX_calligraphic_fragment 1 +#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 +#endif /* GL_SGIX_calligraphic_fragment */ + +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 +#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D +#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E +#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F +#endif /* GL_SGIX_clipmap */ + +#ifndef GL_SGIX_convolution_accuracy +#define GL_SGIX_convolution_accuracy 1 +#define GL_CONVOLUTION_HINT_SGIX 0x8316 +#endif /* GL_SGIX_convolution_accuracy */ + +#ifndef GL_SGIX_depth_pass_instrument +#define GL_SGIX_depth_pass_instrument 1 +#endif /* GL_SGIX_depth_pass_instrument */ + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 +#endif /* GL_SGIX_depth_texture */ + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 +typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushRasterSGIX (void); #endif +#endif /* GL_SGIX_flush_raster */ + +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 +#endif /* GL_SGIX_fog_offset */ + +#ifndef GL_SGIX_fragment_lighting +#define GL_SGIX_fragment_lighting 1 +#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 +#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 +#define GL_LIGHT_ENV_MODE_SGIX 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B +#define GL_FRAGMENT_LIGHT0_SGIX 0x840C +#define GL_FRAGMENT_LIGHT1_SGIX 0x840D +#define GL_FRAGMENT_LIGHT2_SGIX 0x840E +#define GL_FRAGMENT_LIGHT3_SGIX 0x840F +#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 +#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 +#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 +#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 +typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode); +GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params); +GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param); +#endif +#endif /* GL_SGIX_fragment_lighting */ -#ifndef GL_NV_vertex_program1_1 -#define GL_NV_vertex_program1_1 1 +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 +#define GL_FRAMEZOOM_SGIX 0x818B +#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C +#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D +typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameZoomSGIX (GLint factor); #endif +#endif /* GL_SGIX_framezoom */ -#ifndef GL_EXT_shadow_funcs -#define GL_EXT_shadow_funcs 1 +#ifndef GL_SGIX_igloo_interface +#define GL_SGIX_igloo_interface 1 +typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const void *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const void *params); #endif +#endif /* GL_SGIX_igloo_interface */ -#ifndef GL_EXT_stencil_two_side -#define GL_EXT_stencil_two_side 1 +#ifndef GL_SGIX_instruments +#define GL_SGIX_instruments 1 +#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 +#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 +typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); +typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); +typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); +typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); +GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer); +GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p); +GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker); +GLAPI void APIENTRY glStartInstrumentsSGIX (void); +GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker); #endif +#endif /* GL_SGIX_instruments */ -#ifndef GL_ATI_text_fragment_shader -#define GL_ATI_text_fragment_shader 1 -#endif +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 +#define GL_INTERLACE_SGIX 0x8094 +#endif /* GL_SGIX_interlace */ -#ifndef GL_APPLE_client_storage -#define GL_APPLE_client_storage 1 -#endif +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 +#define GL_IR_INSTRUMENT1_SGIX 0x817F +#endif /* GL_SGIX_ir_instrument1 */ -#ifndef GL_APPLE_element_array -#define GL_APPLE_element_array 1 +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 +#define GL_LIST_PRIORITY_SGIX 0x8182 +typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerAPPLE (GLenum, const GLvoid *); -GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum, GLint, GLsizei); -GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, GLint, GLsizei); -GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum, const GLint *, const GLsizei *, GLsizei); -GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, const GLint *, const GLsizei *, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params); +GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param); +GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param); +GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params); #endif +#endif /* GL_SGIX_list_priority */ -#ifndef GL_APPLE_fence -#define GL_APPLE_fence 1 +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B +typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenFencesAPPLE (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei, const GLuint *); -GLAPI void APIENTRY glSetFenceAPPLE (GLuint); -GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint); -GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint); -GLAPI void APIENTRY glFinishFenceAPPLE (GLuint); -GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum, GLuint); -GLAPI void APIENTRY glFinishObjectAPPLE (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); -typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); -typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode); #endif +#endif /* GL_SGIX_pixel_texture */ -#ifndef GL_APPLE_vertex_array_object -#define GL_APPLE_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint); -GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei, const GLuint *); -GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); -#endif +#ifndef GL_SGIX_pixel_tiles +#define GL_SGIX_pixel_tiles 1 +#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E +#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F +#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 +#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 +#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 +#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 +#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 +#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 +#endif /* GL_SGIX_pixel_tiles */ -#ifndef GL_APPLE_vertex_array_range -#define GL_APPLE_vertex_array_range 1 +#ifndef GL_SGIX_polynomial_ffd +#define GL_SGIX_polynomial_ffd 1 +#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 +#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 +#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 +#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 +#define GL_DEFORMATIONS_MASK_SGIX 0x8196 +#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei, GLvoid *); -GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei, GLvoid *); -GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); -#endif - -#ifndef GL_APPLE_ycbcr_422 -#define GL_APPLE_ycbcr_422 1 -#endif - -#ifndef GL_S3_s3tc -#define GL_S3_s3tc 1 +GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +GLAPI void APIENTRY glDeformSGIX (GLbitfield mask); +GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask); #endif +#endif /* GL_SGIX_polynomial_ffd */ -#ifndef GL_ATI_draw_buffers -#define GL_ATI_draw_buffers 1 +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 +#define GL_REFERENCE_PLANE_SGIX 0x817D +#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E +typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersATI (GLsizei, const GLenum *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); -#endif - -#ifndef GL_ATI_pixel_format_float -#define GL_ATI_pixel_format_float 1 -/* This is really a WGL extension, but defines some associated GL enums. - * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string. - */ +GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation); #endif +#endif /* GL_SGIX_reference_plane */ -#ifndef GL_ATI_texture_env_combine3 -#define GL_ATI_texture_env_combine3 1 -#endif +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 +#define GL_PACK_RESAMPLE_SGIX 0x842E +#define GL_UNPACK_RESAMPLE_SGIX 0x842F +#define GL_RESAMPLE_REPLICATE_SGIX 0x8433 +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x8434 +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#endif /* GL_SGIX_resample */ -#ifndef GL_ATI_texture_float -#define GL_ATI_texture_float 1 -#endif +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif /* GL_SGIX_scalebias_hint */ -#ifndef GL_NV_float_buffer -#define GL_NV_float_buffer 1 -#endif +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D +#endif /* GL_SGIX_shadow */ -#ifndef GL_NV_fragment_program -#define GL_NV_fragment_program 1 -/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint, GLsizei, const GLubyte *, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint, GLsizei, const GLubyte *, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint, GLsizei, const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint, GLsizei, const GLubyte *, const GLdouble *); -GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint, GLsizei, const GLubyte *, GLfloat *); -GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint, GLsizei, const GLubyte *, GLdouble *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); -#endif +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 +#define GL_SHADOW_AMBIENT_SGIX 0x80BF +#endif /* GL_SGIX_shadow_ambient */ -#ifndef GL_NV_half_float -#define GL_NV_half_float 1 +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 +#define GL_SPRITE_SGIX 0x8148 +#define GL_SPRITE_MODE_SGIX 0x8149 +#define GL_SPRITE_AXIS_SGIX 0x814A +#define GL_SPRITE_TRANSLATION_SGIX 0x814B +#define GL_SPRITE_AXIAL_SGIX 0x814C +#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D +#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertex2hNV (GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertex3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertex4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *); -GLAPI void APIENTRY glNormal3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glColor4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV); -GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glFogCoordhNV (GLhalfNV); -GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *); -GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV); -GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib1hNV (GLuint, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib2hNV (GLuint, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib3hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib4hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint, GLsizei, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint, GLsizei, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint, GLsizei, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint, GLsizei, const GLhalfNV *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); -typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); -typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); -typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); -typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params); #endif +#endif /* GL_SGIX_sprite */ -#ifndef GL_NV_pixel_data_range -#define GL_NV_pixel_data_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelDataRangeNV (GLenum, GLsizei, GLvoid *); -GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); -#endif +#ifndef GL_SGIX_subsample +#define GL_SGIX_subsample 1 +#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 +#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 +#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 +#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 +#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 +#endif /* GL_SGIX_subsample */ -#ifndef GL_NV_primitive_restart -#define GL_NV_primitive_restart 1 +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 +typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPrimitiveRestartNV (void); -GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +GLAPI void APIENTRY glTagSampleBufferSGIX (void); #endif +#endif /* GL_SGIX_tag_sample_buffer */ -#ifndef GL_NV_texture_expand_normal -#define GL_NV_texture_expand_normal 1 -#endif +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE +#endif /* GL_SGIX_texture_add_env */ + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif /* GL_SGIX_texture_coordinate_clamp */ -#ifndef GL_NV_vertex_program2 -#define GL_NV_vertex_program2 1 -#endif +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 +#endif /* GL_SGIX_texture_lod_bias */ -#ifndef GL_ATI_map_object_buffer -#define GL_ATI_map_object_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint); -GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); -#endif +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E +#endif /* GL_SGIX_texture_multi_buffer */ -#ifndef GL_ATI_separate_stencil -#define GL_ATI_separate_stencil 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilOpSeparateATI (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum, GLenum, GLint, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -#endif +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C +#endif /* GL_SGIX_texture_scale_bias */ -#ifndef GL_ATI_vertex_attrib_array_object -#define GL_ATI_vertex_attrib_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint, GLint, GLenum, GLboolean, GLsizei, GLuint, GLuint); -GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); -#endif +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF +#endif /* GL_SGIX_vertex_preclip */ -#ifndef GL_OES_read_format -#define GL_OES_read_format 1 -#endif +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC +#endif /* GL_SGIX_ycrcb */ -#ifndef GL_EXT_depth_bounds_test -#define GL_EXT_depth_bounds_test 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDepthBoundsEXT (GLclampd, GLclampd); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); -#endif +#ifndef GL_SGIX_ycrcb_subsample +#define GL_SGIX_ycrcb_subsample 1 +#endif /* GL_SGIX_ycrcb_subsample */ -#ifndef GL_EXT_texture_mirror_clamp -#define GL_EXT_texture_mirror_clamp 1 -#endif +#ifndef GL_SGIX_ycrcba +#define GL_SGIX_ycrcba 1 +#define GL_YCRCB_SGIX 0x8318 +#define GL_YCRCBA_SGIX 0x8319 +#endif /* GL_SGIX_ycrcba */ -#ifndef GL_EXT_blend_equation_separate -#define GL_EXT_blend_equation_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); -#endif +#ifndef GL_SGI_color_matrix +#define GL_SGI_color_matrix 1 +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB +#endif /* GL_SGI_color_matrix */ -#ifndef GL_MESA_pack_invert -#define GL_MESA_pack_invert 1 +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF +typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, void *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, void *table); +GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params); #endif +#endif /* GL_SGI_color_table */ -#ifndef GL_MESA_ycbcr_texture -#define GL_MESA_ycbcr_texture 1 -#endif +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD +#endif /* GL_SGI_texture_color_table */ -#ifndef GL_EXT_pixel_buffer_object -#define GL_EXT_pixel_buffer_object 1 +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 +typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFinishTextureSUNX (void); #endif +#endif /* GL_SUNX_constant_data */ -#ifndef GL_NV_fragment_program_option -#define GL_NV_fragment_program_option 1 -#endif +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 +#define GL_WRAP_BORDER_SUN 0x81D4 +#endif /* GL_SUN_convolution_border_modes */ -#ifndef GL_NV_fragment_program2 -#define GL_NV_fragment_program2 1 +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor); +GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor); #endif +#endif /* GL_SUN_global_alpha */ -#ifndef GL_NV_vertex_program2_option -#define GL_NV_vertex_program2_option 1 +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 +typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width); #endif +#endif /* GL_SUN_mesh_array */ -#ifndef GL_NV_vertex_program3 -#define GL_NV_vertex_program3 1 -#endif +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif /* GL_SUN_slice_accum */ -#ifndef GL_EXT_framebuffer_object -#define GL_EXT_framebuffer_object 1 +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const void **pointer); #ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint); -GLAPI void APIENTRY glBindRenderbufferEXT (GLenum, GLuint); -GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei, GLuint *); -GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum, GLenum, GLsizei, GLsizei); -GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum, GLenum, GLint *); -GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint); -GLAPI void APIENTRY glBindFramebufferEXT (GLenum, GLuint); -GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei, GLuint *); -GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum); -GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum, GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum, GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLint); -GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum, GLenum, GLenum, GLuint); -GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGenerateMipmapEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); -typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code); +GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code); +GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code); +GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code); +GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code); +GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code); +GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const void **pointer); #endif +#endif /* GL_SUN_triangle_list */ -#ifndef GL_GREMEDY_string_marker -#define GL_GREMEDY_string_marker 1 +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); -#endif +GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif +#endif /* GL_SUN_vertex */ -#ifndef GL_NV_texture_barrier -#define GL_NV_texture_barrier 1 -#ifdef GL_EXT_PROTOTYPES -GLAPI void APIENTRY glTextureBarrierNV (void); -#endif /* GL_EXT_PROTOTYPES */ -typedef void (APIENTRYP PNFGLTEXTUREBARRIERNVPROC) (void); -#endif +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB +#endif /* GL_WIN_phong_shading */ + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#endif /* GL_WIN_specular_fog */ #ifdef __cplusplus } diff --git a/src/share/native/sun/java2d/opengl/J2D_GL/khrplatform.h b/src/share/native/sun/java2d/opengl/J2D_GL/khrplatform.h new file mode 100644 index 0000000000000000000000000000000000000000..777768811d4834909c6b43583ea59960fa2acb68 --- /dev/null +++ b/src/share/native/sun/java2d/opengl/J2D_GL/khrplatform.h @@ -0,0 +1,321 @@ +/* + * 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. + */ + +#ifndef __khrplatform_h_ +#define __khrplatform_h_ + +/* +** This file is available under and governed by the GNU General Public +** License version 2 only, as published by the Free Software Foundation. +** However, the following notice accompanied the original version of this +** file: +** +** Copyright (c) 2008-2018 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Khronos platform-specific types and definitions. + * + * The master copy of khrplatform.h is maintained in the Khronos EGL + * Registry repository at https://github.com/KhronosGroup/EGL-Registry + * The last semantic modification to khrplatform.h was at commit ID: + * 67a3e0864c2d75ea5287b9f3d2eb74a745936692 + * + * Adopters may modify this file to suit their platform. Adopters are + * encouraged to submit platform specific modifications to the Khronos + * group so that they can be included in future versions of this file. + * Please submit changes by filing pull requests or issues on + * the EGL Registry repository linked above. + * + * + * See the Implementer's Guidelines for information about where this file + * should be located on your system and for more details of its use: + * http://www.khronos.org/registry/implementers_guide.pdf + * + * This file should be included as + * #include + * by Khronos client API header files that use its types and defines. + * + * The types in khrplatform.h should only be used to define API-specific types. + * + * Types defined in khrplatform.h: + * khronos_int8_t signed 8 bit + * khronos_uint8_t unsigned 8 bit + * khronos_int16_t signed 16 bit + * khronos_uint16_t unsigned 16 bit + * khronos_int32_t signed 32 bit + * khronos_uint32_t unsigned 32 bit + * khronos_int64_t signed 64 bit + * khronos_uint64_t unsigned 64 bit + * khronos_intptr_t signed same number of bits as a pointer + * khronos_uintptr_t unsigned same number of bits as a pointer + * khronos_ssize_t signed size + * khronos_usize_t unsigned size + * khronos_float_t signed 32 bit floating point + * khronos_time_ns_t unsigned 64 bit time in nanoseconds + * khronos_utime_nanoseconds_t unsigned time interval or absolute time in + * nanoseconds + * khronos_stime_nanoseconds_t signed time interval in nanoseconds + * khronos_boolean_enum_t enumerated boolean type. This should + * only be used as a base type when a client API's boolean type is + * an enum. Client APIs which use an integer or other type for + * booleans cannot use this as the base type for their boolean. + * + * Tokens defined in khrplatform.h: + * + * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. + * + * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. + * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. + * + * Calling convention macros defined in this file: + * KHRONOS_APICALL + * KHRONOS_APIENTRY + * KHRONOS_APIATTRIBUTES + * + * These may be used in function prototypes as: + * + * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( + * int arg1, + * int arg2) KHRONOS_APIATTRIBUTES; + */ + +#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC) +# define KHRONOS_STATIC 1 +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APICALL + *------------------------------------------------------------------------- + * This precedes the return type of the function in the function prototype. + */ +#if defined(KHRONOS_STATIC) + /* If the preprocessor constant KHRONOS_STATIC is defined, make the + * header compatible with static linking. */ +# define KHRONOS_APICALL +#elif defined(_WIN32) +# define KHRONOS_APICALL __declspec(dllimport) +#elif defined (__SYMBIAN32__) +# define KHRONOS_APICALL IMPORT_C +#elif (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303) \ + || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +/* KHRONOS_APIATTRIBUTES is not used by the client API headers yet */ +# define KHRONOS_APICALL __attribute__((visibility("default"))) +#else +# define KHRONOS_APICALL +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIENTRY + *------------------------------------------------------------------------- + * This follows the return type of the function and precedes the function + * name in the function prototype. + */ +#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(KHRONOS_STATIC) + /* Win32 but not WinCE */ +# define KHRONOS_APIENTRY __stdcall +#else +# define KHRONOS_APIENTRY +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIATTRIBUTES + *------------------------------------------------------------------------- + * This follows the closing parenthesis of the function prototype arguments. + */ +#if defined (__ARMCC_2__) +#define KHRONOS_APIATTRIBUTES __softfp +#else +#define KHRONOS_APIATTRIBUTES +#endif + +/*------------------------------------------------------------------------- + * basic type definitions + *-----------------------------------------------------------------------*/ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) + + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__VMS ) || defined(__sgi) + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) + +/* + * Win32 + */ +typedef __int32 khronos_int32_t; +typedef unsigned __int32 khronos_uint32_t; +typedef __int64 khronos_int64_t; +typedef unsigned __int64 khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__sun__) || defined(__digital__) + +/* + * Sun or Digital + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#if defined(__arch64__) || defined(_LP64) +typedef long int khronos_int64_t; +typedef unsigned long int khronos_uint64_t; +#else +typedef long long int khronos_int64_t; +typedef unsigned long long int khronos_uint64_t; +#endif /* __arch64__ */ +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif 0 + +/* + * Hypothetical platform with no float or int64 support + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#define KHRONOS_SUPPORT_INT64 0 +#define KHRONOS_SUPPORT_FLOAT 0 + +#else + +/* + * Generic fallback + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#endif + + +/* + * Types that are (so far) the same on all platforms + */ +typedef signed char khronos_int8_t; +typedef unsigned char khronos_uint8_t; +typedef signed short int khronos_int16_t; +typedef unsigned short int khronos_uint16_t; + +/* + * Types that differ between LLP64 and LP64 architectures - in LLP64, + * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears + * to be the only LLP64 architecture in current use. + */ +#ifdef _WIN64 +typedef signed long long int khronos_intptr_t; +typedef unsigned long long int khronos_uintptr_t; +typedef signed long long int khronos_ssize_t; +typedef unsigned long long int khronos_usize_t; +#else +typedef signed long int khronos_intptr_t; +typedef unsigned long int khronos_uintptr_t; +typedef signed long int khronos_ssize_t; +typedef unsigned long int khronos_usize_t; +#endif + +#if KHRONOS_SUPPORT_FLOAT +/* + * Float type + */ +typedef float khronos_float_t; +#endif + +#if KHRONOS_SUPPORT_INT64 +/* Time types + * + * These types can be used to represent a time interval in nanoseconds or + * an absolute Unadjusted System Time. Unadjusted System Time is the number + * of nanoseconds since some arbitrary system event (e.g. since the last + * time the system booted). The Unadjusted System Time is an unsigned + * 64 bit value that wraps back to 0 every 584 years. Time intervals + * may be either signed or unsigned. + */ +typedef khronos_uint64_t khronos_utime_nanoseconds_t; +typedef khronos_int64_t khronos_stime_nanoseconds_t; +#endif + +/* + * Dummy value used to pad enum types to 32 bits. + */ +#ifndef KHRONOS_MAX_ENUM +#define KHRONOS_MAX_ENUM 0x7FFFFFFF +#endif + +/* + * Enumerated boolean type + * + * Values other than zero should be considered to be true. Therefore + * comparisons should not be made against KHRONOS_TRUE. + */ +typedef enum { + KHRONOS_FALSE = 0, + KHRONOS_TRUE = 1, + KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM +} khronos_boolean_enum_t; + +#endif /* __khrplatform_h_ */ diff --git a/src/share/native/sun/security/ec/impl/mpi.c b/src/share/native/sun/security/ec/impl/mpi.c index c91a04f62e4af6e9ff46d324c395f17361fd63e7..1add21e51a06baad099166a6488cdcf1a8ba9600 100644 --- a/src/share/native/sun/security/ec/impl/mpi.c +++ b/src/share/native/sun/security/ec/impl/mpi.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2020, 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 @@ -34,7 +34,7 @@ * Netscape Communications Corporation * Douglas Stebila of Sun Laboratories. * - * Last Modified Date from the Original Code: June 2014 + * Last Modified Date from the Original Code: Nov 2019 *********************************************************************** */ /* Arbitrary precision integer arithmetic library */ @@ -2134,7 +2134,10 @@ mp_err s_mp_almost_inverse(const mp_int *a, const mp_int *p, mp_int *c) } } if (res >= 0) { - while (MP_SIGN(c) != MP_ZPOS) { + if (s_mp_cmp(c, p) >= 0) { + MP_CHECKOK( mp_div(c, p, NULL, c)); + } + if (MP_SIGN(c) != MP_ZPOS) { MP_CHECKOK( mp_add(c, p, c) ); } res = k; diff --git a/src/solaris/bin/java_md_solinux.c b/src/solaris/bin/java_md_solinux.c index 6d977109d13393a4a0fd432825cc78bdfe486ce5..bbe8713d0aa486a3964bdc77ae492faaaaea672d 100644 --- a/src/solaris/bin/java_md_solinux.c +++ b/src/solaris/bin/java_md_solinux.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1111,3 +1111,24 @@ ProcessPlatformOption(const char *arg) { return JNI_FALSE; } + +#ifndef __solaris__ + +/* + * Provide a CounterGet() implementation based on gettimeofday() which + * is universally available, even though it may not be 'high resolution' + * compared to platforms that provide gethrtime() (like Solaris). It is + * also subject to time-of-day changes, but alternatives may not be + * known to be available at either build time or run time. + */ +uint64_t CounterGet() { + uint64_t result = 0; + struct timeval tv; + if (gettimeofday(&tv, NULL) != -1) { + result = 1000000LL * (uint64_t)tv.tv_sec; + result += (uint64_t)tv.tv_usec; + } + return result; +} + +#endif // !__solaris__ diff --git a/src/solaris/bin/java_md_solinux.h b/src/solaris/bin/java_md_solinux.h index 3f1dc115b4d2fb0c856fcbcb5d2f62ccbb8348b6..dada3422b54dabf8a969a0fadd29935ab862d4bd 100644 --- a/src/solaris/bin/java_md_solinux.h +++ b/src/solaris/bin/java_md_solinux.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. * 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,17 +26,17 @@ #ifndef JAVA_MD_SOLINUX_H #define JAVA_MD_SOLINUX_H -#ifdef HAVE_GETHRTIME +#include +#ifdef __solaris__ /* * Support for doing cheap, accurate interval timing. */ -#include #define CounterGet() (gethrtime()/1000) #define Counter2Micros(counts) (counts) -#else /* ! HAVE_GETHRTIME */ -#define CounterGet() (0) -#define Counter2Micros(counts) (1) -#endif /* HAVE_GETHRTIME */ +#else /* ! __solaris__ */ +uint64_t CounterGet(void); +#define Counter2Micros(counts) (counts) +#endif /* __solaris__ */ /* pointer to environment */ extern char **environ; diff --git a/src/solaris/classes/java/lang/UNIXProcess.java b/src/solaris/classes/java/lang/UNIXProcess.java index fe26fd893014c0fdbfc66e035eaef1d3b77f58e0..674681cd290734de8d24242c9425aeeb1557ed86 100644 --- a/src/solaris/classes/java/lang/UNIXProcess.java +++ b/src/solaris/classes/java/lang/UNIXProcess.java @@ -401,12 +401,11 @@ final class UNIXProcess extends Process { public synchronized boolean waitFor(long timeout, TimeUnit unit) throws InterruptedException { + long remainingNanos = unit.toNanos(timeout); // throw NPE before other conditions if (hasExited) return true; if (timeout <= 0) return false; - long remainingNanos = unit.toNanos(timeout); long deadline = System.nanoTime() + remainingNanos; - do { TimeUnit.NANOSECONDS.timedWait(this, remainingNanos); if (hasExited) { diff --git a/src/solaris/classes/sun/awt/X11/XBaseWindow.java b/src/solaris/classes/sun/awt/X11/XBaseWindow.java index 297e2dd40218bcdd452dfd0f69e817a17a59d245..0569fc09808dbfe3c26d1f04de9e08bc00d5e503 100644 --- a/src/solaris/classes/sun/awt/X11/XBaseWindow.java +++ b/src/solaris/classes/sun/awt/X11/XBaseWindow.java @@ -1004,29 +1004,37 @@ public class XBaseWindow { * InputEvent.BUTTON_DOWN_MASK. * One more bit is reserved for FIRST_HIGH_BIT. */ - if (xbe.get_button() > SunToolkit.MAX_BUTTONS_SUPPORTED) { + int theButton = xbe.get_button(); + if (theButton > SunToolkit.MAX_BUTTONS_SUPPORTED) { return; } int buttonState = 0; buttonState = xbe.get_state() & XConstants.ALL_BUTTONS_MASK; - switch (xev.get_type()) { - case XConstants.ButtonPress: - if (buttonState == 0) { - XWindowPeer parent = getToplevelXWindow(); - // See 6385277, 6981400. - if (parent != null && parent.isFocusableWindow()) { - // A click in a client area drops the actual focused window retaining. - parent.setActualFocusedWindow(null); - parent.requestWindowFocus(xbe.get_time(), true); - } - XAwtState.setAutoGrabWindow(this); - } - break; - case XConstants.ButtonRelease: - if (isFullRelease(buttonState, xbe.get_button())) { - XAwtState.setAutoGrabWindow(null); + + boolean isWheel = (theButton == XConstants.MouseWheelUp || + theButton == XConstants.MouseWheelDown); + + // don't give focus if it's just the mouse wheel turning + if (!isWheel) { + switch (xev.get_type()) { + case XConstants.ButtonPress: + if (buttonState == 0) { + XWindowPeer parent = getToplevelXWindow(); + // See 6385277, 6981400. + if (parent != null && parent.isFocusableWindow()) { + // A click in a client area drops the actual focused window retaining. + parent.setActualFocusedWindow(null); + parent.requestWindowFocus(xbe.get_time(), true); + } + XAwtState.setAutoGrabWindow(this); + } + break; + case XConstants.ButtonRelease: + if (isFullRelease(buttonState, xbe.get_button())) { + XAwtState.setAutoGrabWindow(null); + } + break; } - break; } } public void handleMotionNotify(XEvent xev) { diff --git a/src/solaris/classes/sun/awt/X11/XConstants.java b/src/solaris/classes/sun/awt/X11/XConstants.java index 91c533898b8df57c5c4a17748c0486a588773653..264a6beb484dbb11e8e9cda199346806dadaf702 100644 --- a/src/solaris/classes/sun/awt/X11/XConstants.java +++ b/src/solaris/classes/sun/awt/X11/XConstants.java @@ -206,6 +206,11 @@ final public class XConstants { public static final int buttons [] = new int [] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}; + // those should probably be wrapped in a method or such + // as it may be possible to remap them via x11 configuration files + public static final int MouseWheelUp = buttons[3]; + public static final int MouseWheelDown = buttons[4]; + /* Notify modes */ public static final int NotifyNormal = 0 ; diff --git a/src/solaris/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine b/src/solaris/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine index c79fdbde9c8bf8d7d11a4fbc0f0908736eb7cb71..d6fe0859f5613491d839de2e614e3c394732722d 100644 --- a/src/solaris/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine +++ b/src/solaris/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine @@ -1,3 +1,9 @@ +# note: the last class is the default Rendering Engine +# Pisces in JDK8u, Marlin in JDK9+ + +# Marlin Rendering Engine module +sun.java2d.marlin.MarlinRenderingEngine + # Jules Rendering Engine module sun.java2d.jules.JulesRenderingEngine diff --git a/src/solaris/classes/sun/java2d/xr/XRDrawLine.java b/src/solaris/classes/sun/java2d/xr/XRDrawLine.java index 66b595e9455766c638ea9999e0d765a337627fab..d4170c4f59c2d457e1b54d34d3c40673c01088e4 100644 --- a/src/solaris/classes/sun/java2d/xr/XRDrawLine.java +++ b/src/solaris/classes/sun/java2d/xr/XRDrawLine.java @@ -224,7 +224,7 @@ public class XRDrawLine { outcode2 = outcode(x2, y2, cxmin, cymin, cxmax, cymax); while ((outcode1 | outcode2) != 0) { - int xsteps = 0, ysteps = 0; + long xsteps = 0, ysteps = 0; if ((outcode1 & outcode2) != 0) { return false; diff --git a/src/solaris/classes/sun/nio/fs/LinuxFileSystem.java b/src/solaris/classes/sun/nio/fs/LinuxFileSystem.java index c154ff564769b3b012bd0b5fe5331ee1de9e0f00..cfd83963b2bce8e9bafac7b4e39b6b5e386617a7 100644 --- a/src/solaris/classes/sun/nio/fs/LinuxFileSystem.java +++ b/src/solaris/classes/sun/nio/fs/LinuxFileSystem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2018, 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 @@ -79,10 +79,26 @@ class LinuxFileSystem extends UnixFileSystem { ArrayList entries = new ArrayList<>(); try { long fp = setmntent(Util.toBytes(fstab), Util.toBytes("r")); + int maxLineSize = 1024; + try { + for (;;) { + int lineSize = getlinelen(fp); + if (lineSize == -1) + break; + if (lineSize > maxLineSize) + maxLineSize = lineSize; + } + } catch (UnixException x) { + // nothing we need to do + } finally { + rewind(fp); + } + try { for (;;) { UnixMountEntry entry = new UnixMountEntry(); - int res = getmntent(fp, entry); + // count in NUL character at the end + int res = getmntent(fp, entry, maxLineSize + 1); if (res < 0) break; entries.add(entry); diff --git a/src/solaris/classes/sun/nio/fs/LinuxNativeDispatcher.java b/src/solaris/classes/sun/nio/fs/LinuxNativeDispatcher.java index 0186870688a23c2c5c2253f05bcfd03aa2b25230..a0713a3686cb1d3708c5dfb51b3b3d6e47071f08 100644 --- a/src/solaris/classes/sun/nio/fs/LinuxNativeDispatcher.java +++ b/src/solaris/classes/sun/nio/fs/LinuxNativeDispatcher.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 @@ -54,7 +54,17 @@ class LinuxNativeDispatcher extends UnixNativeDispatcher { /** * int getmntent(FILE *fp, struct mnttab *mp, int len); */ - static native int getmntent(long fp, UnixMountEntry entry) + + static int getmntent(long fp, UnixMountEntry entry, int buflen) throws UnixException { + NativeBuffer buffer = NativeBuffers.getNativeBuffer(buflen); + try { + return getmntent0(fp, entry, buffer.address(), buflen); + } finally { + buffer.release(); + } + } + + static native int getmntent0(long fp, UnixMountEntry entry, long buffer, int bufLen) throws UnixException; /** @@ -62,6 +72,11 @@ class LinuxNativeDispatcher extends UnixNativeDispatcher { */ static native void endmntent(long stream) throws UnixException; + /** + * ssize_t getline(char **lineptr, size_t *n, FILE *stream); + */ + static native int getlinelen(long stream) throws UnixException; + /** * ssize_t fgetxattr(int filedes, const char *name, void *value, size_t size); */ diff --git a/src/solaris/classes/sun/nio/fs/UnixNativeDispatcher.java b/src/solaris/classes/sun/nio/fs/UnixNativeDispatcher.java index 7a8c918af2b12f5db7f0c208ddaa35022c450b78..6aa24f2e29038760eae5e9feefb256d3c3f2f542 100644 --- a/src/solaris/classes/sun/nio/fs/UnixNativeDispatcher.java +++ b/src/solaris/classes/sun/nio/fs/UnixNativeDispatcher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2013, 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 @@ -116,6 +116,11 @@ class UnixNativeDispatcher { */ static native void fclose(long stream) throws UnixException; + /** + * void rewind(FILE* stream); + */ + static native void rewind(long stream) throws UnixException; + /** * link(const char* existing, const char* new) */ diff --git a/src/solaris/native/java/net/NetworkInterface.c b/src/solaris/native/java/net/NetworkInterface.c index f71da7b6cd00fb2c8d1d0f36131a45be3cd3ce42..6c49c09e7c82a81988a4d9afb0a8f1a3894c6fd8 100644 --- a/src/solaris/native/java/net/NetworkInterface.c +++ b/src/solaris/native/java/net/NetworkInterface.c @@ -259,6 +259,7 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByName0 ifs = enumInterfaces(env); if (ifs == NULL) { + (*env)->ReleaseStringUTFChars(env, name, name_utf); return NULL; } diff --git a/src/solaris/native/java/net/PlainDatagramSocketImpl.c b/src/solaris/native/java/net/PlainDatagramSocketImpl.c index cd15654e1e837a141a2079c1642ea6b19be65b1d..4d8abe034ab728c6d8d62778c95c7d5d8d0cf8a6 100644 --- a/src/solaris/native/java/net/PlainDatagramSocketImpl.c +++ b/src/solaris/native/java/net/PlainDatagramSocketImpl.c @@ -41,7 +41,6 @@ #endif #ifdef __linux__ #include -#include #include #include diff --git a/src/solaris/native/java/net/PlainSocketImpl.c b/src/solaris/native/java/net/PlainSocketImpl.c index 71cbdf8ce67d5f00201e62449757aa557198478b..373c5e36255634b6dd04cbf4f62162391eabe1b5 100644 --- a/src/solaris/native/java/net/PlainSocketImpl.c +++ b/src/solaris/native/java/net/PlainSocketImpl.c @@ -43,7 +43,6 @@ #endif #ifdef __linux__ #include -#include #endif #include "jvm.h" diff --git a/src/solaris/native/java/net/bsd_close.c b/src/solaris/native/java/net/bsd_close.c index af57cef306cdca5fd50c0546f36a4400658e4f3c..89a20707c406d7aeb939627feab2a15f26c50403 100644 --- a/src/solaris/native/java/net/bsd_close.c +++ b/src/solaris/native/java/net/bsd_close.c @@ -23,6 +23,8 @@ * questions. */ +#include +#include #include #include #include @@ -61,18 +63,35 @@ typedef struct { static int sigWakeup = SIGIO; /* - * The fd table and the number of file descriptors + * fdTable holds one entry per file descriptor, up to a certain + * maximum. + * Theoretically, the number of possible file descriptors can get + * large, though usually it does not. Entries for small value file + * descriptors are kept in a simple table, which covers most scenarios. + * Entries for large value file descriptors are kept in an overflow + * table, which is organized as a sparse two dimensional array whose + * slabs are allocated on demand. This covers all corner cases while + * keeping memory consumption reasonable. */ -static fdEntry_t *fdTable; -static int fdCount; -/* - * This limit applies if getlimit() returns unlimited. - * Unfortunately, this means if someone wants a higher limit - * then they have to set an explicit limit, higher than this, - * which is probably counter-intuitive. +/* Base table for low value file descriptors */ +static fdEntry_t* fdTable = NULL; +/* Maximum size of base table (in number of entries). */ +static const int fdTableMaxSize = 0x1000; /* 4K */ +/* Actual size of base table (in number of entries) */ +static int fdTableLen = 0; +/* Max. theoretical number of file descriptors on system. */ +static int fdLimit = 0; + +/* Overflow table, should base table not be large enough. Organized as + * an array of n slabs, each holding 64k entries. */ -#define MAX_FD_COUNT 4096 +static fdEntry_t** fdOverflowTable = NULL; +/* Number of slabs in the overflow table */ +static int fdOverflowTableLen = 0; +/* Number of entries in one slab */ +static const int fdOverflowTableSlabSize = 0x10000; /* 64k */ +pthread_mutex_t fdOverflowTableLock = PTHREAD_MUTEX_INITIALIZER; /* * Null signal handler @@ -88,26 +107,43 @@ static void __attribute((constructor)) init() { struct rlimit nbr_files; sigset_t sigset; struct sigaction sa; - int i; + int i = 0; - /* - * Allocate table based on the maximum number of - * file descriptors. - */ - getrlimit(RLIMIT_NOFILE, &nbr_files); - if (nbr_files.rlim_max == RLIM_INFINITY) { - fdCount = MAX_FD_COUNT; + /* Determine the maximum number of possible file descriptors. */ + if (-1 == getrlimit(RLIMIT_NOFILE, &nbr_files)) { + fprintf(stderr, "library initialization failed - " + "unable to get max # of allocated fds\n"); + abort(); + } + if (nbr_files.rlim_max != RLIM_INFINITY) { + fdLimit = nbr_files.rlim_max; } else { - fdCount = nbr_files.rlim_max; + /* We just do not know. */ + fdLimit = INT_MAX; } - fdTable = (fdEntry_t *)calloc(fdCount, sizeof(fdEntry_t)); + + /* Allocate table for low value file descriptors. */ + fdTableLen = fdLimit < fdTableMaxSize ? fdLimit : fdTableMaxSize; + fdTable = (fdEntry_t*) calloc(fdTableLen, sizeof(fdEntry_t)); if (fdTable == NULL) { fprintf(stderr, "library initialization failed - " "unable to allocate file descriptor table - out of memory"); abort(); + } else { + for (i = 0; i < fdTableLen; i ++) { + pthread_mutex_init(&fdTable[i].lock, NULL); + } } - for (i=0; i fdTableMaxSize) { + fdOverflowTableLen = ((fdLimit - fdTableMaxSize) / fdOverflowTableSlabSize) + 1; + fdOverflowTable = (fdEntry_t**) calloc(fdOverflowTableLen, sizeof(fdEntry_t*)); + if (fdOverflowTable == NULL) { + fprintf(stderr, "library initialization failed - " + "unable to allocate file descriptor overflow table - out of memory"); + abort(); + } } /* @@ -124,17 +160,60 @@ static void __attribute((constructor)) init() { } /* - * Return the fd table for this fd or NULL is fd out - * of range. + * Return the fd table for this fd. */ static inline fdEntry_t *getFdEntry(int fd) { - if (fd < 0 || fd >= fdCount) { + fdEntry_t* result = NULL; + + if (fd < 0) { return NULL; } - return &fdTable[fd]; + + /* This should not happen. If it does, our assumption about + * max. fd value was wrong. */ + assert(fd < fdLimit); + + if (fd < fdTableMaxSize) { + /* fd is in base table. */ + assert(fd < fdTableLen); + result = &fdTable[fd]; + } else { + /* fd is in overflow table. */ + const int indexInOverflowTable = fd - fdTableMaxSize; + const int rootindex = indexInOverflowTable / fdOverflowTableSlabSize; + const int slabindex = indexInOverflowTable % fdOverflowTableSlabSize; + fdEntry_t* slab = NULL; + assert(rootindex < fdOverflowTableLen); + assert(slabindex < fdOverflowTableSlabSize); + pthread_mutex_lock(&fdOverflowTableLock); + /* Allocate new slab in overflow table if needed */ + if (fdOverflowTable[rootindex] == NULL) { + fdEntry_t* const newSlab = + (fdEntry_t*)calloc(fdOverflowTableSlabSize, sizeof(fdEntry_t)); + if (newSlab == NULL) { + fprintf(stderr, "Unable to allocate file descriptor overflow" + " table slab - out of memory"); + pthread_mutex_unlock(&fdOverflowTableLock); + abort(); + } else { + int i; + for (i = 0; i < fdOverflowTableSlabSize; i ++) { + pthread_mutex_init(&newSlab[i].lock, NULL); + } + fdOverflowTable[rootindex] = newSlab; + } + } + pthread_mutex_unlock(&fdOverflowTableLock); + slab = fdOverflowTable[rootindex]; + result = &slab[slabindex]; + } + + return result; + } + /* * Start a blocking operation :- * Insert thread onto thread list for the fd. diff --git a/src/solaris/native/java/net/linux_close.c b/src/solaris/native/java/net/linux_close.c index 98e1ce0987f43d3e5739711cce7805006930db4f..eacc2afd15cd172e23ffc7a3df57062ae9f5d513 100644 --- a/src/solaris/native/java/net/linux_close.c +++ b/src/solaris/native/java/net/linux_close.c @@ -23,6 +23,8 @@ * questions. */ +#include +#include #include #include #include @@ -59,10 +61,35 @@ typedef struct { static int sigWakeup = (__SIGRTMAX - 2); /* - * The fd table and the number of file descriptors + * fdTable holds one entry per file descriptor, up to a certain + * maximum. + * Theoretically, the number of possible file descriptors can get + * large, though usually it does not. Entries for small value file + * descriptors are kept in a simple table, which covers most scenarios. + * Entries for large value file descriptors are kept in an overflow + * table, which is organized as a sparse two dimensional array whose + * slabs are allocated on demand. This covers all corner cases while + * keeping memory consumption reasonable. */ -static fdEntry_t *fdTable; -static int fdCount; + +/* Base table for low value file descriptors */ +static fdEntry_t* fdTable = NULL; +/* Maximum size of base table (in number of entries). */ +static const int fdTableMaxSize = 0x1000; /* 4K */ +/* Actual size of base table (in number of entries) */ +static int fdTableLen = 0; +/* Max. theoretical number of file descriptors on system. */ +static int fdLimit = 0; + +/* Overflow table, should base table not be large enough. Organized as + * an array of n slabs, each holding 64k entries. + */ +static fdEntry_t** fdOverflowTable = NULL; +/* Number of slabs in the overflow table */ +static int fdOverflowTableLen = 0; +/* Number of entries in one slab */ +static const int fdOverflowTableSlabSize = 0x10000; /* 64k */ +pthread_mutex_t fdOverflowTableLock = PTHREAD_MUTEX_INITIALIZER; /* * Null signal handler @@ -78,18 +105,43 @@ static void __attribute((constructor)) init() { struct rlimit nbr_files; sigset_t sigset; struct sigaction sa; + int i = 0; - /* - * Allocate table based on the maximum number of - * file descriptors. - */ - getrlimit(RLIMIT_NOFILE, &nbr_files); - fdCount = nbr_files.rlim_max; - fdTable = (fdEntry_t *)calloc(fdCount, sizeof(fdEntry_t)); + /* Determine the maximum number of possible file descriptors. */ + if (-1 == getrlimit(RLIMIT_NOFILE, &nbr_files)) { + fprintf(stderr, "library initialization failed - " + "unable to get max # of allocated fds\n"); + abort(); + } + if (nbr_files.rlim_max != RLIM_INFINITY) { + fdLimit = nbr_files.rlim_max; + } else { + /* We just do not know. */ + fdLimit = INT_MAX; + } + + /* Allocate table for low value file descriptors. */ + fdTableLen = fdLimit < fdTableMaxSize ? fdLimit : fdTableMaxSize; + fdTable = (fdEntry_t*) calloc(fdTableLen, sizeof(fdEntry_t)); if (fdTable == NULL) { fprintf(stderr, "library initialization failed - " "unable to allocate file descriptor table - out of memory"); abort(); + } else { + for (i = 0; i < fdTableLen; i ++) { + pthread_mutex_init(&fdTable[i].lock, NULL); + } + } + + /* Allocate overflow table, if needed */ + if (fdLimit > fdTableMaxSize) { + fdOverflowTableLen = ((fdLimit - fdTableMaxSize) / fdOverflowTableSlabSize) + 1; + fdOverflowTable = (fdEntry_t**) calloc(fdOverflowTableLen, sizeof(fdEntry_t*)); + if (fdOverflowTable == NULL) { + fprintf(stderr, "library initialization failed - " + "unable to allocate file descriptor overflow table - out of memory"); + abort(); + } } /* @@ -106,15 +158,57 @@ static void __attribute((constructor)) init() { } /* - * Return the fd table for this fd or NULL is fd out - * of range. + * Return the fd table for this fd. */ static inline fdEntry_t *getFdEntry(int fd) { - if (fd < 0 || fd >= fdCount) { + fdEntry_t* result = NULL; + + if (fd < 0) { return NULL; } - return &fdTable[fd]; + + /* This should not happen. If it does, our assumption about + * max. fd value was wrong. */ + assert(fd < fdLimit); + + if (fd < fdTableMaxSize) { + /* fd is in base table. */ + assert(fd < fdTableLen); + result = &fdTable[fd]; + } else { + /* fd is in overflow table. */ + const int indexInOverflowTable = fd - fdTableMaxSize; + const int rootindex = indexInOverflowTable / fdOverflowTableSlabSize; + const int slabindex = indexInOverflowTable % fdOverflowTableSlabSize; + fdEntry_t* slab = NULL; + assert(rootindex < fdOverflowTableLen); + assert(slabindex < fdOverflowTableSlabSize); + pthread_mutex_lock(&fdOverflowTableLock); + /* Allocate new slab in overflow table if needed */ + if (fdOverflowTable[rootindex] == NULL) { + fdEntry_t* const newSlab = + (fdEntry_t*)calloc(fdOverflowTableSlabSize, sizeof(fdEntry_t)); + if (newSlab == NULL) { + fprintf(stderr, "Unable to allocate file descriptor overflow" + " table slab - out of memory"); + pthread_mutex_unlock(&fdOverflowTableLock); + abort(); + } else { + int i; + for (i = 0; i < fdOverflowTableSlabSize; i ++) { + pthread_mutex_init(&newSlab[i].lock, NULL); + } + fdOverflowTable[rootindex] = newSlab; + } + } + pthread_mutex_unlock(&fdOverflowTableLock); + slab = fdOverflowTable[rootindex]; + result = &slab[slabindex]; + } + + return result; + } /* diff --git a/src/solaris/native/sun/awt/awt_Robot.c b/src/solaris/native/sun/awt/awt_Robot.c index 819b491ad1f45fc5deedb93ca93e9ac7ff67a168..35ff9478ad132b6258efc06199c0bffe0cfe43f7 100644 --- a/src/solaris/native/sun/awt/awt_Robot.c +++ b/src/solaris/native/sun/awt/awt_Robot.c @@ -43,11 +43,13 @@ #include #include #include -#include "robot_common.h" #include "canvas.h" #include "wsutils.h" #include "list.h" #include "multiVis.h" + +#include "java_awt_event_InputEvent.h" + #if defined(__linux__) || defined(MACOSX) #include #endif diff --git a/src/solaris/native/sun/awt/gtk2_interface.c b/src/solaris/native/sun/awt/gtk2_interface.c index 4156869ef95fc8484e2b84402afdca50b1dbaf35..201565a18c2979f1d85dd68e1078ac073f32f08f 100644 --- a/src/solaris/native/sun/awt/gtk2_interface.c +++ b/src/solaris/native/sun/awt/gtk2_interface.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1015,45 +1015,46 @@ static gint gtk2_copy_image(gint *dst, gint width, gint height) black = (*fp_gdk_pixbuf_get_pixels)(gtk2_black_pixbuf); stride = (*fp_gdk_pixbuf_get_rowstride)(gtk2_black_pixbuf); padding = stride - width * 4; + if (padding >= 0 && stride > 0) { + for (i = 0; i < height; i++) { + for (j = 0; j < width; j++) { + int r1 = *white++; + int r2 = *black++; + int alpha = 0xff + r2 - r1; + + switch (alpha) { + case 0: /* transparent pixel */ + r = g = b = 0; + black += 3; + white += 3; + is_opaque = FALSE; + break; + + case 0xff: /* opaque pixel */ + r = r2; + g = *black++; + b = *black++; + black++; + white += 3; + break; + + default: /* translucent pixel */ + r = 0xff * r2 / alpha; + g = 0xff * *black++ / alpha; + b = 0xff * *black++ / alpha; + black++; + white += 3; + is_opaque = FALSE; + is_bitmask = FALSE; + break; + } - for (i = 0; i < height; i++) { - for (j = 0; j < width; j++) { - int r1 = *white++; - int r2 = *black++; - int alpha = 0xff + r2 - r1; - - switch (alpha) { - case 0: /* transparent pixel */ - r = g = b = 0; - black += 3; - white += 3; - is_opaque = FALSE; - break; - - case 0xff: /* opaque pixel */ - r = r2; - g = *black++; - b = *black++; - black++; - white += 3; - break; - - default: /* translucent pixel */ - r = 0xff * r2 / alpha; - g = 0xff * *black++ / alpha; - b = 0xff * *black++ / alpha; - black++; - white += 3; - is_opaque = FALSE; - is_bitmask = FALSE; - break; + *dst++ = (alpha << 24 | r << 16 | g << 8 | b); } - *dst++ = (alpha << 24 | r << 16 | g << 8 | b); + white += padding; + black += padding; } - - white += padding; - black += padding; } return is_opaque ? java_awt_Transparency_OPAQUE : (is_bitmask ? java_awt_Transparency_BITMASK : diff --git a/src/solaris/native/sun/awt/gtk3_interface.c b/src/solaris/native/sun/awt/gtk3_interface.c index adb5f2b78edca902705223cf4f4148a6b4770ec7..da27ae992898f25843febc2c60ac4fce01e7893e 100644 --- a/src/solaris/native/sun/awt/gtk3_interface.c +++ b/src/solaris/native/sun/awt/gtk3_interface.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -347,8 +347,10 @@ GtkApi* gtk3_load(JNIEnv *env, const char* lib_name) fp_cairo_image_surface_create = dl_symbol("cairo_image_surface_create"); fp_cairo_surface_destroy = dl_symbol("cairo_surface_destroy"); + fp_cairo_surface_status = dl_symbol("cairo_surface_status"); fp_cairo_create = dl_symbol("cairo_create"); fp_cairo_destroy = dl_symbol("cairo_destroy"); + fp_cairo_status = dl_symbol("cairo_status"); fp_cairo_fill = dl_symbol("cairo_fill"); fp_cairo_rectangle = dl_symbol("cairo_rectangle"); fp_cairo_set_source_rgb = dl_symbol("cairo_set_source_rgb"); @@ -775,6 +777,9 @@ static void gtk3_init_painting(JNIEnv *env, gint width, gint height) } cr = fp_cairo_create(surface); + if (fp_cairo_surface_status(surface) || fp_cairo_status(cr)) { + JNU_ThrowOutOfMemoryError(env, "The surface size is too big"); + } } /* @@ -797,16 +802,17 @@ static gint gtk3_copy_image(gint *dst, gint width, gint height) data = (*fp_cairo_image_surface_get_data)(surface); stride = (*fp_cairo_image_surface_get_stride)(surface); padding = stride - width * 4; - - for (i = 0; i < height; i++) { - for (j = 0; j < width; j++) { - int r = *data++; - int g = *data++; - int b = *data++; - int a = *data++; - *dst++ = (a << 24 | b << 16 | g << 8 | r); + if (stride > 0 && padding >= 0) { + for (i = 0; i < height; i++) { + for (j = 0; j < width; j++) { + int r = *data++; + int g = *data++; + int b = *data++; + int a = *data++; + *dst++ = (a << 24 | b << 16 | g << 8 | r); + } + data += padding; } - data += padding; } return java_awt_Transparency_TRANSLUCENT; } diff --git a/src/solaris/native/sun/awt/gtk3_interface.h b/src/solaris/native/sun/awt/gtk3_interface.h index 783ac8734a058bb4260930ff91ea9b3aa0abebcc..1e4b4c7abbe1dd650c675507bcd26827796a3b0c 100644 --- a/src/solaris/native/sun/awt/gtk3_interface.h +++ b/src/solaris/native/sun/awt/gtk3_interface.h @@ -132,6 +132,48 @@ typedef enum { CAIRO_FORMAT_RGB16_565 = 4 } cairo_format_t; +typedef enum _cairo_status { + CAIRO_STATUS_SUCCESS = 0, + + CAIRO_STATUS_NO_MEMORY, + CAIRO_STATUS_INVALID_RESTORE, + CAIRO_STATUS_INVALID_POP_GROUP, + CAIRO_STATUS_NO_CURRENT_POINT, + CAIRO_STATUS_INVALID_MATRIX, + CAIRO_STATUS_INVALID_STATUS, + CAIRO_STATUS_NULL_POINTER, + CAIRO_STATUS_INVALID_STRING, + CAIRO_STATUS_INVALID_PATH_DATA, + CAIRO_STATUS_READ_ERROR, + CAIRO_STATUS_WRITE_ERROR, + CAIRO_STATUS_SURFACE_FINISHED, + CAIRO_STATUS_SURFACE_TYPE_MISMATCH, + CAIRO_STATUS_PATTERN_TYPE_MISMATCH, + CAIRO_STATUS_INVALID_CONTENT, + CAIRO_STATUS_INVALID_FORMAT, + CAIRO_STATUS_INVALID_VISUAL, + CAIRO_STATUS_FILE_NOT_FOUND, + CAIRO_STATUS_INVALID_DASH, + CAIRO_STATUS_INVALID_DSC_COMMENT, + CAIRO_STATUS_INVALID_INDEX, + CAIRO_STATUS_CLIP_NOT_REPRESENTABLE, + CAIRO_STATUS_TEMP_FILE_ERROR, + CAIRO_STATUS_INVALID_STRIDE, + CAIRO_STATUS_FONT_TYPE_MISMATCH, + CAIRO_STATUS_USER_FONT_IMMUTABLE, + CAIRO_STATUS_USER_FONT_ERROR, + CAIRO_STATUS_NEGATIVE_COUNT, + CAIRO_STATUS_INVALID_CLUSTERS, + CAIRO_STATUS_INVALID_SLANT, + CAIRO_STATUS_INVALID_WEIGHT, + CAIRO_STATUS_INVALID_SIZE, + CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED, + CAIRO_STATUS_DEVICE_TYPE_MISMATCH, + CAIRO_STATUS_DEVICE_ERROR, + + CAIRO_STATUS_LAST_STATUS +} cairo_status_t; + /* We define all structure pointers to be void* */ typedef void GdkPixbuf; typedef void GMainContext; @@ -363,8 +405,10 @@ static void (*fp_g_strfreev)(gchar **str_array); static cairo_surface_t* (*fp_cairo_image_surface_create)(cairo_format_t format, int width, int height); static void (*fp_cairo_surface_destroy)(cairo_surface_t *surface); +static cairo_status_t (*fp_cairo_surface_status)(cairo_surface_t *surface); static cairo_t* (*fp_cairo_create)(cairo_surface_t *target); static void (*fp_cairo_destroy)(cairo_t *cr); +static cairo_status_t (*fp_cairo_status)(cairo_t *cr); static void (*fp_cairo_fill)(cairo_t *cr); static void (*fp_cairo_surface_flush)(cairo_surface_t *surface); static void (*fp_cairo_rectangle)(cairo_t *cr, double x, double y, double width, diff --git a/src/solaris/native/sun/awt/list.c b/src/solaris/native/sun/awt/list.c index af3fcb929733e26cacd471b4bf86d8be879846f2..abbfe7c72c0f45e512b2dbdc1bc9f08ce76ef532 100644 --- a/src/solaris/native/sun/awt/list.c +++ b/src/solaris/native/sun/awt/list.c @@ -1,4 +1,5 @@ /* + * Copyright (c) 1999, 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 +22,6 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -/* $XConsortium: list.c /main/4 1996/10/14 15:03:56 swick $ */ /** ------------------------------------------------------------------------ This file contains routines for manipulating generic lists. Lists are implemented with a "harness". In other words, each @@ -36,16 +36,14 @@ However, the following notice accompanied the original version of this file: -Copyright (c) 1994 Hewlett-Packard Co. -Copyright (c) 1996 X Consortium +Copyright 1994 Hewlett-Packard Co. +Copyright 1996, 1998 The Open Group -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -53,32 +51,28 @@ in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -Except as contained in this notice, the name of the X Consortium shall +Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization -from the X Consortium. +from The Open Group. ----------------------------------------------------------------------- **/ #include #include + #include "list.h" /** ------------------------------------------------------------------------ Sets the pointers of the specified list to NULL. --------------------------------------------------------------------- **/ -#if NeedFunctionPrototypes void zero_list(list_ptr lp) -#else -void zero_list(lp) - list_ptr lp; -#endif { lp->next = NULL; lp->ptr.item = NULL; @@ -92,13 +86,7 @@ void zero_list(lp) and the next pointer in the new node is set to NULL. Returns 1 if successful, 0 if the malloc failed. -------------------------------------------------------------------- **/ -#if NeedFunctionPrototypes -int32_t add_to_list(list_ptr lp, void *item) -#else -int32_t add_to_list(lp, item) - list_ptr lp; - void *item; -#endif +int add_to_list(list_ptr lp, void *item) { while (lp->next) { lp = lp->next; @@ -118,11 +106,11 @@ int32_t add_to_list(lp, item) Creates a new list and sets its pointers to NULL. Returns a pointer to the new list. -------------------------------------------------------------------- **/ -list_ptr new_list () +list_ptr new_list (void) { list_ptr lp; - if (lp = (list_ptr) malloc( sizeof( list_item))) { + if ((lp = (list_ptr) malloc( sizeof( list_item)))) { lp->next = NULL; lp->ptr.item = NULL; } @@ -140,38 +128,27 @@ list_ptr new_list () curr pointer in the new list is the same as in the old list. Returns a pointer to the new list head. -------------------------------------------------------------------- **/ -#if NeedFunctionPrototypes -list_ptr dup_list_head(list_ptr lp, int32_t start_at_curr) -#else -list_ptr dup_list_head(lp, start_at_curr) - list_ptr lp; - int32_t start_at_curr; -#endif +list_ptr dup_list_head(list_ptr lp, int start_at_curr) { - list_ptr new_list; + list_ptr new_listp; - if ((new_list = (list_ptr) malloc( sizeof( list_item))) == NULL) { + if ((new_listp = (list_ptr) malloc( sizeof( list_item))) == NULL) { return (list_ptr)NULL; } - new_list->next = start_at_curr ? lp->ptr.curr : lp->next; - new_list->ptr.curr = lp->ptr.curr; + new_listp->next = start_at_curr ? lp->ptr.curr : lp->next; + new_listp->ptr.curr = lp->ptr.curr; - return new_list; + return new_listp; } /** ------------------------------------------------------------------------ Returns the number of items in the list. -------------------------------------------------------------------- **/ -#if NeedFunctionPrototypes -uint32_t list_length(list_ptr lp) -#else -uint32_t list_length(lp) - list_ptr lp; -#endif +unsigned int list_length(list_ptr lp) { - uint32_t count = 0; + unsigned int count = 0; while (lp->next) { count++; @@ -191,13 +168,7 @@ uint32_t list_length(lp) Returns a pointer to the item, so the caller can free it if it so desires. If a match is not found, returns NULL. -------------------------------------------------------------------- **/ -#if NeedFunctionPrototypes void *delete_from_list(list_ptr lp, void *item) -#else -void *delete_from_list(lp, item) - list_ptr lp; - void *item; -#endif { list_ptr new_next; @@ -222,13 +193,7 @@ void *delete_from_list(lp, item) with new_list(). If free_items is true, each item pointed to from the node is freed, in addition to the node itself. -------------------------------------------------------------------- **/ -#if NeedFunctionPrototypes -void delete_list(list_ptr lp, int32_t free_items) -#else -void delete_list(lp, free_items) - list_ptr lp; - int32_t free_items; -#endif +void delete_list(list_ptr lp, int free_items) { list_ptr del_node; void *item; @@ -244,13 +209,7 @@ void delete_list(lp, free_items) } } -#if NeedFunctionPrototypes void delete_list_destroying(list_ptr lp, void destructor(void *item)) -#else -void delete_list_destroying(lp, destructor) - list_ptr lp; - void (*destructor)(); -#endif { list_ptr del_node; void *item; @@ -272,12 +231,7 @@ void delete_list_destroying(lp, destructor) Sets the list head node's curr ptr to the first node in the list. Returns NULL if the list is empty. -------------------------------------------------------------------- **/ -#if NeedFunctionPrototypes void * first_in_list(list_ptr lp) -#else -void * first_in_list(lp) - list_ptr lp; -#endif { if (! lp) { @@ -294,12 +248,7 @@ void * first_in_list(lp) first_in_list must have been called prior. Returns NULL if no next item. -------------------------------------------------------------------- **/ -#if NeedFunctionPrototypes void * next_in_list(list_ptr lp) -#else -void * next_in_list(lp) - list_ptr lp; -#endif { if (! lp) { @@ -312,12 +261,8 @@ void * next_in_list(lp) return lp->ptr.curr ? lp->ptr.curr->ptr.item : NULL; } -#if NeedFunctionPrototypes -int32_t list_is_empty(list_ptr lp) -#else -int32_t list_is_empty(lp) - list_ptr lp; -#endif +int list_is_empty(list_ptr lp) { return (lp == NULL || lp->next == NULL); } + diff --git a/src/solaris/native/sun/awt/list.h b/src/solaris/native/sun/awt/list.h index 7528b7c3e5322c1179a04d9a6e4a0412230115e4..ff538ccfe07e0df0c0f1fd8ffcdd260a5f1703b1 100644 --- a/src/solaris/native/sun/awt/list.h +++ b/src/solaris/native/sun/awt/list.h @@ -1,4 +1,5 @@ /* + * Copyright (c) 1999, 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 +22,6 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -/* $XConsortium: list.h /main/4 1996/10/14 15:04:04 swick $ */ /** ------------------------------------------------------------------------ This file contains routines for manipulating generic lists. Lists are implemented with a "harness". In other words, each @@ -36,16 +36,14 @@ However, the following notice accompanied the original version of this file: -Copyright (c) 1994 Hewlett-Packard Co. -Copyright (c) 1996 X Consortium +Copyright 1994 Hewlett-Packard Co. +Copyright 1996, 1998 The Open Group -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -53,23 +51,22 @@ in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -Except as contained in this notice, the name of the X Consortium shall +Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization -from the X Consortium. +from The Open Group. -------------------------------------------------------------------- **/ -#include "gdefs.h" - #ifndef LIST_DEF #define LIST_DEF +#include #define LESS -1 #define EQUAL 0 #define GREATER 1 @@ -85,65 +82,41 @@ typedef struct _list_item { } list, list_item, *list_ptr; typedef void (*DESTRUCT_FUNC_PTR)( -#if NeedFunctionPrototypes void * -#endif ); void zero_list( -#if NeedFunctionPrototypes list_ptr -#endif ); -int32_t add_to_list ( -#if NeedFunctionPrototypes +int add_to_list ( list_ptr , void * -#endif ); list_ptr new_list ( -#if NeedFunctionPrototypes void -#endif ); list_ptr dup_list_head ( -#if NeedFunctionPrototypes - list_ptr , int32_t -#endif + list_ptr , int ); -uint32_t list_length( -#if NeedFunctionPrototypes +unsigned int list_length( list_ptr -#endif ); void *delete_from_list ( -#if NeedFunctionPrototypes list_ptr , void * -#endif ); void delete_list( -#if NeedFunctionPrototypes - list_ptr , int32_t -#endif + list_ptr , int ); void delete_list_destroying ( -#if NeedFunctionPrototypes list_ptr , DESTRUCT_FUNC_PTR -#endif ); void *first_in_list ( -#if NeedFunctionPrototypes list_ptr -#endif ); void *next_in_list ( -#if NeedFunctionPrototypes list_ptr -#endif ); -int32_t list_is_empty ( -#if NeedFunctionPrototypes +int list_is_empty ( list_ptr -#endif ); #endif diff --git a/src/solaris/native/sun/awt/multiVis.c b/src/solaris/native/sun/awt/multiVis.c index 22f539896bfb443cb3f80feac727b78fd8bb9ca8..9dae81087c50f092beffb5e3096d6666b1ea8555 100644 --- a/src/solaris/native/sun/awt/multiVis.c +++ b/src/solaris/native/sun/awt/multiVis.c @@ -22,7 +22,6 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -/* $XConsortium: multiVis.c /main/4 1996/10/14 15:04:08 swick $ */ /** ------------------------------------------------------------------------ This file contains functions to create a list of regions which tile a specified window. Each region contains all visible @@ -37,16 +36,14 @@ However, the following notice accompanied the original version of this file: -Copyright (c) 1994 Hewlett-Packard Co. -Copyright (c) 1996 X Consortium +Copyright 1994 Hewlett-Packard Co. +Copyright 1996, 1998 The Open Group -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -54,17 +51,18 @@ in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -Except as contained in this notice, the name of the X Consortium shall +Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization -from the X Consortium. +from The Open Group. ------------------------------------------------------------------------ **/ + #include #include #include @@ -73,20 +71,16 @@ from the X Consortium. #include "list.h" #include "wsutils.h" #include "multiVis.h" -#include "robot_common.h" - -static char *vis_class_str[] = { "StaticGray" , "GrayScale" , "StaticColor", - "PseudoColor","TrueColor","DirectColor" } ; /* These structures are copied from X11/region.h. For some reason - * they're invisible from the outside.*/ - + * they're invisible from the outside. + */ typedef struct { short x1, x2, y1, y2; } myBox, myBOX, myBoxRec, *myBoxPtr; -typedef struct my_XRegion { /* 64-bit: Region is supposed to be opaque */ - long size; /* but it is defined here anyway. I'm going */ - long numRects; /* to leave those longs alone. */ +typedef struct my_XRegion { + long size; + long numRects; myBOX *rects; myBOX extents; } myREGION; @@ -96,10 +90,10 @@ typedef struct { Window win; Visual *vis; Colormap cmap; - int32_t x_rootrel, y_rootrel; /* root relative location of window */ - int32_t x_vis, y_vis; /* rt rel x,y of vis part, not parent clipped */ - int32_t width, height; /* width and height of visible part */ - int32_t border_width; /* border width of the window */ + int x_rootrel, y_rootrel; /* root relative location of window */ + int x_vis, y_vis; /* rt rel x,y of vis part, not parent clipped */ + int width, height; /* width and height of visible part */ + int border_width; /* border width of the window */ Window parent; /* id of parent (for debugging) */ } image_win_type; @@ -110,10 +104,10 @@ typedef struct { Window win; /* lowest window of this visual */ Visual *vis; Colormap cmap; - int32_t x_rootrel, y_rootrel; /* root relative location of bottom window */ - int32_t x_vis, y_vis; /* rt rel x,y of vis part, not parent clipped */ - int32_t width, height; /* w & h of visible rect of bottom window */ - int32_t border; /* border width of the window */ + int x_rootrel, y_rootrel; /* root relative location of bottom window */ + int x_vis, y_vis; /* rt rel x,y of vis part, not parent clipped */ + int width, height; /* w & h of visible rect of bottom window */ + int border; /* border width of the window */ Region visible_region; } image_region_type; @@ -143,77 +137,67 @@ extern list_ptr new_list(); extern list_ptr dup_list_head(); extern void * first_in_list(); extern void * next_in_list(); -extern int32_t add_to_list(); +extern int add_to_list(); extern void zero_list(); extern void delete_list(); extern void delete_list_destroying(); -extern uint32_t list_length(); +extern unsigned int list_length(); */ /* Prototype Declarations for Static Functions */ +static void QueryColorMap( + Display *, Colormap , Visual *, + XColor **, int *, int *, int * + ); static void TransferImage( -#if NeedFunctionPrototypes - Display *, XImage *,int32_t, int32_t , image_region_type*, - XImage *,int32_t ,int32_t -#endif + Display *, XImage *,int, int , image_region_type*, + XImage *,int ,int ); static XImage * ReadRegionsInList( -#if NeedFunctionPrototypes - Display *, Visual *, int32_t ,int32_t ,int32_t , - int32_t , XRectangle, list_ptr -#endif + Display *, Visual *, int, int, unsigned int, + unsigned int, XRectangle, list_ptr ); static list_ptr make_region_list( -#if NeedFunctionPrototypes Display*, Window, XRectangle*, - int32_t*, int32_t, XVisualInfo**, int32_t * -#endif + int*, int, XVisualInfo**, int * ); static void destroy_region_list( -#if NeedFunctionPrototypes list_ptr -#endif ) ; static void subtr_rect_from_image_region( -#if NeedFunctionPrototypes - image_region_type *, int32_t , int32_t , int32_t , int32_t -#endif + image_region_type *, int , int , int , int ); static void add_rect_to_image_region( -#if NeedFunctionPrototypes image_region_type *, - int32_t , int32_t , int32_t , int32_t -#endif + int , int , int , int ); -static int32_t src_in_region_list( -#if NeedFunctionPrototypes +static int src_in_region_list( image_win_type *, list_ptr -#endif ); static void add_window_to_list( -#if NeedFunctionPrototypes - list_ptr, Window, int32_t, int32_t , - int32_t , int32_t , int32_t , int32_t, int32_t, + list_ptr, Window, int, int , + int , int , int , int, int, Visual*, Colormap, Window -#endif ); -static int32_t src_in_image( -#if NeedFunctionPrototypes - image_win_type *, int32_t , XVisualInfo** -#endif +static int src_in_image( + image_win_type *, int , XVisualInfo** ); -static int32_t src_in_overlay( -#if NeedFunctionPrototypes - image_region_type *, int32_t, OverlayInfo *, int32_t*, int32_t* -#endif +static int src_in_overlay( + image_region_type *, int, OverlayInfo *, int*, int* ); +static void make_src_list( + Display *, list_ptr, XRectangle *, Window, + int, int, XWindowAttributes *, XRectangle * +); +static void destroy_image_region( + image_region_type * +); /* End of Prototype Declarations */ -void initFakeVisual(Vis) -Visual *Vis ; +void initFakeVisual(Visual *Vis) { Vis->ext_data=NULL; Vis->class = DirectColor ; @@ -224,42 +208,91 @@ Visual *Vis ; Vis->bits_per_rgb = 8 ; } -/* QueryColorMap has been moved into robot_common.c so it can be used by - * awt_DataTransferer.c as well. +static void +QueryColorMap(Display *disp, Colormap src_cmap, Visual *src_vis, + XColor **src_colors, int *rShift, int *gShift, int *bShift) +{ + unsigned int ncolors,i ; + unsigned long redMask, greenMask, blueMask; + int redShift, greenShift, blueShift; + XColor *colors ; + + ncolors = (unsigned) src_vis->map_entries ; +/* JDK modification. + * use calloc instead of malloc to initialize allocated memory + * *src_colors = colors = (XColor *)malloc(ncolors * sizeof(XColor) ) ; */ + *src_colors = colors = (XColor *)calloc(ncolors, sizeof(XColor)); + + if(src_vis->class != TrueColor && src_vis->class != DirectColor) + { + for(i=0 ; i < ncolors ; i++) + { + colors[i].pixel = i ; + colors[i].pad = 0; + colors[i].flags = DoRed|DoGreen|DoBlue; + } + } + else /** src is decomposed rgb ***/ + { + /* Get the X colormap */ + redMask = src_vis->red_mask; + greenMask = src_vis->green_mask; + blueMask = src_vis->blue_mask; + redShift = 0; while (!(redMask&0x1)) { + redShift++; + redMask = redMask>>1; + } + greenShift = 0; while (!(greenMask&0x1)) { + greenShift++; + greenMask = greenMask>>1; + } + blueShift = 0; while (!(blueMask&0x1)) { + blueShift++; + blueMask = blueMask>>1; + } + *rShift = redShift ; + *gShift = greenShift ; + *bShift = blueShift ; + for (i=0; icmap,reg->vis,&colors, + QueryColorMap(disp,reg->cmap,reg->vis,&colors, &rShift,&gShift,&bShift) ; - targetBytesPerLine = target_image->bytes_per_line; - switch (reg->vis->class) { case TrueColor : for(i=0 ; i < srch ; i++) { for(j=0 ; j < srcw ; j++) { - old_pixel = (int32_t) XGetPixel(reg_image,j,i) ; + old_pixel = XGetPixel(reg_image,j,i) ; -/* commented out since not using server RGB masks in all true color modes +/* + * JDK modification. + * commented out since not using server RGB masks in all true color modes * causes the R and B values to be swapped around on some X servers * - robi.khan@eng 9/7/1999 - * if( reg->vis->map_entries == 16) { + * if( reg->vis->map_entries == 16) { */ - red_ind = (old_pixel & reg->vis->red_mask) >> rShift ; + red_ind = (old_pixel & reg->vis->red_mask) >> rShift ; green_ind = (old_pixel & reg->vis->green_mask) >> gShift ; - blue_ind = (old_pixel & reg->vis->blue_mask) >> bShift ; + blue_ind = (old_pixel & reg->vis->blue_mask) >> bShift ; new_pixel = ( ((colors[red_ind].red >> 8) << RED_SHIFT) |((colors[green_ind].green >> 8) << GREEN_SHIFT) |((colors[blue_ind].blue >> 8) << BLUE_SHIFT) ); -/* } - * else - * new_pixel = old_pixel; +/* JDK modification. + * else part of above modification + * + * } + * else + * new_pixel = old_pixel; */ XPutPixel(target_image,dst_x+j, dst_y+i,new_pixel); @@ -343,14 +375,15 @@ int32_t srcw,srch,dst_x , dst_y ; case DirectColor : for(i=0 ; i < srch ; i++) { + for(j=0 ; j < srcw ; j++) { - old_pixel = (int32_t) XGetPixel(reg_image,j,i) ; - red_ind = (old_pixel & reg->vis->red_mask) >> rShift ; - green_ind = (old_pixel & reg->vis->green_mask) >> gShift ; - blue_ind = (old_pixel & reg->vis->blue_mask) >> bShift ; + old_pixel = XGetPixel(reg_image,j,i) ; + red_ind = (old_pixel & reg->vis->red_mask) >> rShift ; + green_ind = (old_pixel & reg->vis->green_mask) >> gShift ; + blue_ind = (old_pixel & reg->vis->blue_mask) >> bShift ; - new_pixel = ( + new_pixel = ( ((colors[red_ind].red >> 8) << RED_SHIFT) |((colors[green_ind].green >> 8) << GREEN_SHIFT) |((colors[blue_ind].blue >> 8) << BLUE_SHIFT) @@ -365,9 +398,9 @@ int32_t srcw,srch,dst_x , dst_y ; { for(j=0 ; j < srcw ; j++) { - old_pixel = (int32_t) XGetPixel(reg_image,j,i) ; + old_pixel = XGetPixel(reg_image,j,i) ; - new_pixel = ( + new_pixel = ( ((colors[old_pixel].red >> 8) << RED_SHIFT) |((colors[old_pixel].green >> 8) << GREEN_SHIFT) |((colors[old_pixel].blue >> 8) << BLUE_SHIFT) @@ -378,66 +411,76 @@ int32_t srcw,srch,dst_x , dst_y ; } break; } - - /* Fix memory leak by freeing colors - * - robi.khan@eng 9/22/1999 - */ + /* JDK modification + * Fix memory leak by freeing colors + * - robi.khan@eng 9/22/1999 + */ free(colors); } static XImage * -ReadRegionsInList(disp,fakeVis,depth,format,width,height,bbox,regions) -Display *disp ; -Visual *fakeVis ; -int32_t depth , width , height ; -int32_t format ; -XRectangle bbox; /* bounding box of grabbed area */ -list_ptr regions;/* list of regions to read from */ +ReadRegionsInList(Display *disp, Visual *fakeVis, int depth, int format, + unsigned int width, unsigned int height, + XRectangle bbox, /* bounding box of grabbed area */ + list_ptr regions) /* list of regions to read from */ { - XImage *ximage ; - image_region_type* reg; - int32_t rect; + image_region_type *reg; + int dst_x, dst_y; /* where in pixmap to write (UL) */ + int diff; + + XImage *reg_image,*ximage ; + int srcRect_x,srcRect_y,srcRect_width,srcRect_height ; + int bytes_per_line; + + ximage = XCreateImage(disp,fakeVis,depth,format,0,NULL,width,height, + 8,0) ; + bytes_per_line = ximage->bytes_per_line; - ximage = XCreateImage(disp,fakeVis,(uint32_t) depth,format,0,NULL, - (uint32_t)width,(uint32_t)height,8,0); + if (format == ZPixmap) + ximage->data = malloc((size_t) height * bytes_per_line); + else + ximage->data = malloc((size_t) height * bytes_per_line * depth); - ximage->data = calloc(ximage->bytes_per_line*height*((format==ZPixmap)? 1 : depth), sizeof(char)); ximage->bits_per_pixel = depth; /** Valid only if format is ZPixmap ***/ for (reg = (image_region_type *) first_in_list( regions); reg; reg = (image_region_type *) next_in_list( regions)) { - struct my_XRegion *vis_reg = (struct my_XRegion *)(reg->visible_region); - for (rect = 0; rect < vis_reg->numRects; rect++) + int rect; + struct my_XRegion *vis_reg; + vis_reg = (struct my_XRegion *)(reg->visible_region); + for (rect = 0; + rect < vis_reg->numRects; + rect++) { - /** ------------------------------------------------------------------------ - Intersect bbox with visible part of region giving src rect & output - location. Width is the min right side minus the max left side. - Similar for height. Offset src rect so x,y are relative to - origin of win, not the root-relative visible rect of win. - ------------------------------------------------------------------------ **/ - int32_t srcRect_width = MIN( vis_reg->rects[rect].x2, bbox.width + bbox.x) - - MAX( vis_reg->rects[rect].x1, bbox.x); - - int32_t srcRect_height = MIN( vis_reg->rects[rect].y2, bbox.height + bbox.y) - - MAX( vis_reg->rects[rect].y1, bbox.y); - - int32_t diff = bbox.x - vis_reg->rects[rect].x1; - int32_t srcRect_x = MAX( 0, diff) + (vis_reg->rects[rect].x1 - reg->x_rootrel - reg->border); - int32_t dst_x = MAX( 0, -diff) ; - - diff = bbox.y - vis_reg->rects[rect].y1; - int32_t srcRect_y = MAX( 0, diff) + (vis_reg->rects[rect].y1 - reg->y_rootrel - reg->border); - int32_t dst_y = MAX( 0, -diff) ; - XImage* reg_image = XGetImage(disp,reg->win,srcRect_x,srcRect_y, - (uint32_t) srcRect_width, (uint32_t) srcRect_height,AllPlanes,format) ; - - if (reg_image) { - TransferImage(disp,reg_image,srcRect_width, - srcRect_height,reg,ximage,dst_x,dst_y) ; - XDestroyImage(reg_image); - } - } + /** ------------------------------------------------------------------------ + Intersect bbox with visible part of region giving src rect & output + location. Width is the min right side minus the max left side. + Similar for height. Offset src rect so x,y are relative to + origin of win, not the root-relative visible rect of win. + ------------------------------------------------------------------------ **/ + srcRect_width = MIN( vis_reg->rects[rect].x2, bbox.width + bbox.x) - + MAX( vis_reg->rects[rect].x1, bbox.x); + srcRect_height = MIN( vis_reg->rects[rect].y2, bbox.height + bbox.y) - + MAX( vis_reg->rects[rect].y1, bbox.y); + diff = bbox.x - vis_reg->rects[rect].x1; + srcRect_x = MAX( 0, diff) + (vis_reg->rects[rect].x1 - reg->x_rootrel - reg->border); + dst_x = MAX( 0, -diff) ; + diff = bbox.y - vis_reg->rects[rect].y1; + srcRect_y = MAX( 0, diff) + (vis_reg->rects[rect].y1 - reg->y_rootrel - reg->border); + dst_y = MAX( 0, -diff) ; + reg_image = XGetImage(disp,reg->win,srcRect_x,srcRect_y, + srcRect_width,srcRect_height,AllPlanes,format) ; + + /* JDK Modification + * Enclose in if test and also call XDestroyImage + */ + if (reg_image) { + TransferImage(disp,reg_image,srcRect_width, + srcRect_height,reg,ximage,dst_x,dst_y) ; + XDestroyImage(reg_image); + } + } } return ximage ; } @@ -446,62 +489,61 @@ list_ptr regions;/* list of regions to read from */ /** ------------------------------------------------------------------------ ------------------------------------------------------------------------ **/ -XImage *ReadAreaToImage(disp, srcRootWinid, x, y, width, height, - numVisuals,pVisuals,numOverlayVisuals,pOverlayVisuals,numImageVisuals, - pImageVisuals,vis_regions,vis_image_regions,format,allImage) - Display *disp; - Window srcRootWinid; /* root win on which grab was done */ - int32_t x; /* root rel UL corner of bounding box of grab */ - int32_t y; - uint32_t width; /* size of bounding box of grab */ - uint32_t height; - /** int32_t transparentOverlays; ***/ - int32_t numVisuals; - XVisualInfo *pVisuals; - int32_t numOverlayVisuals; - OverlayInfo *pOverlayVisuals; - int32_t numImageVisuals; - XVisualInfo **pImageVisuals; - list_ptr vis_regions; /* list of regions to read from */ - list_ptr vis_image_regions ;/* list of regions to read from */ - int32_t format; - int32_t allImage ; +XImage *ReadAreaToImage(Display *disp, + /* root win on which grab was done */ + Window srcRootWinid, + /* root rel UL corner of bounding box of grab */ + int x, int y, + /* size of bounding box of grab */ + unsigned int width, unsigned int height, + int numVisuals, XVisualInfo *pVisuals, + int numOverlayVisuals, OverlayInfo *pOverlayVisuals, + int numImageVisuals, XVisualInfo **pImageVisuals, + /* list of regions to read from */ + list_ptr vis_regions, + /* list of regions to read from */ + list_ptr vis_image_regions, + int format, int allImage) { image_region_type *reg; XRectangle bbox; /* bounding box of grabbed area */ - int32_t depth ; - XImage *ximage, *ximage_ipm ; + int depth ; + XImage *ximage, *ximage_ipm = NULL; Visual fakeVis ; - int32_t x1, y1; + int x1, y1; XImage *image; +#if 0 unsigned char *pmData , *ipmData ; - int32_t transparentColor, transparentType; - int32_t srcRect_x,srcRect_y,srcRect_width,srcRect_height ; - int32_t diff ; - int32_t dst_x, dst_y; /* where in pixmap to write (UL) */ - int32_t pixel; +#endif + int transparentColor, transparentType; + int srcRect_x,srcRect_y,srcRect_width,srcRect_height ; + int diff ; + int dst_x, dst_y; /* where in pixmap to write (UL) */ + int pixel; - bbox.x = (short) x; /* init X rect for bounding box */ - bbox.y = (short) y; - bbox.width = (unsigned short) width; - bbox.height = (unsigned short) height; - ximage_ipm = NULL; + bbox.x = x; /* init X rect for bounding box */ + bbox.y = y; + bbox.width = width; + bbox.height = height; initFakeVisual(&fakeVis) ; depth = 24 ; - ximage = ReadRegionsInList(disp,&fakeVis,depth,format, - (int32_t) width, (int32_t) height, bbox,vis_regions) ; - + ximage = ReadRegionsInList(disp,&fakeVis,depth,format,width,height, + bbox,vis_regions) ; +#if 0 pmData = (unsigned char *)ximage -> data ; +#endif /* if transparency possible do it again, but this time for image planes only */ if (vis_image_regions && (vis_image_regions->next) && !allImage) { - ximage_ipm = ReadRegionsInList(disp,&fakeVis,depth,format, - (int32_t) width, (int32_t) height,bbox,vis_image_regions) ; + ximage_ipm = ReadRegionsInList(disp,&fakeVis,depth,format,width,height, + bbox,vis_image_regions) ; +#if 0 ipmData = (unsigned char *)ximage_ipm -> data ; +#endif } /* Now tranverse the overlay visual windows and test for transparency index. */ /* If you find one, subsitute the value from the matching image plane pixmap. */ @@ -513,21 +555,20 @@ XImage *ReadAreaToImage(disp, srcRootWinid, x, y, width, height, if (src_in_overlay( reg, numOverlayVisuals, pOverlayVisuals, &transparentColor, &transparentType)) { - int32_t test = 0 ; + int test = 0 ; srcRect_width = MIN( reg->width + reg->x_vis, bbox.width + bbox.x) - MAX( reg->x_vis, bbox.x); srcRect_height = MIN( reg->height + reg->y_vis, bbox.height + bbox.y) - MAX( reg->y_vis, bbox.y); - diff = bbox.x - reg->x_vis; - srcRect_x = MAX( 0, diff) + (reg->x_vis - reg->x_rootrel - reg->border); - dst_x = MAX( 0, -diff) ; + diff = bbox.x - reg->x_vis; + srcRect_x = MAX( 0, diff) + (reg->x_vis - reg->x_rootrel - reg->border); + dst_x = MAX( 0, -diff) ; diff = bbox.y - reg->y_vis; srcRect_y = MAX( 0, diff) + (reg->y_vis - reg->y_rootrel - reg->border); dst_y = MAX( 0, -diff) ; /* let's test some pixels for transparency */ - image = XGetImage(disp, reg->win, srcRect_x, srcRect_y, - (uint32_t) srcRect_width, (uint32_t) srcRect_height, - 0xffffffff, ZPixmap); + image = XGetImage(disp, reg->win, srcRect_x, srcRect_y, + srcRect_width, srcRect_height, 0xffffffff, ZPixmap); /* let's assume byte per pixel for overlay image for now */ if ((image->depth == 8) && (transparentType == TransparentPixel)) @@ -541,24 +582,24 @@ XImage *ReadAreaToImage(disp, srcRootWinid, x, y, width, height, { if (*pixel_ptr++ == transparentColor) { - /* +#if 0 *pmData++ = *ipmData++; *pmData++ = *ipmData++; *pmData++ = *ipmData++; - */ - pixel = (int32_t) XGetPixel(ximage_ipm,dst_x+x1,dst_y+y1) ; - XPutPixel(ximage,dst_x+x1, dst_y+y1,(unsigned long)pixel); +#endif + pixel = XGetPixel(ximage_ipm,dst_x+x1,dst_y+y1) ; + XPutPixel(ximage,dst_x+x1, dst_y+y1,pixel); if(!test){ test = 1 ; } } - /* +#if 0 else { pmData +=3; ipmData +=3; } - */ +#endif } start_of_line += image->bytes_per_line; } @@ -567,53 +608,52 @@ XImage *ReadAreaToImage(disp, srcRootWinid, x, y, width, height, for (y1 = 0; y1 < srcRect_height; y1++) { for (x1 = 0; x1 < srcRect_width; x1++) { - int32_t pixel_value = (int32_t) XGetPixel(image, x1, y1); + int pixel_value = XGetPixel(image, x1, y1); if (pixel_value == transparentColor) { - /* +#if 0 *pmData++ = *ipmData++; *pmData++ = *ipmData++; *pmData++ = *ipmData++; - */ - pixel = (int32_t) XGetPixel(ximage_ipm,dst_x+x1,dst_y+y1) ; - XPutPixel(ximage,dst_x+x1, dst_y+y1,(unsigned long)pixel); +#endif + pixel = XGetPixel(ximage_ipm,dst_x+x1,dst_y+y1) ; + XPutPixel(ximage,dst_x+x1, dst_y+y1,pixel); if(!test){ test = 1 ; } } - /* +#if 0 else { pmData +=3; ipmData +=3; } - */ +#endif } } } else { for (y1 = 0; y1 < srcRect_height; y1++) { for (x1 = 0; x1 < srcRect_width; x1++) { - int32_t pixel_value = (int32_t) XGetPixel(image, x1, y1); + int pixel_value = XGetPixel(image, x1, y1); if (pixel_value & transparentColor) { - /* +#if 0 *pmData++ = *ipmData++; *pmData++ = *ipmData++; *pmData++ = *ipmData++; - */ - pixel = (int32_t) XGetPixel(ximage_ipm,dst_x+x1, - dst_y+y1) ; - XPutPixel(ximage,dst_x+x1, dst_y+y1,(unsigned long)pixel); +#endif + pixel = XGetPixel(ximage_ipm,dst_x+x1,dst_y+y1) ; + XPutPixel(ximage,dst_x+x1, dst_y+y1,pixel); if(!test){ test = 1 ; } } - /* +#if 0 else { pmData +=3; ipmData +=3; } - */ +#endif } } } @@ -621,6 +661,7 @@ XImage *ReadAreaToImage(disp, srcRootWinid, x, y, width, height, XDestroyImage (image); } /* end of src_in_overlay */ } /** end transparency **/ + /* JDK modification - call XDestroyImage if non-null */ if (ximage_ipm != NULL) { XDestroyImage(ximage_ipm); } @@ -640,38 +681,36 @@ XImage *ReadAreaToImage(disp, srcRootWinid, x, y, width, height, image_wins must point to an existing list struct that's already been zeroed (zero_list()). ------------------------------------------------------------------------ **/ -static void make_src_list( disp, image_wins, bbox, curr, x_rootrel, y_rootrel, - curr_attrs, pclip) - Display *disp; - list_ptr image_wins; - XRectangle *bbox; /* bnding box of area we want */ - Window curr; - int32_t x_rootrel; /* pos of curr WRT root */ - int32_t y_rootrel; - XWindowAttributes *curr_attrs; - XRectangle *pclip; /* visible part of curr, not */ - /* obscurred by ancestors */ +static void make_src_list(Display *disp, list_ptr image_wins, + /* bnding box of area we want */ + XRectangle *bbox, + Window curr, + /* pos of curr WRT root */ + int x_rootrel, int y_rootrel, + XWindowAttributes *curr_attrs, + /* visible part of curr, not obscurred by ancestors */ + XRectangle *pclip) { XWindowAttributes child_attrs; Window root, parent, *child; /* variables for XQueryTree() */ Window *save_child_list; /* variables for XQueryTree() */ - uint32_t nchild; /* variables for XQueryTree() */ + unsigned int nchild; /* variables for XQueryTree() */ XRectangle child_clip; /* vis part of child */ - int32_t curr_clipX, curr_clipY, curr_clipRt, curr_clipBt; + int curr_clipX, curr_clipY, curr_clipRt, curr_clipBt; /* check that win is mapped & not outside bounding box */ if (curr_attrs->map_state == IsViewable && curr_attrs->class == InputOutput && - !( pclip->x >= (bbox->x + bbox->width) || - pclip->y >= (bbox->y + bbox->height) || - (pclip->x + pclip->width) <= bbox->x || - (pclip->y + pclip->height) <= bbox->y)) { + !( pclip->x >= (int) (bbox->x + bbox->width) || + pclip->y >= (int) (bbox->y + bbox->height) || + (int) (pclip->x + pclip->width) <= bbox->x || + (int) (pclip->y + pclip->height) <= bbox->y)) { XQueryTree( disp, curr, &root, &parent, &child, &nchild ); save_child_list = child; /* so we can free list when we're done */ add_window_to_list( image_wins, curr, x_rootrel, y_rootrel, - (int32_t) pclip->x, (int32_t) pclip->y, - (int32_t) pclip->width, (int32_t) pclip->height, + pclip->x, pclip->y, + pclip->width, pclip->height, curr_attrs->border_width,curr_attrs->visual, curr_attrs->colormap, parent); @@ -683,40 +722,39 @@ static void make_src_list( disp, image_wins, bbox, curr, x_rootrel, y_rootrel, child loop, we figure the clip rect for each child by adding in it's rectangle (not taking into account the child's borders). ------------------------------------------------------------------------ **/ - curr_clipX = MAX( pclip->x, x_rootrel + curr_attrs->border_width); - curr_clipY = MAX( pclip->y, y_rootrel + curr_attrs->border_width); - curr_clipRt = MIN(pclip->x + pclip->width, - x_rootrel + curr_attrs->width + 2 * curr_attrs->border_width); - - curr_clipBt = MIN(pclip->y + pclip->height, - y_rootrel + curr_attrs->height + 2 * curr_attrs->border_width); - + curr_clipX = MAX( pclip->x, x_rootrel + (int) curr_attrs->border_width); + curr_clipY = MAX( pclip->y, y_rootrel + (int) curr_attrs->border_width); + curr_clipRt = MIN( pclip->x + (int) pclip->width, + x_rootrel + (int) curr_attrs->width + + 2 * (int) curr_attrs->border_width); + curr_clipBt = MIN( pclip->y + (int) pclip->height, + y_rootrel + (int) curr_attrs->height + + 2 * (int) curr_attrs->border_width); while (nchild--) { - int32_t new_width, new_height; - int32_t child_xrr, child_yrr; /* root relative x & y of child */ + int new_width, new_height; + int child_xrr, child_yrr; /* root relative x & y of child */ XGetWindowAttributes( disp, *child, &child_attrs); /* intersect parent & child clip rects */ child_xrr = x_rootrel + child_attrs.x + curr_attrs->border_width; - child_clip.x = (short) MAX( curr_clipX, child_xrr); - new_width = MIN(curr_clipRt, - child_xrr + child_attrs.width + - 2 * child_attrs.border_width) - child_clip.x; - + child_clip.x = MAX( curr_clipX, child_xrr); + new_width = MIN( curr_clipRt, child_xrr + (int) child_attrs.width + + 2 * child_attrs.border_width) + - child_clip.x; if (new_width >= 0) { - child_clip.width = (unsigned short) new_width; + child_clip.width = new_width; child_yrr = y_rootrel + child_attrs.y + curr_attrs->border_width; - child_clip.y = (short) MAX( curr_clipY, child_yrr); - new_height = MIN(curr_clipBt, - child_yrr + (int32_t) child_attrs.height + - 2 * child_attrs.border_width) - child_clip.y; - + child_clip.y = MAX( curr_clipY, child_yrr); + new_height = MIN( curr_clipBt, + child_yrr + (int) child_attrs.height + + 2 * child_attrs.border_width) + - child_clip.y; if (new_height >= 0) { - child_clip.height = (unsigned short) new_height; + child_clip.height = new_height; make_src_list( disp, image_wins, bbox, *child, child_xrr, child_yrr, &child_attrs, &child_clip); @@ -737,15 +775,9 @@ static void make_src_list( disp, image_wins, bbox, curr, x_rootrel, y_rootrel, there will be two regions in the list. Returns a pointer to the list. ------------------------------------------------------------------------ **/ -static list_ptr make_region_list( disp, win, bbox, hasNonDefault, - numImageVisuals, pImageVisuals, allImage) - Display *disp; - Window win; - XRectangle *bbox; - int32_t *hasNonDefault; - int32_t numImageVisuals; - XVisualInfo **pImageVisuals; - int32_t *allImage; +static list_ptr make_region_list(Display *disp, Window win, XRectangle *bbox, + int *hasNonDefault, int numImageVisuals, + XVisualInfo **pImageVisuals, int *allImage) { XWindowAttributes win_attrs; list image_wins; @@ -755,9 +787,9 @@ static list_ptr make_region_list( disp, win, bbox, hasNonDefault, image_win_type *base_src, *src; Region bbox_region = XCreateRegion(); XRectangle clip; - int32_t image_only; + int image_only; - int32_t count=0 ; + int count=0 ; *hasNonDefault = False; XUnionRectWithRegion( bbox, bbox_region, bbox_region); @@ -766,8 +798,8 @@ static list_ptr make_region_list( disp, win, bbox, hasNonDefault, zero_list( &image_wins); clip.x = 0; clip.y = 0; - clip.width = (unsigned short) win_attrs.width; - clip.height = (unsigned short) win_attrs.height; + clip.width = win_attrs.width; + clip.height = win_attrs.height; make_src_list( disp, &image_wins, bbox, win, 0 /* x_rootrel */, 0 /* y_rootrel */, &win_attrs, &clip); @@ -840,8 +872,7 @@ static list_ptr make_region_list( disp, win, bbox, hasNonDefault, /** ------------------------------------------------------------------------ Destructor called from destroy_region_list(). ------------------------------------------------------------------------ **/ -void destroy_image_region( image_region) - image_region_type *image_region; +static void destroy_image_region(image_region_type *image_region) { XDestroyRegion( image_region->visible_region); free( (void *) image_region); @@ -850,8 +881,7 @@ void destroy_image_region( image_region) /** ------------------------------------------------------------------------ Destroys the region list, destroying all the regions contained in it. ------------------------------------------------------------------------ **/ -static void destroy_region_list( rlist) - list_ptr rlist; +static void destroy_region_list(list_ptr rlist) { delete_list_destroying( rlist, (DESTRUCT_FUNC_PTR)destroy_image_region); } @@ -863,21 +893,17 @@ static void destroy_region_list( rlist) only provides a way to subtract one region from another, not a rectangle from a region. ------------------------------------------------------------------------ **/ -static void subtr_rect_from_image_region( image_region, x, y, width, height) - image_region_type *image_region; - int32_t x; - int32_t y; - int32_t width; - int32_t height; +static void subtr_rect_from_image_region(image_region_type *image_region, + int x, int y, int width, int height) { XRectangle rect; Region rect_region; rect_region = XCreateRegion(); - rect.x = (short)x; - rect.y = (short)y; - rect.width = (unsigned short)width; - rect.height = (unsigned short)height; + rect.x = x; + rect.y = y; + rect.width = width; + rect.height = height; XUnionRectWithRegion( &rect, rect_region, rect_region); XSubtractRegion( image_region->visible_region, rect_region, image_region->visible_region); @@ -888,19 +914,15 @@ static void subtr_rect_from_image_region( image_region, x, y, width, height) /** ------------------------------------------------------------------------ Adds the specified rectangle to the region in image_region. ------------------------------------------------------------------------ **/ -static void add_rect_to_image_region( image_region, x, y, width, height) - image_region_type *image_region; - int32_t x; - int32_t y; - int32_t width; - int32_t height; +static void add_rect_to_image_region(image_region_type *image_region, + int x, int y, int width, int height) { XRectangle rect; - rect.x = (short) x; - rect.y = (short) y; - rect.width = (unsigned short) width; - rect.height = (unsigned short) height; + rect.x = x; + rect.y = y; + rect.width = width; + rect.height = height; XUnionRectWithRegion( &rect, image_region->visible_region, image_region->visible_region); } @@ -910,9 +932,7 @@ static void add_rect_to_image_region( image_region, x, y, width, height) Returns TRUE if the given src's visual is already represented in the image_regions list, FALSE otherwise. ------------------------------------------------------------------------ **/ -static int32_t src_in_region_list( src, image_regions) - image_win_type *src; - list_ptr image_regions; +static int src_in_region_list(image_win_type *src, list_ptr image_regions) { image_region_type *ir; @@ -931,20 +951,10 @@ static int32_t src_in_region_list( src, image_regions) /** ------------------------------------------------------------------------ Makes a new entry in image_wins with the given fields filled in. ------------------------------------------------------------------------ **/ -static void add_window_to_list( image_wins, w, xrr, yrr, x_vis, y_vis, - width, height, border_width,vis, cmap, parent) - list_ptr image_wins; - Window w; - int32_t xrr; - int32_t yrr; - int32_t x_vis; - int32_t y_vis; - int32_t width; - int32_t height; - int32_t border_width; - Visual *vis; - Colormap cmap; - Window parent; +static void add_window_to_list(list_ptr image_wins, Window w, + int xrr, int yrr, int x_vis, int y_vis, + int width, int height, int border_width, + Visual *vis, Colormap cmap, Window parent) { image_win_type *new_src; @@ -970,12 +980,10 @@ static void add_window_to_list( image_wins, w, xrr, yrr, x_vis, y_vis, Returns TRUE if the given src's visual is in the image planes, FALSE otherwise. ------------------------------------------------------------------------ **/ -static int32_t src_in_image( src, numImageVisuals, pImageVisuals) - image_win_type *src; - int32_t numImageVisuals; - XVisualInfo **pImageVisuals; +static int src_in_image(image_win_type *src, int numImageVisuals, + XVisualInfo **pImageVisuals) { - int32_t i; + int i; for (i = 0 ; i < numImageVisuals ; i++) { @@ -990,15 +998,11 @@ static int32_t src_in_image( src, numImageVisuals, pImageVisuals) Returns TRUE if the given src's visual is in the overlay planes and transparency is possible, FALSE otherwise. ------------------------------------------------------------------------ **/ -static int32_t src_in_overlay( src, numOverlayVisuals, pOverlayVisuals, - transparentColor, transparentType) - image_region_type *src; - int32_t numOverlayVisuals; - OverlayInfo *pOverlayVisuals; - int32_t *transparentColor; - int32_t *transparentType; +static int src_in_overlay(image_region_type *src, int numOverlayVisuals, + OverlayInfo *pOverlayVisuals, + int *transparentColor, int *transparentType) { - int32_t i; + int i; for (i = 0 ; i < numOverlayVisuals ; i++) { @@ -1039,7 +1043,7 @@ static int32_t src_in_overlay( src, numOverlayVisuals, pOverlayVisuals, #define DIRECT_COLOR 0x11 -static int32_t weCreateServerOverlayVisualsProperty = False; +static int weCreateServerOverlayVisualsProperty = False; /****************************************************************************** @@ -1064,42 +1068,40 @@ static int32_t weCreateServerOverlayVisualsProperty = False; * ******************************************************************************/ -int32_t GetXVisualInfo(display, screen, transparentOverlays, - numVisuals, pVisuals, - numOverlayVisuals, pOverlayVisuals, - numImageVisuals, pImageVisuals) - - Display *display; /* Which X server (aka "display"). */ - int32_t screen; /* Which screen of the "display". */ - int32_t *transparentOverlays; /* Non-zero if there's at least one - * overlay visual and if at least one - * of those supports a transparent - * pixel. */ - int32_t *numVisuals; /* Number of XVisualInfo struct's - * pointed to to by pVisuals. */ - XVisualInfo **pVisuals; /* All of the device's visuals. */ - int32_t *numOverlayVisuals; /* Number of OverlayInfo's pointed - * to by pOverlayVisuals. If this - * number is zero, the device does - * not have overlay planes. */ - OverlayInfo **pOverlayVisuals; /* The device's overlay plane visual - * information. */ - int32_t *numImageVisuals; /* Number of XVisualInfo's pointed - * to by pImageVisuals. */ - XVisualInfo ***pImageVisuals; /* The device's image visuals. */ +int GetXVisualInfo(/* Which X server (aka "display"). */ + Display *display, + /* Which screen of the "display". */ + int screen, + /* Non-zero if there's at least one overlay visual and + * if at least one of those supports a transparent pixel. */ + int *transparentOverlays, + /* Number of XVisualInfo struct's pointed to by pVisuals. */ + int *numVisuals, + /* All of the device's visuals. */ + XVisualInfo **pVisuals, + /* Number of OverlayInfo's pointed to by pOverlayVisuals. + * If this number is zero, the device does not have + * overlay planes. */ + int *numOverlayVisuals, + /* The device's overlay plane visual information. */ + OverlayInfo **pOverlayVisuals, + /* Number of XVisualInfo's pointed to by pImageVisuals. */ + int *numImageVisuals, + /* The device's image visuals. */ + XVisualInfo ***pImageVisuals) { - XVisualInfo getVisInfo; /* Parameters of XGetVisualInfo */ - int32_t mask; + XVisualInfo getVisInfo; /* Paramters of XGetVisualInfo */ + int mask; XVisualInfo *pVis, **pIVis; /* Faster, local copies */ OverlayInfo *pOVis; OverlayVisualPropertyRec *pOOldVis; - int32_t nVisuals, nOVisuals; + int nVisuals, nOVisuals; Atom overlayVisualsAtom; /* Parameters for XGetWindowProperty */ Atom actualType; unsigned long numLongs, bytesAfter; - int32_t actualFormat; - int32_t nImageVisualsAlloced; /* Values to process the XVisualInfo */ - int32_t imageVisual; /* array */ + int actualFormat; + int nImageVisualsAlloced; /* Values to process the XVisualInfo */ + int imageVisual; /* array */ /* First, get the list of visuals for this screen. */ @@ -1125,10 +1127,10 @@ int32_t GetXVisualInfo(display, screen, transparentOverlays, * do-while loop makes sure we get the entire list from the X server. */ bytesAfter = 0; - numLongs = sizeof(OverlayVisualPropertyRec) / 4; + numLongs = sizeof(OverlayVisualPropertyRec) / sizeof(long); do { - numLongs += bytesAfter * 4; + numLongs += bytesAfter * sizeof(long); XGetWindowProperty(display, RootWindow(display, screen), overlayVisualsAtom, 0, numLongs, False, overlayVisualsAtom, &actualType, &actualFormat, @@ -1137,7 +1139,6 @@ int32_t GetXVisualInfo(display, screen, transparentOverlays, /* Calculate the number of overlay visuals in the list. */ - /* *numOverlayVisuals = numLongs / (sizeof(OverlayVisualPropertyRec) / 4); */ *numOverlayVisuals = numLongs / (sizeof(OverlayVisualPropertyRec) / sizeof(long)); } else @@ -1199,11 +1200,8 @@ int32_t GetXVisualInfo(display, screen, transparentOverlays, * ******************************************************************************/ -void FreeXVisualInfo(pVisuals, pOverlayVisuals, pImageVisuals) - - XVisualInfo *pVisuals; - OverlayInfo *pOverlayVisuals; - XVisualInfo **pImageVisuals; +void FreeXVisualInfo(XVisualInfo *pVisuals, OverlayInfo *pOverlayVisuals, + XVisualInfo **pImageVisuals) { XFree(pVisuals); if (weCreateServerOverlayVisualsProperty) diff --git a/src/solaris/native/sun/awt/multiVis.h b/src/solaris/native/sun/awt/multiVis.h index b1d7085a77820a9fb25be9e87a0b66715fd523fd..a505cd1a45701d9b2e0a7b24fdc81ba47fe49806 100644 --- a/src/solaris/native/sun/awt/multiVis.h +++ b/src/solaris/native/sun/awt/multiVis.h @@ -1,4 +1,5 @@ /* + * Copyright (c) 1999, 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 +22,6 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -/* $XConsortium: multiVis.h /main/4 1996/10/14 15:04:12 swick $ */ /** ------------------------------------------------------------------------ This file contains routines for manipulating generic lists. Lists are implemented with a "harness". In other words, each @@ -36,16 +36,14 @@ However, the following notice accompanied the original version of this file: -Copyright (c) 1994 Hewlett-Packard Co. -Copyright (c) 1996 X Consortium +Copyright 1994 Hewlett-Packard Co. +Copyright 1996, 1998 The Open Group -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -53,38 +51,32 @@ in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -Except as contained in this notice, the name of the X Consortium shall +Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization -from the X Consortium. +from The Open Group. ------------------------------------------------------------------------ **/ -extern int32_t GetMultiVisualRegions( -#if NeedFunctionPrototypes - Display *, Window, int32_t, int32_t, uint32_t, - uint32_t, int32_t *, int32_t *, XVisualInfo **, int32_t *, - OverlayInfo **, int32_t *, XVisualInfo ***, list_ptr *, - list_ptr *, int32_t * -#endif +extern int GetMultiVisualRegions( + Display *, Window, int, int, unsigned int, + unsigned int, int *, int *, XVisualInfo **, int *, + OverlayInfo **, int *, XVisualInfo ***, list_ptr *, + list_ptr *, int * ); extern XImage *ReadAreaToImage( -#if NeedFunctionPrototypes - Display *, Window, int32_t, int32_t, uint32_t, - uint32_t, int32_t, XVisualInfo *, int32_t, - OverlayInfo *, int32_t, XVisualInfo **, list_ptr, - list_ptr, int32_t, int32_t -#endif + Display *, Window, int, int, unsigned int, + unsigned int, int, XVisualInfo *, int, + OverlayInfo *, int, XVisualInfo **, list_ptr, + list_ptr, int, int ); extern void initFakeVisual( -#if NeedFunctionPrototypes Visual * -#endif ); diff --git a/src/solaris/native/sun/awt/robot_common.c b/src/solaris/native/sun/awt/robot_common.c deleted file mode 100644 index da61f299b5c1fda2dfb027441bc702c42a81a24b..0000000000000000000000000000000000000000 --- a/src/solaris/native/sun/awt/robot_common.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifdef HEADLESS - #error This file should not be included in headless library -#endif - -#ifdef MACOSX -#include -#endif - -#include "robot_common.h" - -/* - * QueryColorMap is taken from multiVis.c, part of the xwd distribution from - * X.org. It was moved here so it can be shared with awt_DataTransferer.c - */ -int32_t -QueryColorMap(Display *disp, - Colormap src_cmap, - Visual *src_vis, - XColor **src_colors, - int32_t *rShift, int32_t *gShift, int32_t *bShift) - -{ - int32_t ncolors, i; - unsigned long redMask, greenMask, blueMask; - int32_t redShift, greenShift, blueShift; - XColor *colors ; - - ncolors = src_vis->map_entries ; - *src_colors = colors = (XColor *)calloc(ncolors,sizeof(XColor) ) ; - - if(src_vis->class != TrueColor && src_vis->class != DirectColor) - { - for(i=0 ; i < ncolors ; i++) - { - colors[i].pixel = i ; - colors[i].pad = 0; - colors[i].flags = DoRed|DoGreen|DoBlue; - } - } - else /** src is decomposed rgb ***/ - { - /* Get the X colormap */ - redMask = src_vis->red_mask; - greenMask = src_vis->green_mask; - blueMask = src_vis->blue_mask; - redShift = 0; while (!(redMask&0x1)) { - redShift++; - redMask = redMask>>1; - } - greenShift = 0; while (!(greenMask&0x1)) { - greenShift++; - greenMask = greenMask>>1; - } - blueShift = 0; while (!(blueMask&0x1)) { - blueShift++; - blueMask = blueMask>>1; - } - *rShift = redShift ; - *gShift = greenShift ; - *bShift = blueShift ; - for (i=0; i #include "gtk_interface.h" #include "com_sun_java_swing_plaf_gtk_GTKEngine.h" +#include +#include /* Static buffer for conversion from java.lang.String to UTF-8 */ static char conversionBuffer[CONV_BUFFER_SIZE]; @@ -307,6 +308,11 @@ JNIEXPORT void JNICALL Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeStartPainting( JNIEnv *env, jobject this, jint w, jint h) { + if (w > 0x7FFF || h > 0x7FFF || (uintptr_t)4 * w * h > 0x7FFFFFFFL) { + // Same limitation as in X11SurfaceData.c + JNU_ThrowOutOfMemoryError(env, "Can't create offscreen surface"); + return; + } gtk->gdk_threads_enter(); gtk->init_painting(env, w, h); gtk->gdk_threads_leave(); diff --git a/src/solaris/native/sun/awt/wsutils.h b/src/solaris/native/sun/awt/wsutils.h index 9ff6c5d23e8353f3c26f4090d9571672513d7821..52666a26bef6ebd058a3eb707a5d93095e35e37f 100644 --- a/src/solaris/native/sun/awt/wsutils.h +++ b/src/solaris/native/sun/awt/wsutils.h @@ -1,4 +1,5 @@ /* + * Copyright (c) 1999, 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 +22,6 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -/* $XConsortium: wsutils.h /main/3 1996/10/14 15:04:17 swick $ */ /** ------------------------------------------------------------------------ This file contains routines for manipulating generic lists. Lists are implemented with a "harness". In other words, each @@ -36,16 +36,14 @@ However, the following notice accompanied the original version of this file: -Copyright (c) 1994 Hewlett-Packard Co. -Copyright (c) 1996 X Consortium +Copyright 1994 Hewlett-Packard Co. +Copyright 1996, 1998 The Open Group -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -53,17 +51,18 @@ in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -Except as contained in this notice, the name of the X Consortium shall +Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization -from the X Consortium. +from The Open Group. ------------------------------------------------------------------------ **/ + /****************************************************************************** * * This file contains various typedef's, macros and procedure declarations for @@ -71,16 +70,18 @@ from the X Consortium. * ******************************************************************************/ +typedef unsigned long Pixel; + /* This is the actual structure returned by the X server describing the * SERVER_OVERLAY_VISUAL property. */ typedef struct { VisualID visualID; /* The VisualID of the overlay visual */ - long transparentType; /* Can be None, TransparentPixel or + int transparentType; /* Can be None, TransparentPixel or * TransparentMask */ - long value; /* Pixel value */ - long layer; /* Overlay planes will always be in + Pixel value; /* Pixel value */ + int layer; /* Overlay planes will always be in * layer 1 */ } OverlayVisualPropertyRec; @@ -93,10 +94,10 @@ typedef struct typedef struct { XVisualInfo *pOverlayVisualInfo; /* Pointer to the XVisualInfo struct */ - long transparentType; /* Can be None, TransparentPixel or + int transparentType; /* Can be None, TransparentPixel or * TransparentMask */ - long value; /* Pixel value */ - long layer; /* Overlay planes will always be in + Pixel value; /* Pixel value */ + int layer; /* Overlay planes will always be in * layer 1 */ } OverlayInfo; @@ -158,27 +159,25 @@ typedef struct * ******************************************************************************/ -extern int32_t GetXVisualInfo( -#if NeedFunctionPrototypes +extern int GetXVisualInfo( Display *display, /* Which X server (aka "display"). */ - int32_t screen, /* Which screen of the "display". */ - int32_t *transparentOverlays, /* Non-zero if there's at least one + int screen, /* Which screen of the "display". */ + int *transparentOverlays, /* Non-zero if there's at least one * overlay visual and if at least one * of those supports a transparent * pixel. */ - int32_t *numVisuals, /* Number of XVisualInfo struct's + int *numVisuals, /* Number of XVisualInfo struct's * pointed to to by pVisuals. */ XVisualInfo **pVisuals, /* All of the device's visuals. */ - int32_t *numOverlayVisuals, /* Number of OverlayInfo's pointed + int *numOverlayVisuals, /* Number of OverlayInfo's pointed * to by pOverlayVisuals. If this * number is zero, the device does * not have overlay planes. */ OverlayInfo **pOverlayVisuals, /* The device's overlay plane visual * information. */ - int32_t *numImageVisuals, /* Number of XVisualInfo's pointed + int *numImageVisuals, /* Number of XVisualInfo's pointed * to by pImageVisuals. */ XVisualInfo ***pImageVisuals /* The device's image visuals. */ -#endif ); @@ -191,11 +190,9 @@ extern int32_t GetXVisualInfo( ******************************************************************************/ extern void FreeXVisualInfo( -#if NeedFunctionPrototypes XVisualInfo *pVisuals, OverlayInfo *pOverlayVisuals, XVisualInfo **pImageVisuals -#endif ); @@ -219,22 +216,20 @@ extern void FreeXVisualInfo( * ******************************************************************************/ -extern int32_t FindImagePlanesVisual( -#if NeedFunctionPrototypes +extern int FindImagePlanesVisual( Display *display, /* Which X server (aka "display"). */ - int32_t screen, /* Which screen of the "display". */ - int32_t numImageVisuals, /* Number of XVisualInfo's pointed + int screen, /* Which screen of the "display". */ + int numImageVisuals, /* Number of XVisualInfo's pointed * to by pImageVisuals. */ XVisualInfo **pImageVisuals, /* The device's image visuals. */ - int32_t sbCmapHint, /* What Starbase cmap modes will be + int sbCmapHint, /* What Starbase cmap modes will be * used with the visual. NOTE: This * is a mask of the possible values. */ - int32_t depthHint, /* Desired depth. */ - int32_t depthFlexibility, /* How much the actual value in + int depthHint, /* Desired depth. */ + int depthFlexibility, /* How much the actual value in * "depthHint" is desired. */ Visual **pImageVisualToUse, /* The screen's image visual to use. */ - int32_t *depthObtained /* Actual depth of the visual. */ -#endif + int *depthObtained /* Actual depth of the visual. */ ); @@ -267,25 +262,23 @@ extern int32_t FindImagePlanesVisual( * ******************************************************************************/ -extern int32_t FindOverlayPlanesVisual( -#if NeedFunctionPrototypes +extern int FindOverlayPlanesVisual( Display *display, /* Which X server (aka "display"). */ - int32_t screen, /* Which screen of the "display". */ - int32_t numOverlayVisuals, /* Number of OverlayInfo's pointed + int screen, /* Which screen of the "display". */ + int numOverlayVisuals, /* Number of OverlayInfo's pointed * to by pOverlayVisuals. */ OverlayInfo *pOverlayVisuals, /* The device's overlay plane visual * information. */ - int32_t depthHint, /* Desired depth. */ - int32_t depthFlexibility, /* How much the actual value in + int depthHint, /* Desired depth. */ + int depthFlexibility, /* How much the actual value in * "depthHint" is desired. */ - int32_t transparentBackground, /* Non-zero if the visual must have + int transparentBackground, /* Non-zero if the visual must have * a transparent color. */ Visual **pOverlayVisualToUse, /* The screen's overlay visual to * use. */ - int32_t *depthObtained, /* Actual depth of the visual. */ - int32_t *transparentColor /* The transparent color the program + int *depthObtained, /* Actual depth of the visual. */ + int *transparentColor /* The transparent color the program * can use with the visual. */ -#endif ); @@ -308,27 +301,25 @@ extern int32_t FindOverlayPlanesVisual( * ******************************************************************************/ -extern int32_t CreateImagePlanesWindow( -#if NeedFunctionPrototypes +extern int CreateImagePlanesWindow( Display *display, /* Which X server (aka "display"). */ - int32_t screen, /* Which screen of the "display". */ + int screen, /* Which screen of the "display". */ Window parentWindow, /* Window ID of the parent window for * the created window. */ - int32_t windowX, /* Desired X coord. of the window. */ - int32_t windowY, /* Desired Y coord of the window. */ - int32_t windowWidth, /* Desired width of the window. */ - int32_t windowHeight, /* Desired height of the window. */ - int32_t windowDepth, /* Desired depth of the window. */ + int windowX, /* Desired X coord. of the window. */ + int windowY, /* Desired Y coord of the window. */ + int windowWidth, /* Desired width of the window. */ + int windowHeight, /* Desired height of the window. */ + int windowDepth, /* Desired depth of the window. */ Visual *pImageVisualToUse, /* The window's image planes visual. */ - int32_t argc, /* Program's argc parameter. */ + int argc, /* Program's argc parameter. */ char *argv[], /* Program's argv parameter. */ char *windowName, /* Name to put on window's border. */ char *iconName, /* Name to put on window's icon. */ Window *imageWindow, /* Window ID of the created window. */ Colormap *imageColormap, /* The window's colormap. */ - int32_t *mustFreeImageColormap /* Non-zero if the program must call + int *mustFreeImageColormap /* Non-zero if the program must call * XFreeColormap() for imageColormap. */ -#endif ); @@ -351,30 +342,28 @@ extern int32_t CreateImagePlanesWindow( * ******************************************************************************/ -int32_t CreateOverlayPlanesWindow( -#if NeedFunctionPrototypes +int CreateOverlayPlanesWindow( Display *display, /* Which X server (aka "display"). */ - int32_t screen, /* Which screen of the "display". */ + int screen, /* Which screen of the "display". */ Window parentWindow, /* Window ID of the parent window for * the created window. */ - int32_t windowX, /* Desired X coord. of the window. */ - int32_t windowY, /* Desired Y coord of the window. */ - int32_t windowWidth, /* Desired width of the window. */ - int32_t windowHeight, /* Desired height of the window. */ - int32_t windowDepth, /* Desired depth of the window. */ + int windowX, /* Desired X coord. of the window. */ + int windowY, /* Desired Y coord of the window. */ + int windowWidth, /* Desired width of the window. */ + int windowHeight, /* Desired height of the window. */ + int windowDepth, /* Desired depth of the window. */ Visual *pOverlayVisualToUse, /* The window's overlay planes visual.*/ - int32_t argc, /* Program's argc parameter. */ + int argc, /* Program's argc parameter. */ char *argv[], /* Program's argv parameter. */ char *windowName, /* Name to put on window's border. */ char *iconName, /* Name to put on window's icon. */ - int32_t transparentBackground, /* Non-zero if the window's background + int transparentBackground, /* Non-zero if the window's background * should be a transparent color. */ - int32_t *transparentColor, /* The transparent color to use as the + int *transparentColor, /* The transparent color to use as the * window's background. */ Window *overlayWindow, /* Window ID of the created window. */ Colormap *overlayColormap, /* The window's colormap. */ - int32_t *mustFreeOverlayColormap/* Non-zero if the program must call + int *mustFreeOverlayColormap/* Non-zero if the program must call * XFreeColormap() for * overlayColormap. */ -#endif ); diff --git a/src/solaris/native/sun/java2d/opengl/J2D_GL/glx.h b/src/solaris/native/sun/java2d/opengl/J2D_GL/glx.h index 26b9669dfc3b1e36c99d1201bbe6c8d54f083fa0..cfbbdca487ac9505ec1008405e2aa93881b32f84 100644 --- a/src/solaris/native/sun/java2d/opengl/J2D_GL/glx.h +++ b/src/solaris/native/sun/java2d/opengl/J2D_GL/glx.h @@ -22,7 +22,6 @@ * questions. */ -/* $Id: glx.h,v 1.38 2002/10/14 13:52:27 brianp Exp $ */ /* * This file is available under and governed by the GNU General Public @@ -31,9 +30,8 @@ * file: * * Mesa 3-D graphics library - * Version: 4.1 * - * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -48,9 +46,10 @@ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. */ @@ -58,31 +57,15 @@ #define GLX_H -#ifdef __VMS -#include -# ifdef __cplusplus -/* VMS Xlib.h gives problems with C++. - * this avoids a bunch of trivial warnings */ -#pragma message disable nosimpint -#endif -#endif #include #include -#ifdef __VMS -# ifdef __cplusplus -#pragma message enable nosimpint -#endif -#endif - -/* modified for inclusion in Java 2D source tree */ -/* #include */ +/* JDK modification of include path to be sure to pick up the correct file */ #include "J2D_GL/gl.h" -/* + #if defined(USE_MGL_NAMESPACE) -#include +#include "glx_mangle.h" #endif -*/ #ifdef __cplusplus @@ -146,8 +129,6 @@ extern "C" { */ #define GLX_CONFIG_CAVEAT 0x20 #define GLX_DONT_CARE 0xFFFFFFFF -#define GLX_SLOW_CONFIG 0x8001 -#define GLX_NON_CONFORMANT_CONFIG 0x800D #define GLX_X_VISUAL_TYPE 0x22 #define GLX_TRANSPARENT_TYPE 0x23 #define GLX_TRANSPARENT_INDEX_VALUE 0x24 @@ -155,17 +136,6 @@ extern "C" { #define GLX_TRANSPARENT_GREEN_VALUE 0x26 #define GLX_TRANSPARENT_BLUE_VALUE 0x27 #define GLX_TRANSPARENT_ALPHA_VALUE 0x28 -#define GLX_MAX_PBUFFER_WIDTH 0x8016 -#define GLX_MAX_PBUFFER_HEIGHT 0x8017 -#define GLX_MAX_PBUFFER_PIXELS 0x8018 -#define GLX_PRESERVED_CONTENTS 0x801B -#define GLX_LARGEST_PBUFFER 0x801C -#define GLX_WIDTH 0x801D -#define GLX_HEIGHT 0x801E -#define GLX_EVENT_MASK 0x801F -#define GLX_DRAWABLE_TYPE 0x8010 -#define GLX_FBCONFIG_ID 0x8013 -#define GLX_VISUAL_ID 0x800B #define GLX_WINDOW_BIT 0x00000001 #define GLX_PIXMAP_BIT 0x00000002 #define GLX_PBUFFER_BIT 0x00000004 @@ -177,10 +147,8 @@ extern "C" { #define GLX_DEPTH_BUFFER_BIT 0x00000020 #define GLX_STENCIL_BUFFER_BIT 0x00000040 #define GLX_ACCUM_BUFFER_BIT 0x00000080 -#define GLX_DRAWABLE_TYPE 0x8010 -#define GLX_RENDER_TYPE 0x8011 -#define GLX_X_RENDERABLE 0x8012 #define GLX_NONE 0x8000 +#define GLX_SLOW_CONFIG 0x8001 #define GLX_TRUE_COLOR 0x8002 #define GLX_DIRECT_COLOR 0x8003 #define GLX_PSEUDO_COLOR 0x8004 @@ -189,28 +157,33 @@ extern "C" { #define GLX_STATIC_GRAY 0x8007 #define GLX_TRANSPARENT_RGB 0x8008 #define GLX_TRANSPARENT_INDEX 0x8009 +#define GLX_VISUAL_ID 0x800B +#define GLX_SCREEN 0x800C +#define GLX_NON_CONFORMANT_CONFIG 0x800D +#define GLX_DRAWABLE_TYPE 0x8010 +#define GLX_RENDER_TYPE 0x8011 +#define GLX_X_RENDERABLE 0x8012 +#define GLX_FBCONFIG_ID 0x8013 #define GLX_RGBA_TYPE 0x8014 #define GLX_COLOR_INDEX_TYPE 0x8015 -#define GLX_COLOR_INDEX_BIT 0x00000002 -#define GLX_RGBA_BIT 0x00000001 -#define GLX_SCREEN 0x800C -#define GLX_PBUFFER_CLOBBER_MASK 0x08000000 +#define GLX_MAX_PBUFFER_WIDTH 0x8016 +#define GLX_MAX_PBUFFER_HEIGHT 0x8017 +#define GLX_MAX_PBUFFER_PIXELS 0x8018 +#define GLX_PRESERVED_CONTENTS 0x801B +#define GLX_LARGEST_PBUFFER 0x801C +#define GLX_WIDTH 0x801D +#define GLX_HEIGHT 0x801E +#define GLX_EVENT_MASK 0x801F #define GLX_DAMAGED 0x8020 #define GLX_SAVED 0x8021 #define GLX_WINDOW 0x8022 #define GLX_PBUFFER 0x8023 - -/** - * REMIND: these values are backwards from Sun's OpenGL headers, so we - * swap them here if building on Solaris/Sparc - */ -#ifdef __sparc -#define GLX_PBUFFER_HEIGHT 0x8041 -#define GLX_PBUFFER_WIDTH 0x8040 -#else /* __sparc */ #define GLX_PBUFFER_HEIGHT 0x8040 #define GLX_PBUFFER_WIDTH 0x8041 -#endif /* __sparc */ +#define GLX_RGBA_BIT 0x00000001 +#define GLX_COLOR_INDEX_BIT 0x00000002 +#define GLX_PBUFFER_CLOBBER_MASK 0x08000000 + /* * GLX 1.4 and later: @@ -231,6 +204,16 @@ typedef XID GLXWindow; typedef XID GLXPbuffer; +/* +** Events. +** __GLX_NUMBER_EVENTS is set to 17 to account for the BufferClobberSGIX +** event - this helps initialization if the server supports the pbuffer +** extension and the client doesn't. +*/ +#define GLX_PbufferClobber 0 +#define GLX_BufferSwapComplete 1 + +#define __GLX_NUMBER_EVENTS 17 extern XVisualInfo* glXChooseVisual( Display *dpy, int screen, int *attribList ); @@ -335,200 +318,158 @@ extern void glXSelectEvent( Display *dpy, GLXDrawable drawable, extern void glXGetSelectedEvent( Display *dpy, GLXDrawable drawable, unsigned long *mask ); - -/* GLX 1.4 and later */ -extern void (*glXGetProcAddress(const GLubyte *procname))(); - - -#ifndef GLX_GLXEXT_LEGACY - -/* modified for inclusion in Java 2D source tree */ -/* #include */ -#include "J2D_GL/glxext.h" - -#else +/* GLX 1.3 function pointer typedefs */ +typedef GLXFBConfig * (* PFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements); +typedef GLXFBConfig * (* PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements); +typedef int (* PFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value); +typedef XVisualInfo * (* PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config); +typedef GLXWindow (* PFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list); +typedef void (* PFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win); +typedef GLXPixmap (* PFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list); +typedef void (* PFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap); +typedef GLXPbuffer (* PFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list); +typedef void (* PFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf); +typedef void (* PFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value); +typedef GLXContext (* PFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct); +typedef Bool (* PFNGLXMAKECONTEXTCURRENTPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); +typedef GLXDrawable (* PFNGLXGETCURRENTREADDRAWABLEPROC) (void); +typedef Display * (* PFNGLXGETCURRENTDISPLAYPROC) (void); +typedef int (* PFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value); +typedef void (* PFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask); +typedef void (* PFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask); /* - * 28. GLX_EXT_visual_info extension - */ -#ifndef GLX_EXT_visual_info -#define GLX_EXT_visual_info 1 - -#define GLX_X_VISUAL_TYPE_EXT 0x22 -#define GLX_TRANSPARENT_TYPE_EXT 0x23 -#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24 -#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25 -#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26 -#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27 -#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28 -#define GLX_TRUE_COLOR_EXT 0x8002 -#define GLX_DIRECT_COLOR_EXT 0x8003 -#define GLX_PSEUDO_COLOR_EXT 0x8004 -#define GLX_STATIC_COLOR_EXT 0x8005 -#define GLX_GRAY_SCALE_EXT 0x8006 -#define GLX_STATIC_GRAY_EXT 0x8007 -#define GLX_NONE_EXT 0x8000 -#define GLX_TRANSPARENT_RGB_EXT 0x8008 -#define GLX_TRANSPARENT_INDEX_EXT 0x8009 - -#endif /* 28. GLX_EXT_visual_info extension */ - - - -/* - * 41. GLX_SGI_video_sync - */ -#ifndef GLX_SGI_video_sync -#define GLX_SGI_video_sync 1 - -extern int glXGetVideoSyncSGI(unsigned int *count); -extern int glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count); - -#endif /* GLX_SGI_video_sync */ - - - -/* - * 42. GLX_EXT_visual_rating - */ -#ifndef GLX_EXT_visual_rating -#define GLX_EXT_visual_rating 1 - -#define GLX_VISUAL_CAVEAT_EXT 0x20 -/*#define GLX_NONE_EXT 0x8000*/ -#define GLX_SLOW_VISUAL_EXT 0x8001 -#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D - -#endif /* GLX_EXT_visual_rating */ - - - -/* - * 47. GLX_EXT_import_context + * ARB 2. GLX_ARB_get_proc_address */ -#ifndef GLX_EXT_import_context -#define GLX_EXT_import_context 1 - -#define GLX_SHARE_CONTEXT_EXT 0x800A -#define GLX_VISUAL_ID_EXT 0x800B -#define GLX_SCREEN_EXT 0x800C - -extern void glXFreeContextEXT(Display *dpy, GLXContext context); - -extern GLXContextID glXGetContextIDEXT(const GLXContext context); - -extern Display *glXGetCurrentDisplayEXT(void); - -extern GLXContext glXImportContextEXT(Display *dpy, GLXContextID contextID); - -extern int glXQueryContextInfoEXT(Display *dpy, GLXContext context, - int attribute,int *value); +#ifndef GLX_ARB_get_proc_address +#define GLX_ARB_get_proc_address 1 -#endif /* GLX_EXT_import_context */ +typedef void (*__GLXextFuncPtr)(void); +extern __GLXextFuncPtr glXGetProcAddressARB (const GLubyte *); +#endif /* GLX_ARB_get_proc_address */ -/* - * 215. GLX_MESA_copy_sub_buffer - */ -#ifndef GLX_MESA_copy_sub_buffer -#define GLX_MESA_copy_sub_buffer 1 -extern void glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable, - int x, int y, int width, int height ); +/* GLX 1.4 and later */ +extern void (*glXGetProcAddress(const GLubyte *procname))( void ); -#endif +/* GLX 1.4 function pointer typedefs */ +typedef __GLXextFuncPtr (* PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName); +#ifndef GLX_GLXEXT_LEGACY -/* - * 216. GLX_MESA_pixmap_colormap - */ -#ifndef GLX_MESA_pixmap_colormap -#define GLX_MESA_pixmap_colormap 1 +/* JDK modification of include path to be sure to pick up the correct file */ +#include "J2D_GL/glxext.h" -extern GLXPixmap glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visual, - Pixmap pixmap, Colormap cmap ); +#endif /* GLX_GLXEXT_LEGACY */ -#endif /* GLX_MESA_pixmap_colormap */ +/** + ** The following aren't in glxext.h yet. + **/ /* - * 217. GLX_MESA_release_buffers + * ???. GLX_NV_vertex_array_range */ -#ifndef GLX_MESA_release_buffers -#define GLX_MESA_release_buffers 1 - -extern Bool glXReleaseBuffersMESA( Display *dpy, GLXDrawable d ); +#ifndef GLX_NV_vertex_array_range +#define GLX_NV_vertex_array_range -#endif /* GLX_MESA_release_buffers */ +extern void *glXAllocateMemoryNV(GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); +extern void glXFreeMemoryNV(GLvoid *pointer); +typedef void * ( * PFNGLXALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); +typedef void ( * PFNGLXFREEMEMORYNVPROC) (GLvoid *pointer); +#endif /* GLX_NV_vertex_array_range */ /* - * 218. GLX_MESA_set_3dfx_mode + * ARB ?. GLX_ARB_render_texture + * XXX This was never finalized! */ -#ifndef GLX_MESA_set_3dfx_mode -#define GLX_MESA_set_3dfx_mode 1 - -#define GLX_3DFX_WINDOW_MODE_MESA 0x1 -#define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2 - -extern Bool glXSet3DfxModeMESA( int mode ); +#ifndef GLX_ARB_render_texture +#define GLX_ARB_render_texture 1 -#endif /* GLX_MESA_set_3dfx_mode */ +extern Bool glXBindTexImageARB(Display *dpy, GLXPbuffer pbuffer, int buffer); +extern Bool glXReleaseTexImageARB(Display *dpy, GLXPbuffer pbuffer, int buffer); +extern Bool glXDrawableAttribARB(Display *dpy, GLXDrawable draw, const int *attribList); +#endif /* GLX_ARB_render_texture */ /* - * ARB 2. GLX_ARB_get_proc_address + * #?. GLX_MESA_swap_frame_usage */ -#ifndef GLX_ARB_get_proc_address -#define GLX_ARB_get_proc_address 1 - -extern void (*glXGetProcAddressARB(const GLubyte *procName))(); - -#endif /* GLX_ARB_get_proc_address */ +#ifndef GLX_MESA_swap_frame_usage +#define GLX_MESA_swap_frame_usage 1 +extern int glXGetFrameUsageMESA(Display *dpy, GLXDrawable drawable, float *usage); +extern int glXBeginFrameTrackingMESA(Display *dpy, GLXDrawable drawable); +extern int glXEndFrameTrackingMESA(Display *dpy, GLXDrawable drawable); +extern int glXQueryFrameTrackingMESA(Display *dpy, GLXDrawable drawable, int64_t *swapCount, int64_t *missedFrames, float *lastMissedUsage); +typedef int (*PFNGLXGETFRAMEUSAGEMESAPROC) (Display *dpy, GLXDrawable drawable, float *usage); +typedef int (*PFNGLXBEGINFRAMETRACKINGMESAPROC)(Display *dpy, GLXDrawable drawable); +typedef int (*PFNGLXENDFRAMETRACKINGMESAPROC)(Display *dpy, GLXDrawable drawable); +typedef int (*PFNGLXQUERYFRAMETRACKINGMESAPROC)(Display *dpy, GLXDrawable drawable, int64_t *swapCount, int64_t *missedFrames, float *lastMissedUsage); -#endif /* GLX_GLXEXT_LEGACY */ - +#endif /* GLX_MESA_swap_frame_usage */ -/** - ** The following aren't in glxext.h yet. - **/ /* - * ???. GLX_NV_vertex_array_range + * #?. GLX_MESA_swap_control */ -#ifndef GLX_NV_vertex_array_range -#define GLX_NV_vertex_array_range +#ifndef GLX_MESA_swap_control +#define GLX_MESA_swap_control 1 -extern void *glXAllocateMemoryNV(GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); -extern void glXFreeMemoryNV(GLvoid *pointer); -typedef void * ( * PFNGLXALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); -typedef void ( * PFNGLXFREEMEMORYNVPROC) (GLvoid *pointer); +extern int glXSwapIntervalMESA(unsigned int interval); +extern int glXGetSwapIntervalMESA(void); -#endif /* GLX_NV_vertex_array_range */ +typedef int (*PFNGLXSWAPINTERVALMESAPROC)(unsigned int interval); +typedef int (*PFNGLXGETSWAPINTERVALMESAPROC)(void); +#endif /* GLX_MESA_swap_control */ +/*** Should these go here, or in another header? */ /* - * ???. GLX_MESA_agp_offset - */ -#ifndef GLX_MESA_agp_offset -#define GLX_MESA_agp_offset 1 - -extern GLuint glXGetAGPOffsetMESA(const GLvoid *pointer); -typedef GLuint (* PFNGLXGETAGPOFFSETMESAPROC) (const GLvoid *pointer); - -#endif /* GLX_MESA_agp_offset */ - - +** GLX Events +*/ +typedef struct { + int event_type; /* GLX_DAMAGED or GLX_SAVED */ + int draw_type; /* GLX_WINDOW or GLX_PBUFFER */ + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came for SendEvent request */ + Display *display; /* display the event was read from */ + GLXDrawable drawable; /* XID of Drawable */ + unsigned int buffer_mask; /* mask indicating which buffers are affected */ + unsigned int aux_buffer; /* which aux buffer was affected */ + int x, y; + int width, height; + int count; /* if nonzero, at least this many more */ +} GLXPbufferClobberEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Drawable drawable; /* drawable on which event was requested in event mask */ + int event_type; + int64_t ust; + int64_t msc; + int64_t sbc; +} GLXBufferSwapComplete; + +typedef union __GLXEvent { + GLXPbufferClobberEvent glxpbufferclobber; + GLXBufferSwapComplete glxbufferswapcomplete; + long pad[24]; +} GLXEvent; #ifdef __cplusplus } diff --git a/src/solaris/native/sun/java2d/opengl/J2D_GL/glxext.h b/src/solaris/native/sun/java2d/opengl/J2D_GL/glxext.h index 3e7fdfb7e4500603a80ced37454cd057968d568a..033fe73d87f9fa86981de955b346e15adb5bb436 100644 --- a/src/solaris/native/sun/java2d/opengl/J2D_GL/glxext.h +++ b/src/solaris/native/sun/java2d/opengl/J2D_GL/glxext.h @@ -22,8 +22,8 @@ * questions. */ -#ifndef __glxext_h_ -#define __glxext_h_ +#ifndef __glx_glxext_h_ +#define __glx_glxext_h_ 1 #ifdef __cplusplus extern "C" { @@ -35,7 +35,7 @@ extern "C" { ** However, the following notice accompanied the original version of this ** file: ** -** Copyright (c) 2007 The Khronos Group Inc. +** Copyright (c) 2013-2018 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the @@ -56,580 +56,937 @@ extern "C" { ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** https://github.com/KhronosGroup/OpenGL-Registry +*/ -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) -#define WIN32_LEAN_AND_MEAN 1 -#include -#endif - -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -/*************************************************************/ +#define GLX_GLXEXT_VERSION 20180525 -/* Header file version number, required by OpenGL ABI for Linux */ -/* glxext.h last updated 2002/03/22 */ -/* Current version at http://oss.sgi.com/projects/ogl-sample/registry/ */ -#define GLX_GLXEXT_VERSION 5 +/* Generated C header for: + * API: glx + * Versions considered: .* + * Versions emitted: 1\.[3-9] + * Default extensions included: glx + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ #ifndef GLX_VERSION_1_3 -#define GLX_WINDOW_BIT 0x00000001 -#define GLX_PIXMAP_BIT 0x00000002 -#define GLX_PBUFFER_BIT 0x00000004 -#define GLX_RGBA_BIT 0x00000001 -#define GLX_COLOR_INDEX_BIT 0x00000002 -#define GLX_PBUFFER_CLOBBER_MASK 0x08000000 -#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001 -#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002 -#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004 -#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008 -#define GLX_AUX_BUFFERS_BIT 0x00000010 -#define GLX_DEPTH_BUFFER_BIT 0x00000020 -#define GLX_STENCIL_BUFFER_BIT 0x00000040 -#define GLX_ACCUM_BUFFER_BIT 0x00000080 -#define GLX_CONFIG_CAVEAT 0x20 -#define GLX_X_VISUAL_TYPE 0x22 -#define GLX_TRANSPARENT_TYPE 0x23 -#define GLX_TRANSPARENT_INDEX_VALUE 0x24 -#define GLX_TRANSPARENT_RED_VALUE 0x25 -#define GLX_TRANSPARENT_GREEN_VALUE 0x26 -#define GLX_TRANSPARENT_BLUE_VALUE 0x27 -#define GLX_TRANSPARENT_ALPHA_VALUE 0x28 -#define GLX_DONT_CARE 0xFFFFFFFF -#define GLX_NONE 0x8000 -#define GLX_SLOW_CONFIG 0x8001 -#define GLX_TRUE_COLOR 0x8002 -#define GLX_DIRECT_COLOR 0x8003 -#define GLX_PSEUDO_COLOR 0x8004 -#define GLX_STATIC_COLOR 0x8005 -#define GLX_GRAY_SCALE 0x8006 -#define GLX_STATIC_GRAY 0x8007 -#define GLX_TRANSPARENT_RGB 0x8008 -#define GLX_TRANSPARENT_INDEX 0x8009 -#define GLX_VISUAL_ID 0x800B -#define GLX_SCREEN 0x800C -#define GLX_NON_CONFORMANT_CONFIG 0x800D -#define GLX_DRAWABLE_TYPE 0x8010 -#define GLX_RENDER_TYPE 0x8011 -#define GLX_X_RENDERABLE 0x8012 -#define GLX_FBCONFIG_ID 0x8013 -#define GLX_RGBA_TYPE 0x8014 -#define GLX_COLOR_INDEX_TYPE 0x8015 -#define GLX_MAX_PBUFFER_WIDTH 0x8016 -#define GLX_MAX_PBUFFER_HEIGHT 0x8017 -#define GLX_MAX_PBUFFER_PIXELS 0x8018 -#define GLX_PRESERVED_CONTENTS 0x801B -#define GLX_LARGEST_PBUFFER 0x801C -#define GLX_WIDTH 0x801D -#define GLX_HEIGHT 0x801E -#define GLX_EVENT_MASK 0x801F -#define GLX_DAMAGED 0x8020 -#define GLX_SAVED 0x8021 -#define GLX_WINDOW 0x8022 -#define GLX_PBUFFER 0x8023 -#define GLX_PBUFFER_HEIGHT 0x8040 -#define GLX_PBUFFER_WIDTH 0x8041 -#endif +#define GLX_VERSION_1_3 1 +typedef XID GLXContextID; +typedef struct __GLXFBConfigRec *GLXFBConfig; +typedef XID GLXWindow; +typedef XID GLXPbuffer; +#define GLX_WINDOW_BIT 0x00000001 +#define GLX_PIXMAP_BIT 0x00000002 +#define GLX_PBUFFER_BIT 0x00000004 +#define GLX_RGBA_BIT 0x00000001 +#define GLX_COLOR_INDEX_BIT 0x00000002 +#define GLX_PBUFFER_CLOBBER_MASK 0x08000000 +#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001 +#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002 +#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004 +#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008 +#define GLX_AUX_BUFFERS_BIT 0x00000010 +#define GLX_DEPTH_BUFFER_BIT 0x00000020 +#define GLX_STENCIL_BUFFER_BIT 0x00000040 +#define GLX_ACCUM_BUFFER_BIT 0x00000080 +#define GLX_CONFIG_CAVEAT 0x20 +#define GLX_X_VISUAL_TYPE 0x22 +#define GLX_TRANSPARENT_TYPE 0x23 +#define GLX_TRANSPARENT_INDEX_VALUE 0x24 +#define GLX_TRANSPARENT_RED_VALUE 0x25 +#define GLX_TRANSPARENT_GREEN_VALUE 0x26 +#define GLX_TRANSPARENT_BLUE_VALUE 0x27 +#define GLX_TRANSPARENT_ALPHA_VALUE 0x28 +#define GLX_DONT_CARE 0xFFFFFFFF +#define GLX_NONE 0x8000 +#define GLX_SLOW_CONFIG 0x8001 +#define GLX_TRUE_COLOR 0x8002 +#define GLX_DIRECT_COLOR 0x8003 +#define GLX_PSEUDO_COLOR 0x8004 +#define GLX_STATIC_COLOR 0x8005 +#define GLX_GRAY_SCALE 0x8006 +#define GLX_STATIC_GRAY 0x8007 +#define GLX_TRANSPARENT_RGB 0x8008 +#define GLX_TRANSPARENT_INDEX 0x8009 +#define GLX_VISUAL_ID 0x800B +#define GLX_SCREEN 0x800C +#define GLX_NON_CONFORMANT_CONFIG 0x800D +#define GLX_DRAWABLE_TYPE 0x8010 +#define GLX_RENDER_TYPE 0x8011 +#define GLX_X_RENDERABLE 0x8012 +#define GLX_FBCONFIG_ID 0x8013 +#define GLX_RGBA_TYPE 0x8014 +#define GLX_COLOR_INDEX_TYPE 0x8015 +#define GLX_MAX_PBUFFER_WIDTH 0x8016 +#define GLX_MAX_PBUFFER_HEIGHT 0x8017 +#define GLX_MAX_PBUFFER_PIXELS 0x8018 +#define GLX_PRESERVED_CONTENTS 0x801B +#define GLX_LARGEST_PBUFFER 0x801C +#define GLX_WIDTH 0x801D +#define GLX_HEIGHT 0x801E +#define GLX_EVENT_MASK 0x801F +#define GLX_DAMAGED 0x8020 +#define GLX_SAVED 0x8021 +#define GLX_WINDOW 0x8022 +#define GLX_PBUFFER 0x8023 +#define GLX_PBUFFER_HEIGHT 0x8040 +#define GLX_PBUFFER_WIDTH 0x8041 +typedef GLXFBConfig *( *PFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements); +typedef GLXFBConfig *( *PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements); +typedef int ( *PFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value); +typedef XVisualInfo *( *PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config); +typedef GLXWindow ( *PFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list); +typedef void ( *PFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win); +typedef GLXPixmap ( *PFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list); +typedef void ( *PFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap); +typedef GLXPbuffer ( *PFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list); +typedef void ( *PFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf); +typedef void ( *PFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value); +typedef GLXContext ( *PFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct); +typedef Bool ( *PFNGLXMAKECONTEXTCURRENTPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); +typedef GLXDrawable ( *PFNGLXGETCURRENTREADDRAWABLEPROC) (void); +typedef int ( *PFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value); +typedef void ( *PFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask); +typedef void ( *PFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask); +#ifdef GLX_GLXEXT_PROTOTYPES +GLXFBConfig *glXGetFBConfigs (Display *dpy, int screen, int *nelements); +GLXFBConfig *glXChooseFBConfig (Display *dpy, int screen, const int *attrib_list, int *nelements); +int glXGetFBConfigAttrib (Display *dpy, GLXFBConfig config, int attribute, int *value); +XVisualInfo *glXGetVisualFromFBConfig (Display *dpy, GLXFBConfig config); +GLXWindow glXCreateWindow (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list); +void glXDestroyWindow (Display *dpy, GLXWindow win); +GLXPixmap glXCreatePixmap (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list); +void glXDestroyPixmap (Display *dpy, GLXPixmap pixmap); +GLXPbuffer glXCreatePbuffer (Display *dpy, GLXFBConfig config, const int *attrib_list); +void glXDestroyPbuffer (Display *dpy, GLXPbuffer pbuf); +void glXQueryDrawable (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value); +GLXContext glXCreateNewContext (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct); +Bool glXMakeContextCurrent (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); +GLXDrawable glXGetCurrentReadDrawable (void); +int glXQueryContext (Display *dpy, GLXContext ctx, int attribute, int *value); +void glXSelectEvent (Display *dpy, GLXDrawable draw, unsigned long event_mask); +void glXGetSelectedEvent (Display *dpy, GLXDrawable draw, unsigned long *event_mask); +#endif +#endif /* GLX_VERSION_1_3 */ #ifndef GLX_VERSION_1_4 -#define GLX_SAMPLE_BUFFERS 100000 -#define GLX_SAMPLES 100001 -#endif +#define GLX_VERSION_1_4 1 +typedef void ( *__GLXextFuncPtr)(void); +#define GLX_SAMPLE_BUFFERS 100000 +#define GLX_SAMPLES 100001 +typedef __GLXextFuncPtr ( *PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName); +#ifdef GLX_GLXEXT_PROTOTYPES +__GLXextFuncPtr glXGetProcAddress (const GLubyte *procName); +#endif +#endif /* GLX_VERSION_1_4 */ + +#ifndef GLX_ARB_context_flush_control +#define GLX_ARB_context_flush_control 1 +#define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 +#define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0 +#define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 +#endif /* GLX_ARB_context_flush_control */ + +#ifndef GLX_ARB_create_context +#define GLX_ARB_create_context 1 +#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001 +#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 +#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define GLX_CONTEXT_FLAGS_ARB 0x2094 +typedef GLXContext ( *PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list); +#ifdef GLX_GLXEXT_PROTOTYPES +GLXContext glXCreateContextAttribsARB (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list); +#endif +#endif /* GLX_ARB_create_context */ + +#ifndef GLX_ARB_create_context_no_error +#define GLX_ARB_create_context_no_error 1 +#define GLX_CONTEXT_OPENGL_NO_ERROR_ARB 0x31B3 +#endif /* GLX_ARB_create_context_no_error */ + +#ifndef GLX_ARB_create_context_profile +#define GLX_ARB_create_context_profile 1 +#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 +#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 +#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 +#endif /* GLX_ARB_create_context_profile */ + +#ifndef GLX_ARB_create_context_robustness +#define GLX_ARB_create_context_robustness 1 +#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GLX_NO_RESET_NOTIFICATION_ARB 0x8261 +#endif /* GLX_ARB_create_context_robustness */ + +#ifndef GLX_ARB_fbconfig_float +#define GLX_ARB_fbconfig_float 1 +#define GLX_RGBA_FLOAT_TYPE_ARB 0x20B9 +#define GLX_RGBA_FLOAT_BIT_ARB 0x00000004 +#endif /* GLX_ARB_fbconfig_float */ + +#ifndef GLX_ARB_framebuffer_sRGB +#define GLX_ARB_framebuffer_sRGB 1 +#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20B2 +#endif /* GLX_ARB_framebuffer_sRGB */ #ifndef GLX_ARB_get_proc_address +#define GLX_ARB_get_proc_address 1 +typedef __GLXextFuncPtr ( *PFNGLXGETPROCADDRESSARBPROC) (const GLubyte *procName); +#ifdef GLX_GLXEXT_PROTOTYPES +__GLXextFuncPtr glXGetProcAddressARB (const GLubyte *procName); #endif +#endif /* GLX_ARB_get_proc_address */ #ifndef GLX_ARB_multisample -#define GLX_SAMPLE_BUFFERS_ARB 100000 -#define GLX_SAMPLES_ARB 100001 -#endif - -#ifndef GLX_SGIS_multisample -#define GLX_SAMPLE_BUFFERS_SGIS 100000 -#define GLX_SAMPLES_SGIS 100001 -#endif - -#ifndef GLX_EXT_visual_info -#define GLX_X_VISUAL_TYPE_EXT 0x22 -#define GLX_TRANSPARENT_TYPE_EXT 0x23 -#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24 -#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25 -#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26 -#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27 -#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28 -#define GLX_NONE_EXT 0x8000 -#define GLX_TRUE_COLOR_EXT 0x8002 -#define GLX_DIRECT_COLOR_EXT 0x8003 -#define GLX_PSEUDO_COLOR_EXT 0x8004 -#define GLX_STATIC_COLOR_EXT 0x8005 -#define GLX_GRAY_SCALE_EXT 0x8006 -#define GLX_STATIC_GRAY_EXT 0x8007 -#define GLX_TRANSPARENT_RGB_EXT 0x8008 -#define GLX_TRANSPARENT_INDEX_EXT 0x8009 -#endif - -#ifndef GLX_SGI_swap_control -#endif +#define GLX_ARB_multisample 1 +#define GLX_SAMPLE_BUFFERS_ARB 100000 +#define GLX_SAMPLES_ARB 100001 +#endif /* GLX_ARB_multisample */ -#ifndef GLX_SGI_video_sync -#endif +#ifndef GLX_ARB_robustness_application_isolation +#define GLX_ARB_robustness_application_isolation 1 +#define GLX_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008 +#endif /* GLX_ARB_robustness_application_isolation */ -#ifndef GLX_SGI_make_current_read -#endif +#ifndef GLX_ARB_robustness_share_group_isolation +#define GLX_ARB_robustness_share_group_isolation 1 +#endif /* GLX_ARB_robustness_share_group_isolation */ -#ifndef GLX_SGIX_video_source -#endif +#ifndef GLX_ARB_vertex_buffer_object +#define GLX_ARB_vertex_buffer_object 1 +#define GLX_CONTEXT_ALLOW_BUFFER_BYTE_ORDER_MISMATCH_ARB 0x2095 +#endif /* GLX_ARB_vertex_buffer_object */ -#ifndef GLX_EXT_visual_rating -#define GLX_VISUAL_CAVEAT_EXT 0x20 -#define GLX_SLOW_VISUAL_EXT 0x8001 -#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D -/* reuse GLX_NONE_EXT */ -#endif +#ifndef GLX_3DFX_multisample +#define GLX_3DFX_multisample 1 +#define GLX_SAMPLE_BUFFERS_3DFX 0x8050 +#define GLX_SAMPLES_3DFX 0x8051 +#endif /* GLX_3DFX_multisample */ + +#ifndef GLX_AMD_gpu_association +#define GLX_AMD_gpu_association 1 +#define GLX_GPU_VENDOR_AMD 0x1F00 +#define GLX_GPU_RENDERER_STRING_AMD 0x1F01 +#define GLX_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 +#define GLX_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 +#define GLX_GPU_RAM_AMD 0x21A3 +#define GLX_GPU_CLOCK_AMD 0x21A4 +#define GLX_GPU_NUM_PIPES_AMD 0x21A5 +#define GLX_GPU_NUM_SIMD_AMD 0x21A6 +#define GLX_GPU_NUM_RB_AMD 0x21A7 +#define GLX_GPU_NUM_SPI_AMD 0x21A8 +typedef unsigned int ( *PFNGLXGETGPUIDSAMDPROC) (unsigned int maxCount, unsigned int *ids); +typedef int ( *PFNGLXGETGPUINFOAMDPROC) (unsigned int id, int property, GLenum dataType, unsigned int size, void *data); +typedef unsigned int ( *PFNGLXGETCONTEXTGPUIDAMDPROC) (GLXContext ctx); +typedef GLXContext ( *PFNGLXCREATEASSOCIATEDCONTEXTAMDPROC) (unsigned int id, GLXContext share_list); +typedef GLXContext ( *PFNGLXCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (unsigned int id, GLXContext share_context, const int *attribList); +typedef Bool ( *PFNGLXDELETEASSOCIATEDCONTEXTAMDPROC) (GLXContext ctx); +typedef Bool ( *PFNGLXMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (GLXContext ctx); +typedef GLXContext ( *PFNGLXGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void); +typedef void ( *PFNGLXBLITCONTEXTFRAMEBUFFERAMDPROC) (GLXContext dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef GLX_GLXEXT_PROTOTYPES +unsigned int glXGetGPUIDsAMD (unsigned int maxCount, unsigned int *ids); +int glXGetGPUInfoAMD (unsigned int id, int property, GLenum dataType, unsigned int size, void *data); +unsigned int glXGetContextGPUIDAMD (GLXContext ctx); +GLXContext glXCreateAssociatedContextAMD (unsigned int id, GLXContext share_list); +GLXContext glXCreateAssociatedContextAttribsAMD (unsigned int id, GLXContext share_context, const int *attribList); +Bool glXDeleteAssociatedContextAMD (GLXContext ctx); +Bool glXMakeAssociatedContextCurrentAMD (GLXContext ctx); +GLXContext glXGetCurrentAssociatedContextAMD (void); +void glXBlitContextFramebufferAMD (GLXContext dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +#endif /* GLX_AMD_gpu_association */ + +#ifndef GLX_EXT_buffer_age +#define GLX_EXT_buffer_age 1 +#define GLX_BACK_BUFFER_AGE_EXT 0x20F4 +#endif /* GLX_EXT_buffer_age */ + +#ifndef GLX_EXT_create_context_es2_profile +#define GLX_EXT_create_context_es2_profile 1 +#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 +#endif /* GLX_EXT_create_context_es2_profile */ + +#ifndef GLX_EXT_create_context_es_profile +#define GLX_EXT_create_context_es_profile 1 +#define GLX_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004 +#endif /* GLX_EXT_create_context_es_profile */ + +#ifndef GLX_EXT_fbconfig_packed_float +#define GLX_EXT_fbconfig_packed_float 1 +#define GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT 0x20B1 +#define GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT 0x00000008 +#endif /* GLX_EXT_fbconfig_packed_float */ + +#ifndef GLX_EXT_framebuffer_sRGB +#define GLX_EXT_framebuffer_sRGB 1 +#define GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20B2 +#endif /* GLX_EXT_framebuffer_sRGB */ #ifndef GLX_EXT_import_context -#define GLX_SHARE_CONTEXT_EXT 0x800A -#define GLX_VISUAL_ID_EXT 0x800B -#define GLX_SCREEN_EXT 0x800C -#endif - -#ifndef GLX_SGIX_fbconfig -#define GLX_WINDOW_BIT_SGIX 0x00000001 -#define GLX_PIXMAP_BIT_SGIX 0x00000002 -#define GLX_RGBA_BIT_SGIX 0x00000001 -#define GLX_COLOR_INDEX_BIT_SGIX 0x00000002 -#define GLX_DRAWABLE_TYPE_SGIX 0x8010 -#define GLX_RENDER_TYPE_SGIX 0x8011 -#define GLX_X_RENDERABLE_SGIX 0x8012 -#define GLX_FBCONFIG_ID_SGIX 0x8013 -#define GLX_RGBA_TYPE_SGIX 0x8014 -#define GLX_COLOR_INDEX_TYPE_SGIX 0x8015 -/* reuse GLX_SCREEN_EXT */ -#endif - -#ifndef GLX_SGIX_pbuffer -#define GLX_PBUFFER_BIT_SGIX 0x00000004 -#define GLX_BUFFER_CLOBBER_MASK_SGIX 0x08000000 -#define GLX_FRONT_LEFT_BUFFER_BIT_SGIX 0x00000001 -#define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX 0x00000002 -#define GLX_BACK_LEFT_BUFFER_BIT_SGIX 0x00000004 -#define GLX_BACK_RIGHT_BUFFER_BIT_SGIX 0x00000008 -#define GLX_AUX_BUFFERS_BIT_SGIX 0x00000010 -#define GLX_DEPTH_BUFFER_BIT_SGIX 0x00000020 -#define GLX_STENCIL_BUFFER_BIT_SGIX 0x00000040 -#define GLX_ACCUM_BUFFER_BIT_SGIX 0x00000080 -#define GLX_SAMPLE_BUFFERS_BIT_SGIX 0x00000100 -#define GLX_MAX_PBUFFER_WIDTH_SGIX 0x8016 -#define GLX_MAX_PBUFFER_HEIGHT_SGIX 0x8017 -#define GLX_MAX_PBUFFER_PIXELS_SGIX 0x8018 -#define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX 0x8019 -#define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX 0x801A -#define GLX_PRESERVED_CONTENTS_SGIX 0x801B -#define GLX_LARGEST_PBUFFER_SGIX 0x801C -#define GLX_WIDTH_SGIX 0x801D -#define GLX_HEIGHT_SGIX 0x801E -#define GLX_EVENT_MASK_SGIX 0x801F -#define GLX_DAMAGED_SGIX 0x8020 -#define GLX_SAVED_SGIX 0x8021 -#define GLX_WINDOW_SGIX 0x8022 -#define GLX_PBUFFER_SGIX 0x8023 -#endif - -#ifndef GLX_SGI_cushion -#endif - -#ifndef GLX_SGIX_video_resize -#define GLX_SYNC_FRAME_SGIX 0x00000000 -#define GLX_SYNC_SWAP_SGIX 0x00000001 -#endif - -#ifndef GLX_SGIX_dmbuffer -#define GLX_DIGITAL_MEDIA_PBUFFER_SGIX 0x8024 -#endif - -#ifndef GLX_SGIX_swap_group -#endif - -#ifndef GLX_SGIX_swap_barrier +#define GLX_EXT_import_context 1 +#define GLX_SHARE_CONTEXT_EXT 0x800A +#define GLX_VISUAL_ID_EXT 0x800B +#define GLX_SCREEN_EXT 0x800C +typedef Display *( *PFNGLXGETCURRENTDISPLAYEXTPROC) (void); +typedef int ( *PFNGLXQUERYCONTEXTINFOEXTPROC) (Display *dpy, GLXContext context, int attribute, int *value); +typedef GLXContextID ( *PFNGLXGETCONTEXTIDEXTPROC) (const GLXContext context); +typedef GLXContext ( *PFNGLXIMPORTCONTEXTEXTPROC) (Display *dpy, GLXContextID contextID); +typedef void ( *PFNGLXFREECONTEXTEXTPROC) (Display *dpy, GLXContext context); +#ifdef GLX_GLXEXT_PROTOTYPES +Display *glXGetCurrentDisplayEXT (void); +int glXQueryContextInfoEXT (Display *dpy, GLXContext context, int attribute, int *value); +GLXContextID glXGetContextIDEXT (const GLXContext context); +GLXContext glXImportContextEXT (Display *dpy, GLXContextID contextID); +void glXFreeContextEXT (Display *dpy, GLXContext context); #endif +#endif /* GLX_EXT_import_context */ -#ifndef GLX_SGIS_blended_overlay -#define GLX_BLENDED_RGBA_SGIS 0x8025 -#endif +#ifndef GLX_EXT_libglvnd +#define GLX_EXT_libglvnd 1 +#define GLX_VENDOR_NAMES_EXT 0x20F6 +#endif /* GLX_EXT_libglvnd */ -#ifndef GLX_SGIS_shared_multisample -#define GLX_MULTISAMPLE_SUB_RECT_WIDTH_SGIS 0x8026 -#define GLX_MULTISAMPLE_SUB_RECT_HEIGHT_SGIS 0x8027 -#endif +#ifndef GLX_EXT_no_config_context +#define GLX_EXT_no_config_context 1 +#endif /* GLX_EXT_no_config_context */ -#ifndef GLX_SUN_get_transparent_index +#ifndef GLX_EXT_stereo_tree +#define GLX_EXT_stereo_tree 1 +typedef struct { + int type; + unsigned long serial; + Bool send_event; + Display *display; + int extension; + int evtype; + GLXDrawable window; + Bool stereo_tree; +} GLXStereoNotifyEventEXT; +#define GLX_STEREO_TREE_EXT 0x20F5 +#define GLX_STEREO_NOTIFY_MASK_EXT 0x00000001 +#define GLX_STEREO_NOTIFY_EXT 0x00000000 +#endif /* GLX_EXT_stereo_tree */ + +#ifndef GLX_EXT_swap_control +#define GLX_EXT_swap_control 1 +#define GLX_SWAP_INTERVAL_EXT 0x20F1 +#define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2 +typedef void ( *PFNGLXSWAPINTERVALEXTPROC) (Display *dpy, GLXDrawable drawable, int interval); +#ifdef GLX_GLXEXT_PROTOTYPES +void glXSwapIntervalEXT (Display *dpy, GLXDrawable drawable, int interval); +#endif +#endif /* GLX_EXT_swap_control */ + +#ifndef GLX_EXT_swap_control_tear +#define GLX_EXT_swap_control_tear 1 +#define GLX_LATE_SWAPS_TEAR_EXT 0x20F3 +#endif /* GLX_EXT_swap_control_tear */ + +#ifndef GLX_EXT_texture_from_pixmap +#define GLX_EXT_texture_from_pixmap 1 +#define GLX_TEXTURE_1D_BIT_EXT 0x00000001 +#define GLX_TEXTURE_2D_BIT_EXT 0x00000002 +#define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004 +#define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0 +#define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1 +#define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2 +#define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3 +#define GLX_Y_INVERTED_EXT 0x20D4 +#define GLX_TEXTURE_FORMAT_EXT 0x20D5 +#define GLX_TEXTURE_TARGET_EXT 0x20D6 +#define GLX_MIPMAP_TEXTURE_EXT 0x20D7 +#define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8 +#define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9 +#define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA +#define GLX_TEXTURE_1D_EXT 0x20DB +#define GLX_TEXTURE_2D_EXT 0x20DC +#define GLX_TEXTURE_RECTANGLE_EXT 0x20DD +#define GLX_FRONT_LEFT_EXT 0x20DE +#define GLX_FRONT_RIGHT_EXT 0x20DF +#define GLX_BACK_LEFT_EXT 0x20E0 +#define GLX_BACK_RIGHT_EXT 0x20E1 +#define GLX_FRONT_EXT 0x20DE +#define GLX_BACK_EXT 0x20E0 +#define GLX_AUX0_EXT 0x20E2 +#define GLX_AUX1_EXT 0x20E3 +#define GLX_AUX2_EXT 0x20E4 +#define GLX_AUX3_EXT 0x20E5 +#define GLX_AUX4_EXT 0x20E6 +#define GLX_AUX5_EXT 0x20E7 +#define GLX_AUX6_EXT 0x20E8 +#define GLX_AUX7_EXT 0x20E9 +#define GLX_AUX8_EXT 0x20EA +#define GLX_AUX9_EXT 0x20EB +typedef void ( *PFNGLXBINDTEXIMAGEEXTPROC) (Display *dpy, GLXDrawable drawable, int buffer, const int *attrib_list); +typedef void ( *PFNGLXRELEASETEXIMAGEEXTPROC) (Display *dpy, GLXDrawable drawable, int buffer); +#ifdef GLX_GLXEXT_PROTOTYPES +void glXBindTexImageEXT (Display *dpy, GLXDrawable drawable, int buffer, const int *attrib_list); +void glXReleaseTexImageEXT (Display *dpy, GLXDrawable drawable, int buffer); #endif +#endif /* GLX_EXT_texture_from_pixmap */ -/* - * REMIND: This is a Sun-private constant used to get the gamma value for - * a GLXFBConfig. This was never publically documented as part of - * a Sun extension, and therefore never ended up in the official SGI - * glxext.h header file, so we've copied it here from the Sun OpenGL - * headers (glxtokens.h). - */ -#define GLX_GAMMA_VALUE_SUN 0x8173 +#ifndef GLX_EXT_visual_info +#define GLX_EXT_visual_info 1 +#define GLX_X_VISUAL_TYPE_EXT 0x22 +#define GLX_TRANSPARENT_TYPE_EXT 0x23 +#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24 +#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25 +#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26 +#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27 +#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28 +#define GLX_NONE_EXT 0x8000 +#define GLX_TRUE_COLOR_EXT 0x8002 +#define GLX_DIRECT_COLOR_EXT 0x8003 +#define GLX_PSEUDO_COLOR_EXT 0x8004 +#define GLX_STATIC_COLOR_EXT 0x8005 +#define GLX_GRAY_SCALE_EXT 0x8006 +#define GLX_STATIC_GRAY_EXT 0x8007 +#define GLX_TRANSPARENT_RGB_EXT 0x8008 +#define GLX_TRANSPARENT_INDEX_EXT 0x8009 +#endif /* GLX_EXT_visual_info */ -#ifndef GLX_3DFX_multisample -#define GLX_SAMPLE_BUFFERS_3DFX 0x8050 -#define GLX_SAMPLES_3DFX 0x8051 +#ifndef GLX_EXT_visual_rating +#define GLX_EXT_visual_rating 1 +#define GLX_VISUAL_CAVEAT_EXT 0x20 +#define GLX_SLOW_VISUAL_EXT 0x8001 +#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D +#endif /* GLX_EXT_visual_rating */ + +#ifndef GLX_INTEL_swap_event +#define GLX_INTEL_swap_event 1 +#define GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK 0x04000000 +#define GLX_EXCHANGE_COMPLETE_INTEL 0x8180 +#define GLX_COPY_COMPLETE_INTEL 0x8181 +#define GLX_FLIP_COMPLETE_INTEL 0x8182 +#endif /* GLX_INTEL_swap_event */ + +#ifndef GLX_MESA_agp_offset +#define GLX_MESA_agp_offset 1 +typedef unsigned int ( *PFNGLXGETAGPOFFSETMESAPROC) (const void *pointer); +#ifdef GLX_GLXEXT_PROTOTYPES +unsigned int glXGetAGPOffsetMESA (const void *pointer); #endif +#endif /* GLX_MESA_agp_offset */ #ifndef GLX_MESA_copy_sub_buffer +#define GLX_MESA_copy_sub_buffer 1 +typedef void ( *PFNGLXCOPYSUBBUFFERMESAPROC) (Display *dpy, GLXDrawable drawable, int x, int y, int width, int height); +#ifdef GLX_GLXEXT_PROTOTYPES +void glXCopySubBufferMESA (Display *dpy, GLXDrawable drawable, int x, int y, int width, int height); #endif +#endif /* GLX_MESA_copy_sub_buffer */ #ifndef GLX_MESA_pixmap_colormap +#define GLX_MESA_pixmap_colormap 1 +typedef GLXPixmap ( *PFNGLXCREATEGLXPIXMAPMESAPROC) (Display *dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap); +#ifdef GLX_GLXEXT_PROTOTYPES +GLXPixmap glXCreateGLXPixmapMESA (Display *dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap); +#endif +#endif /* GLX_MESA_pixmap_colormap */ + +#ifndef GLX_MESA_query_renderer +#define GLX_MESA_query_renderer 1 +#define GLX_RENDERER_VENDOR_ID_MESA 0x8183 +#define GLX_RENDERER_DEVICE_ID_MESA 0x8184 +#define GLX_RENDERER_VERSION_MESA 0x8185 +#define GLX_RENDERER_ACCELERATED_MESA 0x8186 +#define GLX_RENDERER_VIDEO_MEMORY_MESA 0x8187 +#define GLX_RENDERER_UNIFIED_MEMORY_ARCHITECTURE_MESA 0x8188 +#define GLX_RENDERER_PREFERRED_PROFILE_MESA 0x8189 +#define GLX_RENDERER_OPENGL_CORE_PROFILE_VERSION_MESA 0x818A +#define GLX_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION_MESA 0x818B +#define GLX_RENDERER_OPENGL_ES_PROFILE_VERSION_MESA 0x818C +#define GLX_RENDERER_OPENGL_ES2_PROFILE_VERSION_MESA 0x818D +#define GLX_RENDERER_ID_MESA 0x818E +typedef Bool ( *PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC) (int attribute, unsigned int *value); +typedef const char *( *PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC) (int attribute); +typedef Bool ( *PFNGLXQUERYRENDERERINTEGERMESAPROC) (Display *dpy, int screen, int renderer, int attribute, unsigned int *value); +typedef const char *( *PFNGLXQUERYRENDERERSTRINGMESAPROC) (Display *dpy, int screen, int renderer, int attribute); +#ifdef GLX_GLXEXT_PROTOTYPES +Bool glXQueryCurrentRendererIntegerMESA (int attribute, unsigned int *value); +const char *glXQueryCurrentRendererStringMESA (int attribute); +Bool glXQueryRendererIntegerMESA (Display *dpy, int screen, int renderer, int attribute, unsigned int *value); +const char *glXQueryRendererStringMESA (Display *dpy, int screen, int renderer, int attribute); #endif +#endif /* GLX_MESA_query_renderer */ #ifndef GLX_MESA_release_buffers +#define GLX_MESA_release_buffers 1 +typedef Bool ( *PFNGLXRELEASEBUFFERSMESAPROC) (Display *dpy, GLXDrawable drawable); +#ifdef GLX_GLXEXT_PROTOTYPES +Bool glXReleaseBuffersMESA (Display *dpy, GLXDrawable drawable); #endif +#endif /* GLX_MESA_release_buffers */ #ifndef GLX_MESA_set_3dfx_mode -#define GLX_3DFX_WINDOW_MODE_MESA 0x1 -#define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2 -#endif - -#ifndef GLX_SGIX_visual_select_group -#define GLX_VISUAL_SELECT_GROUP_SGIX 0x8028 -#endif - -#ifndef GLX_OML_swap_method -#define GLX_SWAP_METHOD_OML 0x8060 -#define GLX_SWAP_EXCHANGE_OML 0x8061 -#define GLX_SWAP_COPY_OML 0x8062 -#define GLX_SWAP_UNDEFINED_OML 0x8063 -#endif - -#ifndef GLX_OML_sync_control -#endif - -/*************************************************************/ - -#ifndef GLX_ARB_get_proc_address -typedef void (*__GLXextFuncPtr)(void); -#endif - -#ifndef GLX_SGIX_video_source -typedef XID GLXVideoSourceSGIX; -#endif - -#ifndef GLX_SGIX_fbconfig -typedef XID GLXFBConfigIDSGIX; -typedef struct __GLXFBConfigRec *GLXFBConfigSGIX; -#endif - -#ifndef GLX_SGIX_pbuffer -typedef XID GLXPbufferSGIX; -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came for SendEvent request */ - Display *display; /* display the event was read from */ - GLXDrawable drawable; /* i.d. of Drawable */ - int event_type; /* GLX_DAMAGED_SGIX or GLX_SAVED_SGIX */ - int draw_type; /* GLX_WINDOW_SGIX or GLX_PBUFFER_SGIX */ - unsigned int mask; /* mask indicating which buffers are affected*/ - int x, y; - int width, height; - int count; /* if nonzero, at least this many more */ -} GLXBufferClobberEventSGIX; +#define GLX_MESA_set_3dfx_mode 1 +#define GLX_3DFX_WINDOW_MODE_MESA 0x1 +#define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2 +typedef Bool ( *PFNGLXSET3DFXMODEMESAPROC) (int mode); +#ifdef GLX_GLXEXT_PROTOTYPES +Bool glXSet3DfxModeMESA (int mode); #endif +#endif /* GLX_MESA_set_3dfx_mode */ -#ifndef GLX_VERSION_1_3 -#define GLX_VERSION_1_3 1 +#ifndef GLX_MESA_swap_control +#define GLX_MESA_swap_control 1 +typedef int ( *PFNGLXGETSWAPINTERVALMESAPROC) (void); +typedef int ( *PFNGLXSWAPINTERVALMESAPROC) (unsigned int interval); #ifdef GLX_GLXEXT_PROTOTYPES -extern GLXFBConfig * glXGetFBConfigs (Display *, int, int *); -extern GLXFBConfig * glXChooseFBConfig (Display *, int, const int *, int *); -extern int glXGetFBConfigAttrib (Display *, GLXFBConfig, int, int *); -extern XVisualInfo * glXGetVisualFromFBConfig (Display *, GLXFBConfig); -extern GLXWindow glXCreateWindow (Display *, GLXFBConfig, Window, const int *); -extern void glXDestroyWindow (Display *, GLXWindow); -extern GLXPixmap glXCreatePixmap (Display *, GLXFBConfig, Pixmap, const int *); -extern void glXDestroyPixmap (Display *, GLXPixmap); -extern GLXPbuffer glXCreatePbuffer (Display *, GLXFBConfig, const int *); -extern void glXDestroyPbuffer (Display *, GLXPbuffer); -extern void glXQueryDrawable (Display *, GLXDrawable, int, unsigned int *); -extern GLXContext glXCreateNewContext (Display *, GLXFBConfig, int, GLXContext, Bool); -extern Bool glXMakeContextCurrent (Display *, GLXDrawable, GLXDrawable, GLXContext); -extern GLXDrawable glXGetCurrentReadDrawable (void); -extern Display * glXGetCurrentDisplay (void); -extern int glXQueryContext (Display *, GLXContext, int, int *); -extern void glXSelectEvent (Display *, GLXDrawable, unsigned long); -extern void glXGetSelectedEvent (Display *, GLXDrawable, unsigned long *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLXFBConfig * ( * PFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements); -typedef GLXFBConfig * ( * PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements); -typedef int ( * PFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value); -typedef XVisualInfo * ( * PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config); -typedef GLXWindow ( * PFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list); -typedef void ( * PFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win); -typedef GLXPixmap ( * PFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list); -typedef void ( * PFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap); -typedef GLXPbuffer ( * PFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list); -typedef void ( * PFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf); -typedef void ( * PFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value); -typedef GLXContext ( * PFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct); -typedef Bool ( * PFNGLXMAKECONTEXTCURRENTPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); -typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLEPROC) (void); -typedef Display * ( * PFNGLXGETCURRENTDISPLAYPROC) (void); -typedef int ( * PFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value); -typedef void ( * PFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask); -typedef void ( * PFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask); +int glXGetSwapIntervalMESA (void); +int glXSwapIntervalMESA (unsigned int interval); #endif +#endif /* GLX_MESA_swap_control */ -#ifndef GLX_VERSION_1_4 -#define GLX_VERSION_1_4 1 +#ifndef GLX_NV_copy_buffer +#define GLX_NV_copy_buffer 1 +typedef void ( *PFNGLXCOPYBUFFERSUBDATANVPROC) (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void ( *PFNGLXNAMEDCOPYBUFFERSUBDATANVPROC) (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); #ifdef GLX_GLXEXT_PROTOTYPES -extern __GLXextFuncPtr glXGetProcAddress (const GLubyte *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef __GLXextFuncPtr ( * PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName); +void glXCopyBufferSubDataNV (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +void glXNamedCopyBufferSubDataNV (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); #endif +#endif /* GLX_NV_copy_buffer */ -#ifndef GLX_ARB_get_proc_address -#define GLX_ARB_get_proc_address 1 +#ifndef GLX_NV_copy_image +#define GLX_NV_copy_image 1 +typedef void ( *PFNGLXCOPYIMAGESUBDATANVPROC) (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); #ifdef GLX_GLXEXT_PROTOTYPES -extern __GLXextFuncPtr glXGetProcAddressARB (const GLubyte *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef __GLXextFuncPtr ( * PFNGLXGETPROCADDRESSARBPROC) (const GLubyte *procName); +void glXCopyImageSubDataNV (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); #endif +#endif /* GLX_NV_copy_image */ -#ifndef GLX_ARB_multisample -#define GLX_ARB_multisample 1 +#ifndef GLX_NV_delay_before_swap +#define GLX_NV_delay_before_swap 1 +typedef Bool ( *PFNGLXDELAYBEFORESWAPNVPROC) (Display *dpy, GLXDrawable drawable, GLfloat seconds); +#ifdef GLX_GLXEXT_PROTOTYPES +Bool glXDelayBeforeSwapNV (Display *dpy, GLXDrawable drawable, GLfloat seconds); +#endif +#endif /* GLX_NV_delay_before_swap */ + +#ifndef GLX_NV_float_buffer +#define GLX_NV_float_buffer 1 +#define GLX_FLOAT_COMPONENTS_NV 0x20B0 +#endif /* GLX_NV_float_buffer */ + +#ifndef GLX_NV_multisample_coverage +#define GLX_NV_multisample_coverage 1 +#define GLX_COVERAGE_SAMPLES_NV 100001 +#define GLX_COLOR_SAMPLES_NV 0x20B3 +#endif /* GLX_NV_multisample_coverage */ + +#ifndef GLX_NV_present_video +#define GLX_NV_present_video 1 +#define GLX_NUM_VIDEO_SLOTS_NV 0x20F0 +typedef unsigned int *( *PFNGLXENUMERATEVIDEODEVICESNVPROC) (Display *dpy, int screen, int *nelements); +typedef int ( *PFNGLXBINDVIDEODEVICENVPROC) (Display *dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list); +#ifdef GLX_GLXEXT_PROTOTYPES +unsigned int *glXEnumerateVideoDevicesNV (Display *dpy, int screen, int *nelements); +int glXBindVideoDeviceNV (Display *dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list); +#endif +#endif /* GLX_NV_present_video */ + +#ifndef GLX_NV_robustness_video_memory_purge +#define GLX_NV_robustness_video_memory_purge 1 +#define GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV 0x20F7 +#endif /* GLX_NV_robustness_video_memory_purge */ + +#ifndef GLX_NV_swap_group +#define GLX_NV_swap_group 1 +typedef Bool ( *PFNGLXJOINSWAPGROUPNVPROC) (Display *dpy, GLXDrawable drawable, GLuint group); +typedef Bool ( *PFNGLXBINDSWAPBARRIERNVPROC) (Display *dpy, GLuint group, GLuint barrier); +typedef Bool ( *PFNGLXQUERYSWAPGROUPNVPROC) (Display *dpy, GLXDrawable drawable, GLuint *group, GLuint *barrier); +typedef Bool ( *PFNGLXQUERYMAXSWAPGROUPSNVPROC) (Display *dpy, int screen, GLuint *maxGroups, GLuint *maxBarriers); +typedef Bool ( *PFNGLXQUERYFRAMECOUNTNVPROC) (Display *dpy, int screen, GLuint *count); +typedef Bool ( *PFNGLXRESETFRAMECOUNTNVPROC) (Display *dpy, int screen); +#ifdef GLX_GLXEXT_PROTOTYPES +Bool glXJoinSwapGroupNV (Display *dpy, GLXDrawable drawable, GLuint group); +Bool glXBindSwapBarrierNV (Display *dpy, GLuint group, GLuint barrier); +Bool glXQuerySwapGroupNV (Display *dpy, GLXDrawable drawable, GLuint *group, GLuint *barrier); +Bool glXQueryMaxSwapGroupsNV (Display *dpy, int screen, GLuint *maxGroups, GLuint *maxBarriers); +Bool glXQueryFrameCountNV (Display *dpy, int screen, GLuint *count); +Bool glXResetFrameCountNV (Display *dpy, int screen); +#endif +#endif /* GLX_NV_swap_group */ + +#ifndef GLX_NV_video_capture +#define GLX_NV_video_capture 1 +typedef XID GLXVideoCaptureDeviceNV; +#define GLX_DEVICE_ID_NV 0x20CD +#define GLX_UNIQUE_ID_NV 0x20CE +#define GLX_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF +typedef int ( *PFNGLXBINDVIDEOCAPTUREDEVICENVPROC) (Display *dpy, unsigned int video_capture_slot, GLXVideoCaptureDeviceNV device); +typedef GLXVideoCaptureDeviceNV *( *PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC) (Display *dpy, int screen, int *nelements); +typedef void ( *PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device); +typedef int ( *PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device, int attribute, int *value); +typedef void ( *PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device); +#ifdef GLX_GLXEXT_PROTOTYPES +int glXBindVideoCaptureDeviceNV (Display *dpy, unsigned int video_capture_slot, GLXVideoCaptureDeviceNV device); +GLXVideoCaptureDeviceNV *glXEnumerateVideoCaptureDevicesNV (Display *dpy, int screen, int *nelements); +void glXLockVideoCaptureDeviceNV (Display *dpy, GLXVideoCaptureDeviceNV device); +int glXQueryVideoCaptureDeviceNV (Display *dpy, GLXVideoCaptureDeviceNV device, int attribute, int *value); +void glXReleaseVideoCaptureDeviceNV (Display *dpy, GLXVideoCaptureDeviceNV device); +#endif +#endif /* GLX_NV_video_capture */ + +#ifndef GLX_NV_video_out +#define GLX_NV_video_out 1 +typedef unsigned int GLXVideoDeviceNV; +#define GLX_VIDEO_OUT_COLOR_NV 0x20C3 +#define GLX_VIDEO_OUT_ALPHA_NV 0x20C4 +#define GLX_VIDEO_OUT_DEPTH_NV 0x20C5 +#define GLX_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 +#define GLX_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 +#define GLX_VIDEO_OUT_FRAME_NV 0x20C8 +#define GLX_VIDEO_OUT_FIELD_1_NV 0x20C9 +#define GLX_VIDEO_OUT_FIELD_2_NV 0x20CA +#define GLX_VIDEO_OUT_STACKED_FIELDS_1_2_NV 0x20CB +#define GLX_VIDEO_OUT_STACKED_FIELDS_2_1_NV 0x20CC +typedef int ( *PFNGLXGETVIDEODEVICENVPROC) (Display *dpy, int screen, int numVideoDevices, GLXVideoDeviceNV *pVideoDevice); +typedef int ( *PFNGLXRELEASEVIDEODEVICENVPROC) (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice); +typedef int ( *PFNGLXBINDVIDEOIMAGENVPROC) (Display *dpy, GLXVideoDeviceNV VideoDevice, GLXPbuffer pbuf, int iVideoBuffer); +typedef int ( *PFNGLXRELEASEVIDEOIMAGENVPROC) (Display *dpy, GLXPbuffer pbuf); +typedef int ( *PFNGLXSENDPBUFFERTOVIDEONVPROC) (Display *dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock); +typedef int ( *PFNGLXGETVIDEOINFONVPROC) (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +#ifdef GLX_GLXEXT_PROTOTYPES +int glXGetVideoDeviceNV (Display *dpy, int screen, int numVideoDevices, GLXVideoDeviceNV *pVideoDevice); +int glXReleaseVideoDeviceNV (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice); +int glXBindVideoImageNV (Display *dpy, GLXVideoDeviceNV VideoDevice, GLXPbuffer pbuf, int iVideoBuffer); +int glXReleaseVideoImageNV (Display *dpy, GLXPbuffer pbuf); +int glXSendPbufferToVideoNV (Display *dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock); +int glXGetVideoInfoNV (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); #endif +#endif /* GLX_NV_video_out */ -#ifndef GLX_SGIS_multisample -#define GLX_SGIS_multisample 1 -#endif +#ifndef GLX_OML_swap_method +#define GLX_OML_swap_method 1 +#define GLX_SWAP_METHOD_OML 0x8060 +#define GLX_SWAP_EXCHANGE_OML 0x8061 +#define GLX_SWAP_COPY_OML 0x8062 +#define GLX_SWAP_UNDEFINED_OML 0x8063 +#endif /* GLX_OML_swap_method */ -#ifndef GLX_EXT_visual_info -#define GLX_EXT_visual_info 1 +#ifndef GLX_OML_sync_control +#define GLX_OML_sync_control 1 +#ifndef GLEXT_64_TYPES_DEFINED +/* This code block is duplicated in glext.h, so must be protected */ +#define GLEXT_64_TYPES_DEFINED +/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ +/* (as used in the GLX_OML_sync_control extension). */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +/* JDK modification */ +#elif defined(__sun__) +#include +#elif defined(__digital__) +#include +#if defined(__STDC__) +#if defined(__arch64__) || defined(_LP64) +typedef long int int64_t; +typedef unsigned long int uint64_t; +#else +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#endif /* __arch64__ */ +#endif /* __STDC__ */ + +#elif defined( __VMS ) || defined(__sgi) +#include +#elif defined(__SCO__) || defined(__USLC__) +#include +#elif defined(__UNIXOS2__) || defined(__SOL64__) +typedef long int int32_t; +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#elif defined(_WIN32) && defined(__GNUC__) +#include +#elif defined(_WIN32) +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +/* Fallback if nothing above works */ +#include #endif - -#ifndef GLX_SGI_swap_control -#define GLX_SGI_swap_control 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern int glXSwapIntervalSGI (int); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef int ( * PFNGLXSWAPINTERVALSGIPROC) (int interval); #endif - -#ifndef GLX_SGI_video_sync -#define GLX_SGI_video_sync 1 +typedef Bool ( *PFNGLXGETSYNCVALUESOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc); +typedef Bool ( *PFNGLXGETMSCRATEOMLPROC) (Display *dpy, GLXDrawable drawable, int32_t *numerator, int32_t *denominator); +typedef int64_t ( *PFNGLXSWAPBUFFERSMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder); +typedef Bool ( *PFNGLXWAITFORMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc); +typedef Bool ( *PFNGLXWAITFORSBCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_sbc, int64_t *ust, int64_t *msc, int64_t *sbc); #ifdef GLX_GLXEXT_PROTOTYPES -extern int glXGetVideoSyncSGI (unsigned int *); -extern int glXWaitVideoSyncSGI (int, int, unsigned int *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef int ( * PFNGLXGETVIDEOSYNCSGIPROC) (unsigned int *count); -typedef int ( * PFNGLXWAITVIDEOSYNCSGIPROC) (int divisor, int remainder, unsigned int *count); +Bool glXGetSyncValuesOML (Display *dpy, GLXDrawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc); +Bool glXGetMscRateOML (Display *dpy, GLXDrawable drawable, int32_t *numerator, int32_t *denominator); +int64_t glXSwapBuffersMscOML (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder); +Bool glXWaitForMscOML (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc); +Bool glXWaitForSbcOML (Display *dpy, GLXDrawable drawable, int64_t target_sbc, int64_t *ust, int64_t *msc, int64_t *sbc); #endif +#endif /* GLX_OML_sync_control */ -#ifndef GLX_SGI_make_current_read -#define GLX_SGI_make_current_read 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXMakeCurrentReadSGI (Display *, GLXDrawable, GLXDrawable, GLXContext); -extern GLXDrawable glXGetCurrentReadDrawableSGI (void); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Bool ( * PFNGLXMAKECURRENTREADSGIPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); -typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLESGIPROC) (void); -#endif +#ifndef GLX_SGIS_blended_overlay +#define GLX_SGIS_blended_overlay 1 +#define GLX_BLENDED_RGBA_SGIS 0x8025 +#endif /* GLX_SGIS_blended_overlay */ -#ifdef _VL_H -#ifndef GLX_SGIX_video_source -#define GLX_SGIX_video_source 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern GLXVideoSourceSGIX glXCreateGLXVideoSourceSGIX (Display *, int, VLServer, VLPath, int, VLNode); -extern void glXDestroyGLXVideoSourceSGIX (Display *, GLXVideoSourceSGIX); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLXVideoSourceSGIX ( * PFNGLXCREATEGLXVIDEOSOURCESGIXPROC) (Display *display, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode); -typedef void ( * PFNGLXDESTROYGLXVIDEOSOURCESGIXPROC) (Display *dpy, GLXVideoSourceSGIX glxvideosource); -#endif +#ifndef GLX_SGIS_multisample +#define GLX_SGIS_multisample 1 +#define GLX_SAMPLE_BUFFERS_SGIS 100000 +#define GLX_SAMPLES_SGIS 100001 +#endif /* GLX_SGIS_multisample */ -#endif /* _VL_H */ -#ifndef GLX_EXT_visual_rating -#define GLX_EXT_visual_rating 1 -#endif +#ifndef GLX_SGIS_shared_multisample +#define GLX_SGIS_shared_multisample 1 +#define GLX_MULTISAMPLE_SUB_RECT_WIDTH_SGIS 0x8026 +#define GLX_MULTISAMPLE_SUB_RECT_HEIGHT_SGIS 0x8027 +#endif /* GLX_SGIS_shared_multisample */ -#ifndef GLX_EXT_import_context -#define GLX_EXT_import_context 1 +#ifndef GLX_SGIX_dmbuffer +#define GLX_SGIX_dmbuffer 1 +typedef XID GLXPbufferSGIX; +#ifdef _DM_BUFFER_H_ +#define GLX_DIGITAL_MEDIA_PBUFFER_SGIX 0x8024 +typedef Bool ( *PFNGLXASSOCIATEDMPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer); #ifdef GLX_GLXEXT_PROTOTYPES -extern Display * glXGetCurrentDisplayEXT (void); -extern int glXQueryContextInfoEXT (Display *, GLXContext, int, int *); -extern GLXContextID glXGetContextIDEXT (const GLXContext); -extern GLXContext glXImportContextEXT (Display *, GLXContextID); -extern void glXFreeContextEXT (Display *, GLXContext); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Display * ( * PFNGLXGETCURRENTDISPLAYEXTPROC) (void); -typedef int ( * PFNGLXQUERYCONTEXTINFOEXTPROC) (Display *dpy, GLXContext context, int attribute, int *value); -typedef GLXContextID ( * PFNGLXGETCONTEXTIDEXTPROC) (const GLXContext context); -typedef GLXContext ( * PFNGLXIMPORTCONTEXTEXTPROC) (Display *dpy, GLXContextID contextID); -typedef void ( * PFNGLXFREECONTEXTEXTPROC) (Display *dpy, GLXContext context); +Bool glXAssociateDMPbufferSGIX (Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer); #endif +#endif /* _DM_BUFFER_H_ */ +#endif /* GLX_SGIX_dmbuffer */ #ifndef GLX_SGIX_fbconfig #define GLX_SGIX_fbconfig 1 +typedef struct __GLXFBConfigRec *GLXFBConfigSGIX; +#define GLX_WINDOW_BIT_SGIX 0x00000001 +#define GLX_PIXMAP_BIT_SGIX 0x00000002 +#define GLX_RGBA_BIT_SGIX 0x00000001 +#define GLX_COLOR_INDEX_BIT_SGIX 0x00000002 +#define GLX_DRAWABLE_TYPE_SGIX 0x8010 +#define GLX_RENDER_TYPE_SGIX 0x8011 +#define GLX_X_RENDERABLE_SGIX 0x8012 +#define GLX_FBCONFIG_ID_SGIX 0x8013 +#define GLX_RGBA_TYPE_SGIX 0x8014 +#define GLX_COLOR_INDEX_TYPE_SGIX 0x8015 +typedef int ( *PFNGLXGETFBCONFIGATTRIBSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value); +typedef GLXFBConfigSGIX *( *PFNGLXCHOOSEFBCONFIGSGIXPROC) (Display *dpy, int screen, int *attrib_list, int *nelements); +typedef GLXPixmap ( *PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap); +typedef GLXContext ( *PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct); +typedef XVisualInfo *( *PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config); +typedef GLXFBConfigSGIX ( *PFNGLXGETFBCONFIGFROMVISUALSGIXPROC) (Display *dpy, XVisualInfo *vis); #ifdef GLX_GLXEXT_PROTOTYPES -extern int glXGetFBConfigAttribSGIX (Display *, GLXFBConfigSGIX, int, int *); -extern GLXFBConfigSGIX * glXChooseFBConfigSGIX (Display *, int, int *, int *); -extern GLXPixmap glXCreateGLXPixmapWithConfigSGIX (Display *, GLXFBConfigSGIX, Pixmap); -extern GLXContext glXCreateContextWithConfigSGIX (Display *, GLXFBConfigSGIX, int, GLXContext, Bool); -extern XVisualInfo * glXGetVisualFromFBConfigSGIX (Display *, GLXFBConfigSGIX); -extern GLXFBConfigSGIX glXGetFBConfigFromVisualSGIX (Display *, XVisualInfo *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef int ( * PFNGLXGETFBCONFIGATTRIBSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value); -typedef GLXFBConfigSGIX * ( * PFNGLXCHOOSEFBCONFIGSGIXPROC) (Display *dpy, int screen, int *attrib_list, int *nelements); -typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap); -typedef GLXContext ( * PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct); -typedef XVisualInfo * ( * PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config); -typedef GLXFBConfigSGIX ( * PFNGLXGETFBCONFIGFROMVISUALSGIXPROC) (Display *dpy, XVisualInfo *vis); -#endif - -#ifndef GLX_SGIX_pbuffer -#define GLX_SGIX_pbuffer 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern GLXPbufferSGIX glXCreateGLXPbufferSGIX (Display *, GLXFBConfigSGIX, unsigned int, unsigned int, int *); -extern void glXDestroyGLXPbufferSGIX (Display *, GLXPbufferSGIX); -extern int glXQueryGLXPbufferSGIX (Display *, GLXPbufferSGIX, int, unsigned int *); -extern void glXSelectEventSGIX (Display *, GLXDrawable, unsigned long); -extern void glXGetSelectedEventSGIX (Display *, GLXDrawable, unsigned long *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLXPbufferSGIX ( * PFNGLXCREATEGLXPBUFFERSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list); -typedef void ( * PFNGLXDESTROYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf); -typedef int ( * PFNGLXQUERYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value); -typedef void ( * PFNGLXSELECTEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long mask); -typedef void ( * PFNGLXGETSELECTEDEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long *mask); +int glXGetFBConfigAttribSGIX (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value); +GLXFBConfigSGIX *glXChooseFBConfigSGIX (Display *dpy, int screen, int *attrib_list, int *nelements); +GLXPixmap glXCreateGLXPixmapWithConfigSGIX (Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap); +GLXContext glXCreateContextWithConfigSGIX (Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct); +XVisualInfo *glXGetVisualFromFBConfigSGIX (Display *dpy, GLXFBConfigSGIX config); +GLXFBConfigSGIX glXGetFBConfigFromVisualSGIX (Display *dpy, XVisualInfo *vis); #endif +#endif /* GLX_SGIX_fbconfig */ -#ifndef GLX_SGI_cushion -#define GLX_SGI_cushion 1 +#ifndef GLX_SGIX_hyperpipe +#define GLX_SGIX_hyperpipe 1 +typedef struct { + char pipeName[80]; /* Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] */ + int networkId; +} GLXHyperpipeNetworkSGIX; +typedef struct { + char pipeName[80]; /* Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] */ + int channel; + unsigned int participationType; + int timeSlice; +} GLXHyperpipeConfigSGIX; +typedef struct { + char pipeName[80]; /* Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] */ + int srcXOrigin, srcYOrigin, srcWidth, srcHeight; + int destXOrigin, destYOrigin, destWidth, destHeight; +} GLXPipeRect; +typedef struct { + char pipeName[80]; /* Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] */ + int XOrigin, YOrigin, maxHeight, maxWidth; +} GLXPipeRectLimits; +#define GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX 80 +#define GLX_BAD_HYPERPIPE_CONFIG_SGIX 91 +#define GLX_BAD_HYPERPIPE_SGIX 92 +#define GLX_HYPERPIPE_DISPLAY_PIPE_SGIX 0x00000001 +#define GLX_HYPERPIPE_RENDER_PIPE_SGIX 0x00000002 +#define GLX_PIPE_RECT_SGIX 0x00000001 +#define GLX_PIPE_RECT_LIMITS_SGIX 0x00000002 +#define GLX_HYPERPIPE_STEREO_SGIX 0x00000003 +#define GLX_HYPERPIPE_PIXEL_AVERAGE_SGIX 0x00000004 +#define GLX_HYPERPIPE_ID_SGIX 0x8030 +typedef GLXHyperpipeNetworkSGIX *( *PFNGLXQUERYHYPERPIPENETWORKSGIXPROC) (Display *dpy, int *npipes); +typedef int ( *PFNGLXHYPERPIPECONFIGSGIXPROC) (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId); +typedef GLXHyperpipeConfigSGIX *( *PFNGLXQUERYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId, int *npipes); +typedef int ( *PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId); +typedef int ( *PFNGLXBINDHYPERPIPESGIXPROC) (Display *dpy, int hpId); +typedef int ( *PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList); +typedef int ( *PFNGLXHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList); +typedef int ( *PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList); #ifdef GLX_GLXEXT_PROTOTYPES -extern void glXCushionSGI (Display *, Window, float); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef void ( * PFNGLXCUSHIONSGIPROC) (Display *dpy, Window window, float cushion); +GLXHyperpipeNetworkSGIX *glXQueryHyperpipeNetworkSGIX (Display *dpy, int *npipes); +int glXHyperpipeConfigSGIX (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId); +GLXHyperpipeConfigSGIX *glXQueryHyperpipeConfigSGIX (Display *dpy, int hpId, int *npipes); +int glXDestroyHyperpipeConfigSGIX (Display *dpy, int hpId); +int glXBindHyperpipeSGIX (Display *dpy, int hpId); +int glXQueryHyperpipeBestAttribSGIX (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList); +int glXHyperpipeAttribSGIX (Display *dpy, int timeSlice, int attrib, int size, void *attribList); +int glXQueryHyperpipeAttribSGIX (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList); #endif +#endif /* GLX_SGIX_hyperpipe */ -#ifndef GLX_SGIX_video_resize -#define GLX_SGIX_video_resize 1 +#ifndef GLX_SGIX_pbuffer +#define GLX_SGIX_pbuffer 1 +#define GLX_PBUFFER_BIT_SGIX 0x00000004 +#define GLX_BUFFER_CLOBBER_MASK_SGIX 0x08000000 +#define GLX_FRONT_LEFT_BUFFER_BIT_SGIX 0x00000001 +#define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX 0x00000002 +#define GLX_BACK_LEFT_BUFFER_BIT_SGIX 0x00000004 +#define GLX_BACK_RIGHT_BUFFER_BIT_SGIX 0x00000008 +#define GLX_AUX_BUFFERS_BIT_SGIX 0x00000010 +#define GLX_DEPTH_BUFFER_BIT_SGIX 0x00000020 +#define GLX_STENCIL_BUFFER_BIT_SGIX 0x00000040 +#define GLX_ACCUM_BUFFER_BIT_SGIX 0x00000080 +#define GLX_SAMPLE_BUFFERS_BIT_SGIX 0x00000100 +#define GLX_MAX_PBUFFER_WIDTH_SGIX 0x8016 +#define GLX_MAX_PBUFFER_HEIGHT_SGIX 0x8017 +#define GLX_MAX_PBUFFER_PIXELS_SGIX 0x8018 +#define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX 0x8019 +#define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX 0x801A +#define GLX_PRESERVED_CONTENTS_SGIX 0x801B +#define GLX_LARGEST_PBUFFER_SGIX 0x801C +#define GLX_WIDTH_SGIX 0x801D +#define GLX_HEIGHT_SGIX 0x801E +#define GLX_EVENT_MASK_SGIX 0x801F +#define GLX_DAMAGED_SGIX 0x8020 +#define GLX_SAVED_SGIX 0x8021 +#define GLX_WINDOW_SGIX 0x8022 +#define GLX_PBUFFER_SGIX 0x8023 +typedef GLXPbufferSGIX ( *PFNGLXCREATEGLXPBUFFERSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list); +typedef void ( *PFNGLXDESTROYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf); +typedef int ( *PFNGLXQUERYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value); +typedef void ( *PFNGLXSELECTEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long mask); +typedef void ( *PFNGLXGETSELECTEDEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long *mask); #ifdef GLX_GLXEXT_PROTOTYPES -extern int glXBindChannelToWindowSGIX (Display *, int, int, Window); -extern int glXChannelRectSGIX (Display *, int, int, int, int, int, int); -extern int glXQueryChannelRectSGIX (Display *, int, int, int *, int *, int *, int *); -extern int glXQueryChannelDeltasSGIX (Display *, int, int, int *, int *, int *, int *); -extern int glXChannelRectSyncSGIX (Display *, int, int, GLenum); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef int ( * PFNGLXBINDCHANNELTOWINDOWSGIXPROC) (Display *display, int screen, int channel, Window window); -typedef int ( * PFNGLXCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int x, int y, int w, int h); -typedef int ( * PFNGLXQUERYCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int *dx, int *dy, int *dw, int *dh); -typedef int ( * PFNGLXQUERYCHANNELDELTASSGIXPROC) (Display *display, int screen, int channel, int *x, int *y, int *w, int *h); -typedef int ( * PFNGLXCHANNELRECTSYNCSGIXPROC) (Display *display, int screen, int channel, GLenum synctype); +GLXPbufferSGIX glXCreateGLXPbufferSGIX (Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list); +void glXDestroyGLXPbufferSGIX (Display *dpy, GLXPbufferSGIX pbuf); +int glXQueryGLXPbufferSGIX (Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value); +void glXSelectEventSGIX (Display *dpy, GLXDrawable drawable, unsigned long mask); +void glXGetSelectedEventSGIX (Display *dpy, GLXDrawable drawable, unsigned long *mask); #endif +#endif /* GLX_SGIX_pbuffer */ -#ifdef _DM_BUFFER_H_ -#ifndef GLX_SGIX_dmbuffer -#define GLX_SGIX_dmbuffer 1 +#ifndef GLX_SGIX_swap_barrier +#define GLX_SGIX_swap_barrier 1 +typedef void ( *PFNGLXBINDSWAPBARRIERSGIXPROC) (Display *dpy, GLXDrawable drawable, int barrier); +typedef Bool ( *PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC) (Display *dpy, int screen, int *max); #ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXAssociateDMPbufferSGIX (Display *, GLXPbufferSGIX, DMparams *, DMbuffer); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Bool ( * PFNGLXASSOCIATEDMPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer); +void glXBindSwapBarrierSGIX (Display *dpy, GLXDrawable drawable, int barrier); +Bool glXQueryMaxSwapBarriersSGIX (Display *dpy, int screen, int *max); #endif +#endif /* GLX_SGIX_swap_barrier */ -#endif /* _DM_BUFFER_H_ */ #ifndef GLX_SGIX_swap_group #define GLX_SGIX_swap_group 1 +typedef void ( *PFNGLXJOINSWAPGROUPSGIXPROC) (Display *dpy, GLXDrawable drawable, GLXDrawable member); #ifdef GLX_GLXEXT_PROTOTYPES -extern void glXJoinSwapGroupSGIX (Display *, GLXDrawable, GLXDrawable); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef void ( * PFNGLXJOINSWAPGROUPSGIXPROC) (Display *dpy, GLXDrawable drawable, GLXDrawable member); +void glXJoinSwapGroupSGIX (Display *dpy, GLXDrawable drawable, GLXDrawable member); #endif +#endif /* GLX_SGIX_swap_group */ -#ifndef GLX_SGIX_swap_barrier -#define GLX_SGIX_swap_barrier 1 +#ifndef GLX_SGIX_video_resize +#define GLX_SGIX_video_resize 1 +#define GLX_SYNC_FRAME_SGIX 0x00000000 +#define GLX_SYNC_SWAP_SGIX 0x00000001 +typedef int ( *PFNGLXBINDCHANNELTOWINDOWSGIXPROC) (Display *display, int screen, int channel, Window window); +typedef int ( *PFNGLXCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int x, int y, int w, int h); +typedef int ( *PFNGLXQUERYCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int *dx, int *dy, int *dw, int *dh); +typedef int ( *PFNGLXQUERYCHANNELDELTASSGIXPROC) (Display *display, int screen, int channel, int *x, int *y, int *w, int *h); +typedef int ( *PFNGLXCHANNELRECTSYNCSGIXPROC) (Display *display, int screen, int channel, GLenum synctype); #ifdef GLX_GLXEXT_PROTOTYPES -extern void glXBindSwapBarrierSGIX (Display *, GLXDrawable, int); -extern Bool glXQueryMaxSwapBarriersSGIX (Display *, int, int *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef void ( * PFNGLXBINDSWAPBARRIERSGIXPROC) (Display *dpy, GLXDrawable drawable, int barrier); -typedef Bool ( * PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC) (Display *dpy, int screen, int *max); +int glXBindChannelToWindowSGIX (Display *display, int screen, int channel, Window window); +int glXChannelRectSGIX (Display *display, int screen, int channel, int x, int y, int w, int h); +int glXQueryChannelRectSGIX (Display *display, int screen, int channel, int *dx, int *dy, int *dw, int *dh); +int glXQueryChannelDeltasSGIX (Display *display, int screen, int channel, int *x, int *y, int *w, int *h); +int glXChannelRectSyncSGIX (Display *display, int screen, int channel, GLenum synctype); #endif +#endif /* GLX_SGIX_video_resize */ -#ifndef GLX_SUN_get_transparent_index -#define GLX_SUN_get_transparent_index 1 +#ifndef GLX_SGIX_video_source +#define GLX_SGIX_video_source 1 +typedef XID GLXVideoSourceSGIX; +#ifdef _VL_H +typedef GLXVideoSourceSGIX ( *PFNGLXCREATEGLXVIDEOSOURCESGIXPROC) (Display *display, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode); +typedef void ( *PFNGLXDESTROYGLXVIDEOSOURCESGIXPROC) (Display *dpy, GLXVideoSourceSGIX glxvideosource); #ifdef GLX_GLXEXT_PROTOTYPES -extern Status glXGetTransparentIndexSUN (Display *, Window, Window, long *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Status ( * PFNGLXGETTRANSPARENTINDEXSUNPROC) (Display *dpy, Window overlay, Window underlay, long *pTransparentIndex); +GLXVideoSourceSGIX glXCreateGLXVideoSourceSGIX (Display *display, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode); +void glXDestroyGLXVideoSourceSGIX (Display *dpy, GLXVideoSourceSGIX glxvideosource); #endif +#endif /* _VL_H */ +#endif /* GLX_SGIX_video_source */ -#ifndef GLX_MESA_copy_sub_buffer -#define GLX_MESA_copy_sub_buffer 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern void glXCopySubBufferMESA (Display *, GLXDrawable, int, int, int, int); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef void ( * PFNGLXCOPYSUBBUFFERMESAPROC) (Display *dpy, GLXDrawable drawable, int x, int y, int width, int height); -#endif +#ifndef GLX_SGIX_visual_select_group +#define GLX_SGIX_visual_select_group 1 +#define GLX_VISUAL_SELECT_GROUP_SGIX 0x8028 +#endif /* GLX_SGIX_visual_select_group */ -#ifndef GLX_MESA_pixmap_colormap -#define GLX_MESA_pixmap_colormap 1 +#ifndef GLX_SGI_cushion +#define GLX_SGI_cushion 1 +typedef void ( *PFNGLXCUSHIONSGIPROC) (Display *dpy, Window window, float cushion); #ifdef GLX_GLXEXT_PROTOTYPES -extern GLXPixmap glXCreateGLXPixmapMESA (Display *, XVisualInfo *, Pixmap, Colormap); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPMESAPROC) (Display *dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap); +void glXCushionSGI (Display *dpy, Window window, float cushion); #endif +#endif /* GLX_SGI_cushion */ -#ifndef GLX_MESA_release_buffers -#define GLX_MESA_release_buffers 1 +#ifndef GLX_SGI_make_current_read +#define GLX_SGI_make_current_read 1 +typedef Bool ( *PFNGLXMAKECURRENTREADSGIPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); +typedef GLXDrawable ( *PFNGLXGETCURRENTREADDRAWABLESGIPROC) (void); #ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXReleaseBuffersMESA (Display *, GLXDrawable); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Bool ( * PFNGLXRELEASEBUFFERSMESAPROC) (Display *dpy, GLXDrawable drawable); +Bool glXMakeCurrentReadSGI (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); +GLXDrawable glXGetCurrentReadDrawableSGI (void); #endif +#endif /* GLX_SGI_make_current_read */ -#ifndef GLX_MESA_set_3dfx_mode -#define GLX_MESA_set_3dfx_mode 1 +#ifndef GLX_SGI_swap_control +#define GLX_SGI_swap_control 1 +typedef int ( *PFNGLXSWAPINTERVALSGIPROC) (int interval); #ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXSet3DfxModeMESA (int); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Bool ( * PFNGLXSET3DFXMODEMESAPROC) (int mode); +int glXSwapIntervalSGI (int interval); #endif +#endif /* GLX_SGI_swap_control */ -#ifndef GLX_SGIX_visual_select_group -#define GLX_SGIX_visual_select_group 1 -#endif - -#ifndef GLX_OML_swap_method -#define GLX_OML_swap_method 1 +#ifndef GLX_SGI_video_sync +#define GLX_SGI_video_sync 1 +typedef int ( *PFNGLXGETVIDEOSYNCSGIPROC) (unsigned int *count); +typedef int ( *PFNGLXWAITVIDEOSYNCSGIPROC) (int divisor, int remainder, unsigned int *count); +#ifdef GLX_GLXEXT_PROTOTYPES +int glXGetVideoSyncSGI (unsigned int *count); +int glXWaitVideoSyncSGI (int divisor, int remainder, unsigned int *count); #endif +#endif /* GLX_SGI_video_sync */ -#if defined(__STDC_VERSION__) -#if __STDC_VERSION__ >= 199901L -/* Include ISO C99 integer types for OML_sync_control; need a better test */ -#include +/* + * JDK modification + * REMIND: This is a Sun-private constant used to get the gamma value for + * a GLXFBConfig. This was never publically documented as part of + * a Sun extension, and therefore never ended up in the official SGI + * glxext.h header file, so we've copied it here from the Sun OpenGL + * headers (glxtokens.h). + */ +#define GLX_GAMMA_VALUE_SUN 0x8173 -#ifndef GLX_OML_sync_control -#define GLX_OML_sync_control 1 +#ifndef GLX_SUN_get_transparent_index +#define GLX_SUN_get_transparent_index 1 +typedef Status ( *PFNGLXGETTRANSPARENTINDEXSUNPROC) (Display *dpy, Window overlay, Window underlay, long *pTransparentIndex); #ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXGetSyncValuesOML (Display *, GLXDrawable, int64_t *, int64_t *, int64_t *); -extern Bool glXGetMscRateOML (Display *, GLXDrawable, int32_t *, int32_t *); -extern int64_t glXSwapBuffersMscOML (Display *, GLXDrawable, int64_t, int64_t, int64_t); -extern Bool glXWaitForMscOML (Display *, GLXDrawable, int64_t, int64_t, int64_t, int64_t *, int64_t *, int64_t *); -extern Bool glXWaitForSbcOML (Display *, GLXDrawable, int64_t, int64_t *, int64_t *, int64_t *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Bool ( * PFNGLXGETSYNCVALUESOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc); -typedef Bool ( * PFNGLXGETMSCRATEOMLPROC) (Display *dpy, GLXDrawable drawable, int32_t *numerator, int32_t *denominator); -typedef int64_t ( * PFNGLXSWAPBUFFERSMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder); -typedef Bool ( * PFNGLXWAITFORMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc); -typedef Bool ( * PFNGLXWAITFORSBCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_sbc, int64_t *ust, int64_t *msc, int64_t *sbc); -#endif - -#endif /* C99 version test */ -#endif /* STDC test */ +Status glXGetTransparentIndexSUN (Display *dpy, Window overlay, Window underlay, long *pTransparentIndex); +#endif +#endif /* GLX_SUN_get_transparent_index */ #ifdef __cplusplus } diff --git a/src/solaris/native/sun/java2d/x11/X11PMBlitLoops.c b/src/solaris/native/sun/java2d/x11/X11PMBlitLoops.c index c94d58b8a626a7ba74da9502895ba7aef144b05a..bfa554cd3c19d0230ad1bf2bf9a1fb777f296989 100644 --- a/src/solaris/native/sun/java2d/x11/X11PMBlitLoops.c +++ b/src/solaris/native/sun/java2d/x11/X11PMBlitLoops.c @@ -263,7 +263,7 @@ Java_sun_java2d_x11_X11PMBlitLoops_updateBitmask return; } dstScan = image->bytes_per_line; - image->data = malloc(dstScan * height); + image->data = malloc((size_t) dstScan * height); if (image->data == NULL) { XFree(image); AWT_UNLOCK(); diff --git a/src/solaris/native/sun/java2d/x11/X11TextRenderer_md.c b/src/solaris/native/sun/java2d/x11/X11TextRenderer_md.c index cda230e8db9b653e3acb9431d4f5dc404710d2af..c7aff6f34c84f9a80065b69d4ad55a896d3caa48 100644 --- a/src/solaris/native/sun/java2d/x11/X11TextRenderer_md.c +++ b/src/solaris/native/sun/java2d/x11/X11TextRenderer_md.c @@ -154,7 +154,7 @@ static void FillBitmap(XImage *theImage, height = bottom - top; top -= clipTop; left -= clipLeft; - pPix = ((jubyte *) theImage->data) + (left >> 3) + top * scan; + pPix = ((jubyte *) theImage->data) + (left >> 3) + (intptr_t) top * scan; left &= 0x07; if (theImage->bitmap_bit_order == MSBFirst) { left = 0x80 >> left; diff --git a/src/solaris/native/sun/java2d/x11/XRBackendNative.c b/src/solaris/native/sun/java2d/x11/XRBackendNative.c index 733606ec444ee44ba148aceb3cae11c48dce5513..7b62a864166ebad9b8d9b1fda0a334a0bee7d8de 100644 --- a/src/solaris/native/sun/java2d/x11/XRBackendNative.c +++ b/src/solaris/native/sun/java2d/x11/XRBackendNative.c @@ -756,7 +756,7 @@ Java_sun_java2d_xr_XRBackendNative_putMaskNative if (ea != 1.0f) { for (line=0; line < height; line++) { for (pix=0; pix < width; pix++) { - int index = maskScan*line + pix + maskOff; + size_t index = (size_t) maskScan * line + pix + maskOff; mask[index] = (((unsigned char) mask[index])*ea); } } @@ -781,8 +781,8 @@ Java_sun_java2d_xr_XRBackendNative_putMaskNative if (imageFits) { for (line=0; line < height; line++) { for (pix=0; pix < width; pix++) { - img->data[line*img->bytes_per_line + pix] = - (unsigned char) (mask[maskScan*line + pix + maskOff]); + img->data[(size_t) line * img->bytes_per_line + pix] = + (unsigned char) (mask[(size_t) maskScan * line + pix + maskOff]); } } } else { diff --git a/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c b/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c index c8500db5c877e63aea7cb71c598230c3d4bae77d..bd836bfcd6b8639d7b3a7dcd1258082d3c3cd65a 100644 --- a/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c +++ b/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.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 @@ -169,12 +169,11 @@ Java_sun_nio_fs_LinuxNativeDispatcher_setmntent0(JNIEnv* env, jclass this, jlong } JNIEXPORT jint JNICALL -Java_sun_nio_fs_LinuxNativeDispatcher_getmntent(JNIEnv* env, jclass this, - jlong value, jobject entry) +Java_sun_nio_fs_LinuxNativeDispatcher_getmntent0(JNIEnv* env, jclass this, + jlong value, jobject entry, jlong buffer, jint bufLen) { struct mntent ent; - char buf[1024]; - int buflen = sizeof(buf); + char * buf = (char*)jlong_to_ptr(buffer); struct mntent* m; FILE* fp = jlong_to_ptr(value); jsize len; @@ -184,7 +183,7 @@ Java_sun_nio_fs_LinuxNativeDispatcher_getmntent(JNIEnv* env, jclass this, char* fstype; char* options; - m = getmntent_r(fp, &ent, (char*)&buf, buflen); + m = getmntent_r(fp, &ent, buf, (int)bufLen); if (m == NULL) return -1; name = m->mnt_fsname; @@ -230,3 +229,37 @@ Java_sun_nio_fs_LinuxNativeDispatcher_endmntent(JNIEnv* env, jclass this, jlong /* FIXME - man page doesn't explain how errors are returned */ endmntent(fp); } + +/** + * This function returns line length without NUL terminator or -1 on EOF. + * Since getline is missing on Solaris10 this function was moved from + * UnixNativeDispatcher to LinuxNativeDispatcher as part of backport form jdk11. + */ +JNIEXPORT jint JNICALL +Java_sun_nio_fs_LinuxNativeDispatcher_getlinelen(JNIEnv* env, jclass this, jlong stream) +{ + FILE* fp = jlong_to_ptr(stream); + size_t lineSize = 0; + char * lineBuffer = NULL; + int saved_errno; + + ssize_t res = getline(&lineBuffer, &lineSize, fp); + saved_errno = errno; + + /* Should free lineBuffer no matter result, according to man page */ + if (lineBuffer != NULL) + free(lineBuffer); + + if (feof(fp)) + return -1; + + /* On successfull return res >= 0, otherwise res is -1 */ + if (res == -1) + throwUnixException(env, saved_errno); + + if (res > INT_MAX) + throwUnixException(env, EOVERFLOW); + + return (jint)res; +} + diff --git a/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c b/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c index 2799f9ab0d61f8a30d372e14ab66019db3ea83bc..cb4cfc01908d99f6490cbc98c66ab1ba5274253c 100644 --- a/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c +++ b/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2013, 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 @@ -367,6 +367,20 @@ Java_sun_nio_fs_UnixNativeDispatcher_fclose(JNIEnv* env, jclass this, jlong stre } } +JNIEXPORT void JNICALL +Java_sun_nio_fs_UnixNativeDispatcher_rewind(JNIEnv* env, jclass this, jlong stream) +{ + FILE* fp = jlong_to_ptr(stream); + int saved_errno; + + errno = 0; + rewind(fp); + saved_errno = errno; + if (ferror(fp)) { + throwUnixException(env, saved_errno); + } +} + JNIEXPORT jint JNICALL Java_sun_nio_fs_UnixNativeDispatcher_open0(JNIEnv* env, jclass this, jlong pathAddress, jint oflags, jint mode) diff --git a/src/windows/classes/com/sun/java/accessibility/AccessBridge.java b/src/windows/classes/com/sun/java/accessibility/AccessBridge.java index 11b6d001f2c38120db16e90d6ddc9c2fe83f6069..ebc904b0d570321ee83e562186976eb3941257d8 100644 --- a/src/windows/classes/com/sun/java/accessibility/AccessBridge.java +++ b/src/windows/classes/com/sun/java/accessibility/AccessBridge.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1550,6 +1550,38 @@ final public class AccessBridge extends AccessBridgeLoader { return null; } + private int getNonVisibleChildrenCountTillIndex(AccessibleContext parentAC, int index) { + if (parentAC != null && index >= 0 && index < parentAC.getAccessibleChildrenCount()) { + int nonVisibleChildrenCount = 0; + for (int i = 0; i <= index; i++) { + if (!parentAC.getAccessibleChild(i).getAccessibleContext().getAccessibleStateSet().contains(AccessibleState.VISIBLE)) { + nonVisibleChildrenCount++; + } + } + return nonVisibleChildrenCount; + } + return 0; + } + + private Accessible getVisibleChildAtIndex(AccessibleContext parentAC, int index) { + if (parentAC != null && index >= 0 && index < parentAC.getAccessibleChildrenCount()) { + int visibleIndex = -1; + int childrenCount = parentAC.getAccessibleChildrenCount(); + for (int i = 0; i <= childrenCount; i++) { + Accessible child = parentAC.getAccessibleChild(i); + if (child != null) { + AccessibleContext ac = child.getAccessibleContext(); + if (ac != null && ac.getAccessibleStateSet().contains(AccessibleState.VISIBLE)) { + visibleIndex++; + } + if (visibleIndex == index) { + return child; + } + } + } + } + return null; + } /** * returns the AccessibleParent from an AccessibleContext */ @@ -1580,7 +1612,12 @@ final public class AccessBridge extends AccessBridgeLoader { return InvocationUtils.invokeAndWait(new Callable() { @Override public Integer call() throws Exception { - return ac.getAccessibleIndexInParent(); + int indexInParent = ac.getAccessibleIndexInParent(); + Accessible parent = ac.getAccessibleParent(); + if (parent != null) { + indexInParent -= getNonVisibleChildrenCountTillIndex(parent.getAccessibleContext(), indexInParent); + } + return indexInParent; } }, ac); } @@ -1594,7 +1631,8 @@ final public class AccessBridge extends AccessBridgeLoader { return InvocationUtils.invokeAndWait(new Callable() { @Override public Integer call() throws Exception { - return ac.getAccessibleChildrenCount(); + int childrenCount = ac.getAccessibleChildrenCount(); + return childrenCount - getNonVisibleChildrenCountTillIndex(ac, childrenCount - 1); } }, ac); } @@ -1630,7 +1668,7 @@ final public class AccessBridge extends AccessBridgeLoader { return InvocationUtils.invokeAndWait(new Callable() { @Override public AccessibleContext call() throws Exception { - Accessible a = ac.getAccessibleChild(index); + Accessible a = getVisibleChildAtIndex(ac, index); if (a != null) { return a.getAccessibleContext(); } @@ -3615,7 +3653,11 @@ final public class AccessBridge extends AccessBridgeLoader { AccessibleRelation[] relations = ars.toArray(); if (relations != null && i >= 0 && i < relations.length) { Object[] targets = relations[i].getTarget(); - return targets.length; + if (targets != null) { + int targetCount = targets.length - + getNonVisibleTargetCountTillIndex(targets, targets.length - 1); + return targetCount; + } } } } @@ -3641,7 +3683,7 @@ final public class AccessBridge extends AccessBridgeLoader { if (relations != null && i >= 0 && i < relations.length) { Object[] targets = relations[i].getTarget(); if (targets != null && j >= 0 & j < targets.length) { - Object o = targets[j]; + Object o = getVisibleTargetAtIndex(targets, j); if (o instanceof Accessible) { return ((Accessible) o).getAccessibleContext(); } @@ -3654,6 +3696,40 @@ final public class AccessBridge extends AccessBridgeLoader { }, ac); } + private Object getVisibleTargetAtIndex(Object[] targets, int index) { + if (index >= 0 && index < targets.length) { + int visibleTargetIndex = -1; + for (int i = 0; i < targets.length; i++) { + if (targets[i] instanceof Accessible) { + AccessibleContext ac = ((Accessible) targets[i]).getAccessibleContext(); + if (ac != null && ac.getAccessibleStateSet().contains(AccessibleState.VISIBLE)) { + visibleTargetIndex++; + } + if (visibleTargetIndex == index) { + return targets[i]; + } + } + } + } + return null; + } + + private int getNonVisibleTargetCountTillIndex(Object[] targets, int index) { + if (index >= 0 && index < targets.length) { + int nonVisibleTargetsCount = 0; + for (int i = 0; i <= index; i++) { + if (targets[i] instanceof Accessible) { + AccessibleContext ac = ((Accessible) targets[i]).getAccessibleContext(); + if (ac != null && !ac.getAccessibleStateSet().contains(AccessibleState.VISIBLE)) { + nonVisibleTargetsCount++; + } + } + } + return nonVisibleTargetsCount; + } + return 0; + } + // ========= AccessibleHypertext ========= private Map hyperTextContextMap = new WeakHashMap<>(); diff --git a/src/windows/classes/java/lang/ProcessImpl.java b/src/windows/classes/java/lang/ProcessImpl.java index 1970260e57eac3b3af2953f09a7d465cabc7416f..5c43ef77ebbc4ac0ba36cb0302f48235f33333bc 100644 --- a/src/windows/classes/java/lang/ProcessImpl.java +++ b/src/windows/classes/java/lang/ProcessImpl.java @@ -516,12 +516,11 @@ final class ProcessImpl extends Process { public boolean waitFor(long timeout, TimeUnit unit) throws InterruptedException { + long remainingNanos = unit.toNanos(timeout); // throw NPE before other conditions if (getExitCodeProcess(handle) != STILL_ACTIVE) return true; if (timeout <= 0) return false; - long remainingNanos = unit.toNanos(timeout); long deadline = System.nanoTime() + remainingNanos; - do { // Round up to next millisecond long msTimeout = TimeUnit.NANOSECONDS.toMillis(remainingNanos + 999_999L); diff --git a/src/windows/classes/sun/nio/ch/WindowsSelectorImpl.java b/src/windows/classes/sun/nio/ch/WindowsSelectorImpl.java index eec35ea9518f9ef11dc7d31b98ebd7165ca8b398..53f290225b4d52946122cba190541a5dff59517d 100644 --- a/src/windows/classes/sun/nio/ch/WindowsSelectorImpl.java +++ b/src/windows/classes/sun/nio/ch/WindowsSelectorImpl.java @@ -40,6 +40,7 @@ import java.util.List; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import sun.misc.Unsafe; /** * A multi-threaded implementation of Selector for Windows. @@ -49,12 +50,26 @@ import java.util.Iterator; */ final class WindowsSelectorImpl extends SelectorImpl { + private static final Unsafe unsafe = Unsafe.getUnsafe(); + private static int addressSize = unsafe.addressSize(); + + private static int dependsArch(int value32, int value64) { + return (addressSize == 4) ? value32 : value64; + } + // Initial capacity of the poll array private final int INIT_CAP = 8; // Maximum number of sockets for select(). // Should be INIT_CAP times a power of 2 private final static int MAX_SELECTABLE_FDS = 1024; + // Size of FD_SET struct to allocate a buffer for it in SubSelector, + // aligned to 8 bytes on 64-bit: + // struct { unsigned int fd_count; SOCKET fd_array[MAX_SELECTABLE_FDS]; }. + private static final long SIZEOF_FD_SET = dependsArch( + 4 + MAX_SELECTABLE_FDS * 4, // SOCKET = unsigned int + 4 + MAX_SELECTABLE_FDS * 8 + 4); // SOCKET = unsigned __int64 + // The list of SelectableChannels serviced by this Selector. Every mod // MAX_SELECTABLE_FDS entry is bogus, to align this array with the poll // array, where the corresponding entry is occupied by the wakeupSocket @@ -283,6 +298,9 @@ final class WindowsSelectorImpl extends SelectorImpl { private final int[] readFds = new int [MAX_SELECTABLE_FDS + 1]; private final int[] writeFds = new int [MAX_SELECTABLE_FDS + 1]; private final int[] exceptFds = new int [MAX_SELECTABLE_FDS + 1]; + // Buffer for readfds, writefds and exceptfds structs that are passed + // to native select(). + private final long fdsBuffer = unsafe.allocateMemory(SIZEOF_FD_SET * 6); private SubSelector() { this.pollArrayIndex = 0; // main thread @@ -295,7 +313,7 @@ final class WindowsSelectorImpl extends SelectorImpl { private int poll() throws IOException{ // poll for the main thread return poll0(pollWrapper.pollArrayAddress, Math.min(totalChannels, MAX_SELECTABLE_FDS), - readFds, writeFds, exceptFds, timeout); + readFds, writeFds, exceptFds, timeout, fdsBuffer); } private int poll(int index) throws IOException { @@ -304,11 +322,11 @@ final class WindowsSelectorImpl extends SelectorImpl { (pollArrayIndex * PollArrayWrapper.SIZE_POLLFD), Math.min(MAX_SELECTABLE_FDS, totalChannels - (index + 1) * MAX_SELECTABLE_FDS), - readFds, writeFds, exceptFds, timeout); + readFds, writeFds, exceptFds, timeout, fdsBuffer); } private native int poll0(long pollAddress, int numfds, - int[] readFds, int[] writeFds, int[] exceptFds, long timeout); + int[] readFds, int[] writeFds, int[] exceptFds, long timeout, long fdsBuffer); private int processSelectedKeys(long updateCount) { int numKeysUpdated = 0; @@ -400,6 +418,10 @@ final class WindowsSelectorImpl extends SelectorImpl { } return numKeysUpdated; } + + private void freeFDSetBuffer() { + unsafe.freeMemory(fdsBuffer); + } } // Represents a helper thread used for select. @@ -425,8 +447,10 @@ final class WindowsSelectorImpl extends SelectorImpl { while (true) { // poll loop // wait for the start of poll. If this thread has become // redundant, then exit. - if (startLock.waitForStart(this)) + if (startLock.waitForStart(this)) { + subSelector.freeFDSetBuffer(); return; + } // call poll() try { subSelector.poll(index); @@ -525,6 +549,7 @@ final class WindowsSelectorImpl extends SelectorImpl { for (SelectThread t: threads) t.makeZombie(); startLock.startThreads(); + subSelector.freeFDSetBuffer(); } } } diff --git a/src/windows/classes/sun/security/krb5/internal/tools/Kinit.java b/src/windows/classes/sun/security/krb5/internal/tools/Kinit.java index 5839a5e13e4a72488b3f0abe482736b8a7e84ec7..066728647c4a1eefea8fc753348cd5e8b8731967 100644 --- a/src/windows/classes/sun/security/krb5/internal/tools/Kinit.java +++ b/src/windows/classes/sun/security/krb5/internal/tools/Kinit.java @@ -59,26 +59,25 @@ public class Kinit { * We currently support only file-based credentials cache to * store the tickets obtained from the KDC. * By default, for all Unix platforms a cache file named - * /tmp/krb5cc_<uid> will be generated. The <uid> is the + * {@code /tmp/krb5cc_} will be generated. The {@code } is the * numeric user identifier. * For all other platforms, a cache file named - * <USER_HOME>/krb5cc_<USER_NAME> would be generated. + * {@code /krb5cc_} would be generated. *

    - * <USER_HOME> is obtained from java.lang.System + * {@code } is obtained from {@code java.lang.System} * property user.home. - * <USER_NAME> is obtained from java.lang.System + * {@code } is obtained from {@code java.lang.System} * property user.name. - * If <USER_HOME> is null the cache file would be stored in + * If {@code } is null the cache file would be stored in * the current directory that the program is running from. - * <USER_NAME> is operating system's login username. + * {@code } is operating system's login username. * It could be different from user's principal name. - *

    - *

    + *

    * For instance, on Windows NT, it could be - * c:\winnt\profiles\duke\krb5cc_duke, in - * which duke is the <USER_NAME>, and c:\winnt\profile\duke is the - * <USER_HOME>. - *

    + * {@code c:\winnt\profiles\duke\krb5cc_duke}, in + * which duke is the {@code } and {@code c:\winnt\profile\duke} is the + * {@code }. + *

    * A single user could have multiple principal names, * but the primary principal of the credentials cache could only be one, * which means one cache file could only store tickets for one @@ -88,10 +87,8 @@ public class Kinit { * To avoid overwriting, you need to specify * a different cache file name when you request a * new ticket. - *

    - *

    + *

    * You can specify the location of the cache file by using the -c option - * */ public static void main(String[] args) { diff --git a/src/windows/classes/sun/security/krb5/internal/tools/Klist.java b/src/windows/classes/sun/security/krb5/internal/tools/Klist.java index 37f59adae80e66cb1f33601ef255eb02bc4aaf0d..c8b70ffaed94c862d2edcd4e96bc7d9a63f1cba9 100644 --- a/src/windows/classes/sun/security/krb5/internal/tools/Klist.java +++ b/src/windows/classes/sun/security/krb5/internal/tools/Klist.java @@ -71,8 +71,10 @@ public class Klist { *

  • -n do not reverse-resolve addresses * * available options for keytabs: + *
      *
    • -t shows keytab entry timestamps *
    • -K shows keytab entry DES keys + *
    */ public static void main(String[] args) { Klist klist = new Klist(); diff --git a/src/windows/classes/sun/security/mscapi/CKey.java b/src/windows/classes/sun/security/mscapi/CKey.java new file mode 100644 index 0000000000000000000000000000000000000000..84d3e82cec1ab8a39031f59da35166e997802abd --- /dev/null +++ b/src/windows/classes/sun/security/mscapi/CKey.java @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. + * 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.mscapi; + +import sun.security.util.KeyUtil; +import sun.security.util.Length; + +import java.math.BigInteger; +import java.security.Key; +import java.security.interfaces.ECPrivateKey; +import java.security.interfaces.ECPublicKey; + +/** + * The handle for a key using the Microsoft Crypto API. + * + * @see CPrivateKey + * @see CPublicKey + * + * @since 1.6 + * @author Stanley Man-Kit Ho + */ +abstract class CKey implements Key, Length { + private static final long serialVersionUID = -1088859394025049194L; + + static class NativeHandles { + + long hCryptProv = 0; + long hCryptKey = 0; + + public NativeHandles(long hCryptProv, long hCryptKey) { + this.hCryptProv = hCryptProv; + this.hCryptKey = hCryptKey; + } + + @SuppressWarnings("deprecation") + protected void finalize() throws Throwable { + try { + synchronized(this) { + cleanUp(hCryptProv, hCryptKey); + hCryptProv = 0; + hCryptKey = 0; + } + + } finally { + super.finalize(); + } + } + } + + protected final NativeHandles handles; + + protected final int keyLength; + + protected final String algorithm; + + protected CKey(String algorithm, NativeHandles handles, int keyLength) { + this.algorithm = algorithm; + this.handles = handles; + this.keyLength = keyLength; + } + + // Native method to cleanup the key handle. + private native static void cleanUp(long hCryptProv, long hCryptKey); + + @Override + public int length() { + return keyLength; + } + + public long getHCryptKey() { + return handles.hCryptKey; + } + + public long getHCryptProvider() { + return handles.hCryptProv; + } + + public String getAlgorithm() { + return algorithm; + } + + protected native static String getContainerName(long hCryptProv); + + protected native static String getKeyType(long hCryptKey); + + // This java method generates EC BLOBs for public key or private key. + // See https://docs.microsoft.com/en-us/windows/desktop/api/bcrypt/ns-bcrypt-_bcrypt_ecckey_blob + static byte[] generateECBlob(Key k) { + + int keyBitLength = KeyUtil.getKeySize(k); + int keyLen = (keyBitLength + 7) / 8; + boolean isPrivate = k instanceof ECPrivateKey; + + byte[] keyBlob = new byte[8 + keyLen * (isPrivate ? 3 : 2)]; + keyBlob[0] = 'E'; + keyBlob[1] = 'C'; + keyBlob[2] = 'S'; + if (isPrivate) { + keyBlob[3] = (byte) (keyBitLength == 256 ? '2' + : (keyBitLength == 384 ? '4' : '6')); + } else { + keyBlob[3] = (byte) (keyBitLength == 256 ? '1' + : (keyBitLength == 384 ? '3' : '5')); + } + BigInteger x; + BigInteger y; + // Fill the array in reverse order (s -> y -> x -> len) in case + // one BigInteger encoding has an extra 0 at the beginning + if (isPrivate) { + // We can keep X and Y zero and it still works + ECPrivateKey prk = (ECPrivateKey)k; + BigInteger s = prk.getS(); + byte[] bs = s.toByteArray(); + System.arraycopy( + bs, 0, + keyBlob, 8 + keyLen + keyLen + keyLen - bs.length, + bs.length); + } else { + ECPublicKey puk = (ECPublicKey)k; + x = puk.getW().getAffineX(); + y = puk.getW().getAffineY(); + byte[] by = y.toByteArray(); + System.arraycopy(by, 0, keyBlob, 8 + keyLen + keyLen - by.length, + by.length); + byte[] bx = x.toByteArray(); + System.arraycopy(bx, 0, keyBlob, 8 + keyLen - bx.length, bx.length); + } + keyBlob[4] = (byte) keyLen; + keyBlob[5] = keyBlob[6] = keyBlob[7] = 0; + return keyBlob; + } +} diff --git a/src/windows/classes/sun/security/mscapi/RSAKeyPair.java b/src/windows/classes/sun/security/mscapi/CKeyPair.java similarity index 70% rename from src/windows/classes/sun/security/mscapi/RSAKeyPair.java rename to src/windows/classes/sun/security/mscapi/CKeyPair.java index 0880c20d85db562fed705eb1deb2726140c171b1..ce0f1a2268aa5cc27a8ca2807d0b71175db93d3b 100644 --- a/src/windows/classes/sun/security/mscapi/RSAKeyPair.java +++ b/src/windows/classes/sun/security/mscapi/CKeyPair.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * 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,27 +30,26 @@ package sun.security.mscapi; * * @since 1.6 */ -class RSAKeyPair { +class CKeyPair { - private final RSAPrivateKey privateKey; + private final CPrivateKey privateKey; - private final RSAPublicKey publicKey; + private final CPublicKey publicKey; /** - * Construct an RSAKeyPair object. + * This method is called by native codes in security.cpp. */ - RSAKeyPair(long hCryptProv, long hCryptKey, int keyLength) - { - Key.NativeHandles handles = new Key.NativeHandles(hCryptProv, hCryptKey); - privateKey = new RSAPrivateKey(handles, keyLength); - publicKey = new RSAPublicKey(handles, keyLength); + CKeyPair(String alg, long hCryptProv, long hCryptKey, int keyLength) { + CKey.NativeHandles handles = new CKey.NativeHandles(hCryptProv, hCryptKey); + privateKey = CPrivateKey.of(alg, handles, keyLength); + publicKey = CPublicKey.of(alg, handles, keyLength); } - public RSAPrivateKey getPrivate() { + public CPrivateKey getPrivate() { return privateKey; } - public RSAPublicKey getPublic() { + public CPublicKey getPublic() { return publicKey; } } diff --git a/src/windows/classes/sun/security/mscapi/CKeyPairGenerator.java b/src/windows/classes/sun/security/mscapi/CKeyPairGenerator.java new file mode 100644 index 0000000000000000000000000000000000000000..2745b937876e647be4fc47ca2e5759c8bc0abc24 --- /dev/null +++ b/src/windows/classes/sun/security/mscapi/CKeyPairGenerator.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. + * 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.mscapi; + +import java.util.UUID; +import java.security.*; +import java.security.spec.AlgorithmParameterSpec; +import java.security.spec.RSAKeyGenParameterSpec; + +import sun.security.rsa.RSAKeyFactory; +import static sun.security.util.SecurityProviderConstants.DEF_RSA_KEY_SIZE; + +/** + * RSA keypair generator. + * + * Standard algorithm, minimum key length is 512 bit, maximum is 16,384. + * Generates a private key that is exportable. + * + * @since 1.6 + */ +public abstract class CKeyPairGenerator extends KeyPairGeneratorSpi { + + protected String keyAlg; + + public CKeyPairGenerator(String keyAlg) { + this.keyAlg = keyAlg; + } + + public static class RSA extends CKeyPairGenerator { + public RSA() { + super("RSA"); + // initialize to default in case the app does not call initialize() + initialize(DEF_RSA_KEY_SIZE, null); + } + + // Supported by Microsoft Base, Strong and Enhanced Cryptographic Providers + static final int KEY_SIZE_MIN = 512; // disallow MSCAPI min. of 384 + static final int KEY_SIZE_MAX = 16384; + + // size of the key to generate, KEY_SIZE_MIN <= keySize <= KEY_SIZE_MAX + private int keySize; + + // initialize the generator. See JCA doc + // random is always ignored + @Override + public void initialize(int keySize, SecureRandom random) { + + try { + RSAKeyFactory.checkKeyLengths(keySize, null, + KEY_SIZE_MIN, KEY_SIZE_MAX); + } catch (InvalidKeyException e) { + throw new InvalidParameterException(e.getMessage()); + } + + this.keySize = keySize; + } + + // second initialize method. See JCA doc + // random and exponent are always ignored + @Override + public void initialize(AlgorithmParameterSpec params, SecureRandom random) + throws InvalidAlgorithmParameterException { + + int tmpSize; + if (params == null) { + tmpSize = DEF_RSA_KEY_SIZE; + } else if (params instanceof RSAKeyGenParameterSpec) { + + if (((RSAKeyGenParameterSpec) params).getPublicExponent() != null) { + throw new InvalidAlgorithmParameterException + ("Exponent parameter is not supported"); + } + tmpSize = ((RSAKeyGenParameterSpec) params).getKeysize(); + + } else { + throw new InvalidAlgorithmParameterException + ("Params must be an instance of RSAKeyGenParameterSpec"); + } + + try { + RSAKeyFactory.checkKeyLengths(tmpSize, null, + KEY_SIZE_MIN, KEY_SIZE_MAX); + } catch (InvalidKeyException e) { + throw new InvalidAlgorithmParameterException( + "Invalid Key sizes", e); + } + + this.keySize = tmpSize; + } + + // generate the keypair. See JCA doc + @Override + public KeyPair generateKeyPair() { + + try { + // Generate each keypair in a unique key container + CKeyPair keys = + generateCKeyPair(keyAlg, keySize, + "{" + UUID.randomUUID().toString() + "}"); + return new KeyPair(keys.getPublic(), keys.getPrivate()); + + } catch (KeyException e) { + throw new ProviderException(e); + } + } + + private static native CKeyPair generateCKeyPair(String alg, int keySize, + String keyContainerName) throws KeyException; + } +} diff --git a/src/windows/classes/sun/security/mscapi/KeyStore.java b/src/windows/classes/sun/security/mscapi/CKeyStore.java similarity index 86% rename from src/windows/classes/sun/security/mscapi/KeyStore.java rename to src/windows/classes/sun/security/mscapi/CKeyStore.java index 599b0db9d0f56daeac513bcd15a07141d7813430..9e2f8a36a30f89c444bf4e31279cc5ba1d602cac 100644 --- a/src/windows/classes/sun/security/mscapi/KeyStore.java +++ b/src/windows/classes/sun/security/mscapi/CKeyStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * 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,8 +31,10 @@ import java.io.InputStream; import java.io.OutputStream; import java.security.AccessController; import java.security.InvalidKeyException; +import java.security.Key; import java.security.KeyStoreSpi; import java.security.KeyStoreException; +import java.security.PrivilegedAction; import java.security.UnrecoverableKeyException; import java.security.NoSuchAlgorithmException; import java.security.SecurityPermission; @@ -43,38 +45,37 @@ import java.security.cert.CertificateFactory; import java.security.interfaces.RSAPrivateCrtKey; import java.util.*; -import sun.security.action.GetPropertyAction; +import sun.security.util.Debug; /** * Implementation of key store for Windows using the Microsoft Crypto API. * * @since 1.6 */ -abstract class KeyStore extends KeyStoreSpi { +abstract class CKeyStore extends KeyStoreSpi { - public static final class MY extends KeyStore { + public static final class MY extends CKeyStore { public MY() { super("MY"); } } - public static final class ROOT extends KeyStore { + public static final class ROOT extends CKeyStore { public ROOT() { super("ROOT"); } } - class KeyEntry - { - private Key privateKey; - private X509Certificate certChain[]; + class KeyEntry { + private CKey privateKey; + private X509Certificate[] certChain; private String alias; - KeyEntry(Key key, X509Certificate[] chain) { + KeyEntry(CKey key, X509Certificate[] chain) { this(null, key, chain); } - KeyEntry(String alias, Key key, X509Certificate[] chain) { + KeyEntry(String alias, CKey key, X509Certificate[] chain) { this.privateKey = key; this.certChain = chain; /* @@ -91,16 +92,14 @@ abstract class KeyStore extends KeyStoreSpi { /** * Gets the alias for the keystore entry. */ - String getAlias() - { + String getAlias() { return alias; } /** * Sets the alias for the keystore entry. */ - void setAlias(String alias) - { + void setAlias(String alias) { // TODO - set friendly name prop in cert store this.alias = alias; } @@ -108,44 +107,42 @@ abstract class KeyStore extends KeyStoreSpi { /** * Gets the private key for the keystore entry. */ - Key getPrivateKey() - { + CKey getPrivateKey() { return privateKey; } /** * Sets the private key for the keystore entry. */ - void setPrivateKey(RSAPrivateCrtKey key) - throws InvalidKeyException, KeyStoreException - { + void setRSAPrivateKey(Key k) + throws InvalidKeyException, KeyStoreException { + RSAPrivateCrtKey key = (RSAPrivateCrtKey) k; byte[] modulusBytes = key.getModulus().toByteArray(); // Adjust key length due to sign bit int keyBitLength = (modulusBytes[0] == 0) - ? (modulusBytes.length - 1) * 8 - : modulusBytes.length * 8; + ? (modulusBytes.length - 1) * 8 + : modulusBytes.length * 8; - byte[] keyBlob = generatePrivateKeyBlob( - keyBitLength, - modulusBytes, - key.getPublicExponent().toByteArray(), - key.getPrivateExponent().toByteArray(), - key.getPrimeP().toByteArray(), - key.getPrimeQ().toByteArray(), - key.getPrimeExponentP().toByteArray(), - key.getPrimeExponentQ().toByteArray(), - key.getCrtCoefficient().toByteArray()); + byte[] keyBlob = generateRSAPrivateKeyBlob( + keyBitLength, + modulusBytes, + key.getPublicExponent().toByteArray(), + key.getPrivateExponent().toByteArray(), + key.getPrimeP().toByteArray(), + key.getPrimeQ().toByteArray(), + key.getPrimeExponentP().toByteArray(), + key.getPrimeExponentQ().toByteArray(), + key.getCrtCoefficient().toByteArray()); - privateKey = storePrivateKey(Objects.requireNonNull(keyBlob), - "{" + UUID.randomUUID().toString() + "}", keyBitLength); + privateKey = storePrivateKey("RSA", Objects.requireNonNull(keyBlob), + "{" + UUID.randomUUID().toString() + "}", keyBitLength); } /** * Gets the certificate chain for the keystore entry. */ - X509Certificate[] getCertificateChain() - { + X509Certificate[] getCertificateChain() { return certChain; } @@ -153,8 +150,7 @@ abstract class KeyStore extends KeyStoreSpi { * Sets the certificate chain for the keystore entry. */ void setCertificateChain(X509Certificate[] chain) - throws CertificateException, KeyStoreException - { + throws CertificateException, KeyStoreException { for (int i = 0; i < chain.length; i++) { byte[] encoding = chain[i].getEncoded(); if (i == 0 && privateKey != null) { @@ -186,6 +182,7 @@ abstract class KeyStore extends KeyStoreSpi { 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. @@ -200,11 +197,10 @@ abstract class KeyStore extends KeyStoreSpi { */ private final String storeName; - KeyStore(String storeName) { + CKeyStore(String storeName) { // Get the compatibility mode - String prop = - AccessController.doPrivileged( - new GetPropertyAction(KEYSTORE_COMPATIBILITY_MODE_PROP)); + String prop = AccessController.doPrivileged( + (PrivilegedAction) () -> System.getProperty(KEYSTORE_COMPATIBILITY_MODE_PROP)); if ("false".equalsIgnoreCase(prop)) { keyStoreCompatibilityMode = false; @@ -239,8 +235,7 @@ abstract class KeyStore extends KeyStoreSpi { * @exception UnrecoverableKeyException if the key cannot be recovered. */ public java.security.Key engineGetKey(String alias, char[] password) - throws NoSuchAlgorithmException, UnrecoverableKeyException - { + throws NoSuchAlgorithmException, UnrecoverableKeyException { if (alias == null) { return null; } @@ -269,8 +264,7 @@ abstract class KeyStore extends KeyStoreSpi { * alias identifies either a trusted certificate entry or a * key entry without a certificate chain). */ - public Certificate[] engineGetCertificateChain(String alias) - { + public Certificate[] engineGetCertificateChain(String alias) { if (alias == null) { return null; } @@ -299,8 +293,7 @@ abstract class KeyStore extends KeyStoreSpi { * @return the certificate, or null if the given alias does not exist or * does not contain a certificate. */ - public Certificate engineGetCertificate(String alias) - { + public Certificate engineGetCertificate(String alias) { if (alias == null) { return null; } @@ -363,8 +356,7 @@ abstract class KeyStore extends KeyStoreSpi { * some other reason. */ public void engineSetKeyEntry(String alias, java.security.Key key, - char[] password, Certificate[] chain) throws KeyStoreException - { + char[] password, Certificate[] chain) throws KeyStoreException { if (alias == null) { throw new KeyStoreException("alias must not be null"); } @@ -399,7 +391,7 @@ abstract class KeyStore extends KeyStoreSpi { entry.setAlias(alias); try { - entry.setPrivateKey((RSAPrivateCrtKey) key); + entry.setRSAPrivateKey(key); entry.setCertificateChain(xchain); } catch (CertificateException ce) { @@ -440,8 +432,7 @@ abstract class KeyStore extends KeyStoreSpi { */ public void engineSetKeyEntry(String alias, byte[] key, Certificate[] chain) - throws KeyStoreException - { + throws KeyStoreException { throw new UnsupportedOperationException( "Cannot assign the encoded key to the given alias."); } @@ -461,8 +452,7 @@ abstract class KeyStore extends KeyStoreSpi { * fails for some other reason. */ public void engineSetCertificateEntry(String alias, Certificate cert) - throws KeyStoreException - { + throws KeyStoreException { if (alias == null) { throw new KeyStoreException("alias must not be null"); } @@ -504,9 +494,7 @@ abstract class KeyStore extends KeyStoreSpi { * * @exception KeyStoreException if the entry cannot be removed. */ - public void engineDeleteEntry(String alias) - throws KeyStoreException - { + public void engineDeleteEntry(String alias) throws KeyStoreException { if (alias == null) { throw new KeyStoreException("alias must not be null"); } @@ -515,7 +503,7 @@ abstract class KeyStore extends KeyStoreSpi { if (entry != null) { // Get end-entity certificate and remove from system cert store X509Certificate[] certChain = entry.getCertificateChain(); - if (certChain != null) { + if (certChain != null && certChain.length > 0) { try { @@ -527,10 +515,10 @@ abstract class KeyStore extends KeyStoreSpi { throw new KeyStoreException("Cannot remove entry: ", e); } } - Key privateKey = entry.getPrivateKey(); + CKey privateKey = entry.getPrivateKey(); if (privateKey != null) { destroyKeyContainer( - Key.getContainerName(privateKey.getHCryptProvider())); + CKey.getContainerName(privateKey.getHCryptProvider())); } } } @@ -543,15 +531,12 @@ abstract class KeyStore extends KeyStoreSpi { public Enumeration engineAliases() { final Iterator iter = entries.keySet().iterator(); - return new Enumeration() - { - public boolean hasMoreElements() - { + return new Enumeration() { + public boolean hasMoreElements() { return iter.hasNext(); } - public String nextElement() - { + public String nextElement() { return iter.next(); } }; @@ -631,7 +616,9 @@ abstract class KeyStore extends KeyStoreSpi { for (Map.Entry mapEntry : entries.entrySet()) { KeyEntry entry = mapEntry.getValue(); - if (entry.certChain != null && entry.certChain[0].equals(cert)) { + if (entry.certChain != null && + entry.certChain.length > 0 && + entry.certChain[0].equals(cert)) { return entry.getAlias(); } } @@ -659,8 +646,7 @@ abstract class KeyStore extends KeyStoreSpi { * parameter is non-null. */ public void engineStore(OutputStream stream, char[] password) - throws IOException, NoSuchAlgorithmException, CertificateException - { + throws IOException, NoSuchAlgorithmException, CertificateException { if (stream != null && !keyStoreCompatibilityMode) { throw new IOException("Keystore output stream must be null"); } @@ -698,8 +684,7 @@ abstract class KeyStore extends KeyStoreSpi { * this provider's getName method. */ public void engineLoad(InputStream stream, char[] password) - throws IOException, NoSuchAlgorithmException, CertificateException - { + throws IOException, NoSuchAlgorithmException, CertificateException { if (stream != null && !keyStoreCompatibilityMode) { throw new IOException("Keystore input stream must be null"); } @@ -728,6 +713,11 @@ abstract class KeyStore extends KeyStoreSpi { } catch (KeyStoreException e) { throw new IOException(e); } + + if (debug != null) { + debug.println("MSCAPI keystore load: entry count: " + + entries.size()); + } } /** @@ -753,79 +743,67 @@ abstract class KeyStore extends KeyStoreSpi { /** * Generates a certificate chain from the collection of * certificates and stores the result into a key entry. - * This method is called by native code in libsunmscapi. + *

    + * This method is called by native codes in security.cpp. */ private void generateCertificateChain(String alias, - Collection certCollection) - { - try - { + Collection certCollection) { + try { X509Certificate[] certChain = new X509Certificate[certCollection.size()]; int i = 0; for (Iterator iter = - certCollection.iterator(); iter.hasNext(); i++) - { + certCollection.iterator(); iter.hasNext(); i++) { certChain[i] = (X509Certificate) iter.next(); } storeWithUniqueAlias(alias, new KeyEntry(alias, null, certChain)); - } - catch (Throwable e) - { + } catch (Throwable e) { // Ignore the exception and skip this entry - // If e is thrown, remember to deal with it in - // native code. + // TODO - throw CertificateException? } } /** - * Generates RSA key and certificate chain from the private key handle, + * Generates key and certificate chain from the private key handle, * collection of certificates and stores the result into key entries. - * This method is called by native code in libsunmscapi. + *

    + * This method is called by native codes in security.cpp. */ - private void generateRSAKeyAndCertificateChain(String alias, - long hCryptProv, long hCryptKey, int keyLength, - Collection certCollection) - { - try - { + private void generateKeyAndCertificateChain(boolean isRSA, String alias, + long hCryptProv, long hCryptKey, int keyLength, + Collection certCollection) { + try { X509Certificate[] certChain = new X509Certificate[certCollection.size()]; int i = 0; for (Iterator iter = - certCollection.iterator(); iter.hasNext(); i++) - { + certCollection.iterator(); iter.hasNext(); i++) { certChain[i] = (X509Certificate) iter.next(); } - storeWithUniqueAlias(alias, new KeyEntry(alias, - new RSAPrivateKey(new Key.NativeHandles(hCryptProv, - hCryptKey), keyLength), + CPrivateKey.of(isRSA ? "RSA" : "EC", hCryptProv, hCryptKey, keyLength), certChain)); - } - catch (Throwable e) - { + } catch (Throwable e) { // Ignore the exception and skip this entry - // If e is thrown, remember to deal with it in - // native code. + // TODO - throw CertificateException? } } /** * Generates certificates from byte data and stores into cert collection. - * This method is called by native code in libsunmscapi. + *

    + * This method is called by native codes in security.cpp. * * @param data Byte data. * @param certCollection Collection of certificates. */ private void generateCertificate(byte[] data, Collection certCollection) { - try - { + try { ByteArrayInputStream bis = new ByteArrayInputStream(data); // Obtain certificate factory @@ -837,26 +815,19 @@ abstract class KeyStore extends KeyStoreSpi { Collection c = certificateFactory.generateCertificates(bis); certCollection.addAll(c); - } - catch (CertificateException e) - { + } catch (CertificateException e) { // Ignore the exception and skip this certificate - // If e is thrown, remember to deal with it in - // native code. - } - catch (Throwable te) - { + // TODO - throw CertificateException? + } catch (Throwable te) { // Ignore the exception and skip this certificate - // If e is thrown, remember to deal with it in - // native code. + // TODO - throw CertificateException? } } /** * Returns the name of the keystore. */ - private String getName() - { + private String getName() { return storeName; } @@ -901,7 +872,7 @@ abstract class KeyStore extends KeyStoreSpi { /** * Generates a private-key BLOB from a key's components. */ - private native byte[] generatePrivateKeyBlob( + private native byte[] generateRSAPrivateKeyBlob( int keyBitLength, byte[] modulus, byte[] publicExponent, @@ -912,6 +883,6 @@ abstract class KeyStore extends KeyStoreSpi { byte[] exponentQ, byte[] crtCoefficient) throws InvalidKeyException; - private native RSAPrivateKey storePrivateKey(byte[] keyBlob, + private native CPrivateKey storePrivateKey(String alg, byte[] keyBlob, String keyContainerName, int keySize) throws KeyStoreException; } diff --git a/src/windows/classes/sun/security/mscapi/RSAPrivateKey.java b/src/windows/classes/sun/security/mscapi/CPrivateKey.java similarity index 54% rename from src/windows/classes/sun/security/mscapi/RSAPrivateKey.java rename to src/windows/classes/sun/security/mscapi/CPrivateKey.java index ca692dfa2f343b227fcd068075dae73f95926e98..60fb4fb6723062543be738ff691f1cc402b0c2d3 100644 --- a/src/windows/classes/sun/security/mscapi/RSAPrivateKey.java +++ b/src/windows/classes/sun/security/mscapi/CPrivateKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * 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,57 +28,52 @@ package sun.security.mscapi; import java.security.PrivateKey; /** - * The handle for an RSA private key using the Microsoft Crypto API. + * The handle for a private key using the Microsoft Crypto API. * * @author Stanley Man-Kit Ho * @since 1.6 */ -class RSAPrivateKey extends Key implements PrivateKey -{ +class CPrivateKey extends CKey implements PrivateKey { + private static final long serialVersionUID = 8113152807912338063L; - /** - * Construct an RSAPrivateKey object. - */ - RSAPrivateKey(long hCryptProv, long hCryptKey, int keyLength) - { - super(new NativeHandles(hCryptProv, hCryptKey), keyLength); + private CPrivateKey(String alg, NativeHandles handles, int keyLength) { + super(alg, handles, keyLength); + } + + // Called by native code inside security.cpp + static CPrivateKey of( + String alg, long hCryptProv, long hCryptKey, int keyLength) { + return of(alg, new NativeHandles(hCryptProv, hCryptKey), keyLength); } - /** - * Construct an RSAPrivateKey object. - */ - RSAPrivateKey(NativeHandles handles, int keyLength) - { - super(handles, keyLength); + public static CPrivateKey of(String alg, NativeHandles handles, int keyLength) { + return new CPrivateKey(alg, handles, keyLength); } - /** - * Returns the standard algorithm name for this key. For - * example, "RSA" would indicate that this key is a RSA key. - * See Appendix A in the - * Java Cryptography Architecture API Specification & Reference - * for information about standard algorithm names. - * - * @return the name of the algorithm associated with this key. - */ - public String getAlgorithm() - { - return "RSA"; + // this key does not support encoding + public String getFormat() { + return null; } - public String toString() - { - return "RSAPrivateKey [size=" + keyLength + " bits, type=" + - getKeyType(handles.hCryptKey) + ", container=" + - getContainerName(handles.hCryptProv) + "]"; + // this key does not support encoding + public byte[] getEncoded() { + return null; + } + + public String toString() { + if (handles.hCryptKey != 0) { + return algorithm + "PrivateKey [size=" + keyLength + " bits, type=" + + getKeyType(handles.hCryptKey) + ", container=" + + getContainerName(handles.hCryptProv) + "]"; + } else { + return algorithm + "PrivateKey [size=" + keyLength + " bits, type=CNG]"; + } } // This class is not serializable private void writeObject(java.io.ObjectOutputStream out) - throws java.io.IOException { - + throws java.io.IOException { throw new java.io.NotSerializableException(); } } diff --git a/src/windows/classes/sun/security/mscapi/CPublicKey.java b/src/windows/classes/sun/security/mscapi/CPublicKey.java new file mode 100644 index 0000000000000000000000000000000000000000..8a81c5dc32789e6153718eede5be4dac9cdf9483 --- /dev/null +++ b/src/windows/classes/sun/security/mscapi/CPublicKey.java @@ -0,0 +1,227 @@ +/* + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. + * 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.mscapi; + +import java.math.BigInteger; +import java.security.AlgorithmParameters; +import java.security.KeyException; +import java.security.KeyFactory; +import java.security.KeyRep; +import java.security.ProviderException; +import java.security.PublicKey; +import java.security.interfaces.ECPublicKey; +import java.security.interfaces.RSAPublicKey; +import java.security.spec.ECParameterSpec; +import java.security.spec.ECPoint; +import java.security.spec.ECPublicKeySpec; +import java.util.Arrays; + +import sun.security.rsa.RSAUtil.KeyType; +import sun.security.rsa.RSAPublicKeyImpl; +import sun.security.util.ECKeySizeParameterSpec; + +/** + * The handle for an RSA public key using the Microsoft Crypto API. + * + * @since 1.6 + */ +public abstract class CPublicKey extends CKey implements PublicKey { + + private static final long serialVersionUID = -2289561342425825391L; + + protected byte[] encoding = null; + + public static class CECPublicKey extends CPublicKey implements ECPublicKey { + + private ECPoint w = null; + private static final long serialVersionUID = 12L; + + CECPublicKey(NativeHandles handles, int keyLength) { + super("EC", handles, keyLength); + } + + @Override + public ECPoint getW() { + if (w == null) { + // See CKey::generateECBlob. + try { + byte[] blob = getPublicKeyBlob( + handles.hCryptProv, handles.hCryptKey); + int len = blob[8] & 0xff; + byte[] x = Arrays.copyOfRange(blob, 8, 8 + len); + byte[] y = Arrays.copyOfRange(blob, 8 + len, 8 + len + len); + w = new ECPoint(new BigInteger(1, x), new BigInteger(1, y)); + } catch (KeyException e) { + throw new ProviderException(e); + } + } + return w; + } + + @Override + public byte[] getEncoded() { + if (encoding == null) { + try { + encoding = KeyFactory.getInstance("EC").generatePublic( + new ECPublicKeySpec(getW(), getParams())) + .getEncoded(); + } catch (Exception e) { + // ignore + } + } + return encoding; + } + + @Override + public ECParameterSpec getParams() { + try { + AlgorithmParameters ap = AlgorithmParameters.getInstance("EC"); + ap.init(new ECKeySizeParameterSpec(keyLength)); + return ap.getParameterSpec(ECParameterSpec.class); + } catch (Exception e) { + throw new ProviderException(e); + } + } + + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append(algorithm + "PublicKey [size=").append(keyLength) + .append("]\n ECPoint: ").append(getW()) + .append("\n params: ").append(getParams()); + return sb.toString(); + } + } + + public static class CRSAPublicKey extends CPublicKey implements RSAPublicKey { + + private BigInteger modulus = null; + private BigInteger exponent = null; + private static final long serialVersionUID = 12L; + + CRSAPublicKey(NativeHandles handles, int keyLength) { + super("RSA", handles, keyLength); + } + + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append(algorithm + "PublicKey [size=").append(keyLength) + .append(" bits, type="); + if (handles.hCryptKey != 0) { + sb.append(getKeyType(handles.hCryptKey)) + .append(", container=").append(getContainerName(handles.hCryptProv)); + } else { + sb.append("CNG"); + } + sb.append("]\n modulus: ").append(getModulus()) + .append("\n public exponent: ").append(getPublicExponent()); + return sb.toString(); + } + + @Override + public BigInteger getPublicExponent() { + if (exponent == null) { + try { + byte[] publicKeyBlob = getPublicKeyBlob( + handles.hCryptProv, handles.hCryptKey); + exponent = new BigInteger(1, getExponent(publicKeyBlob)); + } catch (KeyException e) { + throw new ProviderException(e); + } + } + return exponent; + } + + @Override + public BigInteger getModulus() { + if (modulus == null) { + try { + byte[] publicKeyBlob = getPublicKeyBlob( + handles.hCryptProv, handles.hCryptKey); + modulus = new BigInteger(1, getModulus(publicKeyBlob)); + } catch (KeyException e) { + throw new ProviderException(e); + } + } + return modulus; + } + + @Override + public byte[] getEncoded() { + if (encoding == null) { + try { + encoding = RSAPublicKeyImpl.newKey(KeyType.RSA, null, + getModulus(), getPublicExponent()).getEncoded(); + } catch (KeyException e) { + // ignore + } + } + return encoding; + } + + private native byte[] getExponent(byte[] keyBlob) throws KeyException; + + private native byte[] getModulus(byte[] keyBlob) throws KeyException; + } + + // Called by native code inside security.cpp + static CPublicKey of( + String alg, long hCryptProv, long hCryptKey, int keyLength) { + return of(alg, new NativeHandles(hCryptProv, hCryptKey), keyLength); + } + + public static CPublicKey of( + String alg, NativeHandles handles, int keyLength) { + switch (alg) { + case "RSA": + return new CRSAPublicKey(handles, keyLength); + case "EC": + return new CECPublicKey(handles, keyLength); + default: + throw new AssertionError("Unsupported algorithm: " + alg); + } + } + + protected CPublicKey( + String alg, NativeHandles handles, int keyLength) { + super(alg, handles, keyLength); + } + + @Override + public String getFormat() { + return "X.509"; + } + + protected Object writeReplace() throws java.io.ObjectStreamException { + return new KeyRep(KeyRep.Type.PUBLIC, + getAlgorithm(), + getFormat(), + getEncoded()); + } + + // Returns the CAPI or CNG representation of the key. + native byte[] getPublicKeyBlob(long hCryptProv, long hCryptKey) + throws KeyException; +} diff --git a/src/windows/classes/sun/security/mscapi/RSACipher.java b/src/windows/classes/sun/security/mscapi/CRSACipher.java similarity index 95% rename from src/windows/classes/sun/security/mscapi/RSACipher.java rename to src/windows/classes/sun/security/mscapi/CRSACipher.java index 023725b62050b94e775eef149fe028d61c6ea410..95f6cbf80ea22722be59643bf92bd5984faf01cc 100644 --- a/src/windows/classes/sun/security/mscapi/RSACipher.java +++ b/src/windows/classes/sun/security/mscapi/CRSACipher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec; import sun.security.util.KeyUtil; /** - * RSA cipher implementation using the Microsoft Crypto API. + * Cipher implementation using the Microsoft Crypto API. * Supports RSA en/decryption and signing/verifying using PKCS#1 v1.5 padding. * * Objects should be instantiated by calling Cipher.getInstance() using the @@ -59,7 +59,7 @@ import sun.security.util.KeyUtil; * @author Andreas Sterbenz * @author Vincent Ryan */ -public final class RSACipher extends CipherSpi { +public final class CRSACipher extends CipherSpi { // constant for an empty byte array private final static byte[] B0 = new byte[0]; @@ -93,10 +93,10 @@ public final class RSACipher extends CipherSpi { private int outputSize; // the public key, if we were initialized using a public key - private sun.security.mscapi.Key publicKey; + private CKey publicKey; // the private key, if we were initialized using a private key - private sun.security.mscapi.Key privateKey; + private CKey privateKey; // cipher parameter for TLS RSA premaster secret private AlgorithmParameterSpec spec = null; @@ -104,7 +104,7 @@ public final class RSACipher extends CipherSpi { // the source of randomness private SecureRandom random; - public RSACipher() { + public CRSACipher() { paddingType = PAD_PKCS1; } @@ -159,6 +159,7 @@ public final class RSACipher extends CipherSpi { } // see JCE spec + @SuppressWarnings("deprecation") protected void engineInit(int opmode, Key key, AlgorithmParameterSpec params, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException { @@ -206,7 +207,7 @@ public final class RSACipher extends CipherSpi { throw new InvalidKeyException("Unknown mode: " + opmode); } - if (!(key instanceof sun.security.mscapi.Key)) { + if (!(key instanceof CKey)) { if (key instanceof java.security.interfaces.RSAPublicKey) { java.security.interfaces.RSAPublicKey rsaKey = (java.security.interfaces.RSAPublicKey) key; @@ -219,7 +220,7 @@ public final class RSACipher extends CipherSpi { // Check against the local and global values to make sure // the sizes are ok. Round up to the nearest byte. RSAKeyFactory.checkKeyLengths(((modulus.bitLength() + 7) & ~7), - exponent, -1, RSAKeyPairGenerator.KEY_SIZE_MAX); + exponent, -1, CKeyPairGenerator.RSA.KEY_SIZE_MAX); byte[] modulusBytes = modulus.toByteArray(); byte[] exponentBytes = exponent.toByteArray(); @@ -229,11 +230,11 @@ public final class RSACipher extends CipherSpi { ? (modulusBytes.length - 1) * 8 : modulusBytes.length * 8; - byte[] keyBlob = RSASignature.generatePublicKeyBlob( + byte[] keyBlob = CSignature.RSA.generatePublicKeyBlob( keyBitLength, modulusBytes, exponentBytes); try { - key = RSASignature.importPublicKey(keyBlob, keyBitLength); + key = CSignature.importPublicKey("RSA", keyBlob, keyBitLength); } catch (KeyStoreException e) { throw new InvalidKeyException(e); @@ -246,12 +247,12 @@ public final class RSACipher extends CipherSpi { if (key instanceof PublicKey) { mode = encrypt ? MODE_ENCRYPT : MODE_VERIFY; - publicKey = (sun.security.mscapi.Key)key; + publicKey = (CKey)key; privateKey = null; outputSize = publicKey.length() / 8; } else if (key instanceof PrivateKey) { mode = encrypt ? MODE_SIGN : MODE_DECRYPT; - privateKey = (sun.security.mscapi.Key)key; + privateKey = (CKey)key; publicKey = null; outputSize = privateKey.length() / 8; } else { @@ -369,6 +370,7 @@ public final class RSACipher extends CipherSpi { } // see JCE spec + @SuppressWarnings("deprecation") protected java.security.Key engineUnwrap(byte[] wrappedKey, String algorithm, int type) throws InvalidKeyException, NoSuchAlgorithmException { @@ -415,8 +417,8 @@ public final class RSACipher extends CipherSpi { // see JCE spec protected int engineGetKeySize(Key key) throws InvalidKeyException { - if (key instanceof sun.security.mscapi.Key) { - return ((sun.security.mscapi.Key) key).length(); + if (key instanceof CKey) { + return ((CKey) key).length(); } else if (key instanceof RSAKey) { return ((RSAKey) key).getModulus().bitLength(); diff --git a/src/windows/classes/sun/security/mscapi/CSignature.java b/src/windows/classes/sun/security/mscapi/CSignature.java new file mode 100644 index 0000000000000000000000000000000000000000..b12d95719026500e2f6d420cbb4989495a9ec3cc --- /dev/null +++ b/src/windows/classes/sun/security/mscapi/CSignature.java @@ -0,0 +1,954 @@ +/* + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. + * 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.mscapi; + +import java.nio.ByteBuffer; +import java.security.*; +import java.security.interfaces.ECPublicKey; +import java.security.interfaces.RSAPublicKey; +import java.security.spec.AlgorithmParameterSpec; +import java.math.BigInteger; +import java.security.spec.MGF1ParameterSpec; +import java.security.spec.PSSParameterSpec; +import java.util.Locale; + +import sun.security.rsa.RSAKeyFactory; +import sun.security.util.ECUtil; +import sun.security.util.KeyUtil; + +/** + * Signature implementation. + * + * Objects should be instantiated by calling Signature.getInstance() using the + * following algorithm names: + * + * . "NONEwithRSA" + * . "SHA1withRSA" + * . "SHA256withRSA" + * . "SHA384withRSA" + * . "SHA512withRSA" + * . "MD5withRSA" + * . "MD2withRSA" + * . "RSASSA-PSS" + * . "SHA1withECDSA" + * . "SHA224withECDSA" + * . "SHA256withECDSA" + * . "SHA384withECDSA" + * . "SHA512withECDSA" + * + * NOTE: RSA keys must be at least 512 bits long. + * + * NOTE: NONEwithRSA must be supplied with a pre-computed message digest. + * Only the following digest algorithms are supported: MD5, SHA-1, + * SHA-256, SHA-384, SHA-512 and a special-purpose digest + * algorithm which is a concatenation of SHA-1 and MD5 digests. + * + * @since 1.6 + * @author Stanley Man-Kit Ho + */ +abstract class CSignature extends SignatureSpi { + // private key algorithm name + protected String keyAlgorithm; + + // message digest implementation we use + protected MessageDigest messageDigest; + + // message digest name + protected String messageDigestAlgorithm; + + // flag indicating whether the digest has been reset + protected boolean needsReset; + + // the signing key + protected CPrivateKey privateKey = null; + + // the verification key + protected CPublicKey publicKey = null; + + /** + * Constructs a new CSignature. Used by subclasses. + */ + CSignature(String keyName, String digestName) { + + this.keyAlgorithm = keyName; + if (digestName != null) { + try { + messageDigest = MessageDigest.getInstance(digestName); + // Get the digest's canonical name + messageDigestAlgorithm = messageDigest.getAlgorithm(); + } catch (NoSuchAlgorithmException e) { + throw new ProviderException(e); + } + } else { + messageDigest = null; + messageDigestAlgorithm = null; + } + needsReset = false; + } + + static class RSA extends CSignature { + + public RSA(String digestAlgorithm) { + super("RSA", digestAlgorithm); + } + + // initialize for signing. See JCA doc + @Override + protected void engineInitSign(PrivateKey key) throws InvalidKeyException { + if (key == null) { + throw new InvalidKeyException("Key cannot be null"); + } + if ((key instanceof CPrivateKey) == false + || !key.getAlgorithm().equalsIgnoreCase("RSA")) { + throw new InvalidKeyException("Key type not supported: " + + key.getClass() + " " + key.getAlgorithm()); + } + privateKey = (CPrivateKey) key; + + // Check against the local and global values to make sure + // the sizes are ok. Round up to nearest byte. + RSAKeyFactory.checkKeyLengths(((privateKey.length() + 7) & ~7), + null, CKeyPairGenerator.RSA.KEY_SIZE_MIN, + CKeyPairGenerator.RSA.KEY_SIZE_MAX); + + this.publicKey = null; + resetDigest(); + } + + // initialize for signing. See JCA doc + @Override + protected void engineInitVerify(PublicKey key) throws InvalidKeyException { + if (key == null) { + throw new InvalidKeyException("Key cannot be null"); + } + // This signature accepts only RSAPublicKey + if ((key instanceof RSAPublicKey) == false) { + throw new InvalidKeyException("Key type not supported: " + + key.getClass()); + } + + + if ((key instanceof CPublicKey) == false) { + + // convert key to MSCAPI format + java.security.interfaces.RSAPublicKey rsaKey = + (java.security.interfaces.RSAPublicKey) key; + + BigInteger modulus = rsaKey.getModulus(); + BigInteger exponent = rsaKey.getPublicExponent(); + + // Check against the local and global values to make sure + // the sizes are ok. Round up to the nearest byte. + RSAKeyFactory.checkKeyLengths(((modulus.bitLength() + 7) & ~7), + exponent, -1, CKeyPairGenerator.RSA.KEY_SIZE_MAX); + + byte[] modulusBytes = modulus.toByteArray(); + byte[] exponentBytes = exponent.toByteArray(); + + // Adjust key length due to sign bit + int keyBitLength = (modulusBytes[0] == 0) + ? (modulusBytes.length - 1) * 8 + : modulusBytes.length * 8; + + byte[] keyBlob = generatePublicKeyBlob( + keyBitLength, modulusBytes, exponentBytes); + + try { + publicKey = importPublicKey("RSA", keyBlob, keyBitLength); + + } catch (KeyStoreException e) { + throw new InvalidKeyException(e); + } + + } else { + publicKey = (CPublicKey) key; + } + + this.privateKey = null; + resetDigest(); + } + + /** + * Returns the signature bytes of all the data + * updated so far. + * The format of the signature depends on the underlying + * signature scheme. + * + * @return the signature bytes of the signing operation's result. + * + * @exception SignatureException if the engine is not + * initialized properly or if this signature algorithm is unable to + * process the input data provided. + */ + @Override + protected byte[] engineSign() throws SignatureException { + + byte[] hash = getDigestValue(); + + if (privateKey.getHCryptKey() == 0) { + return signCngHash(1, hash, hash.length, + 0, + this instanceof NONEwithRSA ? null : messageDigestAlgorithm, + privateKey.getHCryptProvider(), 0); + } else { + // Omit the hash OID when generating a NONEwithRSA signature + boolean noHashOID = this instanceof NONEwithRSA; + // Sign hash using MS Crypto APIs + byte[] result = signHash(noHashOID, hash, hash.length, + messageDigestAlgorithm, privateKey.getHCryptProvider(), + privateKey.getHCryptKey()); + + // Convert signature array from little endian to big endian + return convertEndianArray(result); + } + } + + /** + * Verifies the passed-in signature. + * + * @param sigBytes the signature bytes to be verified. + * + * @return true if the signature was verified, false if not. + * + * @exception SignatureException if the engine is not + * initialized properly, the passed-in signature is improperly + * encoded or of the wrong type, if this signature algorithm is unable to + * process the input data provided, etc. + */ + @Override + protected boolean engineVerify(byte[] sigBytes) + throws SignatureException { + byte[] hash = getDigestValue(); + + if (publicKey.getHCryptKey() == 0) { + return verifyCngSignedHash( + 1, hash, hash.length, + sigBytes, sigBytes.length, + 0, + messageDigestAlgorithm, + publicKey.getHCryptProvider(), + 0); + } else { + return verifySignedHash(hash, hash.length, + messageDigestAlgorithm, convertEndianArray(sigBytes), + sigBytes.length, publicKey.getHCryptProvider(), + publicKey.getHCryptKey()); + } + } + + /** + * Generates a public-key BLOB from a key's components. + */ + // used by CRSACipher + static native byte[] generatePublicKeyBlob( + int keyBitLength, byte[] modulus, byte[] publicExponent) + throws InvalidKeyException; + + } + + // Nested class for NONEwithRSA signatures + public static final class NONEwithRSA extends RSA { + + // the longest supported digest is 512 bits (SHA-512) + private static final int RAW_RSA_MAX = 64; + + private final byte[] precomputedDigest; + private int offset = 0; + + public NONEwithRSA() { + super(null); + precomputedDigest = new byte[RAW_RSA_MAX]; + } + + // Stores the precomputed message digest value. + @Override + protected void engineUpdate(byte b) throws SignatureException { + if (offset >= precomputedDigest.length) { + offset = RAW_RSA_MAX + 1; + return; + } + precomputedDigest[offset++] = b; + } + + // Stores the precomputed message digest value. + @Override + protected void engineUpdate(byte[] b, int off, int len) + throws SignatureException { + if (len > (precomputedDigest.length - offset)) { + offset = RAW_RSA_MAX + 1; + return; + } + System.arraycopy(b, off, precomputedDigest, offset, len); + offset += len; + } + + // Stores the precomputed message digest value. + @Override + protected void engineUpdate(ByteBuffer byteBuffer) { + int len = byteBuffer.remaining(); + if (len <= 0) { + return; + } + if (len > (precomputedDigest.length - offset)) { + offset = RAW_RSA_MAX + 1; + return; + } + byteBuffer.get(precomputedDigest, offset, len); + offset += len; + } + + @Override + protected void resetDigest(){ + offset = 0; + } + + // Returns the precomputed message digest value. + @Override + protected byte[] getDigestValue() throws SignatureException { + if (offset > RAW_RSA_MAX) { + throw new SignatureException("Message digest is too long"); + } + + // Determine the digest algorithm from the digest length + if (offset == 20) { + setDigestName("SHA1"); + } else if (offset == 36) { + setDigestName("SHA1+MD5"); + } else if (offset == 32) { + setDigestName("SHA-256"); + } else if (offset == 48) { + setDigestName("SHA-384"); + } else if (offset == 64) { + setDigestName("SHA-512"); + } else if (offset == 16) { + setDigestName("MD5"); + } else { + throw new SignatureException( + "Message digest length is not supported"); + } + + byte[] result = new byte[offset]; + System.arraycopy(precomputedDigest, 0, result, 0, offset); + offset = 0; + + return result; + } + } + + public static final class SHA1withRSA extends RSA { + public SHA1withRSA() { + super("SHA1"); + } + } + + public static final class SHA256withRSA extends RSA { + public SHA256withRSA() { + super("SHA-256"); + } + } + + public static final class SHA384withRSA extends RSA { + public SHA384withRSA() { + super("SHA-384"); + } + } + + public static final class SHA512withRSA extends RSA { + public SHA512withRSA() { + super("SHA-512"); + } + } + + public static final class MD5withRSA extends RSA { + public MD5withRSA() { + super("MD5"); + } + } + + public static final class MD2withRSA extends RSA { + public MD2withRSA() { + super("MD2"); + } + } + + public static final class SHA1withECDSA extends ECDSA { + public SHA1withECDSA() { + super("SHA-1"); + } + } + + public static final class SHA224withECDSA extends ECDSA { + public SHA224withECDSA() { + super("SHA-224"); + } + } + + public static final class SHA256withECDSA extends ECDSA { + public SHA256withECDSA() { + super("SHA-256"); + } + } + + public static final class SHA384withECDSA extends ECDSA { + public SHA384withECDSA() { + super("SHA-384"); + } + } + + public static final class SHA512withECDSA extends ECDSA { + public SHA512withECDSA() { + super("SHA-512"); + } + } + + static class ECDSA extends CSignature { + + public ECDSA(String messageDigestAlgorithm) { + super("EC", messageDigestAlgorithm); + } + + // initialize for signing. See JCA doc + @Override + protected void engineInitSign(PrivateKey key) throws InvalidKeyException { + if (key == null) { + throw new InvalidKeyException("Key cannot be null"); + } + if ((key instanceof CPrivateKey) == false + || !key.getAlgorithm().equalsIgnoreCase("EC")) { + throw new InvalidKeyException("Key type not supported: " + + key.getClass() + " " + key.getAlgorithm()); + } + privateKey = (CPrivateKey) key; + + this.publicKey = null; + resetDigest(); + } + + // initialize for signing. See JCA doc + @Override + protected void engineInitVerify(PublicKey key) throws InvalidKeyException { + if (key == null) { + throw new InvalidKeyException("Key cannot be null"); + } + // This signature accepts only ECPublicKey + if ((key instanceof ECPublicKey) == false) { + throw new InvalidKeyException("Key type not supported: " + + key.getClass()); + } + + if ((key instanceof CPublicKey) == false) { + try { + publicKey = importECPublicKey("EC", + CKey.generateECBlob(key), + KeyUtil.getKeySize(key)); + } catch (KeyStoreException e) { + throw new InvalidKeyException(e); + } + } else { + publicKey = (CPublicKey) key; + } + + this.privateKey = null; + resetDigest(); + } + + @Override + protected byte[] engineSign() throws SignatureException { + byte[] hash = getDigestValue(); + byte[] raw = signCngHash(0, hash, hash.length, + 0, + null, + privateKey.getHCryptProvider(), 0); + return ECUtil.encodeSignature(raw); + } + + @Override + protected boolean engineVerify(byte[] sigBytes) throws SignatureException { + byte[] hash = getDigestValue(); + sigBytes = ECUtil.decodeSignature(sigBytes); + return verifyCngSignedHash( + 0, + hash, hash.length, + sigBytes, sigBytes.length, + 0, + null, + publicKey.getHCryptProvider(), + 0 + ); + } + } + + public static final class PSS extends RSA { + + private PSSParameterSpec pssParams = null; + + // Workaround: Cannot import raw public key to CNG. This signature + // will be used for verification if key is not from MSCAPI. + private Signature fallbackSignature; + + public PSS() { + super(null); + } + + @Override + protected void engineInitSign(PrivateKey key) throws InvalidKeyException { + super.engineInitSign(key); + fallbackSignature = null; + } + + @Override + protected void engineInitVerify(PublicKey key) throws InvalidKeyException { + if (key == null) { + throw new InvalidKeyException("Key cannot be null"); + } + // This signature accepts only RSAPublicKey + if ((key instanceof java.security.interfaces.RSAPublicKey) == false) { + throw new InvalidKeyException("Key type not supported: " + + key.getClass()); + } + + this.privateKey = null; + + if (key instanceof CPublicKey) { + fallbackSignature = null; + publicKey = (CPublicKey) key; + } else { + if (fallbackSignature == null) { + try { + fallbackSignature = Signature.getInstance( + "RSASSA-PSS", "SunRsaSign"); + } catch (NoSuchAlgorithmException | NoSuchProviderException e) { + throw new InvalidKeyException("Invalid key", e); + } + } + fallbackSignature.initVerify(key); + if (pssParams != null) { + try { + fallbackSignature.setParameter(pssParams); + } catch (InvalidAlgorithmParameterException e) { + throw new InvalidKeyException("Invalid params", e); + } + } + publicKey = null; + } + resetDigest(); + } + + @Override + protected void engineUpdate(byte b) throws SignatureException { + ensureInit(); + if (fallbackSignature != null) { + fallbackSignature.update(b); + } else { + messageDigest.update(b); + } + needsReset = true; + } + + @Override + protected void engineUpdate(byte[] b, int off, int len) throws SignatureException { + ensureInit(); + if (fallbackSignature != null) { + fallbackSignature.update(b, off, len); + } else { + messageDigest.update(b, off, len); + } + needsReset = true; + } + + @Override + protected void engineUpdate(ByteBuffer input) { + try { + ensureInit(); + } catch (SignatureException se) { + // hack for working around API bug + throw new RuntimeException(se.getMessage()); + } + if (fallbackSignature != null) { + try { + fallbackSignature.update(input); + } catch (SignatureException se) { + // hack for working around API bug + throw new RuntimeException(se.getMessage()); + } + } else { + messageDigest.update(input); + } + needsReset = true; + } + + @Override + protected byte[] engineSign() throws SignatureException { + ensureInit(); + byte[] hash = getDigestValue(); + return signCngHash(2, hash, hash.length, + pssParams.getSaltLength(), + ((MGF1ParameterSpec) + pssParams.getMGFParameters()).getDigestAlgorithm(), + privateKey.getHCryptProvider(), privateKey.getHCryptKey()); + } + + @Override + protected boolean engineVerify(byte[] sigBytes) throws SignatureException { + ensureInit(); + if (fallbackSignature != null) { + needsReset = false; + return fallbackSignature.verify(sigBytes); + } else { + byte[] hash = getDigestValue(); + return verifyCngSignedHash( + 2, hash, hash.length, + sigBytes, sigBytes.length, + pssParams.getSaltLength(), + ((MGF1ParameterSpec) + pssParams.getMGFParameters()).getDigestAlgorithm(), + publicKey.getHCryptProvider(), + publicKey.getHCryptKey() + ); + } + } + + @Override + protected void engineSetParameter(AlgorithmParameterSpec params) + throws InvalidAlgorithmParameterException { + if (needsReset) { + throw new ProviderException + ("Cannot set parameters during operations"); + } + this.pssParams = validateSigParams(params); + if (fallbackSignature != null) { + fallbackSignature.setParameter(params); + } + } + + @Override + protected AlgorithmParameters engineGetParameters() { + AlgorithmParameters ap = null; + if (this.pssParams != null) { + try { + ap = AlgorithmParameters.getInstance("RSASSA-PSS"); + ap.init(this.pssParams); + } catch (GeneralSecurityException gse) { + throw new ProviderException(gse.getMessage()); + } + } + return ap; + } + + private void ensureInit() throws SignatureException { + if (this.privateKey == null && this.publicKey == null + && fallbackSignature == null) { + throw new SignatureException("Missing key"); + } + if (this.pssParams == null) { + // Parameters are required for signature verification + throw new SignatureException + ("Parameters required for RSASSA-PSS signatures"); + } + if (fallbackSignature == null && messageDigest == null) { + // This could happen if initVerify(softKey), setParameter(), + // and initSign() were called. No messageDigest. Create it. + try { + messageDigest = MessageDigest + .getInstance(pssParams.getDigestAlgorithm()); + } catch (NoSuchAlgorithmException e) { + throw new SignatureException(e); + } + } + } + + /** + * Validate the specified Signature PSS parameters. + */ + private PSSParameterSpec validateSigParams(AlgorithmParameterSpec p) + throws InvalidAlgorithmParameterException { + + if (p == null) { + throw new InvalidAlgorithmParameterException + ("Parameters cannot be null"); + } + + if (!(p instanceof PSSParameterSpec)) { + throw new InvalidAlgorithmParameterException + ("parameters must be type PSSParameterSpec"); + } + + // no need to validate again if same as current signature parameters + PSSParameterSpec params = (PSSParameterSpec) p; + if (params == this.pssParams) return params; + + // now sanity check the parameter values + if (!(params.getMGFAlgorithm().equalsIgnoreCase("MGF1"))) { + throw new InvalidAlgorithmParameterException("Only supports MGF1"); + + } + + if (params.getTrailerField() != PSSParameterSpec.TRAILER_FIELD_BC) { + throw new InvalidAlgorithmParameterException + ("Only supports TrailerFieldBC(1)"); + } + + AlgorithmParameterSpec algSpec = params.getMGFParameters(); + if (!(algSpec instanceof MGF1ParameterSpec)) { + throw new InvalidAlgorithmParameterException + ("Only support MGF1ParameterSpec"); + } + + MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)algSpec; + + String msgHashAlg = params.getDigestAlgorithm() + .toLowerCase(Locale.ROOT).replaceAll("-", ""); + if (msgHashAlg.equals("sha")) { + msgHashAlg = "sha1"; + } + String mgf1HashAlg = mgfSpec.getDigestAlgorithm() + .toLowerCase(Locale.ROOT).replaceAll("-", ""); + if (mgf1HashAlg.equals("sha")) { + mgf1HashAlg = "sha1"; + } + + if (!mgf1HashAlg.equals(msgHashAlg)) { + throw new InvalidAlgorithmParameterException + ("MGF1 hash must be the same as message hash"); + } + + return params; + } + } + + /** + * Sign hash using CNG API with HCRYPTKEY. + * @param type 0 no padding, 1, pkcs1, 2, pss + */ + native static byte[] signCngHash( + int type, byte[] hash, + int hashSize, int saltLength, String hashAlgorithm, + long hCryptProv, long nCryptKey) + throws SignatureException; + + /** + * Verify a signed hash using CNG API with HCRYPTKEY. + * @param type 0 no padding, 1, pkcs1, 2, pss + */ + private native static boolean verifyCngSignedHash( + int type, byte[] hash, int hashSize, + byte[] signature, int signatureSize, + int saltLength, String hashAlgorithm, + long hCryptProv, long hKey) throws SignatureException; + + /** + * Resets the message digest if needed. + */ + protected void resetDigest() { + if (needsReset) { + if (messageDigest != null) { + messageDigest.reset(); + } + needsReset = false; + } + } + + protected byte[] getDigestValue() throws SignatureException { + needsReset = false; + return messageDigest.digest(); + } + + protected void setDigestName(String name) { + messageDigestAlgorithm = name; + } + + /** + * Updates the data to be signed or verified + * using the specified byte. + * + * @param b the byte to use for the update. + * + * @exception SignatureException if the engine is not initialized + * properly. + */ + @Override + protected void engineUpdate(byte b) throws SignatureException { + messageDigest.update(b); + needsReset = true; + } + + /** + * Updates the data to be signed or verified, using the + * specified array of bytes, starting at the specified offset. + * + * @param b the array of bytes + * @param off the offset to start from in the array of bytes + * @param len the number of bytes to use, starting at offset + * + * @exception SignatureException if the engine is not initialized + * properly + */ + @Override + protected void engineUpdate(byte[] b, int off, int len) + throws SignatureException { + messageDigest.update(b, off, len); + needsReset = true; + } + + /** + * Updates the data to be signed or verified, using the + * specified ByteBuffer. + * + * @param input the ByteBuffer + */ + @Override + protected void engineUpdate(ByteBuffer input) { + messageDigest.update(input); + needsReset = true; + } + + /** + * Convert array from big endian to little endian, or vice versa. + */ + private static byte[] convertEndianArray(byte[] byteArray) { + if (byteArray == null || byteArray.length == 0) + return byteArray; + + byte [] retval = new byte[byteArray.length]; + + // make it big endian + for (int i=0;i < byteArray.length;i++) + retval[i] = byteArray[byteArray.length - i - 1]; + + return retval; + } + + /** + * Sign hash using Microsoft Crypto API with HCRYPTKEY. + * The returned data is in little-endian. + */ + private native static byte[] signHash(boolean noHashOID, byte[] hash, + int hashSize, String hashAlgorithm, long hCryptProv, long hCryptKey) + throws SignatureException; + + /** + * Verify a signed hash using Microsoft Crypto API with HCRYPTKEY. + */ + private native static boolean verifySignedHash(byte[] hash, int hashSize, + String hashAlgorithm, byte[] signature, int signatureSize, + long hCryptProv, long hCryptKey) throws SignatureException; + + /** + * Sets the specified algorithm parameter to the specified + * value. This method supplies a general-purpose mechanism through + * which it is possible to set the various parameters of this object. + * A parameter may be any settable parameter for the algorithm, such as + * a parameter size, or a source of random bits for signature generation + * (if appropriate), or an indication of whether or not to perform + * a specific but optional computation. A uniform algorithm-specific + * naming scheme for each parameter is desirable but left unspecified + * at this time. + * + * @param param the string identifier of the parameter. + * + * @param value the parameter value. + * + * @exception InvalidParameterException if param is an + * invalid parameter for this signature algorithm engine, + * the parameter is already set + * and cannot be set again, a security exception occurs, and so on. + * + * @deprecated Replaced by {@link + * #engineSetParameter(java.security.spec.AlgorithmParameterSpec) + * engineSetParameter}. + */ + @Override + @Deprecated + protected void engineSetParameter(String param, Object value) + throws InvalidParameterException { + throw new InvalidParameterException("Parameter not supported"); + } + + /** + * Sets this signature engine with the specified algorithm parameter. + * + * @param params the parameters + * + * @exception InvalidAlgorithmParameterException if the given + * parameter is invalid + */ + @Override + protected void engineSetParameter(AlgorithmParameterSpec params) + throws InvalidAlgorithmParameterException { + if (params != null) { + throw new InvalidAlgorithmParameterException("No parameter accepted"); + } + } + + /** + * Gets the value of the specified algorithm parameter. + * This method supplies a general-purpose mechanism through which it + * is possible to get the various parameters of this object. A parameter + * may be any settable parameter for the algorithm, such as a parameter + * size, or a source of random bits for signature generation (if + * appropriate), or an indication of whether or not to perform a + * specific but optional computation. A uniform algorithm-specific + * naming scheme for each parameter is desirable but left unspecified + * at this time. + * + * @param param the string name of the parameter. + * + * @return the object that represents the parameter value, or null if + * there is none. + * + * @exception InvalidParameterException if param is an + * invalid parameter for this engine, or another exception occurs while + * trying to get this parameter. + * + * @deprecated + */ + @Override + @Deprecated + protected Object engineGetParameter(String param) + throws InvalidParameterException { + throw new InvalidParameterException("Parameter not supported"); + } + + /** + * Gets the algorithm parameter from this signature engine. + * + * @return the parameter, or null if no parameter is used. + */ + @Override + protected AlgorithmParameters engineGetParameters() { + return null; + } + + /** + * Imports a public-key BLOB. + */ + // used by CRSACipher + static native CPublicKey importPublicKey( + String alg, byte[] keyBlob, int keySize) throws KeyStoreException; + + static native CPublicKey importECPublicKey( + String alg, byte[] keyBlob, int keySize) throws KeyStoreException; +} diff --git a/src/windows/classes/sun/security/mscapi/Key.java b/src/windows/classes/sun/security/mscapi/Key.java deleted file mode 100644 index 8154c489a95a1c1b7d0efc2173531193061f22fb..0000000000000000000000000000000000000000 --- a/src/windows/classes/sun/security/mscapi/Key.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 2005, 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. - */ - -package sun.security.mscapi; - -import sun.security.util.Length; - -/** - * The handle for an RSA or DSA key using the Microsoft Crypto API. - * - * @see RSAPrivateKey - * @see RSAPublicKey - * - * @since 1.6 - * @author Stanley Man-Kit Ho - */ -abstract class Key implements java.security.Key, Length -{ - private static final long serialVersionUID = -1088859394025049194L; - - static class NativeHandles { - long hCryptProv = 0; - long hCryptKey = 0; - - public NativeHandles(long hCryptProv, long hCryptKey) { - this.hCryptProv = hCryptProv; - this.hCryptKey = hCryptKey; - } - - /** - * Finalization method - */ - protected void finalize() throws Throwable - { - try { - synchronized(this) - { - cleanUp(hCryptProv, hCryptKey); - hCryptProv = 0; - hCryptKey = 0; - } - - } finally { - super.finalize(); - } - } - } - - protected NativeHandles handles; - - // Key length - protected int keyLength = 0; - - /** - * Construct a Key object. - */ - protected Key(NativeHandles handles, int keyLength) - { - this.handles = handles; - this.keyLength = keyLength; - } - - /** - * Native method to cleanup the key handle. - */ - private native static void cleanUp(long hCryptProv, long hCryptKey); - - /** - * Return bit length of the key. - */ - @Override - public int length() - { - return keyLength; - } - - - /** - * Return native HCRYPTKEY handle. - */ - public long getHCryptKey() - { - return handles.hCryptKey; - } - - /** - * Return native HCRYPTPROV handle. - */ - public long getHCryptProvider() - { - return handles.hCryptProv; - } - - /** - * Returns the standard algorithm name for this key. For - * example, "RSA" would indicate that this key is a RSA key. - * See Appendix A in the - * Java Cryptography Architecture API Specification & Reference - * for information about standard algorithm names. - * - * @return the name of the algorithm associated with this key. - */ - public abstract String getAlgorithm(); - - /** - * Returns the name of the primary encoding format of this key, - * or null if this key does not support encoding. - * The primary encoding format is - * named in terms of the appropriate ASN.1 data format, if an - * ASN.1 specification for this key exists. - * For example, the name of the ASN.1 data format for public - * keys is SubjectPublicKeyInfo, as - * defined by the X.509 standard; in this case, the returned format is - * "X.509". Similarly, - * the name of the ASN.1 data format for private keys is - * PrivateKeyInfo, - * as defined by the PKCS #8 standard; in this case, the returned format is - * "PKCS#8". - * - * @return the primary encoding format of the key. - */ - public String getFormat() - { - return null; - } - - /** - * Returns the key in its primary encoding format, or null - * if this key does not support encoding. - * - * @return the encoded key, or null if the key does not support - * encoding. - */ - public byte[] getEncoded() - { - return null; - } - - protected native static String getContainerName(long hCryptProv); - - protected native static String getKeyType(long hCryptKey); -} diff --git a/src/windows/classes/sun/security/mscapi/RSAKeyPairGenerator.java b/src/windows/classes/sun/security/mscapi/RSAKeyPairGenerator.java deleted file mode 100644 index 4222dee1ce56a19ebaf29a174f3cb91b250ca623..0000000000000000000000000000000000000000 --- a/src/windows/classes/sun/security/mscapi/RSAKeyPairGenerator.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. 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.mscapi; - -import java.util.UUID; -import java.security.*; -import java.security.spec.AlgorithmParameterSpec; -import java.security.spec.RSAKeyGenParameterSpec; - -import sun.security.jca.JCAUtil; -import sun.security.rsa.RSAKeyFactory; -import static sun.security.util.SecurityProviderConstants.DEF_RSA_KEY_SIZE; - -/** - * RSA keypair generator. - * - * Standard algorithm, minimum key length is 512 bit, maximum is 16,384. - * Generates a private key that is exportable. - * - * @since 1.6 - */ -public final class RSAKeyPairGenerator extends KeyPairGeneratorSpi { - - // Supported by Microsoft Base, Strong and Enhanced Cryptographic Providers - static final int KEY_SIZE_MIN = 512; // disallow MSCAPI min. of 384 - static final int KEY_SIZE_MAX = 16384; - - // size of the key to generate, KEY_SIZE_MIN <= keySize <= KEY_SIZE_MAX - private int keySize; - - public RSAKeyPairGenerator() { - // initialize to default in case the app does not call initialize() - initialize(DEF_RSA_KEY_SIZE, null); - } - - // initialize the generator. See JCA doc - // random is always ignored - public void initialize(int keySize, SecureRandom random) { - - try { - RSAKeyFactory.checkKeyLengths(keySize, null, - KEY_SIZE_MIN, KEY_SIZE_MAX); - } catch (InvalidKeyException e) { - throw new InvalidParameterException(e.getMessage()); - } - - this.keySize = keySize; - } - - // second initialize method. See JCA doc - // random and exponent are always ignored - public void initialize(AlgorithmParameterSpec params, SecureRandom random) - throws InvalidAlgorithmParameterException { - - int tmpSize; - if (params == null) { - tmpSize = DEF_RSA_KEY_SIZE; - } else if (params instanceof RSAKeyGenParameterSpec) { - - if (((RSAKeyGenParameterSpec) params).getPublicExponent() != null) { - throw new InvalidAlgorithmParameterException - ("Exponent parameter is not supported"); - } - tmpSize = ((RSAKeyGenParameterSpec) params).getKeysize(); - - } else { - throw new InvalidAlgorithmParameterException - ("Params must be an instance of RSAKeyGenParameterSpec"); - } - - try { - RSAKeyFactory.checkKeyLengths(tmpSize, null, - KEY_SIZE_MIN, KEY_SIZE_MAX); - } catch (InvalidKeyException e) { - throw new InvalidAlgorithmParameterException( - "Invalid Key sizes", e); - } - - this.keySize = tmpSize; - } - - // generate the keypair. See JCA doc - public KeyPair generateKeyPair() { - - try { - - // Generate each keypair in a unique key container - RSAKeyPair keys = - generateRSAKeyPair(keySize, - "{" + UUID.randomUUID().toString() + "}"); - - return new KeyPair(keys.getPublic(), keys.getPrivate()); - - } catch (KeyException e) { - throw new ProviderException(e); - } - } - - private static native RSAKeyPair generateRSAKeyPair(int keySize, - String keyContainerName) throws KeyException; -} diff --git a/src/windows/classes/sun/security/mscapi/RSAPublicKey.java b/src/windows/classes/sun/security/mscapi/RSAPublicKey.java deleted file mode 100644 index 52081abb5aae34ab39fae200b9654d5ed68d6d05..0000000000000000000000000000000000000000 --- a/src/windows/classes/sun/security/mscapi/RSAPublicKey.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright (c) 2005, 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. - */ - -package sun.security.mscapi; - -import java.math.BigInteger; -import java.security.KeyException; -import java.security.KeyRep; -import java.security.ProviderException; - -import sun.security.rsa.RSAPublicKeyImpl; - -/** - * The handle for an RSA public key using the Microsoft Crypto API. - * - * @since 1.6 - */ -class RSAPublicKey extends Key implements java.security.interfaces.RSAPublicKey -{ - private static final long serialVersionUID = -2289561342425825391L; - - private byte[] publicKeyBlob = null; - private byte[] encoding = null; - private BigInteger modulus = null; - private BigInteger exponent = null; - - /** - * Construct an RSAPublicKey object. - */ - RSAPublicKey(long hCryptProv, long hCryptKey, int keyLength) - { - super(new NativeHandles(hCryptProv, hCryptKey), keyLength); - } - - /** - * Construct an RSAPublicKey object. - */ - RSAPublicKey(NativeHandles handles, int keyLength) - { - super(handles, keyLength); - } - - /** - * Returns the standard algorithm name for this key. For - * example, "RSA" would indicate that this key is a RSA key. - * See Appendix A in the - * Java Cryptography Architecture API Specification & Reference - * for information about standard algorithm names. - * - * @return the name of the algorithm associated with this key. - */ - public String getAlgorithm() - { - return "RSA"; - } - - /** - * Returns a printable description of the key. - */ - public String toString() - { - StringBuffer sb = new StringBuffer(); - - sb.append("RSAPublicKey [size=").append(keyLength) - .append(" bits, type=").append(getKeyType(handles.hCryptKey)) - .append(", container=").append(getContainerName(handles.hCryptProv)) - .append("]\n modulus: ").append(getModulus()) - .append("\n public exponent: ").append(getPublicExponent()); - - return sb.toString(); - } - - /** - * Returns the public exponent. - */ - public BigInteger getPublicExponent() { - - if (exponent == null) { - - try { - publicKeyBlob = getPublicKeyBlob(handles.hCryptKey); - exponent = new BigInteger(1, getExponent(publicKeyBlob)); - - } catch (KeyException e) { - throw new ProviderException(e); - } - } - - return exponent; - } - - /** - * Returns the modulus. - */ - public BigInteger getModulus() { - - if (modulus == null) { - - try { - publicKeyBlob = getPublicKeyBlob(handles.hCryptKey); - modulus = new BigInteger(1, getModulus(publicKeyBlob)); - - } catch (KeyException e) { - throw new ProviderException(e); - } - } - - return modulus; - } - - /** - * Returns the name of the primary encoding format of this key, - * or null if this key does not support encoding. - * The primary encoding format is - * named in terms of the appropriate ASN.1 data format, if an - * ASN.1 specification for this key exists. - * For example, the name of the ASN.1 data format for public - * keys is SubjectPublicKeyInfo, as - * defined by the X.509 standard; in this case, the returned format is - * "X.509". Similarly, - * the name of the ASN.1 data format for private keys is - * PrivateKeyInfo, - * as defined by the PKCS #8 standard; in this case, the returned format is - * "PKCS#8". - * - * @return the primary encoding format of the key. - */ - public String getFormat() - { - return "X.509"; - } - - /** - * Returns the key in its primary encoding format, or null - * if this key does not support encoding. - * - * @return the encoded key, or null if the key does not support - * encoding. - */ - public byte[] getEncoded() - { - if (encoding == null) { - - try { - encoding = new RSAPublicKeyImpl(getModulus(), - getPublicExponent()).getEncoded(); - - } catch (KeyException e) { - // ignore - } - } - return encoding; - } - - protected Object writeReplace() throws java.io.ObjectStreamException { - return new KeyRep(KeyRep.Type.PUBLIC, - getAlgorithm(), - getFormat(), - getEncoded()); - } - - /* - * Returns the Microsoft CryptoAPI representation of the key. - */ - private native byte[] getPublicKeyBlob(long hCryptKey) throws KeyException; - - /* - * Returns the key's public exponent (in big-endian 2's complement format). - */ - private native byte[] getExponent(byte[] keyBlob) throws KeyException; - - /* - * Returns the key's modulus (in big-endian 2's complement format). - */ - private native byte[] getModulus(byte[] keyBlob) throws KeyException; -} diff --git a/src/windows/classes/sun/security/mscapi/RSASignature.java b/src/windows/classes/sun/security/mscapi/RSASignature.java deleted file mode 100644 index 24f8190b0efc43c973136909796b2ca91477175d..0000000000000000000000000000000000000000 --- a/src/windows/classes/sun/security/mscapi/RSASignature.java +++ /dev/null @@ -1,524 +0,0 @@ -/* - * 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 - * 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.mscapi; - -import java.nio.ByteBuffer; -import java.security.PublicKey; -import java.security.PrivateKey; -import java.security.InvalidKeyException; -import java.security.InvalidParameterException; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.ProviderException; -import java.security.MessageDigest; -import java.security.SignatureException; -import java.math.BigInteger; - -import sun.security.rsa.RSAKeyFactory; - -/** - * RSA signature implementation. Supports RSA signing using PKCS#1 v1.5 padding. - * - * Objects should be instantiated by calling Signature.getInstance() using the - * following algorithm names: - * - * . "NONEwithRSA" - * . "SHA1withRSA" - * . "SHA256withRSA" - * . "SHA384withRSA" - * . "SHA512withRSA" - * . "MD5withRSA" - * . "MD2withRSA" - * - * NOTE: RSA keys must be at least 512 bits long. - * - * NOTE: NONEwithRSA must be supplied with a pre-computed message digest. - * Only the following digest algorithms are supported: MD5, SHA-1, - * SHA-256, SHA-384, SHA-512 and a special-purpose digest - * algorithm which is a concatenation of SHA-1 and MD5 digests. - * - * @since 1.6 - * @author Stanley Man-Kit Ho - */ -abstract class RSASignature extends java.security.SignatureSpi -{ - // message digest implementation we use - private final MessageDigest messageDigest; - - // message digest name - private String messageDigestAlgorithm; - - // flag indicating whether the digest has been reset - private boolean needsReset; - - // the signing key - private Key privateKey = null; - - // the verification key - private Key publicKey = null; - - /** - * Constructs a new RSASignature. Used by Raw subclass. - */ - RSASignature() { - messageDigest = null; - messageDigestAlgorithm = null; - } - - /** - * Constructs a new RSASignature. Used by subclasses. - */ - RSASignature(String digestName) { - - try { - messageDigest = MessageDigest.getInstance(digestName); - // Get the digest's canonical name - messageDigestAlgorithm = messageDigest.getAlgorithm(); - - } catch (NoSuchAlgorithmException e) { - throw new ProviderException(e); - } - - needsReset = false; - } - - // Nested class for NONEwithRSA signatures - public static final class Raw extends RSASignature { - - // the longest supported digest is 512 bits (SHA-512) - private static final int RAW_RSA_MAX = 64; - - private final byte[] precomputedDigest; - private int offset = 0; - - public Raw() { - precomputedDigest = new byte[RAW_RSA_MAX]; - } - - // Stores the precomputed message digest value. - @Override - protected void engineUpdate(byte b) throws SignatureException { - if (offset >= precomputedDigest.length) { - offset = RAW_RSA_MAX + 1; - return; - } - precomputedDigest[offset++] = b; - } - - // Stores the precomputed message digest value. - @Override - protected void engineUpdate(byte[] b, int off, int len) - throws SignatureException { - if (len > (precomputedDigest.length - offset)) { - offset = RAW_RSA_MAX + 1; - return; - } - System.arraycopy(b, off, precomputedDigest, offset, len); - offset += len; - } - - // Stores the precomputed message digest value. - @Override - protected void engineUpdate(ByteBuffer byteBuffer) { - int len = byteBuffer.remaining(); - if (len <= 0) { - return; - } - if (len > (precomputedDigest.length - offset)) { - offset = RAW_RSA_MAX + 1; - return; - } - byteBuffer.get(precomputedDigest, offset, len); - offset += len; - } - - @Override - protected void resetDigest(){ - offset = 0; - } - - // Returns the precomputed message digest value. - @Override - protected byte[] getDigestValue() throws SignatureException { - if (offset > RAW_RSA_MAX) { - throw new SignatureException("Message digest is too long"); - } - - // Determine the digest algorithm from the digest length - if (offset == 20) { - setDigestName("SHA1"); - } else if (offset == 36) { - setDigestName("SHA1+MD5"); - } else if (offset == 32) { - setDigestName("SHA-256"); - } else if (offset == 48) { - setDigestName("SHA-384"); - } else if (offset == 64) { - setDigestName("SHA-512"); - } else if (offset == 16) { - setDigestName("MD5"); - } else { - throw new SignatureException( - "Message digest length is not supported"); - } - - byte[] result = new byte[offset]; - System.arraycopy(precomputedDigest, 0, result, 0, offset); - offset = 0; - - return result; - } - } - - public static final class SHA1 extends RSASignature { - public SHA1() { - super("SHA1"); - } - } - - public static final class SHA256 extends RSASignature { - public SHA256() { - super("SHA-256"); - } - } - - public static final class SHA384 extends RSASignature { - public SHA384() { - super("SHA-384"); - } - } - - public static final class SHA512 extends RSASignature { - public SHA512() { - super("SHA-512"); - } - } - - public static final class MD5 extends RSASignature { - public MD5() { - super("MD5"); - } - } - - public static final class MD2 extends RSASignature { - public MD2() { - super("MD2"); - } - } - - // initialize for signing. See JCA doc - protected void engineInitVerify(PublicKey key) - throws InvalidKeyException - { - // This signature accepts only RSAPublicKey - if ((key instanceof java.security.interfaces.RSAPublicKey) == false) { - throw new InvalidKeyException("Key type not supported"); - } - - java.security.interfaces.RSAPublicKey rsaKey = - (java.security.interfaces.RSAPublicKey) key; - - if ((key instanceof sun.security.mscapi.RSAPublicKey) == false) { - - // convert key to MSCAPI format - - BigInteger modulus = rsaKey.getModulus(); - BigInteger exponent = rsaKey.getPublicExponent(); - - // Check against the local and global values to make sure - // the sizes are ok. Round up to the nearest byte. - RSAKeyFactory.checkKeyLengths(((modulus.bitLength() + 7) & ~7), - exponent, -1, RSAKeyPairGenerator.KEY_SIZE_MAX); - - byte[] modulusBytes = modulus.toByteArray(); - byte[] exponentBytes = exponent.toByteArray(); - - // Adjust key length due to sign bit - int keyBitLength = (modulusBytes[0] == 0) - ? (modulusBytes.length - 1) * 8 - : modulusBytes.length * 8; - - byte[] keyBlob = generatePublicKeyBlob( - keyBitLength, modulusBytes, exponentBytes); - - try { - publicKey = importPublicKey(keyBlob, keyBitLength); - - } catch (KeyStoreException e) { - throw new InvalidKeyException(e); - } - - } else { - publicKey = (sun.security.mscapi.RSAPublicKey) key; - } - - this.privateKey = null; - resetDigest(); - } - - // initialize for signing. See JCA doc - protected void engineInitSign(PrivateKey key) throws InvalidKeyException - { - // This signature accepts only RSAPrivateKey - if ((key instanceof sun.security.mscapi.RSAPrivateKey) == false) { - throw new InvalidKeyException("Key type not supported"); - } - privateKey = (sun.security.mscapi.RSAPrivateKey) key; - - // Check against the local and global values to make sure - // the sizes are ok. Round up to nearest byte. - RSAKeyFactory.checkKeyLengths(((privateKey.length() + 7) & ~7), - null, RSAKeyPairGenerator.KEY_SIZE_MIN, - RSAKeyPairGenerator.KEY_SIZE_MAX); - - this.publicKey = null; - resetDigest(); - } - - /** - * Resets the message digest if needed. - */ - protected void resetDigest() { - if (needsReset) { - messageDigest.reset(); - needsReset = false; - } - } - - protected byte[] getDigestValue() throws SignatureException { - needsReset = false; - return messageDigest.digest(); - } - - protected void setDigestName(String name) { - messageDigestAlgorithm = name; - } - - /** - * Updates the data to be signed or verified - * using the specified byte. - * - * @param b the byte to use for the update. - * - * @exception SignatureException if the engine is not initialized - * properly. - */ - protected void engineUpdate(byte b) throws SignatureException - { - messageDigest.update(b); - needsReset = true; - } - - /** - * Updates the data to be signed or verified, using the - * specified array of bytes, starting at the specified offset. - * - * @param b the array of bytes - * @param off the offset to start from in the array of bytes - * @param len the number of bytes to use, starting at offset - * - * @exception SignatureException if the engine is not initialized - * properly - */ - protected void engineUpdate(byte[] b, int off, int len) - throws SignatureException - { - messageDigest.update(b, off, len); - needsReset = true; - } - - /** - * Updates the data to be signed or verified, using the - * specified ByteBuffer. - * - * @param input the ByteBuffer - */ - protected void engineUpdate(ByteBuffer input) - { - messageDigest.update(input); - needsReset = true; - } - - /** - * Returns the signature bytes of all the data - * updated so far. - * The format of the signature depends on the underlying - * signature scheme. - * - * @return the signature bytes of the signing operation's result. - * - * @exception SignatureException if the engine is not - * initialized properly or if this signature algorithm is unable to - * process the input data provided. - */ - protected byte[] engineSign() throws SignatureException { - - byte[] hash = getDigestValue(); - - // Omit the hash OID when generating a Raw signature - boolean noHashOID = this instanceof Raw; - - // Sign hash using MS Crypto APIs - - byte[] result = signHash(noHashOID, hash, hash.length, - messageDigestAlgorithm, privateKey.getHCryptProvider(), - privateKey.getHCryptKey()); - - // Convert signature array from little endian to big endian - return convertEndianArray(result); - } - - /** - * Convert array from big endian to little endian, or vice versa. - */ - private byte[] convertEndianArray(byte[] byteArray) - { - if (byteArray == null || byteArray.length == 0) - return byteArray; - - byte [] retval = new byte[byteArray.length]; - - // make it big endian - for (int i=0;i < byteArray.length;i++) - retval[i] = byteArray[byteArray.length - i - 1]; - - return retval; - } - - /** - * Sign hash using Microsoft Crypto API with HCRYPTKEY. - * The returned data is in little-endian. - */ - private native static byte[] signHash(boolean noHashOID, byte[] hash, - int hashSize, String hashAlgorithm, long hCryptProv, long hCryptKey) - throws SignatureException; - - /** - * Verify a signed hash using Microsoft Crypto API with HCRYPTKEY. - */ - private native static boolean verifySignedHash(byte[] hash, int hashSize, - String hashAlgorithm, byte[] signature, int signatureSize, - long hCryptProv, long hCryptKey) throws SignatureException; - - /** - * Verifies the passed-in signature. - * - * @param sigBytes the signature bytes to be verified. - * - * @return true if the signature was verified, false if not. - * - * @exception SignatureException if the engine is not - * initialized properly, the passed-in signature is improperly - * encoded or of the wrong type, if this signature algorithm is unable to - * process the input data provided, etc. - */ - protected boolean engineVerify(byte[] sigBytes) - throws SignatureException - { - byte[] hash = getDigestValue(); - - return verifySignedHash(hash, hash.length, - messageDigestAlgorithm, convertEndianArray(sigBytes), - sigBytes.length, publicKey.getHCryptProvider(), - publicKey.getHCryptKey()); - } - - /** - * Sets the specified algorithm parameter to the specified - * value. This method supplies a general-purpose mechanism through - * which it is possible to set the various parameters of this object. - * A parameter may be any settable parameter for the algorithm, such as - * a parameter size, or a source of random bits for signature generation - * (if appropriate), or an indication of whether or not to perform - * a specific but optional computation. A uniform algorithm-specific - * naming scheme for each parameter is desirable but left unspecified - * at this time. - * - * @param param the string identifier of the parameter. - * - * @param value the parameter value. - * - * @exception InvalidParameterException if param is an - * invalid parameter for this signature algorithm engine, - * the parameter is already set - * and cannot be set again, a security exception occurs, and so on. - * - * @deprecated Replaced by {@link - * #engineSetParameter(java.security.spec.AlgorithmParameterSpec) - * engineSetParameter}. - */ - @Deprecated - protected void engineSetParameter(String param, Object value) - throws InvalidParameterException - { - throw new InvalidParameterException("Parameter not supported"); - } - - - /** - * Gets the value of the specified algorithm parameter. - * This method supplies a general-purpose mechanism through which it - * is possible to get the various parameters of this object. A parameter - * may be any settable parameter for the algorithm, such as a parameter - * size, or a source of random bits for signature generation (if - * appropriate), or an indication of whether or not to perform a - * specific but optional computation. A uniform algorithm-specific - * naming scheme for each parameter is desirable but left unspecified - * at this time. - * - * @param param the string name of the parameter. - * - * @return the object that represents the parameter value, or null if - * there is none. - * - * @exception InvalidParameterException if param is an - * invalid parameter for this engine, or another exception occurs while - * trying to get this parameter. - * - * @deprecated - */ - @Deprecated - protected Object engineGetParameter(String param) - throws InvalidParameterException - { - throw new InvalidParameterException("Parameter not supported"); - } - - /** - * Generates a public-key BLOB from a key's components. - */ - // used by RSACipher - static native byte[] generatePublicKeyBlob( - int keyBitLength, byte[] modulus, byte[] publicExponent) - throws InvalidKeyException; - - /** - * Imports a public-key BLOB. - */ - // used by RSACipher - static native RSAPublicKey importPublicKey(byte[] keyBlob, int keySize) - throws KeyStoreException; -} diff --git a/src/windows/classes/sun/security/mscapi/SunMSCAPI.java b/src/windows/classes/sun/security/mscapi/SunMSCAPI.java index 7725b27d3c62addea12cc6e6809f3eea49127dba..fb9cb9e175205bcb380f2b57a4cb7b7f9bf9baa8 100644 --- a/src/windows/classes/sun/security/mscapi/SunMSCAPI.java +++ b/src/windows/classes/sun/security/mscapi/SunMSCAPI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * 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,8 +73,8 @@ public final class SunMSCAPI extends Provider { /* * Key store */ - map.put("KeyStore.Windows-MY", "sun.security.mscapi.KeyStore$MY"); - map.put("KeyStore.Windows-ROOT", "sun.security.mscapi.KeyStore$ROOT"); + map.put("KeyStore.Windows-MY", "sun.security.mscapi.CKeyStore$MY"); + map.put("KeyStore.Windows-ROOT", "sun.security.mscapi.CKeyStore$ROOT"); /* * Signature engines @@ -84,60 +84,99 @@ public final class SunMSCAPI extends Provider { // SHA-256, SHA-384, SHA-512 and a special-purpose digest // algorithm which is a concatenation of SHA-1 and MD5 digests. map.put("Signature.NONEwithRSA", - "sun.security.mscapi.RSASignature$Raw"); + "sun.security.mscapi.CSignature$NONEwithRSA"); map.put("Signature.SHA1withRSA", - "sun.security.mscapi.RSASignature$SHA1"); + "sun.security.mscapi.CSignature$SHA1withRSA"); map.put("Signature.SHA256withRSA", - "sun.security.mscapi.RSASignature$SHA256"); + "sun.security.mscapi.CSignature$SHA256withRSA"); map.put("Alg.Alias.Signature.1.2.840.113549.1.1.11", "SHA256withRSA"); map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.11", "SHA256withRSA"); map.put("Signature.SHA384withRSA", - "sun.security.mscapi.RSASignature$SHA384"); + "sun.security.mscapi.CSignature$SHA384withRSA"); map.put("Alg.Alias.Signature.1.2.840.113549.1.1.12", "SHA384withRSA"); map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.12", "SHA384withRSA"); - map.put("Signature.SHA512withRSA", - "sun.security.mscapi.RSASignature$SHA512"); + "sun.security.mscapi.CSignature$SHA512withRSA"); map.put("Alg.Alias.Signature.1.2.840.113549.1.1.13", "SHA512withRSA"); map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.13", "SHA512withRSA"); map.put("Signature.MD5withRSA", - "sun.security.mscapi.RSASignature$MD5"); + "sun.security.mscapi.CSignature$MD5withRSA"); map.put("Signature.MD2withRSA", - "sun.security.mscapi.RSASignature$MD2"); + "sun.security.mscapi.CSignature$MD2withRSA"); + + map.put("Signature.RSASSA-PSS", + "sun.security.mscapi.CSignature$PSS"); + map.put("Alg.Alias.Signature.1.2.840.113549.1.1.10", "RSASSA-PSS"); + map.put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.10", "RSASSA-PSS"); + + map.put("Signature.SHA1withECDSA", + "sun.security.mscapi.CSignature$SHA1withECDSA"); + map.put("Alg.Alias.Signature.1.2.840.10045.4.1", "SHA1withECDSA"); + map.put("Alg.Alias.Signature.OID.1.2.840.10045.4.1", "SHA1withECDSA"); + map.put("Signature.SHA224withECDSA", + "sun.security.mscapi.CSignature$SHA224withECDSA"); + map.put("Alg.Alias.Signature.1.2.840.10045.4.3.1", "SHA224withECDSA"); + map.put("Alg.Alias.Signature.OID.1.2.840.10045.4.3.1", "SHA224withECDSA"); + map.put("Signature.SHA256withECDSA", + "sun.security.mscapi.CSignature$SHA256withECDSA"); + map.put("Alg.Alias.Signature.1.2.840.10045.4.3.2", "SHA256withECDSA"); + map.put("Alg.Alias.Signature.OID.1.2.840.10045.4.3.2", "SHA256withECDSA"); + map.put("Signature.SHA384withECDSA", + "sun.security.mscapi.CSignature$SHA384withECDSA"); + map.put("Alg.Alias.Signature.1.2.840.10045.4.3.3", "SHA384withECDSA"); + map.put("Alg.Alias.Signature.OID.1.2.840.10045.4.3.3", "SHA384withECDSA"); + map.put("Signature.SHA512withECDSA", + "sun.security.mscapi.CSignature$SHA512withECDSA"); + map.put("Alg.Alias.Signature.1.2.840.10045.4.3.4", "SHA512withECDSA"); + map.put("Alg.Alias.Signature.OID.1.2.840.10045.4.3.4", "SHA512withECDSA"); // supported key classes map.put("Signature.NONEwithRSA SupportedKeyClasses", - "sun.security.mscapi.Key"); + "sun.security.mscapi.CKey"); map.put("Signature.SHA1withRSA SupportedKeyClasses", - "sun.security.mscapi.Key"); + "sun.security.mscapi.CKey"); map.put("Signature.SHA256withRSA SupportedKeyClasses", - "sun.security.mscapi.Key"); + "sun.security.mscapi.CKey"); map.put("Signature.SHA384withRSA SupportedKeyClasses", - "sun.security.mscapi.Key"); + "sun.security.mscapi.CKey"); map.put("Signature.SHA512withRSA SupportedKeyClasses", - "sun.security.mscapi.Key"); + "sun.security.mscapi.CKey"); map.put("Signature.MD5withRSA SupportedKeyClasses", - "sun.security.mscapi.Key"); + "sun.security.mscapi.CKey"); map.put("Signature.MD2withRSA SupportedKeyClasses", - "sun.security.mscapi.Key"); + "sun.security.mscapi.CKey"); + + map.put("Signature.RSASSA-PSS SupportedKeyClasses", + "sun.security.mscapi.CKey"); + + map.put("Signature.SHA1withECDSA SupportedKeyClasses", + "sun.security.mscapi.CKey"); + map.put("Signature.SHA224withECDSA SupportedKeyClasses", + "sun.security.mscapi.CKey"); + map.put("Signature.SHA256withECDSA SupportedKeyClasses", + "sun.security.mscapi.CKey"); + map.put("Signature.SHA384withECDSA SupportedKeyClasses", + "sun.security.mscapi.CKey"); + map.put("Signature.SHA512withECDSA SupportedKeyClasses", + "sun.security.mscapi.CKey"); /* * Key Pair Generator engines */ map.put("KeyPairGenerator.RSA", - "sun.security.mscapi.RSAKeyPairGenerator"); + "sun.security.mscapi.CKeyPairGenerator$RSA"); map.put("KeyPairGenerator.RSA KeySize", "1024"); /* * Cipher engines */ - map.put("Cipher.RSA", "sun.security.mscapi.RSACipher"); + map.put("Cipher.RSA", "sun.security.mscapi.CRSACipher"); map.put("Cipher.RSA/ECB/PKCS1Padding", - "sun.security.mscapi.RSACipher"); + "sun.security.mscapi.CRSACipher"); map.put("Cipher.RSA SupportedModes", "ECB"); map.put("Cipher.RSA SupportedPaddings", "PKCS1PADDING"); - map.put("Cipher.RSA SupportedKeyClasses", "sun.security.mscapi.Key"); + map.put("Cipher.RSA SupportedKeyClasses", "sun.security.mscapi.CKey"); if (map != this) { AccessController.doPrivileged(new PutAllAction(this, map)); diff --git a/src/windows/native/sun/font/lcdglyph.c b/src/windows/native/sun/font/lcdglyph.c index d940e8cb468ff52174d975a19f92eb6839bd7e9c..c63d96c301cd451223f89dbf12a8dfc05678f7a8 100644 --- a/src/windows/native/sun/font/lcdglyph.c +++ b/src/windows/native/sun/font/lcdglyph.c @@ -172,7 +172,8 @@ JNIEXPORT jboolean JNICALL JNIEXPORT jlong JNICALL Java_sun_font_FileFontStrike__1getGlyphImageFromWindows (JNIEnv *env, jobject unused, - jstring fontFamily, jint style, jint size, jint glyphCode, jboolean fm) { + jstring fontFamily, jint style, jint size, jint glyphCode, jboolean fm, + jint fontDataSize) { GLYPHMETRICS glyphMetrics; LOGFONTW lf; @@ -188,6 +189,7 @@ Java_sun_font_FileFontStrike__1getGlyphImageFromWindows LPWSTR name; HFONT oldFont, hFont; MAT2 mat2; + DWORD actualFontDataSize; unsigned short width; unsigned short height; @@ -254,6 +256,17 @@ Java_sun_font_FileFontStrike__1getGlyphImageFromWindows } oldFont = SelectObject(hMemoryDC, hFont); + if (fontDataSize > 0) { + // GDI doesn't allow to select a specific font file for drawing, we can + // only check that it picks the file we need by validating font size. + // If it doesn't match, we cannot proceed, as the same glyph code can + // correspond to a completely different glyph in the selected font. + actualFontDataSize = GetFontData(hMemoryDC, 0, 0, NULL, 0); + if (actualFontDataSize != fontDataSize) { + FREE_AND_RETURN; + } + } + tmpBitmap = CreateCompatibleBitmap(hDesktopDC, 1, 1); if (tmpBitmap == NULL) { FREE_AND_RETURN; diff --git a/src/windows/native/sun/java2d/opengl/J2D_GL/wglext.h b/src/windows/native/sun/java2d/opengl/J2D_GL/wglext.h index f03eab7d54895aed5dfad7270bae843fe166bc05..25082ce7ba966c5660cf5cfb82150c5f6a979057 100644 --- a/src/windows/native/sun/java2d/opengl/J2D_GL/wglext.h +++ b/src/windows/native/sun/java2d/opengl/J2D_GL/wglext.h @@ -23,7 +23,7 @@ */ #ifndef __wglext_h_ -#define __wglext_h_ +#define __wglext_h_ 1 #ifdef __cplusplus extern "C" { @@ -35,7 +35,7 @@ extern "C" { ** However, the following notice accompanied the original version of this ** file: ** -** Copyright (c) 2007 The Khronos Group Inc. +** Copyright (c) 2013-2017 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the @@ -56,517 +56,532 @@ extern "C" { ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** https://github.com/KhronosGroup/OpenGL-Registry +*/ -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) #define WIN32_LEAN_AND_MEAN 1 #include #endif -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -/*************************************************************/ - -/* Header file version number */ -/* wglext.h last updated 2002/03/22 */ -/* Current version at http://oss.sgi.com/projects/ogl-sample/registry/ */ -#define WGL_WGLEXT_VERSION 4 - -#ifndef WGL_ARB_buffer_region -#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 -#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 -#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 -#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 -#endif - -#ifndef WGL_ARB_multisample -#define WGL_SAMPLE_BUFFERS_ARB 0x2041 -#define WGL_SAMPLES_ARB 0x2042 -#endif - -#ifndef WGL_ARB_extensions_string -#endif - -#ifndef WGL_ARB_pixel_format -#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 -#define WGL_DRAW_TO_WINDOW_ARB 0x2001 -#define WGL_DRAW_TO_BITMAP_ARB 0x2002 -#define WGL_ACCELERATION_ARB 0x2003 -#define WGL_NEED_PALETTE_ARB 0x2004 -#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 -#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 -#define WGL_SWAP_METHOD_ARB 0x2007 -#define WGL_NUMBER_OVERLAYS_ARB 0x2008 -#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 -#define WGL_TRANSPARENT_ARB 0x200A -#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 -#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 -#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 -#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A -#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B -#define WGL_SHARE_DEPTH_ARB 0x200C -#define WGL_SHARE_STENCIL_ARB 0x200D -#define WGL_SHARE_ACCUM_ARB 0x200E -#define WGL_SUPPORT_GDI_ARB 0x200F -#define WGL_SUPPORT_OPENGL_ARB 0x2010 -#define WGL_DOUBLE_BUFFER_ARB 0x2011 -#define WGL_STEREO_ARB 0x2012 -#define WGL_PIXEL_TYPE_ARB 0x2013 -#define WGL_COLOR_BITS_ARB 0x2014 -#define WGL_RED_BITS_ARB 0x2015 -#define WGL_RED_SHIFT_ARB 0x2016 -#define WGL_GREEN_BITS_ARB 0x2017 -#define WGL_GREEN_SHIFT_ARB 0x2018 -#define WGL_BLUE_BITS_ARB 0x2019 -#define WGL_BLUE_SHIFT_ARB 0x201A -#define WGL_ALPHA_BITS_ARB 0x201B -#define WGL_ALPHA_SHIFT_ARB 0x201C -#define WGL_ACCUM_BITS_ARB 0x201D -#define WGL_ACCUM_RED_BITS_ARB 0x201E -#define WGL_ACCUM_GREEN_BITS_ARB 0x201F -#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 -#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 -#define WGL_DEPTH_BITS_ARB 0x2022 -#define WGL_STENCIL_BITS_ARB 0x2023 -#define WGL_AUX_BUFFERS_ARB 0x2024 -#define WGL_NO_ACCELERATION_ARB 0x2025 -#define WGL_GENERIC_ACCELERATION_ARB 0x2026 -#define WGL_FULL_ACCELERATION_ARB 0x2027 -#define WGL_SWAP_EXCHANGE_ARB 0x2028 -#define WGL_SWAP_COPY_ARB 0x2029 -#define WGL_SWAP_UNDEFINED_ARB 0x202A -#define WGL_TYPE_RGBA_ARB 0x202B -#define WGL_TYPE_COLORINDEX_ARB 0x202C -#endif - -#ifndef WGL_ARB_make_current_read -#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 -#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 -#endif - -#ifndef WGL_ARB_pbuffer -#define WGL_DRAW_TO_PBUFFER_ARB 0x202D -#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E -#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F -#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 -#define WGL_PBUFFER_LARGEST_ARB 0x2033 -#define WGL_PBUFFER_WIDTH_ARB 0x2034 -#define WGL_PBUFFER_HEIGHT_ARB 0x2035 -#define WGL_PBUFFER_LOST_ARB 0x2036 -#endif - -#ifndef WGL_ARB_render_texture -#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 -#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 -#define WGL_TEXTURE_FORMAT_ARB 0x2072 -#define WGL_TEXTURE_TARGET_ARB 0x2073 -#define WGL_MIPMAP_TEXTURE_ARB 0x2074 -#define WGL_TEXTURE_RGB_ARB 0x2075 -#define WGL_TEXTURE_RGBA_ARB 0x2076 -#define WGL_NO_TEXTURE_ARB 0x2077 -#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 -#define WGL_TEXTURE_1D_ARB 0x2079 -#define WGL_TEXTURE_2D_ARB 0x207A -#define WGL_MIPMAP_LEVEL_ARB 0x207B -#define WGL_CUBE_MAP_FACE_ARB 0x207C -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 -#define WGL_FRONT_LEFT_ARB 0x2083 -#define WGL_FRONT_RIGHT_ARB 0x2084 -#define WGL_BACK_LEFT_ARB 0x2085 -#define WGL_BACK_RIGHT_ARB 0x2086 -#define WGL_AUX0_ARB 0x2087 -#define WGL_AUX1_ARB 0x2088 -#define WGL_AUX2_ARB 0x2089 -#define WGL_AUX3_ARB 0x208A -#define WGL_AUX4_ARB 0x208B -#define WGL_AUX5_ARB 0x208C -#define WGL_AUX6_ARB 0x208D -#define WGL_AUX7_ARB 0x208E -#define WGL_AUX8_ARB 0x208F -#define WGL_AUX9_ARB 0x2090 -#endif - -#ifndef WGL_EXT_make_current_read -#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 -#endif - -#ifndef WGL_EXT_pixel_format -#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 -#define WGL_DRAW_TO_WINDOW_EXT 0x2001 -#define WGL_DRAW_TO_BITMAP_EXT 0x2002 -#define WGL_ACCELERATION_EXT 0x2003 -#define WGL_NEED_PALETTE_EXT 0x2004 -#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 -#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 -#define WGL_SWAP_METHOD_EXT 0x2007 -#define WGL_NUMBER_OVERLAYS_EXT 0x2008 -#define WGL_NUMBER_UNDERLAYS_EXT 0x2009 -#define WGL_TRANSPARENT_EXT 0x200A -#define WGL_TRANSPARENT_VALUE_EXT 0x200B -#define WGL_SHARE_DEPTH_EXT 0x200C -#define WGL_SHARE_STENCIL_EXT 0x200D -#define WGL_SHARE_ACCUM_EXT 0x200E -#define WGL_SUPPORT_GDI_EXT 0x200F -#define WGL_SUPPORT_OPENGL_EXT 0x2010 -#define WGL_DOUBLE_BUFFER_EXT 0x2011 -#define WGL_STEREO_EXT 0x2012 -#define WGL_PIXEL_TYPE_EXT 0x2013 -#define WGL_COLOR_BITS_EXT 0x2014 -#define WGL_RED_BITS_EXT 0x2015 -#define WGL_RED_SHIFT_EXT 0x2016 -#define WGL_GREEN_BITS_EXT 0x2017 -#define WGL_GREEN_SHIFT_EXT 0x2018 -#define WGL_BLUE_BITS_EXT 0x2019 -#define WGL_BLUE_SHIFT_EXT 0x201A -#define WGL_ALPHA_BITS_EXT 0x201B -#define WGL_ALPHA_SHIFT_EXT 0x201C -#define WGL_ACCUM_BITS_EXT 0x201D -#define WGL_ACCUM_RED_BITS_EXT 0x201E -#define WGL_ACCUM_GREEN_BITS_EXT 0x201F -#define WGL_ACCUM_BLUE_BITS_EXT 0x2020 -#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 -#define WGL_DEPTH_BITS_EXT 0x2022 -#define WGL_STENCIL_BITS_EXT 0x2023 -#define WGL_AUX_BUFFERS_EXT 0x2024 -#define WGL_NO_ACCELERATION_EXT 0x2025 -#define WGL_GENERIC_ACCELERATION_EXT 0x2026 -#define WGL_FULL_ACCELERATION_EXT 0x2027 -#define WGL_SWAP_EXCHANGE_EXT 0x2028 -#define WGL_SWAP_COPY_EXT 0x2029 -#define WGL_SWAP_UNDEFINED_EXT 0x202A -#define WGL_TYPE_RGBA_EXT 0x202B -#define WGL_TYPE_COLORINDEX_EXT 0x202C -#endif - -#ifndef WGL_EXT_pbuffer -#define WGL_DRAW_TO_PBUFFER_EXT 0x202D -#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E -#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F -#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 -#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 -#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 -#define WGL_PBUFFER_LARGEST_EXT 0x2033 -#define WGL_PBUFFER_WIDTH_EXT 0x2034 -#define WGL_PBUFFER_HEIGHT_EXT 0x2035 -#endif - -#ifndef WGL_EXT_depth_float -#define WGL_DEPTH_FLOAT_EXT 0x2040 -#endif - -#ifndef WGL_3DFX_multisample -#define WGL_SAMPLE_BUFFERS_3DFX 0x2060 -#define WGL_SAMPLES_3DFX 0x2061 -#endif - -#ifndef WGL_EXT_multisample -#define WGL_SAMPLE_BUFFERS_EXT 0x2041 -#define WGL_SAMPLES_EXT 0x2042 -#endif - -#ifndef WGL_I3D_digital_video_control -#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 -#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 -#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 -#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 -#endif - -#ifndef WGL_I3D_gamma -#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E -#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F -#endif +#define WGL_WGLEXT_VERSION 20170817 -#ifndef WGL_I3D_genlock -#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 -#define WGL_GENLOCK_SOURCE_EXTENAL_SYNC_I3D 0x2045 -#define WGL_GENLOCK_SOURCE_EXTENAL_FIELD_I3D 0x2046 -#define WGL_GENLOCK_SOURCE_EXTENAL_TTL_I3D 0x2047 -#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 -#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 -#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A -#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B -#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C -#endif - -#ifndef WGL_I3D_image_buffer -#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 -#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 -#endif - -#ifndef WGL_I3D_swap_frame_lock -#endif - -#ifndef WGL_NV_render_depth_texture -#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 -#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 -#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 -#define WGL_DEPTH_COMPONENT_NV 0x20A7 -#endif - -#ifndef WGL_NV_render_texture_rectangle -#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 -#define WGL_TEXTURE_RECTANGLE_NV 0x20A2 -#endif - -#ifndef WGL_NV_float_buffer -#define WGL_FLOAT_COMPONENTS_NV 0x20B0 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 -#define WGL_TEXTURE_FLOAT_R_NV 0x20B5 -#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 -#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 -#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 -#endif - - -/*************************************************************/ - -#ifndef WGL_ARB_pbuffer -DECLARE_HANDLE(HPBUFFERARB); -#endif -#ifndef WGL_EXT_pbuffer -DECLARE_HANDLE(HPBUFFEREXT); -#endif +/* Generated C header for: + * API: wgl + * Versions considered: .* + * Versions emitted: _nomatch_^ + * Default extensions included: wgl + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ #ifndef WGL_ARB_buffer_region #define WGL_ARB_buffer_region 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HANDLE WINAPI wglCreateBufferRegionARB (HDC, int, UINT); -extern VOID WINAPI wglDeleteBufferRegionARB (HANDLE); -extern BOOL WINAPI wglSaveBufferRegionARB (HANDLE, int, int, int, int); -extern BOOL WINAPI wglRestoreBufferRegionARB (HANDLE, int, int, int, int, int, int); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 +#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 +#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 +#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); -#endif - -#ifndef WGL_ARB_multisample -#define WGL_ARB_multisample 1 -#endif +#ifdef WGL_WGLEXT_PROTOTYPES +HANDLE WINAPI wglCreateBufferRegionARB (HDC hDC, int iLayerPlane, UINT uType); +VOID WINAPI wglDeleteBufferRegionARB (HANDLE hRegion); +BOOL WINAPI wglSaveBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height); +BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); +#endif +#endif /* WGL_ARB_buffer_region */ + +#ifndef WGL_ARB_context_flush_control +#define WGL_ARB_context_flush_control 1 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 +#endif /* WGL_ARB_context_flush_control */ + +#ifndef WGL_ARB_create_context +#define WGL_ARB_create_context 1 +#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 +#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 +#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 +#define WGL_CONTEXT_FLAGS_ARB 0x2094 +#define ERROR_INVALID_VERSION_ARB 0x2095 +typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList); +#ifdef WGL_WGLEXT_PROTOTYPES +HGLRC WINAPI wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int *attribList); +#endif +#endif /* WGL_ARB_create_context */ + +#ifndef WGL_ARB_create_context_no_error +#define WGL_ARB_create_context_no_error 1 +#define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31B3 +#endif /* WGL_ARB_create_context_no_error */ + +#ifndef WGL_ARB_create_context_profile +#define WGL_ARB_create_context_profile 1 +#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 +#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 +#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 +#define ERROR_INVALID_PROFILE_ARB 0x2096 +#endif /* WGL_ARB_create_context_profile */ + +#ifndef WGL_ARB_create_context_robustness +#define WGL_ARB_create_context_robustness 1 +#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 +#endif /* WGL_ARB_create_context_robustness */ #ifndef WGL_ARB_extensions_string #define WGL_ARB_extensions_string 1 +typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); #ifdef WGL_WGLEXT_PROTOTYPES -extern const char * WINAPI wglGetExtensionsStringARB (HDC); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); +const char *WINAPI wglGetExtensionsStringARB (HDC hdc); #endif +#endif /* WGL_ARB_extensions_string */ -#ifndef WGL_ARB_pixel_format -#define WGL_ARB_pixel_format 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetPixelFormatAttribivARB (HDC, int, int, UINT, const int *, int *); -extern BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC, int, int, UINT, const int *, FLOAT *); -extern BOOL WINAPI wglChoosePixelFormatARB (HDC, const int *, const FLOAT *, UINT, int *, UINT *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); -typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -#endif +#ifndef WGL_ARB_framebuffer_sRGB +#define WGL_ARB_framebuffer_sRGB 1 +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 +#endif /* WGL_ARB_framebuffer_sRGB */ #ifndef WGL_ARB_make_current_read #define WGL_ARB_make_current_read 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglMakeContextCurrentARB (HDC, HDC, HGLRC); -extern HDC WINAPI wglGetCurrentReadDCARB (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 +#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglMakeContextCurrentARB (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +HDC WINAPI wglGetCurrentReadDCARB (void); #endif +#endif /* WGL_ARB_make_current_read */ + +#ifndef WGL_ARB_multisample +#define WGL_ARB_multisample 1 +#define WGL_SAMPLE_BUFFERS_ARB 0x2041 +#define WGL_SAMPLES_ARB 0x2042 +#endif /* WGL_ARB_multisample */ #ifndef WGL_ARB_pbuffer #define WGL_ARB_pbuffer 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HPBUFFERARB WINAPI wglCreatePbufferARB (HDC, int, int, int, const int *); -extern HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB); -extern int WINAPI wglReleasePbufferDCARB (HPBUFFERARB, HDC); -extern BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB); -extern BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB, int, int *); -#endif /* WGL_WGLEXT_PROTOTYPES */ +DECLARE_HANDLE(HPBUFFERARB); +#define WGL_DRAW_TO_PBUFFER_ARB 0x202D +#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E +#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 +#define WGL_PBUFFER_LARGEST_ARB 0x2033 +#define WGL_PBUFFER_WIDTH_ARB 0x2034 +#define WGL_PBUFFER_HEIGHT_ARB 0x2035 +#define WGL_PBUFFER_LOST_ARB 0x2036 typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); +#ifdef WGL_WGLEXT_PROTOTYPES +HPBUFFERARB WINAPI wglCreatePbufferARB (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB hPbuffer); +int WINAPI wglReleasePbufferDCARB (HPBUFFERARB hPbuffer, HDC hDC); +BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB hPbuffer); +BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); +#endif +#endif /* WGL_ARB_pbuffer */ + +#ifndef WGL_ARB_pixel_format +#define WGL_ARB_pixel_format 1 +#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 +#define WGL_DRAW_TO_WINDOW_ARB 0x2001 +#define WGL_DRAW_TO_BITMAP_ARB 0x2002 +#define WGL_ACCELERATION_ARB 0x2003 +#define WGL_NEED_PALETTE_ARB 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 +#define WGL_SWAP_METHOD_ARB 0x2007 +#define WGL_NUMBER_OVERLAYS_ARB 0x2008 +#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 +#define WGL_TRANSPARENT_ARB 0x200A +#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 +#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 +#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 +#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A +#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B +#define WGL_SHARE_DEPTH_ARB 0x200C +#define WGL_SHARE_STENCIL_ARB 0x200D +#define WGL_SHARE_ACCUM_ARB 0x200E +#define WGL_SUPPORT_GDI_ARB 0x200F +#define WGL_SUPPORT_OPENGL_ARB 0x2010 +#define WGL_DOUBLE_BUFFER_ARB 0x2011 +#define WGL_STEREO_ARB 0x2012 +#define WGL_PIXEL_TYPE_ARB 0x2013 +#define WGL_COLOR_BITS_ARB 0x2014 +#define WGL_RED_BITS_ARB 0x2015 +#define WGL_RED_SHIFT_ARB 0x2016 +#define WGL_GREEN_BITS_ARB 0x2017 +#define WGL_GREEN_SHIFT_ARB 0x2018 +#define WGL_BLUE_BITS_ARB 0x2019 +#define WGL_BLUE_SHIFT_ARB 0x201A +#define WGL_ALPHA_BITS_ARB 0x201B +#define WGL_ALPHA_SHIFT_ARB 0x201C +#define WGL_ACCUM_BITS_ARB 0x201D +#define WGL_ACCUM_RED_BITS_ARB 0x201E +#define WGL_ACCUM_GREEN_BITS_ARB 0x201F +#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 +#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 +#define WGL_DEPTH_BITS_ARB 0x2022 +#define WGL_STENCIL_BITS_ARB 0x2023 +#define WGL_AUX_BUFFERS_ARB 0x2024 +#define WGL_NO_ACCELERATION_ARB 0x2025 +#define WGL_GENERIC_ACCELERATION_ARB 0x2026 +#define WGL_FULL_ACCELERATION_ARB 0x2027 +#define WGL_SWAP_EXCHANGE_ARB 0x2028 +#define WGL_SWAP_COPY_ARB 0x2029 +#define WGL_SWAP_UNDEFINED_ARB 0x202A +#define WGL_TYPE_RGBA_ARB 0x202B +#define WGL_TYPE_COLORINDEX_ARB 0x202C +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); +typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetPixelFormatAttribivARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); +BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); +BOOL WINAPI wglChoosePixelFormatARB (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); #endif +#endif /* WGL_ARB_pixel_format */ + +#ifndef WGL_ARB_pixel_format_float +#define WGL_ARB_pixel_format_float 1 +#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 +#endif /* WGL_ARB_pixel_format_float */ #ifndef WGL_ARB_render_texture #define WGL_ARB_render_texture 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglBindTexImageARB (HPBUFFERARB, int); -extern BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB, int); -extern BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB, const int *); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 +#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 +#define WGL_TEXTURE_FORMAT_ARB 0x2072 +#define WGL_TEXTURE_TARGET_ARB 0x2073 +#define WGL_MIPMAP_TEXTURE_ARB 0x2074 +#define WGL_TEXTURE_RGB_ARB 0x2075 +#define WGL_TEXTURE_RGBA_ARB 0x2076 +#define WGL_NO_TEXTURE_ARB 0x2077 +#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 +#define WGL_TEXTURE_1D_ARB 0x2079 +#define WGL_TEXTURE_2D_ARB 0x207A +#define WGL_MIPMAP_LEVEL_ARB 0x207B +#define WGL_CUBE_MAP_FACE_ARB 0x207C +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 +#define WGL_FRONT_LEFT_ARB 0x2083 +#define WGL_FRONT_RIGHT_ARB 0x2084 +#define WGL_BACK_LEFT_ARB 0x2085 +#define WGL_BACK_RIGHT_ARB 0x2086 +#define WGL_AUX0_ARB 0x2087 +#define WGL_AUX1_ARB 0x2088 +#define WGL_AUX2_ARB 0x2089 +#define WGL_AUX3_ARB 0x208A +#define WGL_AUX4_ARB 0x208B +#define WGL_AUX5_ARB 0x208C +#define WGL_AUX6_ARB 0x208D +#define WGL_AUX7_ARB 0x208E +#define WGL_AUX8_ARB 0x208F +#define WGL_AUX9_ARB 0x2090 typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglBindTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); +BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); +BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB hPbuffer, const int *piAttribList); #endif +#endif /* WGL_ARB_render_texture */ + +#ifndef WGL_ARB_robustness_application_isolation +#define WGL_ARB_robustness_application_isolation 1 +#define WGL_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008 +#endif /* WGL_ARB_robustness_application_isolation */ + +#ifndef WGL_ARB_robustness_share_group_isolation +#define WGL_ARB_robustness_share_group_isolation 1 +#endif /* WGL_ARB_robustness_share_group_isolation */ + +#ifndef WGL_3DFX_multisample +#define WGL_3DFX_multisample 1 +#define WGL_SAMPLE_BUFFERS_3DFX 0x2060 +#define WGL_SAMPLES_3DFX 0x2061 +#endif /* WGL_3DFX_multisample */ + +#ifndef WGL_3DL_stereo_control +#define WGL_3DL_stereo_control 1 +#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 +#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 +#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 +#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058 +typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglSetStereoEmitterState3DL (HDC hDC, UINT uState); +#endif +#endif /* WGL_3DL_stereo_control */ + +#ifndef WGL_AMD_gpu_association +#define WGL_AMD_gpu_association 1 +#define WGL_GPU_VENDOR_AMD 0x1F00 +#define WGL_GPU_RENDERER_STRING_AMD 0x1F01 +#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 +#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 +#define WGL_GPU_RAM_AMD 0x21A3 +#define WGL_GPU_CLOCK_AMD 0x21A4 +#define WGL_GPU_NUM_PIPES_AMD 0x21A5 +#define WGL_GPU_NUM_SIMD_AMD 0x21A6 +#define WGL_GPU_NUM_RB_AMD 0x21A7 +#define WGL_GPU_NUM_SPI_AMD 0x21A8 +typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids); +typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, int property, GLenum dataType, UINT size, void *data); +typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc); +typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id); +typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList); +typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc); +typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc); +typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void); +typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef WGL_WGLEXT_PROTOTYPES +UINT WINAPI wglGetGPUIDsAMD (UINT maxCount, UINT *ids); +INT WINAPI wglGetGPUInfoAMD (UINT id, int property, GLenum dataType, UINT size, void *data); +UINT WINAPI wglGetContextGPUIDAMD (HGLRC hglrc); +HGLRC WINAPI wglCreateAssociatedContextAMD (UINT id); +HGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT id, HGLRC hShareContext, const int *attribList); +BOOL WINAPI wglDeleteAssociatedContextAMD (HGLRC hglrc); +BOOL WINAPI wglMakeAssociatedContextCurrentAMD (HGLRC hglrc); +HGLRC WINAPI wglGetCurrentAssociatedContextAMD (void); +VOID WINAPI wglBlitContextFramebufferAMD (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +#endif /* WGL_AMD_gpu_association */ + +#ifndef WGL_ATI_pixel_format_float +#define WGL_ATI_pixel_format_float 1 +#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 +#endif /* WGL_ATI_pixel_format_float */ + +#ifndef WGL_EXT_colorspace +#define WGL_EXT_colorspace 1 +#define WGL_COLORSPACE_EXT 0x3087 +#define WGL_COLORSPACE_SRGB_EXT 0x3089 +#define WGL_COLORSPACE_LINEAR_EXT 0x308A +#endif /* WGL_EXT_colorspace */ + +#ifndef WGL_EXT_create_context_es2_profile +#define WGL_EXT_create_context_es2_profile 1 +#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 +#endif /* WGL_EXT_create_context_es2_profile */ + +#ifndef WGL_EXT_create_context_es_profile +#define WGL_EXT_create_context_es_profile 1 +#define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004 +#endif /* WGL_EXT_create_context_es_profile */ + +#ifndef WGL_EXT_depth_float +#define WGL_EXT_depth_float 1 +#define WGL_DEPTH_FLOAT_EXT 0x2040 +#endif /* WGL_EXT_depth_float */ #ifndef WGL_EXT_display_color_table #define WGL_EXT_display_color_table 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort); -extern GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *, GLuint); -extern GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort); -extern VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort); -#endif /* WGL_WGLEXT_PROTOTYPES */ typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length); typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); +#ifdef WGL_WGLEXT_PROTOTYPES +GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort id); +GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *table, GLuint length); +GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort id); +VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort id); #endif +#endif /* WGL_EXT_display_color_table */ #ifndef WGL_EXT_extensions_string #define WGL_EXT_extensions_string 1 +typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); #ifdef WGL_WGLEXT_PROTOTYPES -extern const char * WINAPI wglGetExtensionsStringEXT (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); +const char *WINAPI wglGetExtensionsStringEXT (void); #endif +#endif /* WGL_EXT_extensions_string */ + +#ifndef WGL_EXT_framebuffer_sRGB +#define WGL_EXT_framebuffer_sRGB 1 +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9 +#endif /* WGL_EXT_framebuffer_sRGB */ #ifndef WGL_EXT_make_current_read #define WGL_EXT_make_current_read 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglMakeContextCurrentEXT (HDC, HDC, HGLRC); -extern HDC WINAPI wglGetCurrentReadDCEXT (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglMakeContextCurrentEXT (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +HDC WINAPI wglGetCurrentReadDCEXT (void); #endif +#endif /* WGL_EXT_make_current_read */ + +#ifndef WGL_EXT_multisample +#define WGL_EXT_multisample 1 +#define WGL_SAMPLE_BUFFERS_EXT 0x2041 +#define WGL_SAMPLES_EXT 0x2042 +#endif /* WGL_EXT_multisample */ #ifndef WGL_EXT_pbuffer #define WGL_EXT_pbuffer 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC, int, int, int, const int *); -extern HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT); -extern int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT, HDC); -extern BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT); -extern BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT, int, int *); -#endif /* WGL_WGLEXT_PROTOTYPES */ +DECLARE_HANDLE(HPBUFFEREXT); +#define WGL_DRAW_TO_PBUFFER_EXT 0x202D +#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E +#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 +#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 +#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 +#define WGL_PBUFFER_LARGEST_EXT 0x2033 +#define WGL_PBUFFER_WIDTH_EXT 0x2034 +#define WGL_PBUFFER_HEIGHT_EXT 0x2035 typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); +#ifdef WGL_WGLEXT_PROTOTYPES +HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT hPbuffer); +int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT hPbuffer, HDC hDC); +BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT hPbuffer); +BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); #endif +#endif /* WGL_EXT_pbuffer */ #ifndef WGL_EXT_pixel_format #define WGL_EXT_pixel_format 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC, int, int, UINT, int *, int *); -extern BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC, int, int, UINT, int *, FLOAT *); -extern BOOL WINAPI wglChoosePixelFormatEXT (HDC, const int *, const FLOAT *, UINT, int *, UINT *); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 +#define WGL_DRAW_TO_WINDOW_EXT 0x2001 +#define WGL_DRAW_TO_BITMAP_EXT 0x2002 +#define WGL_ACCELERATION_EXT 0x2003 +#define WGL_NEED_PALETTE_EXT 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 +#define WGL_SWAP_METHOD_EXT 0x2007 +#define WGL_NUMBER_OVERLAYS_EXT 0x2008 +#define WGL_NUMBER_UNDERLAYS_EXT 0x2009 +#define WGL_TRANSPARENT_EXT 0x200A +#define WGL_TRANSPARENT_VALUE_EXT 0x200B +#define WGL_SHARE_DEPTH_EXT 0x200C +#define WGL_SHARE_STENCIL_EXT 0x200D +#define WGL_SHARE_ACCUM_EXT 0x200E +#define WGL_SUPPORT_GDI_EXT 0x200F +#define WGL_SUPPORT_OPENGL_EXT 0x2010 +#define WGL_DOUBLE_BUFFER_EXT 0x2011 +#define WGL_STEREO_EXT 0x2012 +#define WGL_PIXEL_TYPE_EXT 0x2013 +#define WGL_COLOR_BITS_EXT 0x2014 +#define WGL_RED_BITS_EXT 0x2015 +#define WGL_RED_SHIFT_EXT 0x2016 +#define WGL_GREEN_BITS_EXT 0x2017 +#define WGL_GREEN_SHIFT_EXT 0x2018 +#define WGL_BLUE_BITS_EXT 0x2019 +#define WGL_BLUE_SHIFT_EXT 0x201A +#define WGL_ALPHA_BITS_EXT 0x201B +#define WGL_ALPHA_SHIFT_EXT 0x201C +#define WGL_ACCUM_BITS_EXT 0x201D +#define WGL_ACCUM_RED_BITS_EXT 0x201E +#define WGL_ACCUM_GREEN_BITS_EXT 0x201F +#define WGL_ACCUM_BLUE_BITS_EXT 0x2020 +#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 +#define WGL_DEPTH_BITS_EXT 0x2022 +#define WGL_STENCIL_BITS_EXT 0x2023 +#define WGL_AUX_BUFFERS_EXT 0x2024 +#define WGL_NO_ACCELERATION_EXT 0x2025 +#define WGL_GENERIC_ACCELERATION_EXT 0x2026 +#define WGL_FULL_ACCELERATION_EXT 0x2027 +#define WGL_SWAP_EXCHANGE_EXT 0x2028 +#define WGL_SWAP_COPY_EXT 0x2029 +#define WGL_SWAP_UNDEFINED_EXT 0x202A +#define WGL_TYPE_RGBA_EXT 0x202B +#define WGL_TYPE_COLORINDEX_EXT 0x202C typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); +BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); +BOOL WINAPI wglChoosePixelFormatEXT (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); #endif +#endif /* WGL_EXT_pixel_format */ + +#ifndef WGL_EXT_pixel_format_packed_float +#define WGL_EXT_pixel_format_packed_float 1 +#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 +#endif /* WGL_EXT_pixel_format_packed_float */ #ifndef WGL_EXT_swap_control #define WGL_EXT_swap_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglSwapIntervalEXT (int); -extern int WINAPI wglGetSwapIntervalEXT (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); -#endif - -#ifndef WGL_EXT_depth_float -#define WGL_EXT_depth_float 1 -#endif - -#ifndef WGL_NV_vertex_array_range -#define WGL_NV_vertex_array_range 1 #ifdef WGL_WGLEXT_PROTOTYPES -extern void* WINAPI wglAllocateMemoryNV (GLsizei, GLfloat, GLfloat, GLfloat); -extern void WINAPI wglFreeMemoryNV (void *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef void* (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); -typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); +BOOL WINAPI wglSwapIntervalEXT (int interval); +int WINAPI wglGetSwapIntervalEXT (void); #endif +#endif /* WGL_EXT_swap_control */ -#ifndef WGL_3DFX_multisample -#define WGL_3DFX_multisample 1 -#endif - -#ifndef WGL_EXT_multisample -#define WGL_EXT_multisample 1 -#endif - -#ifndef WGL_OML_sync_control -#define WGL_OML_sync_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetSyncValuesOML (HDC, INT64 *, INT64 *, INT64 *); -extern BOOL WINAPI wglGetMscRateOML (HDC, INT32 *, INT32 *); -extern INT64 WINAPI wglSwapBuffersMscOML (HDC, INT64, INT64, INT64); -extern INT64 WINAPI wglSwapLayerBuffersMscOML (HDC, int, INT64, INT64, INT64); -extern BOOL WINAPI wglWaitForMscOML (HDC, INT64, INT64, INT64, INT64 *, INT64 *, INT64 *); -extern BOOL WINAPI wglWaitForSbcOML (HDC, INT64, INT64 *, INT64 *, INT64 *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); -typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator); -typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); -typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); -typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); -typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); -#endif +#ifndef WGL_EXT_swap_control_tear +#define WGL_EXT_swap_control_tear 1 +#endif /* WGL_EXT_swap_control_tear */ #ifndef WGL_I3D_digital_video_control #define WGL_I3D_digital_video_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC, int, int *); -extern BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC, int, const int *); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 +#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 +#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 +#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC hDC, int iAttribute, int *piValue); +BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC hDC, int iAttribute, const int *piValue); #endif +#endif /* WGL_I3D_digital_video_control */ #ifndef WGL_I3D_gamma #define WGL_I3D_gamma 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetGammaTableParametersI3D (HDC, int, int *); -extern BOOL WINAPI wglSetGammaTableParametersI3D (HDC, int, const int *); -extern BOOL WINAPI wglGetGammaTableI3D (HDC, int, USHORT *, USHORT *, USHORT *); -extern BOOL WINAPI wglSetGammaTableI3D (HDC, int, const USHORT *, const USHORT *, const USHORT *); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E +#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetGammaTableParametersI3D (HDC hDC, int iAttribute, int *piValue); +BOOL WINAPI wglSetGammaTableParametersI3D (HDC hDC, int iAttribute, const int *piValue); +BOOL WINAPI wglGetGammaTableI3D (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); +BOOL WINAPI wglSetGammaTableI3D (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); #endif +#endif /* WGL_I3D_gamma */ #ifndef WGL_I3D_genlock #define WGL_I3D_genlock 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglEnableGenlockI3D (HDC); -extern BOOL WINAPI wglDisableGenlockI3D (HDC); -extern BOOL WINAPI wglIsEnabledGenlockI3D (HDC, BOOL *); -extern BOOL WINAPI wglGenlockSourceI3D (HDC, UINT); -extern BOOL WINAPI wglGetGenlockSourceI3D (HDC, UINT *); -extern BOOL WINAPI wglGenlockSourceEdgeI3D (HDC, UINT); -extern BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC, UINT *); -extern BOOL WINAPI wglGenlockSampleRateI3D (HDC, UINT); -extern BOOL WINAPI wglGetGenlockSampleRateI3D (HDC, UINT *); -extern BOOL WINAPI wglGenlockSourceDelayI3D (HDC, UINT); -extern BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC, UINT *); -extern BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC, UINT *, UINT *); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 +#define WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D 0x2045 +#define WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D 0x2046 +#define WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D 0x2047 +#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 +#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 +#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A +#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B +#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag); @@ -579,50 +594,283 @@ typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate) typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay); typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); -#endif +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglEnableGenlockI3D (HDC hDC); +BOOL WINAPI wglDisableGenlockI3D (HDC hDC); +BOOL WINAPI wglIsEnabledGenlockI3D (HDC hDC, BOOL *pFlag); +BOOL WINAPI wglGenlockSourceI3D (HDC hDC, UINT uSource); +BOOL WINAPI wglGetGenlockSourceI3D (HDC hDC, UINT *uSource); +BOOL WINAPI wglGenlockSourceEdgeI3D (HDC hDC, UINT uEdge); +BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC hDC, UINT *uEdge); +BOOL WINAPI wglGenlockSampleRateI3D (HDC hDC, UINT uRate); +BOOL WINAPI wglGetGenlockSampleRateI3D (HDC hDC, UINT *uRate); +BOOL WINAPI wglGenlockSourceDelayI3D (HDC hDC, UINT uDelay); +BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC hDC, UINT *uDelay); +BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); +#endif +#endif /* WGL_I3D_genlock */ #ifndef WGL_I3D_image_buffer #define WGL_I3D_image_buffer 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern LPVOID WINAPI wglCreateImageBufferI3D (HDC, DWORD, UINT); -extern BOOL WINAPI wglDestroyImageBufferI3D (HDC, LPVOID); -extern BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC, const HANDLE *, const LPVOID *, const DWORD *, UINT); -extern BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC, const LPVOID *, UINT); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 +#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count); +#ifdef WGL_WGLEXT_PROTOTYPES +LPVOID WINAPI wglCreateImageBufferI3D (HDC hDC, DWORD dwSize, UINT uFlags); +BOOL WINAPI wglDestroyImageBufferI3D (HDC hDC, LPVOID pAddress); +BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); +BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC hDC, const LPVOID *pAddress, UINT count); #endif +#endif /* WGL_I3D_image_buffer */ #ifndef WGL_I3D_swap_frame_lock #define WGL_I3D_swap_frame_lock 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglEnableFrameLockI3D (void); -extern BOOL WINAPI wglDisableFrameLockI3D (void); -extern BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *); -extern BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *); -#endif /* WGL_WGLEXT_PROTOTYPES */ typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void); typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void); typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag); typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglEnableFrameLockI3D (void); +BOOL WINAPI wglDisableFrameLockI3D (void); +BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *pFlag); +BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *pFlag); #endif +#endif /* WGL_I3D_swap_frame_lock */ #ifndef WGL_I3D_swap_frame_usage #define WGL_I3D_swap_frame_usage 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetFrameUsageI3D (float *); -extern BOOL WINAPI wglBeginFrameTrackingI3D (void); -extern BOOL WINAPI wglEndFrameTrackingI3D (void); -extern BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *, DWORD *, float *); -#endif /* WGL_WGLEXT_PROTOTYPES */ typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage); typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetFrameUsageI3D (float *pUsage); +BOOL WINAPI wglBeginFrameTrackingI3D (void); +BOOL WINAPI wglEndFrameTrackingI3D (void); +BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); +#endif +#endif /* WGL_I3D_swap_frame_usage */ + +#ifndef WGL_NV_DX_interop +#define WGL_NV_DX_interop 1 +#define WGL_ACCESS_READ_ONLY_NV 0x00000000 +#define WGL_ACCESS_READ_WRITE_NV 0x00000001 +#define WGL_ACCESS_WRITE_DISCARD_NV 0x00000002 +typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void *dxObject, HANDLE shareHandle); +typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void *dxDevice); +typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice); +typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); +typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject); +typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access); +typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); +typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglDXSetResourceShareHandleNV (void *dxObject, HANDLE shareHandle); +HANDLE WINAPI wglDXOpenDeviceNV (void *dxDevice); +BOOL WINAPI wglDXCloseDeviceNV (HANDLE hDevice); +HANDLE WINAPI wglDXRegisterObjectNV (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); +BOOL WINAPI wglDXUnregisterObjectNV (HANDLE hDevice, HANDLE hObject); +BOOL WINAPI wglDXObjectAccessNV (HANDLE hObject, GLenum access); +BOOL WINAPI wglDXLockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); +BOOL WINAPI wglDXUnlockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); +#endif +#endif /* WGL_NV_DX_interop */ + +#ifndef WGL_NV_DX_interop2 +#define WGL_NV_DX_interop2 1 +#endif /* WGL_NV_DX_interop2 */ + +#ifndef WGL_NV_copy_image +#define WGL_NV_copy_image 1 +typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglCopyImageSubDataNV (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* WGL_NV_copy_image */ + +#ifndef WGL_NV_delay_before_swap +#define WGL_NV_delay_before_swap 1 +typedef BOOL (WINAPI * PFNWGLDELAYBEFORESWAPNVPROC) (HDC hDC, GLfloat seconds); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglDelayBeforeSwapNV (HDC hDC, GLfloat seconds); #endif +#endif /* WGL_NV_delay_before_swap */ +#ifndef WGL_NV_float_buffer +#define WGL_NV_float_buffer 1 +#define WGL_FLOAT_COMPONENTS_NV 0x20B0 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 +#define WGL_TEXTURE_FLOAT_R_NV 0x20B5 +#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 +#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 +#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 +#endif /* WGL_NV_float_buffer */ + +#ifndef WGL_NV_gpu_affinity +#define WGL_NV_gpu_affinity 1 +DECLARE_HANDLE(HGPUNV); +struct _GPU_DEVICE { + DWORD cb; + CHAR DeviceName[32]; + CHAR DeviceString[128]; + DWORD Flags; + RECT rcVirtualScreen; +}; +typedef struct _GPU_DEVICE *PGPU_DEVICE; +#define ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 +#define ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 +typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu); +typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); +typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList); +typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); +typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglEnumGpusNV (UINT iGpuIndex, HGPUNV *phGpu); +BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); +HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *phGpuList); +BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); +BOOL WINAPI wglDeleteDCNV (HDC hdc); +#endif +#endif /* WGL_NV_gpu_affinity */ + +#ifndef WGL_NV_multisample_coverage +#define WGL_NV_multisample_coverage 1 +#define WGL_COVERAGE_SAMPLES_NV 0x2042 +#define WGL_COLOR_SAMPLES_NV 0x20B9 +#endif /* WGL_NV_multisample_coverage */ + +#ifndef WGL_NV_present_video +#define WGL_NV_present_video 1 +DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); +#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 +typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); +typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); +typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue); +#ifdef WGL_WGLEXT_PROTOTYPES +int WINAPI wglEnumerateVideoDevicesNV (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); +BOOL WINAPI wglBindVideoDeviceNV (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); +BOOL WINAPI wglQueryCurrentContextNV (int iAttribute, int *piValue); +#endif +#endif /* WGL_NV_present_video */ + +#ifndef WGL_NV_render_depth_texture +#define WGL_NV_render_depth_texture 1 +#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 +#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 +#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 +#define WGL_DEPTH_COMPONENT_NV 0x20A7 +#endif /* WGL_NV_render_depth_texture */ + +#ifndef WGL_NV_render_texture_rectangle +#define WGL_NV_render_texture_rectangle 1 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 +#define WGL_TEXTURE_RECTANGLE_NV 0x20A2 +#endif /* WGL_NV_render_texture_rectangle */ + +#ifndef WGL_NV_swap_group +#define WGL_NV_swap_group 1 +typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); +typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); +typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier); +typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count); +typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglJoinSwapGroupNV (HDC hDC, GLuint group); +BOOL WINAPI wglBindSwapBarrierNV (GLuint group, GLuint barrier); +BOOL WINAPI wglQuerySwapGroupNV (HDC hDC, GLuint *group, GLuint *barrier); +BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); +BOOL WINAPI wglQueryFrameCountNV (HDC hDC, GLuint *count); +BOOL WINAPI wglResetFrameCountNV (HDC hDC); +#endif +#endif /* WGL_NV_swap_group */ + +#ifndef WGL_NV_vertex_array_range +#define WGL_NV_vertex_array_range 1 +typedef void *(WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); +typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); +#ifdef WGL_WGLEXT_PROTOTYPES +void *WINAPI wglAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); +void WINAPI wglFreeMemoryNV (void *pointer); +#endif +#endif /* WGL_NV_vertex_array_range */ + +#ifndef WGL_NV_video_capture +#define WGL_NV_video_capture 1 +DECLARE_HANDLE(HVIDEOINPUTDEVICENV); +#define WGL_UNIQUE_ID_NV 0x20CE +#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF +typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); +typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); +typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); +UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); +BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); +BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +#endif +#endif /* WGL_NV_video_capture */ + +#ifndef WGL_NV_video_output +#define WGL_NV_video_output 1 +DECLARE_HANDLE(HPVIDEODEV); +#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0 +#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1 +#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2 +#define WGL_VIDEO_OUT_COLOR_NV 0x20C3 +#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4 +#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5 +#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 +#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 +#define WGL_VIDEO_OUT_FRAME 0x20C8 +#define WGL_VIDEO_OUT_FIELD_1 0x20C9 +#define WGL_VIDEO_OUT_FIELD_2 0x20CA +#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB +#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC +typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice); +typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer); +typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); +typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetVideoDeviceNV (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); +BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV hVideoDevice); +BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); +BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB hPbuffer, int iVideoBuffer); +BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); +BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +#endif +#endif /* WGL_NV_video_output */ + +#ifndef WGL_OML_sync_control +#define WGL_OML_sync_control 1 +typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); +typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator); +typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); +typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); +typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); +typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetSyncValuesOML (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); +BOOL WINAPI wglGetMscRateOML (HDC hdc, INT32 *numerator, INT32 *denominator); +INT64 WINAPI wglSwapBuffersMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); +INT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); +BOOL WINAPI wglWaitForMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); +BOOL WINAPI wglWaitForSbcOML (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); +#endif +#endif /* WGL_OML_sync_control */ #ifdef __cplusplus } diff --git a/src/windows/native/sun/nio/ch/WindowsSelectorImpl.c b/src/windows/native/sun/nio/ch/WindowsSelectorImpl.c index c43496a59bab52aa70bd13cf9e24da28a21b8a5a..63358490650d8c91362d4809e765d29388a1ed2f 100644 --- a/src/windows/native/sun/nio/ch/WindowsSelectorImpl.c +++ b/src/windows/native/sun/nio/ch/WindowsSelectorImpl.c @@ -38,6 +38,7 @@ #include "jvm.h" #include "jni.h" #include "jni_util.h" +#include "nio.h" #include "sun_nio_ch_WindowsSelectorImpl.h" #include "sun_nio_ch_PollArrayWrapper.h" @@ -55,12 +56,14 @@ JNIEXPORT jint JNICALL Java_sun_nio_ch_WindowsSelectorImpl_00024SubSelector_poll0(JNIEnv *env, jobject this, jlong pollAddress, jint numfds, jintArray returnReadFds, jintArray returnWriteFds, - jintArray returnExceptFds, jlong timeout) + jintArray returnExceptFds, jlong timeout, jlong fdsBuffer) { DWORD result = 0; pollfd *fds = (pollfd *) pollAddress; int i; - FD_SET readfds, writefds, exceptfds; + FD_SET *readfds = (FD_SET *) jlong_to_ptr(fdsBuffer); + FD_SET *writefds = (FD_SET *) jlong_to_ptr(fdsBuffer + sizeof(FD_SET)); + FD_SET *exceptfds = (FD_SET *) jlong_to_ptr(fdsBuffer + sizeof(FD_SET) * 2); struct timeval timevalue, *tv; static struct timeval zerotime = {0, 0}; int read_count = 0, write_count = 0, except_count = 0; @@ -82,66 +85,68 @@ Java_sun_nio_ch_WindowsSelectorImpl_00024SubSelector_poll0(JNIEnv *env, jobject /* Set FD_SET structures required for select */ for (i = 0; i < numfds; i++) { if (fds[i].events & POLLIN) { - readfds.fd_array[read_count] = fds[i].fd; + readfds->fd_array[read_count] = fds[i].fd; read_count++; } if (fds[i].events & (POLLOUT | POLLCONN)) { - writefds.fd_array[write_count] = fds[i].fd; + writefds->fd_array[write_count] = fds[i].fd; write_count++; } - exceptfds.fd_array[except_count] = fds[i].fd; + exceptfds->fd_array[except_count] = fds[i].fd; except_count++; } - readfds.fd_count = read_count; - writefds.fd_count = write_count; - exceptfds.fd_count = except_count; + readfds->fd_count = read_count; + writefds->fd_count = write_count; + exceptfds->fd_count = except_count; /* Call select */ - if ((result = select(0 , &readfds, &writefds, &exceptfds, tv)) + if ((result = select(0 , readfds, writefds, exceptfds, tv)) == SOCKET_ERROR) { /* Bad error - this should not happen frequently */ /* Iterate over sockets and call select() on each separately */ - FD_SET errreadfds, errwritefds, errexceptfds; - readfds.fd_count = 0; - writefds.fd_count = 0; - exceptfds.fd_count = 0; + FD_SET *errreadfds = (FD_SET *) jlong_to_ptr(fdsBuffer + sizeof(FD_SET) * 3); + FD_SET *errwritefds = (FD_SET *) jlong_to_ptr(fdsBuffer + sizeof(FD_SET) * 4); + FD_SET *errexceptfds = (FD_SET *) jlong_to_ptr(fdsBuffer + sizeof(FD_SET) * 5); + readfds->fd_count = 0; + writefds->fd_count = 0; + exceptfds->fd_count = 0; for (i = 0; i < numfds; i++) { /* prepare select structures for the i-th socket */ - errreadfds.fd_count = 0; - errwritefds.fd_count = 0; + errreadfds->fd_count = 0; + errwritefds->fd_count = 0; if (fds[i].events & POLLIN) { - errreadfds.fd_array[0] = fds[i].fd; - errreadfds.fd_count = 1; + errreadfds->fd_array[0] = fds[i].fd; + errreadfds->fd_count = 1; } if (fds[i].events & (POLLOUT | POLLCONN)) { - errwritefds.fd_array[0] = fds[i].fd; - errwritefds.fd_count = 1; + errwritefds->fd_array[0] = fds[i].fd; + errwritefds->fd_count = 1; } - errexceptfds.fd_array[0] = fds[i].fd; - errexceptfds.fd_count = 1; + errexceptfds->fd_array[0] = fds[i].fd; + errexceptfds->fd_count = 1; /* call select on the i-th socket */ - if (select(0, &errreadfds, &errwritefds, &errexceptfds, &zerotime) + if (select(0, errreadfds, errwritefds, errexceptfds, &zerotime) == SOCKET_ERROR) { /* This socket causes an error. Add it to exceptfds set */ - exceptfds.fd_array[exceptfds.fd_count] = fds[i].fd; - exceptfds.fd_count++; + exceptfds->fd_array[exceptfds->fd_count] = fds[i].fd; + exceptfds->fd_count++; } else { /* This socket does not cause an error. Process result */ - if (errreadfds.fd_count == 1) { - readfds.fd_array[readfds.fd_count] = fds[i].fd; - readfds.fd_count++; + if (errreadfds->fd_count == 1) { + readfds->fd_array[readfds->fd_count] = fds[i].fd; + readfds->fd_count++; } - if (errwritefds.fd_count == 1) { - writefds.fd_array[writefds.fd_count] = fds[i].fd; - writefds.fd_count++; + if (errwritefds->fd_count == 1) { + writefds->fd_array[writefds->fd_count] = fds[i].fd; + writefds->fd_count++; } - if (errexceptfds.fd_count == 1) { - exceptfds.fd_array[exceptfds.fd_count] = fds[i].fd; - exceptfds.fd_count++; + if (errexceptfds->fd_count == 1) { + exceptfds->fd_array[exceptfds->fd_count] = fds[i].fd; + exceptfds->fd_count++; } } } @@ -151,34 +156,34 @@ Java_sun_nio_ch_WindowsSelectorImpl_00024SubSelector_poll0(JNIEnv *env, jobject /* Each Java array consists of sockets count followed by sockets list */ #ifdef _WIN64 - resultbuf[0] = readfds.fd_count; - for (i = 0; i < (int)readfds.fd_count; i++) { - resultbuf[i + 1] = (int)readfds.fd_array[i]; + resultbuf[0] = readfds->fd_count; + for (i = 0; i < (int)readfds->fd_count; i++) { + resultbuf[i + 1] = (int)readfds->fd_array[i]; } (*env)->SetIntArrayRegion(env, returnReadFds, 0, - readfds.fd_count + 1, resultbuf); + readfds->fd_count + 1, resultbuf); - resultbuf[0] = writefds.fd_count; - for (i = 0; i < (int)writefds.fd_count; i++) { - resultbuf[i + 1] = (int)writefds.fd_array[i]; + resultbuf[0] = writefds->fd_count; + for (i = 0; i < (int)writefds->fd_count; i++) { + resultbuf[i + 1] = (int)writefds->fd_array[i]; } (*env)->SetIntArrayRegion(env, returnWriteFds, 0, - writefds.fd_count + 1, resultbuf); + writefds->fd_count + 1, resultbuf); - resultbuf[0] = exceptfds.fd_count; - for (i = 0; i < (int)exceptfds.fd_count; i++) { - resultbuf[i + 1] = (int)exceptfds.fd_array[i]; + resultbuf[0] = exceptfds->fd_count; + for (i = 0; i < (int)exceptfds->fd_count; i++) { + resultbuf[i + 1] = (int)exceptfds->fd_array[i]; } (*env)->SetIntArrayRegion(env, returnExceptFds, 0, - exceptfds.fd_count + 1, resultbuf); + exceptfds->fd_count + 1, resultbuf); #else (*env)->SetIntArrayRegion(env, returnReadFds, 0, - readfds.fd_count + 1, (jint *)&readfds); + readfds->fd_count + 1, (jint *)readfds); (*env)->SetIntArrayRegion(env, returnWriteFds, 0, - writefds.fd_count + 1, (jint *)&writefds); + writefds->fd_count + 1, (jint *)writefds); (*env)->SetIntArrayRegion(env, returnExceptFds, 0, - exceptfds.fd_count + 1, (jint *)&exceptfds); + exceptfds->fd_count + 1, (jint *)exceptfds); #endif return 0; } diff --git a/src/windows/native/sun/security/mscapi/security.cpp b/src/windows/native/sun/security/mscapi/security.cpp index 12c408e8ee3a13394d9db4e079c8e6048a931520..8ba36f5c02ffd785e25b33bd7908340de6a87718 100644 --- a/src/windows/native/sun/security/mscapi/security.cpp +++ b/src/windows/native/sun/security/mscapi/security.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,14 @@ #include #include #include +#include "sun_security_mscapi_CKey.h" +#include "sun_security_mscapi_CKeyStore.h" +#include "sun_security_mscapi_CRSACipher.h" +#include "sun_security_mscapi_CKeyPairGenerator_RSA.h" +#include "sun_security_mscapi_CPublicKey.h" +#include "sun_security_mscapi_CPublicKey_CRSAPublicKey.h" +#include "sun_security_mscapi_CSignature.h" +#include "sun_security_mscapi_CSignature_RSA.h" #define OID_EKU_ANY "2.5.29.37.0" @@ -50,8 +58,55 @@ #define SIGNATURE_EXCEPTION "java/security/SignatureException" #define OUT_OF_MEMORY_ERROR "java/lang/OutOfMemoryError" +#define SS_CHECK(Status) \ + if (Status != ERROR_SUCCESS) { \ + ThrowException(env, SIGNATURE_EXCEPTION, Status); \ + __leave; \ + } + +#define PP(fmt, ...) \ + if (trace) { \ + fprintf(stdout, "MSCAPI (%ld): ", __LINE__); \ + fprintf(stdout, fmt, ##__VA_ARGS__); \ + fprintf(stdout, "\n"); \ + fflush(stdout); \ + } + extern "C" { +char* trace = getenv("CAPI_TRACE"); + +void showProperty(NCRYPT_HANDLE hKey); + +void dump(LPSTR title, PBYTE data, DWORD len) +{ + if (trace) { + printf("==== %s ====\n", title); + for (DWORD i = 0; i < len; i+=16) { + printf("%04x: ", i); + for (int j = 0; j < 16; j++) { + if (j == 8) { + printf(" "); + } + if (i + j < len) { + printf("%02X ", *(data + i + j) & 0xff); + } else { + printf(" "); + } + } + for (int j = 0; j < 16; j++) { + if (i + j < len) { + int k = *(data + i + j) & 0xff; + if (k < 32 || k > 127) printf("."); + else printf("%c", (char)k); + } + } + printf("\n"); + } + fflush(stdout); + } +} + /* * Throws an arbitrary Java exception with the given message. */ @@ -134,6 +189,37 @@ ALG_ID MapHashAlgorithm(JNIEnv *env, jstring jHashAlgorithm) { return algId; } +/* + * Maps the name of a hash algorithm to a CNG Algorithm Identifier. + */ +LPCWSTR MapHashIdentifier(JNIEnv *env, jstring jHashAlgorithm) { + + const char* pszHashAlgorithm = NULL; + LPCWSTR id = NULL; + + if ((pszHashAlgorithm = env->GetStringUTFChars(jHashAlgorithm, NULL)) + == NULL) { + return id; + } + + if ((strcmp("SHA", pszHashAlgorithm) == 0) || + (strcmp("SHA1", pszHashAlgorithm) == 0) || + (strcmp("SHA-1", pszHashAlgorithm) == 0)) { + + id = BCRYPT_SHA1_ALGORITHM; + } else if (strcmp("SHA-256", pszHashAlgorithm) == 0) { + id = BCRYPT_SHA256_ALGORITHM; + } else if (strcmp("SHA-384", pszHashAlgorithm) == 0) { + id = BCRYPT_SHA384_ALGORITHM; + } else if (strcmp("SHA-512", pszHashAlgorithm) == 0) { + id = BCRYPT_SHA512_ALGORITHM; + } + + if (pszHashAlgorithm) + env->ReleaseStringUTFChars(jHashAlgorithm, pszHashAlgorithm); + + return id; +} /* * Returns a certificate chain context given a certificate context and key @@ -190,7 +276,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_PRNG_generateSeed __try { // Acquire a CSP context. - if(::CryptAcquireContext( + if(::CryptAcquireContext( //deprecated &hCryptProv, NULL, NULL, @@ -218,7 +304,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_PRNG_generateSeed __leave; } - if (::CryptGenRandom( + if (::CryptGenRandom( //deprecated hCryptProv, length, (BYTE *) reseedBytes) == FALSE) { @@ -244,7 +330,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_PRNG_generateSeed __leave; } - if (::CryptGenRandom( + if (::CryptGenRandom( //deprecated hCryptProv, length, (BYTE *) seedBytes) == FALSE) { @@ -268,7 +354,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_PRNG_generateSeed env->ReleaseByteArrayElements(seed, seedBytes, 0); // update orig if (hCryptProv) - ::CryptReleaseContext(hCryptProv, 0); + ::CryptReleaseContext(hCryptProv, 0); //deprecated } return result; @@ -276,11 +362,11 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_PRNG_generateSeed /* - * Class: sun_security_mscapi_KeyStore + * Class: sun_security_mscapi_CKeyStore * Method: loadKeysOrCertificateChains - * Signature: (Ljava/lang/String;Ljava/util/Collection;)V + * Signature: (Ljava/lang/String;)V */ -JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_loadKeysOrCertificateChains +JNIEXPORT void JNICALL Java_sun_security_mscapi_CKeyStore_loadKeysOrCertificateChains (JNIEnv *env, jobject obj, jstring jCertStoreName) { /** @@ -346,10 +432,10 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_loadKeysOrCertificateCh } // Determine method ID to generate RSA certificate chain - jmethodID mGenRSAKeyAndCertChain = env->GetMethodID(clazzOfThis, - "generateRSAKeyAndCertificateChain", - "(Ljava/lang/String;JJILjava/util/Collection;)V"); - if (mGenRSAKeyAndCertChain == NULL) { + jmethodID mGenKeyAndCertChain = env->GetMethodID(clazzOfThis, + "generateKeyAndCertificateChain", + "(ZLjava/lang/String;JJILjava/util/Collection;)V"); + if (mGenKeyAndCertChain == NULL) { __leave; } @@ -358,6 +444,7 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_loadKeysOrCertificateCh // NULL to retrieve the first certificate in the store. while (pCertContext = ::CertEnumCertificatesInStore(hCertStore, pCertContext)) { + PP("--------------------------"); // Check if private key available - client authentication certificate // must have private key available. HCRYPTPROV hCryptProv = NULL; @@ -368,41 +455,48 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_loadKeysOrCertificateCh DWORD dwPublicKeyLength = 0; // First, probe it silently - if (::CryptAcquireCertificatePrivateKey(pCertContext, CRYPT_ACQUIRE_SILENT_FLAG, NULL, + if (::CryptAcquireCertificatePrivateKey(pCertContext, + CRYPT_ACQUIRE_ALLOW_NCRYPT_KEY_FLAG | CRYPT_ACQUIRE_SILENT_FLAG, NULL, &hCryptProv, &dwKeySpec, &bCallerFreeProv) == FALSE && GetLastError() != NTE_SILENT_CONTEXT) { + PP("bHasNoPrivateKey = TRUE!"); bHasNoPrivateKey = TRUE; } else { if (bCallerFreeProv == TRUE) { - ::CryptReleaseContext(hCryptProv, NULL); + ::CryptReleaseContext(hCryptProv, NULL); // deprecated bCallerFreeProv = FALSE; } // Second, acquire the key normally (not silently) - if (::CryptAcquireCertificatePrivateKey(pCertContext, 0, NULL, + if (::CryptAcquireCertificatePrivateKey(pCertContext, CRYPT_ACQUIRE_ALLOW_NCRYPT_KEY_FLAG, NULL, &hCryptProv, &dwKeySpec, &bCallerFreeProv) == FALSE) { + PP("bHasNoPrivateKey = TRUE!!"); bHasNoPrivateKey = TRUE; } else { - // Private key is available - BOOL bGetUserKey = ::CryptGetUserKey(hCryptProv, dwKeySpec, &hUserKey); - - // Skip certificate if cannot find private key - if (bGetUserKey == FALSE) { - if (bCallerFreeProv) - ::CryptReleaseContext(hCryptProv, NULL); - continue; - } - - // Set cipher mode to ECB - DWORD dwCipherMode = CRYPT_MODE_ECB; - ::CryptSetKeyParam(hUserKey, KP_MODE, (BYTE*)&dwCipherMode, NULL); + if ((dwKeySpec & CERT_NCRYPT_KEY_SPEC) == CERT_NCRYPT_KEY_SPEC) { + PP("CNG %I64d", (__int64)hCryptProv); + } else { + // Private key is available + BOOL bGetUserKey = ::CryptGetUserKey(hCryptProv, dwKeySpec, &hUserKey); //deprecated + + // Skip certificate if cannot find private key + if (bGetUserKey == FALSE) { + if (bCallerFreeProv) + ::CryptReleaseContext(hCryptProv, NULL); // deprecated + continue; + } + // Set cipher mode to ECB + DWORD dwCipherMode = CRYPT_MODE_ECB; + ::CryptSetKeyParam(hUserKey, KP_MODE, (BYTE*)&dwCipherMode, NULL); //deprecated + PP("CAPI %I64d %I64d", (__int64)hCryptProv, (__int64)hUserKey); + } // If the private key is present in smart card, we may not be able to // determine the key length by using the private key handle. However, // since public/private key pairs must have the same length, we could @@ -491,6 +585,8 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_loadKeysOrCertificateCh // or SAN. if (pszNameString) { + PP("%s: %s", pszNameString, + pCertContext->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId); if (bHasNoPrivateKey) { // Generate certificate chain and store into cert chain @@ -505,24 +601,57 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_loadKeysOrCertificateCh } else { - // Determine key type: RSA or DSA - DWORD dwData = CALG_RSA_KEYX; - DWORD dwSize = sizeof(DWORD); - ::CryptGetKeyParam(hUserKey, KP_ALGID, (BYTE*)&dwData, - &dwSize, NULL); - - if ((dwData & ALG_TYPE_RSA) == ALG_TYPE_RSA) - { - // Generate RSA certificate chain and store into cert - // chain collection - jstring name = env->NewStringUTF(pszNameString); - if (name == NULL) { - __leave; + if (hUserKey) { + // Only accept RSA for CAPI + DWORD dwData = CALG_RSA_KEYX; + DWORD dwSize = sizeof(DWORD); + ::CryptGetKeyParam(hUserKey, KP_ALGID, (BYTE*)&dwData, //deprecated + &dwSize, NULL); + if ((dwData & ALG_TYPE_RSA) == ALG_TYPE_RSA) + { + // Generate RSA certificate chain and store into cert + // chain collection + jstring name = env->NewStringUTF(pszNameString); + if (name == NULL) { + __leave; + } + env->CallVoidMethod(obj, mGenKeyAndCertChain, + 1, + name, + (jlong) hCryptProv, (jlong) hUserKey, + dwPublicKeyLength, jArrayList); + } + } else { + // Only accept EC for CNG + BYTE buffer[32]; + DWORD len = 0; + if (::NCryptGetProperty( + hCryptProv, NCRYPT_ALGORITHM_PROPERTY, + (PBYTE)buffer, 32, &len, NCRYPT_SILENT_FLAG) == ERROR_SUCCESS) { + jstring name = env->NewStringUTF(pszNameString); + if (name == NULL) { + __leave; + } + if (buffer[0] == 'E' && buffer[2] == 'C' + && (dwPublicKeyLength == 256 + || dwPublicKeyLength == 384 + || dwPublicKeyLength == 521)) { + env->CallVoidMethod(obj, mGenKeyAndCertChain, + 0, + name, + (jlong) hCryptProv, (jlong) 0, + dwPublicKeyLength, jArrayList); + } else if (buffer[0] == 'R' && buffer[2] == 'S' + && buffer[4] == 'A') { + env->CallVoidMethod(obj, mGenKeyAndCertChain, + 1, + name, + (jlong) hCryptProv, (jlong) 0, + dwPublicKeyLength, jArrayList); + } else { + dump("Unknown NCRYPT_ALGORITHM_PROPERTY", buffer, len); + } } - env->CallVoidMethod(obj, mGenRSAKeyAndCertChain, - name, - (jlong) hCryptProv, (jlong) hUserKey, - dwPublicKeyLength, jArrayList); } } } @@ -531,6 +660,8 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_loadKeysOrCertificateCh // Free cert chain if (pCertChainContext) ::CertFreeCertificateChain(pCertChainContext); + } else { + PP("GetCertificateChain failed %d", GetLastError()); } } } @@ -549,27 +680,30 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_loadKeysOrCertificateCh /* - * Class: sun_security_mscapi_Key + * Class: sun_security_mscapi_CKey * Method: cleanUp * Signature: (JJ)V */ -JNIEXPORT void JNICALL Java_sun_security_mscapi_Key_cleanUp +JNIEXPORT void JNICALL Java_sun_security_mscapi_CKey_cleanUp (JNIEnv *env, jclass clazz, jlong hCryptProv, jlong hCryptKey) { - if (hCryptKey != NULL) - ::CryptDestroyKey((HCRYPTKEY) hCryptKey); + if (hCryptKey == NULL && hCryptProv != NULL) { + NCryptFreeObject((NCRYPT_HANDLE)hCryptProv); + } else { + if (hCryptKey != NULL) + ::CryptDestroyKey((HCRYPTKEY) hCryptKey); // deprecated - if (hCryptProv != NULL) - ::CryptReleaseContext((HCRYPTPROV) hCryptProv, NULL); + if (hCryptProv != NULL) + ::CryptReleaseContext((HCRYPTPROV) hCryptProv, NULL); // deprecated + } } - /* - * Class: sun_security_mscapi_RSASignature + * Class: sun_security_mscapi_CSignature * Method: signHash * Signature: (Z[BILjava/lang/String;JJ)[B */ -JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSASignature_signHash +JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_CSignature_signHash (JNIEnv *env, jclass clazz, jboolean noHashOID, jbyteArray jHash, jint jHashSize, jstring jHashAlgorithm, jlong hCryptProv, jlong hCryptKey) @@ -586,7 +720,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSASignature_signHash ALG_ID algId = MapHashAlgorithm(env, jHashAlgorithm); // Acquire a hash object handle. - if (::CryptCreateHash(HCRYPTPROV(hCryptProv), algId, 0, 0, &hHash) == FALSE) + if (::CryptCreateHash(HCRYPTPROV(hCryptProv), algId, 0, 0, &hHash) == FALSE) //deprecated { // Failover to using the PROV_RSA_AES CSP @@ -595,11 +729,11 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSASignature_signHash pbData[0] = '\0'; // Get name of the key container - ::CryptGetProvParam((HCRYPTPROV)hCryptProv, PP_CONTAINER, + ::CryptGetProvParam((HCRYPTPROV)hCryptProv, PP_CONTAINER, //deprecated (BYTE *)pbData, &cbData, 0); // Acquire an alternative CSP handle - if (::CryptAcquireContext(&hCryptProvAlt, LPCSTR(pbData), NULL, + if (::CryptAcquireContext(&hCryptProvAlt, LPCSTR(pbData), NULL, //deprecated PROV_RSA_AES, 0) == FALSE) { @@ -608,7 +742,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSASignature_signHash } // Acquire a hash object handle. - if (::CryptCreateHash(HCRYPTPROV(hCryptProvAlt), algId, 0, 0, + if (::CryptCreateHash(HCRYPTPROV(hCryptProvAlt), algId, 0, 0, //deprecated &hHash) == FALSE) { ThrowException(env, SIGNATURE_EXCEPTION, GetLastError()); @@ -624,7 +758,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSASignature_signHash env->GetByteArrayRegion(jHash, 0, jHashSize, pHashBuffer); // Set hash value in the hash object - if (::CryptSetHashParam(hHash, HP_HASHVAL, (BYTE*)pHashBuffer, NULL) == FALSE) + if (::CryptSetHashParam(hHash, HP_HASHVAL, (BYTE*)pHashBuffer, NULL) == FALSE) //deprecated { ThrowException(env, SIGNATURE_EXCEPTION, GetLastError()); __leave; @@ -635,7 +769,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSASignature_signHash ALG_ID dwAlgId; DWORD dwAlgIdLen = sizeof(ALG_ID); - if (! ::CryptGetKeyParam((HCRYPTKEY) hCryptKey, KP_ALGID, (BYTE*)&dwAlgId, &dwAlgIdLen, 0)) { + if (! ::CryptGetKeyParam((HCRYPTKEY) hCryptKey, KP_ALGID, (BYTE*)&dwAlgId, &dwAlgIdLen, 0)) { //deprecated ThrowException(env, SIGNATURE_EXCEPTION, GetLastError()); __leave; @@ -652,7 +786,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSASignature_signHash dwFlags = CRYPT_NOHASHOID; // omit hash OID in NONEwithRSA signature } - if (::CryptSignHash(hHash, dwKeySpec, NULL, dwFlags, NULL, &dwBufLen) == FALSE) + if (::CryptSignHash(hHash, dwKeySpec, NULL, dwFlags, NULL, &dwBufLen) == FALSE) //deprecated { ThrowException(env, SIGNATURE_EXCEPTION, GetLastError()); __leave; @@ -662,7 +796,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSASignature_signHash if (pSignedHashBuffer == NULL) { __leave; } - if (::CryptSignHash(hHash, dwKeySpec, NULL, dwFlags, (BYTE*)pSignedHashBuffer, &dwBufLen) == FALSE) + if (::CryptSignHash(hHash, dwKeySpec, NULL, dwFlags, (BYTE*)pSignedHashBuffer, &dwBufLen) == FALSE) //deprecated { ThrowException(env, SIGNATURE_EXCEPTION, GetLastError()); __leave; @@ -688,21 +822,143 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSASignature_signHash delete [] pHashBuffer; if (hHash) - ::CryptDestroyHash(hHash); + ::CryptDestroyHash(hHash); //deprecated if (hCryptProvAlt) - ::CryptReleaseContext(hCryptProvAlt, 0); + ::CryptReleaseContext(hCryptProvAlt, 0); // deprecated } return jSignedHash; } /* - * Class: sun_security_mscapi_RSASignature + * Class: sun_security_mscapi_CSignature + * Method: signCngHash + * Signature: (I[BIILjava/lang/String;JJ)[B + */ +JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_CSignature_signCngHash + (JNIEnv *env, jclass clazz, jint type, jbyteArray jHash, + jint jHashSize, jint saltLen, jstring jHashAlgorithm, jlong hCryptProv, + jlong hCryptKey) +{ + jbyteArray jSignedHash = NULL; + + jbyte* pHashBuffer = NULL; + jbyte* pSignedHashBuffer = NULL; + NCRYPT_KEY_HANDLE hk = NULL; + + __try + { + if (hCryptKey == 0) { + hk = (NCRYPT_KEY_HANDLE)hCryptProv; + } else { + SS_CHECK(::NCryptTranslateHandle( + NULL, + &hk, + (HCRYPTPROV)hCryptProv, + (HCRYPTKEY)hCryptKey, + NULL, + 0)); + } + + // Copy hash from Java to native buffer + pHashBuffer = new (env) jbyte[jHashSize]; + if (pHashBuffer == NULL) { + __leave; + } + env->GetByteArrayRegion(jHash, 0, jHashSize, pHashBuffer); + + VOID* param; + DWORD dwFlags; + + switch (type) { + case 0: + param = NULL; + dwFlags = 0; + break; + case 1: + BCRYPT_PKCS1_PADDING_INFO pkcs1Info; + if (jHashAlgorithm) { + pkcs1Info.pszAlgId = MapHashIdentifier(env, jHashAlgorithm); + if (pkcs1Info.pszAlgId == NULL) { + ThrowExceptionWithMessage(env, SIGNATURE_EXCEPTION, + "Unrecognised hash algorithm"); + __leave; + } + } else { + pkcs1Info.pszAlgId = NULL; + } + param = &pkcs1Info; + dwFlags = BCRYPT_PAD_PKCS1; + break; + case 2: + BCRYPT_PSS_PADDING_INFO pssInfo; + pssInfo.pszAlgId = MapHashIdentifier(env, jHashAlgorithm); + pssInfo.cbSalt = saltLen; + if (pssInfo.pszAlgId == NULL) { + ThrowExceptionWithMessage(env, SIGNATURE_EXCEPTION, + "Unrecognised hash algorithm"); + __leave; + } + param = &pssInfo; + dwFlags = BCRYPT_PAD_PSS; + break; + } + + DWORD jSignedHashSize = 0; + SS_CHECK(::NCryptSignHash( + hk, + param, + (BYTE*)pHashBuffer, jHashSize, + NULL, 0, &jSignedHashSize, + dwFlags + )); + + pSignedHashBuffer = new (env) jbyte[jSignedHashSize]; + if (pSignedHashBuffer == NULL) { + __leave; + } + + SS_CHECK(::NCryptSignHash( + hk, + param, + (BYTE*)pHashBuffer, jHashSize, + (BYTE*)pSignedHashBuffer, jSignedHashSize, &jSignedHashSize, + dwFlags + )); + + // Create new byte array + jbyteArray temp = env->NewByteArray(jSignedHashSize); + if (temp == NULL) { + __leave; + } + + // Copy data from native buffer + env->SetByteArrayRegion(temp, 0, jSignedHashSize, pSignedHashBuffer); + + jSignedHash = temp; + } + __finally + { + if (pSignedHashBuffer) + delete [] pSignedHashBuffer; + + if (pHashBuffer) + delete [] pHashBuffer; + + if (hCryptKey != 0 && hk != NULL) + ::NCryptFreeObject(hk); + } + + return jSignedHash; +} + +/* + * Class: sun_security_mscapi_CSignature * Method: verifySignedHash * Signature: ([BIL/java/lang/String;[BIJJ)Z */ -JNIEXPORT jboolean JNICALL Java_sun_security_mscapi_RSASignature_verifySignedHash +JNIEXPORT jboolean JNICALL Java_sun_security_mscapi_CSignature_verifySignedHash (JNIEnv *env, jclass clazz, jbyteArray jHash, jint jHashSize, jstring jHashAlgorithm, jbyteArray jSignedHash, jint jSignedHashSize, jlong hCryptProv, jlong hCryptKey) @@ -730,11 +986,11 @@ JNIEXPORT jboolean JNICALL Java_sun_security_mscapi_RSASignature_verifySignedHas pbData[0] = '\0'; // Get name of the key container - ::CryptGetProvParam((HCRYPTPROV)hCryptProv, PP_CONTAINER, + ::CryptGetProvParam((HCRYPTPROV)hCryptProv, PP_CONTAINER, //deprecated (BYTE *)pbData, &cbData, 0); // Acquire an alternative CSP handle - if (::CryptAcquireContext(&hCryptProvAlt, LPCSTR(pbData), NULL, + if (::CryptAcquireContext(&hCryptProvAlt, LPCSTR(pbData), NULL, //deprecated PROV_RSA_AES, 0) == FALSE) { @@ -766,7 +1022,7 @@ JNIEXPORT jboolean JNICALL Java_sun_security_mscapi_RSASignature_verifySignedHas pSignedHashBuffer); // Set hash value in the hash object - if (::CryptSetHashParam(hHash, HP_HASHVAL, (BYTE*) pHashBuffer, NULL) + if (::CryptSetHashParam(hHash, HP_HASHVAL, (BYTE*) pHashBuffer, NULL) //deprecated == FALSE) { ThrowException(env, SIGNATURE_EXCEPTION, GetLastError()); @@ -777,7 +1033,7 @@ JNIEXPORT jboolean JNICALL Java_sun_security_mscapi_RSASignature_verifySignedHas // public key algorithm, so AT_SIGNATURE is used. // Verify the signature - if (::CryptVerifySignatureA(hHash, (BYTE *) pSignedHashBuffer, + if (::CryptVerifySignatureA(hHash, (BYTE *) pSignedHashBuffer, //deprecated dwSignedHashBufferLen, (HCRYPTKEY) hCryptKey, NULL, 0) == TRUE) { result = JNI_TRUE; @@ -793,22 +1049,225 @@ JNIEXPORT jboolean JNICALL Java_sun_security_mscapi_RSASignature_verifySignedHas delete [] pHashBuffer; if (hHash) - ::CryptDestroyHash(hHash); + ::CryptDestroyHash(hHash); //deprecated if (hCryptProvAlt) - ::CryptReleaseContext(hCryptProvAlt, 0); + ::CryptReleaseContext(hCryptProvAlt, 0); // deprecated } return result; } /* - * Class: sun_security_mscapi_RSAKeyPairGenerator - * Method: generateRSAKeyPair - * Signature: (ILjava/lang/String;)Lsun/security/mscapi/RSAKeyPair; + * Class: sun_security_mscapi_CSignature + * Method: verifyCngSignedHash + * Signature: (I[BI[BIILjava/lang/String;JJ)Z */ -JNIEXPORT jobject JNICALL Java_sun_security_mscapi_RSAKeyPairGenerator_generateRSAKeyPair - (JNIEnv *env, jclass clazz, jint keySize, jstring keyContainerName) +JNIEXPORT jboolean JNICALL Java_sun_security_mscapi_CSignature_verifyCngSignedHash + (JNIEnv *env, jclass clazz, jint type, + jbyteArray jHash, jint jHashSize, + jbyteArray jSignedHash, jint jSignedHashSize, + jint saltLen, jstring jHashAlgorithm, + jlong hCryptProv, jlong hCryptKey) +{ + jbyte* pHashBuffer = NULL; + jbyte* pSignedHashBuffer = NULL; + jboolean result = JNI_FALSE; + NCRYPT_KEY_HANDLE hk = NULL; + + __try + { + if (hCryptKey == 0) { + hk = (NCRYPT_KEY_HANDLE)hCryptProv; + } else { + SS_CHECK(::NCryptTranslateHandle( + NULL, + &hk, + (HCRYPTPROV)hCryptProv, + (HCRYPTKEY)hCryptKey, + NULL, + 0)); + } + + // Copy hash and signedHash from Java to native buffer + pHashBuffer = new (env) jbyte[jHashSize]; + if (pHashBuffer == NULL) { + __leave; + } + env->GetByteArrayRegion(jHash, 0, jHashSize, pHashBuffer); + + pSignedHashBuffer = new (env) jbyte[jSignedHashSize]; + if (pSignedHashBuffer == NULL) { + __leave; + } + env->GetByteArrayRegion(jSignedHash, 0, jSignedHashSize, + pSignedHashBuffer); + + VOID* param; + DWORD dwFlags; + + switch (type) { + case 0: + param = NULL; + dwFlags = 0; + break; + case 1: + BCRYPT_PKCS1_PADDING_INFO pkcs1Info; + if (jHashAlgorithm) { + pkcs1Info.pszAlgId = MapHashIdentifier(env, jHashAlgorithm); + if (pkcs1Info.pszAlgId == NULL) { + ThrowExceptionWithMessage(env, SIGNATURE_EXCEPTION, + "Unrecognised hash algorithm"); + __leave; + } + } else { + pkcs1Info.pszAlgId = NULL; + } + param = &pkcs1Info; + dwFlags = NCRYPT_PAD_PKCS1_FLAG; + break; + case 2: + BCRYPT_PSS_PADDING_INFO pssInfo; + pssInfo.pszAlgId = MapHashIdentifier(env, jHashAlgorithm); + pssInfo.cbSalt = saltLen; + if (pssInfo.pszAlgId == NULL) { + ThrowExceptionWithMessage(env, SIGNATURE_EXCEPTION, + "Unrecognised hash algorithm"); + __leave; + } + param = &pssInfo; + dwFlags = NCRYPT_PAD_PSS_FLAG; + break; + } + + if (::NCryptVerifySignature(hk, param, + (BYTE *) pHashBuffer, jHashSize, + (BYTE *) pSignedHashBuffer, jSignedHashSize, + dwFlags) == ERROR_SUCCESS) + { + result = JNI_TRUE; + } + } + + __finally + { + if (pSignedHashBuffer) + delete [] pSignedHashBuffer; + + if (pHashBuffer) + delete [] pHashBuffer; + + if (hCryptKey != 0 && hk != NULL) + ::NCryptFreeObject(hk); + } + + return result; +} + +#define DUMP_PROP(p) \ + if (::NCryptGetProperty(hKey, p, (PBYTE)buffer, 8192, &len, NCRYPT_SILENT_FLAG) == ERROR_SUCCESS) { \ + sprintf(header, "%s %ls", #p, p); \ + dump(header, buffer, len); \ + } + +#define EXPORT_BLOB(p) \ + desc.cBuffers = 0; \ + if (::NCryptExportKey(hKey, NULL, p, &desc, (PBYTE)buffer, 8192, &len, NCRYPT_SILENT_FLAG) == ERROR_SUCCESS) { \ + sprintf(header, "%s %ls (%ld)", #p, p, desc.cBuffers); \ + dump(header, buffer, len); \ + for (int i = 0; i < (int)desc.cBuffers; i++) { \ + sprintf(header, "desc %ld", desc.pBuffers[i].BufferType); \ + dump(header, (PBYTE)desc.pBuffers[i].pvBuffer, desc.pBuffers[i].cbBuffer); \ + } \ + } + +void showProperty(NCRYPT_HANDLE hKey) { + char header[100]; + BYTE buffer[8192]; + DWORD len = 9; + NCryptBufferDesc desc; + DUMP_PROP(NCRYPT_ALGORITHM_GROUP_PROPERTY); + DUMP_PROP(NCRYPT_ALGORITHM_PROPERTY); + DUMP_PROP(NCRYPT_ASSOCIATED_ECDH_KEY); + DUMP_PROP(NCRYPT_BLOCK_LENGTH_PROPERTY); + DUMP_PROP(NCRYPT_CERTIFICATE_PROPERTY); + DUMP_PROP(NCRYPT_DH_PARAMETERS_PROPERTY); + DUMP_PROP(NCRYPT_EXPORT_POLICY_PROPERTY); + DUMP_PROP(NCRYPT_IMPL_TYPE_PROPERTY); + DUMP_PROP(NCRYPT_KEY_TYPE_PROPERTY); + DUMP_PROP(NCRYPT_KEY_USAGE_PROPERTY); + DUMP_PROP(NCRYPT_LAST_MODIFIED_PROPERTY); + DUMP_PROP(NCRYPT_LENGTH_PROPERTY); + DUMP_PROP(NCRYPT_LENGTHS_PROPERTY); + DUMP_PROP(NCRYPT_MAX_NAME_LENGTH_PROPERTY); + DUMP_PROP(NCRYPT_NAME_PROPERTY); + DUMP_PROP(NCRYPT_PIN_PROMPT_PROPERTY); + DUMP_PROP(NCRYPT_PIN_PROPERTY); + DUMP_PROP(NCRYPT_PROVIDER_HANDLE_PROPERTY); + DUMP_PROP(NCRYPT_READER_PROPERTY); + DUMP_PROP(NCRYPT_ROOT_CERTSTORE_PROPERTY); + DUMP_PROP(NCRYPT_SCARD_PIN_ID); + DUMP_PROP(NCRYPT_SCARD_PIN_INFO); + DUMP_PROP(NCRYPT_SECURE_PIN_PROPERTY); + DUMP_PROP(NCRYPT_SECURITY_DESCR_PROPERTY); + DUMP_PROP(NCRYPT_SECURITY_DESCR_SUPPORT_PROPERTY); + DUMP_PROP(NCRYPT_SMARTCARD_GUID_PROPERTY); + DUMP_PROP(NCRYPT_UI_POLICY_PROPERTY); + DUMP_PROP(NCRYPT_UNIQUE_NAME_PROPERTY); + DUMP_PROP(NCRYPT_USE_CONTEXT_PROPERTY); + DUMP_PROP(NCRYPT_USE_COUNT_ENABLED_PROPERTY); + DUMP_PROP(NCRYPT_USE_COUNT_PROPERTY); + DUMP_PROP(NCRYPT_USER_CERTSTORE_PROPERTY); + DUMP_PROP(NCRYPT_VERSION_PROPERTY); + DUMP_PROP(NCRYPT_WINDOW_HANDLE_PROPERTY); + + EXPORT_BLOB(BCRYPT_DH_PRIVATE_BLOB); + EXPORT_BLOB(BCRYPT_DH_PUBLIC_BLOB); + EXPORT_BLOB(BCRYPT_DSA_PRIVATE_BLOB); + EXPORT_BLOB(BCRYPT_DSA_PUBLIC_BLOB); + EXPORT_BLOB(BCRYPT_ECCPRIVATE_BLOB); + EXPORT_BLOB(BCRYPT_ECCPUBLIC_BLOB); + EXPORT_BLOB(BCRYPT_PUBLIC_KEY_BLOB); + EXPORT_BLOB(BCRYPT_PRIVATE_KEY_BLOB); + EXPORT_BLOB(BCRYPT_RSAFULLPRIVATE_BLOB); + EXPORT_BLOB(BCRYPT_RSAPRIVATE_BLOB); + EXPORT_BLOB(BCRYPT_RSAPUBLIC_BLOB); + EXPORT_BLOB(LEGACY_DH_PRIVATE_BLOB); + EXPORT_BLOB(LEGACY_DH_PUBLIC_BLOB); + EXPORT_BLOB(LEGACY_DSA_PRIVATE_BLOB); + EXPORT_BLOB(LEGACY_DSA_PUBLIC_BLOB); + EXPORT_BLOB(LEGACY_RSAPRIVATE_BLOB); + EXPORT_BLOB(LEGACY_RSAPUBLIC_BLOB); + // Support starts from Windows 8 and Windows Server 2012 + //EXPORT_BLOB(NCRYPT_CIPHER_KEY_BLOB); + EXPORT_BLOB(NCRYPT_OPAQUETRANSPORT_BLOB); + EXPORT_BLOB(NCRYPT_PKCS7_ENVELOPE_BLOB); + //EXPORT_BLOB(NCRYPTBUFFER_CERT_BLOB); + //EXPORT_BLOB(NCRYPT_PKCS8_PRIVATE_KEY_BLOB); + BCryptBuffer bb; + bb.BufferType = NCRYPTBUFFER_PKCS_SECRET; + bb.cbBuffer = 18; + bb.pvBuffer = L"changeit"; + BCryptBufferDesc bbd; + bbd.ulVersion = 0; + bbd.cBuffers = 1; + bbd.pBuffers = &bb; + if(::NCryptExportKey(hKey, NULL, NCRYPT_PKCS8_PRIVATE_KEY_BLOB, NULL, + (PBYTE)buffer, 8192, &len, NCRYPT_SILENT_FLAG) == ERROR_SUCCESS) { + sprintf(header, "NCRYPT_PKCS8_PRIVATE_KEY_BLOB %ls", NCRYPT_PKCS8_PRIVATE_KEY_BLOB); + dump(header, buffer, len); + } + // Support starts from Windows 8 and Windows Server 2012 + //EXPORT_BLOB(NCRYPT_PROTECTED_KEY_BLOB); +} + +/* + * Class: sun_security_mscapi_CKeyPairGenerator_RSA + * Method: generateCKeyPair + * Signature: (Ljava/lang/String;ILjava/lang/String;)Lsun/security/mscapi/CKeyPair; + */ +JNIEXPORT jobject JNICALL Java_sun_security_mscapi_CKeyPairGenerator_00024RSA_generateCKeyPair + (JNIEnv *env, jclass clazz, jstring alg, jint keySize, jstring keyContainerName) { HCRYPTPROV hCryptProv = NULL; HCRYPTKEY hKeyPair; @@ -826,7 +1285,7 @@ JNIEXPORT jobject JNICALL Java_sun_security_mscapi_RSAKeyPairGenerator_generateR // Acquire a CSP context (create a new key container). // Prefer a PROV_RSA_AES CSP, when available, due to its support // for SHA-2-based signatures. - if (::CryptAcquireContext( + if (::CryptAcquireContext( //deprecated &hCryptProv, pszKeyContainerName, NULL, @@ -835,7 +1294,7 @@ JNIEXPORT jobject JNICALL Java_sun_security_mscapi_RSAKeyPairGenerator_generateR { // Failover to using the default CSP (PROV_RSA_FULL) - if (::CryptAcquireContext( + if (::CryptAcquireContext( //deprecated &hCryptProv, pszKeyContainerName, NULL, @@ -847,8 +1306,8 @@ JNIEXPORT jobject JNICALL Java_sun_security_mscapi_RSAKeyPairGenerator_generateR } } - // Generate an RSA keypair - if(::CryptGenKey( + // Generate an keypair + if(::CryptGenKey( //deprecated hCryptProv, AT_KEYEXCHANGE, dwFlags, @@ -858,22 +1317,22 @@ JNIEXPORT jobject JNICALL Java_sun_security_mscapi_RSAKeyPairGenerator_generateR __leave; } - // Get the method ID for the RSAKeyPair constructor - jclass clazzRSAKeyPair = - env->FindClass("sun/security/mscapi/RSAKeyPair"); - if (clazzRSAKeyPair == NULL) { + // Get the method ID for the CKeyPair constructor + jclass clazzCKeyPair = + env->FindClass("sun/security/mscapi/CKeyPair"); + if (clazzCKeyPair == NULL) { __leave; } - jmethodID mNewRSAKeyPair = - env->GetMethodID(clazzRSAKeyPair, "", "(JJI)V"); - if (mNewRSAKeyPair == NULL) { + jmethodID mNewCKeyPair = + env->GetMethodID(clazzCKeyPair, "", "(Ljava/lang/String;JJI)V"); + if (mNewCKeyPair == NULL) { __leave; } - // Create a new RSA keypair - keypair = env->NewObject(clazzRSAKeyPair, mNewRSAKeyPair, - (jlong) hCryptProv, (jlong) hKeyPair, keySize); + // Create a new keypair + keypair = env->NewObject(clazzCKeyPair, mNewCKeyPair, + alg, (jlong) hCryptProv, (jlong) hKeyPair, keySize); } __finally @@ -889,18 +1348,18 @@ JNIEXPORT jobject JNICALL Java_sun_security_mscapi_RSAKeyPairGenerator_generateR } /* - * Class: sun_security_mscapi_Key + * Class: sun_security_mscapi_CKey * Method: getContainerName * Signature: (J)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL Java_sun_security_mscapi_Key_getContainerName +JNIEXPORT jstring JNICALL Java_sun_security_mscapi_CKey_getContainerName (JNIEnv *env, jclass jclazz, jlong hCryptProv) { DWORD cbData = 256; BYTE pbData[256]; pbData[0] = '\0'; - ::CryptGetProvParam( + ::CryptGetProvParam( //deprecated (HCRYPTPROV)hCryptProv, PP_CONTAINER, (BYTE *)pbData, @@ -911,17 +1370,17 @@ JNIEXPORT jstring JNICALL Java_sun_security_mscapi_Key_getContainerName } /* - * Class: sun_security_mscapi_Key + * Class: sun_security_mscapi_CKey * Method: getKeyType * Signature: (J)Ljava/lang/String; */ -JNIEXPORT jstring JNICALL Java_sun_security_mscapi_Key_getKeyType +JNIEXPORT jstring JNICALL Java_sun_security_mscapi_CKey_getKeyType (JNIEnv *env, jclass jclazz, jlong hCryptKey) { ALG_ID dwAlgId; DWORD dwAlgIdLen = sizeof(ALG_ID); - if (::CryptGetKeyParam((HCRYPTKEY) hCryptKey, KP_ALGID, (BYTE*)&dwAlgId, &dwAlgIdLen, 0)) { + if (::CryptGetKeyParam((HCRYPTKEY) hCryptKey, KP_ALGID, (BYTE*)&dwAlgId, &dwAlgIdLen, 0)) { //deprecated if (CALG_RSA_SIGN == dwAlgId) { return env->NewStringUTF("Signature"); @@ -941,11 +1400,11 @@ JNIEXPORT jstring JNICALL Java_sun_security_mscapi_Key_getKeyType } /* - * Class: sun_security_mscapi_KeyStore + * Class: sun_security_mscapi_CKeyStore * Method: storeCertificate * Signature: (Ljava/lang/String;Ljava/lang/String;[BIJJ)V */ -JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_storeCertificate +JNIEXPORT void JNICALL Java_sun_security_mscapi_CKeyStore_storeCertificate (JNIEnv *env, jobject obj, jstring jCertStoreName, jstring jCertAliasName, jbyteArray jCertEncoding, jint jCertEncodingSize, jlong hCryptProv, jlong hCryptKey) @@ -1023,7 +1482,7 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_storeCertificate DWORD dwDataLen; // Get the name of the key container - if (! ::CryptGetProvParam( + if (! ::CryptGetProvParam( //deprecated (HCRYPTPROV) hCryptProv, PP_CONTAINER, NULL, @@ -1039,7 +1498,7 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_storeCertificate __leave; } - if (! ::CryptGetProvParam( + if (! ::CryptGetProvParam( //deprecated (HCRYPTPROV) hCryptProv, PP_CONTAINER, (BYTE *) pszContainerName, @@ -1066,7 +1525,7 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_storeCertificate // Get the name of the provider - if (! ::CryptGetProvParam( + if (! ::CryptGetProvParam( //deprecated (HCRYPTPROV) hCryptProv, PP_NAME, NULL, @@ -1082,7 +1541,7 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_storeCertificate __leave; } - if (! ::CryptGetProvParam( + if (! ::CryptGetProvParam( //deprecated (HCRYPTPROV) hCryptProv, PP_NAME, (BYTE *) pszProviderName, @@ -1108,7 +1567,7 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_storeCertificate keyProviderInfo.pwszProvName = pwszProviderName; // Get and set the type of the provider - if (! ::CryptGetProvParam( + if (! ::CryptGetProvParam( //deprecated (HCRYPTPROV) hCryptProv, PP_PROVTYPE, (LPBYTE) &keyProviderInfo.dwProvType, @@ -1127,7 +1586,7 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_storeCertificate keyProviderInfo.rgProvParam = NULL; // Get the key's algorithm ID - if (! ::CryptGetKeyParam( + if (! ::CryptGetKeyParam( //deprecated (HCRYPTKEY) hCryptKey, KP_ALGID, (LPBYTE) &keyProviderInfo.dwKeySpec, @@ -1206,11 +1665,11 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_storeCertificate } /* - * Class: sun_security_mscapi_KeyStore + * Class: sun_security_mscapi_CKeyStore * Method: removeCertificate * Signature: (Ljava/lang/String;Ljava/lang/String;[BI)V */ -JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_removeCertificate +JNIEXPORT void JNICALL Java_sun_security_mscapi_CKeyStore_removeCertificate (JNIEnv *env, jobject obj, jstring jCertStoreName, jstring jCertAliasName, jbyteArray jCertEncoding, jint jCertEncodingSize) { @@ -1322,12 +1781,12 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_removeCertificate } /* - * Class: sun_security_mscapi_KeyStore + * Class: sun_security_mscapi_CKeyStore * Method: destroyKeyContainer * Signature: (Ljava/lang/String;)V */ -JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_destroyKeyContainer - (JNIEnv *env, jclass clazz, jstring keyContainerName) +JNIEXPORT void JNICALL Java_sun_security_mscapi_CKeyStore_destroyKeyContainer + (JNIEnv *env, jobject clazz, jstring keyContainerName) { HCRYPTPROV hCryptProv = NULL; const char* pszKeyContainerName = NULL; @@ -1348,7 +1807,7 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_destroyKeyContainer } // Acquire a CSP context (to the key container). - if (::CryptAcquireContext( + if (::CryptAcquireContext( //deprecated &hCryptProv, pszKeyContainerName, NULL, @@ -1370,218 +1829,12 @@ JNIEXPORT void JNICALL Java_sun_security_mscapi_KeyStore_destroyKeyContainer } } - - - -/* - * Class: sun_security_mscapi_RSACipher - * Method: findCertificateUsingAlias - * Signature: (Ljava/lang/String;Ljava/lang/String;)J - */ -JNIEXPORT jlong JNICALL Java_sun_security_mscapi_RSACipher_findCertificateUsingAlias - (JNIEnv *env, jobject obj, jstring jCertStoreName, jstring jCertAliasName) -{ - const char* pszCertStoreName = NULL; - const char* pszCertAliasName = NULL; - HCERTSTORE hCertStore = NULL; - PCCERT_CONTEXT pCertContext = NULL; - char* pszNameString = NULL; // certificate's friendly name - DWORD cchNameString = 0; - - __try - { - if ((pszCertStoreName = env->GetStringUTFChars(jCertStoreName, NULL)) - == NULL) { - __leave; - } - if ((pszCertAliasName = env->GetStringUTFChars(jCertAliasName, NULL)) - == NULL) { - __leave; - } - - // Open a system certificate store. - if ((hCertStore = ::CertOpenSystemStore(NULL, pszCertStoreName)) == NULL) { - ThrowException(env, KEYSTORE_EXCEPTION, GetLastError()); - __leave; - } - - // Use CertEnumCertificatesInStore to get the certificates - // from the open store. pCertContext must be reset to - // NULL to retrieve the first certificate in the store. - while (pCertContext = ::CertEnumCertificatesInStore(hCertStore, pCertContext)) - { - if ((cchNameString = ::CertGetNameString(pCertContext, - CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0, NULL, NULL, 0)) == 1) { - - continue; // not found - } - - pszNameString = new (env) char[cchNameString]; - if (pszNameString == NULL) { - __leave; - } - - if (::CertGetNameString(pCertContext, - CERT_NAME_FRIENDLY_DISPLAY_TYPE, 0, NULL, pszNameString, - cchNameString) == 1) { - - continue; // not found - } - - // Compare the certificate's friendly name with supplied alias name - if (strcmp(pszCertAliasName, pszNameString) == 0) { - delete [] pszNameString; - break; - - } else { - delete [] pszNameString; - } - } - } - __finally - { - if (hCertStore) - ::CertCloseStore(hCertStore, 0); - - if (pszCertStoreName) - env->ReleaseStringUTFChars(jCertStoreName, pszCertStoreName); - - if (pszCertAliasName) - env->ReleaseStringUTFChars(jCertAliasName, pszCertAliasName); - } - - return (jlong) pCertContext; -} - /* - * Class: sun_security_mscapi_RSACipher - * Method: getKeyFromCert - * Signature: (JZ)J - */ -JNIEXPORT jlong JNICALL Java_sun_security_mscapi_RSACipher_getKeyFromCert - (JNIEnv *env, jobject obj, jlong pCertContext, jboolean usePrivateKey) -{ - HCRYPTPROV hCryptProv = NULL; - HCRYPTKEY hKey = NULL; - DWORD dwKeySpec; - BOOL bCallerFreeProv = FALSE; - BOOL bRes; - - __try - { - if (usePrivateKey == JNI_TRUE) { - // Locate the key container for the certificate's private key - - // First, probe it silently - bRes = ::CryptAcquireCertificatePrivateKey( - (PCCERT_CONTEXT) pCertContext, CRYPT_ACQUIRE_SILENT_FLAG, - NULL, &hCryptProv, &dwKeySpec, &bCallerFreeProv); - - if (bRes == FALSE && GetLastError() != NTE_SILENT_CONTEXT) - { - ThrowException(env, KEYSTORE_EXCEPTION, GetLastError()); - __leave; - } - - if (bCallerFreeProv == TRUE) { - ::CryptReleaseContext(hCryptProv, NULL); - bCallerFreeProv = FALSE; - } - - // Now, do it normally (not silently) - if (::CryptAcquireCertificatePrivateKey( - (PCCERT_CONTEXT) pCertContext, 0, NULL, &hCryptProv, - &dwKeySpec, &bCallerFreeProv) == FALSE) - { - ThrowException(env, KEYSTORE_EXCEPTION, GetLastError()); - __leave; - } - - // Get a handle to the private key - if (::CryptGetUserKey(hCryptProv, dwKeySpec, &hKey) == FALSE) { - ThrowException(env, KEY_EXCEPTION, GetLastError()); - __leave; - } - } - else // use public key - { - bCallerFreeProv = TRUE; - - // Acquire a CSP context. - if (::CryptAcquireContext(&hCryptProv, "J2SE", NULL, - PROV_RSA_FULL, 0) == FALSE) - { - // If CSP context hasn't been created, create one. - // - if (::CryptAcquireContext(&hCryptProv, "J2SE", NULL, - PROV_RSA_FULL, CRYPT_NEWKEYSET) == FALSE) - { - ThrowException(env, KEYSTORE_EXCEPTION, GetLastError()); - __leave; - } - } - - // Import the certificate's public key into the key container - if (::CryptImportPublicKeyInfo(hCryptProv, X509_ASN_ENCODING, - &(((PCCERT_CONTEXT) pCertContext)->pCertInfo->SubjectPublicKeyInfo), - &hKey) == FALSE) - { - ThrowException(env, KEY_EXCEPTION, GetLastError()); - __leave; - } - } - } - __finally - { - //-------------------------------------------------------------------- - // Clean up. - - if (bCallerFreeProv == TRUE && hCryptProv != NULL) - ::CryptReleaseContext(hCryptProv, 0); - } - - return hKey; // TODO - when finished with this key, call - // CryptDestroyKey(hKey) -} - -/* - * Class: sun_security_mscapi_KeyStore - * Method: getKeyLength - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_sun_security_mscapi_KeyStore_getKeyLength - (JNIEnv *env, jobject obj, jlong hKey) -{ - DWORD dwDataLen = sizeof(DWORD); - BYTE pbData[sizeof(DWORD)]; - DWORD length = 0; - - __try - { - // Get key length (in bits) - //TODO - may need to use KP_BLOCKLEN instead? - if (!(::CryptGetKeyParam((HCRYPTKEY) hKey, KP_KEYLEN, (BYTE *)pbData, &dwDataLen, - 0))) { - - ThrowException(env, KEY_EXCEPTION, GetLastError()); - __leave; - } - length = (DWORD) pbData; - } - __finally - { - // no cleanup required - } - - return (jint) length; -} - -/* - * Class: sun_security_mscapi_RSACipher + * Class: sun_security_mscapi_CRSACipher * Method: encryptDecrypt * Signature: ([BIJZ)[B */ -JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSACipher_encryptDecrypt +JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_CRSACipher_encryptDecrypt (JNIEnv *env, jclass clazz, jbyteArray jData, jint jDataSize, jlong hKey, jboolean doEncrypt) { @@ -1603,7 +1856,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSACipher_encryptDecrypt if (doEncrypt == JNI_TRUE) { // encrypt - if (! ::CryptEncrypt((HCRYPTKEY) hKey, 0, TRUE, 0, (BYTE *)pData, + if (! ::CryptEncrypt((HCRYPTKEY) hKey, 0, TRUE, 0, (BYTE *)pData, //deprecated &dwDataLen, dwBufLen)) { ThrowException(env, KEY_EXCEPTION, GetLastError()); @@ -1626,7 +1879,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSACipher_encryptDecrypt } // decrypt - if (! ::CryptDecrypt((HCRYPTKEY) hKey, 0, TRUE, 0, (BYTE *)pData, + if (! ::CryptDecrypt((HCRYPTKEY) hKey, 0, TRUE, 0, (BYTE *)pData, //deprecated &dwBufLen)) { ThrowException(env, KEY_EXCEPTION, GetLastError()); @@ -1652,12 +1905,12 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSACipher_encryptDecrypt } /* - * Class: sun_security_mscapi_RSAPublicKey + * Class: sun_security_mscapi_CPublicKey * Method: getPublicKeyBlob - * Signature: (J)[B + * Signature: (JJ)[B */ -JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSAPublicKey_getPublicKeyBlob - (JNIEnv *env, jclass clazz, jlong hCryptKey) { +JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_CPublicKey_getPublicKeyBlob + (JNIEnv *env, jobject clazz, jlong hCryptProv, jlong hCryptKey) { jbyteArray blob = NULL; DWORD dwBlobLen; @@ -1667,11 +1920,17 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSAPublicKey_getPublicKeyB { // Determine the size of the blob - if (! ::CryptExportKey((HCRYPTKEY) hCryptKey, 0, PUBLICKEYBLOB, 0, NULL, - &dwBlobLen)) { + if (hCryptKey == 0) { + SS_CHECK(::NCryptExportKey( + (NCRYPT_KEY_HANDLE)hCryptProv, NULL, BCRYPT_ECCPUBLIC_BLOB, + NULL, NULL, 0, &dwBlobLen, NCRYPT_SILENT_FLAG)); + } else { + if (! ::CryptExportKey((HCRYPTKEY) hCryptKey, 0, PUBLICKEYBLOB, 0, NULL, //deprecated + &dwBlobLen)) { - ThrowException(env, KEY_EXCEPTION, GetLastError()); - __leave; + ThrowException(env, KEY_EXCEPTION, GetLastError()); + __leave; + } } pbKeyBlob = new (env) BYTE[dwBlobLen]; @@ -1680,11 +1939,17 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSAPublicKey_getPublicKeyB } // Generate key blob - if (! ::CryptExportKey((HCRYPTKEY) hCryptKey, 0, PUBLICKEYBLOB, 0, - pbKeyBlob, &dwBlobLen)) { + if (hCryptKey == 0) { + SS_CHECK(::NCryptExportKey( + (NCRYPT_KEY_HANDLE)hCryptProv, NULL, BCRYPT_ECCPUBLIC_BLOB, + NULL, pbKeyBlob, dwBlobLen, &dwBlobLen, NCRYPT_SILENT_FLAG)); + } else { + if (! ::CryptExportKey((HCRYPTKEY) hCryptKey, 0, PUBLICKEYBLOB, 0, //deprecated + pbKeyBlob, &dwBlobLen)) { - ThrowException(env, KEY_EXCEPTION, GetLastError()); - __leave; + ThrowException(env, KEY_EXCEPTION, GetLastError()); + __leave; + } } // Create new byte array @@ -1705,12 +1970,12 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSAPublicKey_getPublicKeyB } /* - * Class: sun_security_mscapi_RSAPublicKey + * Class: sun_security_mscapi_CPublicKey_CRSAPublicKey * Method: getExponent * Signature: ([B)[B */ -JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSAPublicKey_getExponent - (JNIEnv *env, jclass clazz, jbyteArray jKeyBlob) { +JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_CPublicKey_00024CRSAPublicKey_getExponent + (JNIEnv *env, jobject clazz, jbyteArray jKeyBlob) { jbyteArray exponent = NULL; jbyte* exponentBytes = NULL; @@ -1770,12 +2035,12 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSAPublicKey_getExponent } /* - * Class: sun_security_mscapi_RSAPublicKey + * Class: sun_security_mscapi_CPublicKey_CRSAPublicKey * Method: getModulus * Signature: ([B)[B */ -JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSAPublicKey_getModulus - (JNIEnv *env, jclass clazz, jbyteArray jKeyBlob) { +JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_CPublicKey_00024CRSAPublicKey_getModulus + (JNIEnv *env, jobject clazz, jbyteArray jKeyBlob) { jbyteArray modulus = NULL; jbyte* modulusBytes = NULL; @@ -1844,38 +2109,47 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSAPublicKey_getModulus * Convert an array in big-endian byte order into little-endian byte order. */ int convertToLittleEndian(JNIEnv *env, jbyteArray source, jbyte* destination, - int destinationLength) { + int destinationLength) { - int sourceLength = env->GetArrayLength(source); + int result = -1; + jbyte* sourceBytes = NULL; - jbyte* sourceBytes = env->GetByteArrayElements(source, 0); - if (sourceBytes == NULL) { - return -1; - } + __try { + int sourceLength = env->GetArrayLength(source); - int copyLen = sourceLength; - if (sourceLength > destinationLength) { - // source might include an extra sign byte - if (sourceLength == destinationLength + 1 && sourceBytes[0] == 0) { - copyLen--; - } else { - return -1; + sourceBytes = env->GetByteArrayElements(source, 0); + if (sourceBytes == NULL) { + __leave; } - } - // Copy bytes from the end of the source array to the beginning of the - // destination array (until the destination array is full). - // This ensures that the sign byte from the source array will be excluded. - for (int i = 0; i < copyLen; i++) { - destination[i] = sourceBytes[sourceLength - 1 - i]; - } - if (copyLen < destinationLength) { - memset(destination + copyLen, 0, destinationLength - copyLen); - } + int copyLen = sourceLength; + if (sourceLength > destinationLength) { + // source might include an extra sign byte + if (sourceLength == destinationLength + 1 && sourceBytes[0] == 0) { + copyLen--; + } else { + __leave; + } + } - env->ReleaseByteArrayElements(source, sourceBytes, JNI_ABORT); + // Copy bytes from the end of the source array to the beginning of the + // destination array (until the destination array is full). + // This ensures that the sign byte from the source array will be excluded. + for (int i = 0; i < copyLen; i++) { + destination[i] = sourceBytes[sourceLength - 1 - i]; + } + if (copyLen < destinationLength) { + memset(destination + copyLen, 0, destinationLength - copyLen); + } + result = destinationLength; + } __finally { + // Clean up. + if (sourceBytes) { + env->ReleaseByteArrayElements(source, sourceBytes, JNI_ABORT); + } + } - return destinationLength; + return result; } /* @@ -2049,12 +2323,12 @@ jbyteArray generateKeyBlob( } /* - * Class: sun_security_mscapi_KeyStore - * Method: generatePrivateKeyBlob + * Class: sun_security_mscapi_CKeyStore + * Method: generateRSAPrivateKeyBlob * Signature: (I[B[B[B[B[B[B[B[B)[B */ -JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_KeyStore_generatePrivateKeyBlob - (JNIEnv *env, jclass clazz, +JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_CKeyStore_generateRSAPrivateKeyBlob + (JNIEnv *env, jobject clazz, jint jKeyBitLength, jbyteArray jModulus, jbyteArray jPublicExponent, @@ -2071,11 +2345,11 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_KeyStore_generatePrivateKe } /* - * Class: sun_security_mscapi_RSASignature + * Class: sun_security_mscapi_CSignature_RSA * Method: generatePublicKeyBlob * Signature: (I[B[B)[B */ -JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSASignature_generatePublicKeyBlob +JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_CSignature_00024RSA_generatePublicKeyBlob (JNIEnv *env, jclass clazz, jint jKeyBitLength, jbyteArray jModulus, @@ -2086,13 +2360,13 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_mscapi_RSASignature_generatePubli } /* - * Class: sun_security_mscapi_KeyStore + * Class: sun_security_mscapi_CKeyStore * Method: storePrivateKey - * Signature: ([BLjava/lang/String;I)Lsun/security/mscapi/RSAPrivateKey; + * Signature: (Ljava/lang/String;[BLjava/lang/String;I)Lsun/security/mscapi/CPrivateKey; */ -JNIEXPORT jobject JNICALL Java_sun_security_mscapi_KeyStore_storePrivateKey - (JNIEnv *env, jclass clazz, jbyteArray keyBlob, jstring keyContainerName, - jint keySize) +JNIEXPORT jobject JNICALL Java_sun_security_mscapi_CKeyStore_storePrivateKey + (JNIEnv *env, jobject clazz, jstring alg, jbyteArray keyBlob, + jstring keyContainerName, jint keySize) { HCRYPTPROV hCryptProv = NULL; HCRYPTKEY hKey = NULL; @@ -2114,7 +2388,7 @@ JNIEXPORT jobject JNICALL Java_sun_security_mscapi_KeyStore_storePrivateKey } // Acquire a CSP context (create a new key container). - if (::CryptAcquireContext( + if (::CryptAcquireContext( //deprecated &hCryptProv, pszKeyContainerName, NULL, @@ -2126,7 +2400,7 @@ JNIEXPORT jobject JNICALL Java_sun_security_mscapi_KeyStore_storePrivateKey } // Import the private key - if (::CryptImportKey( + if (::CryptImportKey( //deprecated hCryptProv, pbKeyBlob, dwBlobLen, @@ -2138,22 +2412,23 @@ JNIEXPORT jobject JNICALL Java_sun_security_mscapi_KeyStore_storePrivateKey __leave; } - // Get the method ID for the RSAPrivateKey constructor - jclass clazzRSAPrivateKey = - env->FindClass("sun/security/mscapi/RSAPrivateKey"); - if (clazzRSAPrivateKey == NULL) { + // Get the method ID for the CPrivateKey constructor + jclass clazzCPrivateKey = + env->FindClass("sun/security/mscapi/CPrivateKey"); + if (clazzCPrivateKey == NULL) { __leave; } - jmethodID mNewRSAPrivateKey = - env->GetMethodID(clazzRSAPrivateKey, "", "(JJI)V"); - if (mNewRSAPrivateKey == NULL) { + jmethodID mNewCPrivateKey = + env->GetStaticMethodID(clazzCPrivateKey, "of", + "(Ljava/lang/String;JJI)Lsun/security/mscapi/CPrivateKey;"); + if (mNewCPrivateKey == NULL) { __leave; } - // Create a new RSA private key - privateKey = env->NewObject(clazzRSAPrivateKey, mNewRSAPrivateKey, - (jlong) hCryptProv, (jlong) hKey, keySize); + // Create a new private key + privateKey = env->CallStaticObjectMethod(clazzCPrivateKey, mNewCPrivateKey, + alg, (jlong) hCryptProv, (jlong) hKey, keySize); } __finally @@ -2173,12 +2448,72 @@ JNIEXPORT jobject JNICALL Java_sun_security_mscapi_KeyStore_storePrivateKey } /* - * Class: sun_security_mscapi_RSASignature + * Class: sun_security_mscapi_CSignature + * Method: importECPublicKey + * Signature: (Ljava/lang/String;[BI)Lsun/security/mscapi/CPublicKey; + */ +JNIEXPORT jobject JNICALL Java_sun_security_mscapi_CSignature_importECPublicKey + (JNIEnv *env, jclass clazz, jstring alg, jbyteArray keyBlob, jint keySize) +{ + BCRYPT_ALG_HANDLE hSignAlg = NULL; + NCRYPT_KEY_HANDLE hTmpKey = NULL; + DWORD dwBlobLen; + BYTE * pbKeyBlob = NULL; + jobject publicKey = NULL; + + __try + { + dwBlobLen = env->GetArrayLength(keyBlob); + if ((pbKeyBlob = (BYTE *) env->GetByteArrayElements(keyBlob, 0)) + == NULL) { + __leave; + } + dump("NCryptImportKey", pbKeyBlob, dwBlobLen); + NCRYPT_PROV_HANDLE hProv; + SS_CHECK(NCryptOpenStorageProvider( + &hProv, L"Microsoft Software Key Storage Provider", 0 )); + SS_CHECK(NCryptImportKey( + hProv, + NULL, + BCRYPT_ECCPUBLIC_BLOB, + NULL, + &hTmpKey, + pbKeyBlob, + dwBlobLen, + 0)); + NCryptFreeObject( hProv ); + // Get the method ID for the CPublicKey constructor + jclass clazzCPublicKey = + env->FindClass("sun/security/mscapi/CPublicKey"); + if (clazzCPublicKey == NULL) { + __leave; + } + + jmethodID mNewCPublicKey = + env->GetStaticMethodID(clazzCPublicKey, "of", + "(Ljava/lang/String;JJI)Lsun/security/mscapi/CPublicKey;"); + if (mNewCPublicKey == NULL) { + __leave; + } + + // Create a new public key + publicKey = env->CallStaticObjectMethod(clazzCPublicKey, mNewCPublicKey, + alg, (jlong) hTmpKey, (jlong) 0, keySize); + } + __finally + { + } + + return publicKey; +} + +/* + * Class: sun_security_mscapi_CSignature * Method: importPublicKey - * Signature: ([BI)Lsun/security/mscapi/RSAPublicKey; + * Signature: (Ljava/lang/String;[BI)Lsun/security/mscapi/CPublicKey; */ -JNIEXPORT jobject JNICALL Java_sun_security_mscapi_RSASignature_importPublicKey - (JNIEnv *env, jclass clazz, jbyteArray keyBlob, jint keySize) +JNIEXPORT jobject JNICALL Java_sun_security_mscapi_CSignature_importPublicKey + (JNIEnv *env, jclass clazz, jstring alg, jbyteArray keyBlob, jint keySize) { HCRYPTPROV hCryptProv = NULL; HCRYPTKEY hKey = NULL; @@ -2197,7 +2532,7 @@ JNIEXPORT jobject JNICALL Java_sun_security_mscapi_RSASignature_importPublicKey // Acquire a CSP context (create a new key container). // Prefer a PROV_RSA_AES CSP, when available, due to its support // for SHA-2-based signatures. - if (::CryptAcquireContext( + if (::CryptAcquireContext( //deprecated &hCryptProv, NULL, NULL, @@ -2206,7 +2541,7 @@ JNIEXPORT jobject JNICALL Java_sun_security_mscapi_RSASignature_importPublicKey { // Failover to using the default CSP (PROV_RSA_FULL) - if (::CryptAcquireContext( + if (::CryptAcquireContext( //deprecated &hCryptProv, NULL, NULL, @@ -2219,7 +2554,7 @@ JNIEXPORT jobject JNICALL Java_sun_security_mscapi_RSASignature_importPublicKey } // Import the public key - if (::CryptImportKey( + if (::CryptImportKey( //deprecated hCryptProv, pbKeyBlob, dwBlobLen, @@ -2231,22 +2566,23 @@ JNIEXPORT jobject JNICALL Java_sun_security_mscapi_RSASignature_importPublicKey __leave; } - // Get the method ID for the RSAPublicKey constructor - jclass clazzRSAPublicKey = - env->FindClass("sun/security/mscapi/RSAPublicKey"); - if (clazzRSAPublicKey == NULL) { + // Get the method ID for the CPublicKey constructor + jclass clazzCPublicKey = + env->FindClass("sun/security/mscapi/CPublicKey"); + if (clazzCPublicKey == NULL) { __leave; } - jmethodID mNewRSAPublicKey = - env->GetMethodID(clazzRSAPublicKey, "", "(JJI)V"); - if (mNewRSAPublicKey == NULL) { + jmethodID mNewCPublicKey = + env->GetStaticMethodID(clazzCPublicKey, "of", + "(Ljava/lang/String;JJI)Lsun/security/mscapi/CPublicKey;"); + if (mNewCPublicKey == NULL) { __leave; } - // Create a new RSA public key - publicKey = env->NewObject(clazzRSAPublicKey, mNewRSAPublicKey, - (jlong) hCryptProv, (jlong) hKey, keySize); + // Create a new public key + publicKey = env->CallStaticObjectMethod(clazzCPublicKey, mNewCPublicKey, + alg, (jlong) hCryptProv, (jlong) hKey, keySize); } __finally diff --git a/test/ProblemList.txt b/test/ProblemList.txt index c86b5ec52ffb180944dd52bf65516bab47880d06..037c7b55875ab50e82771931eb7766b80a959a1f 100644 --- a/test/ProblemList.txt +++ b/test/ProblemList.txt @@ -277,9 +277,6 @@ sun/security/pkcs11/tls/TestKeyMaterial.java generic-all # 7164518 sun/security/krb5/auto/Unreachable.java macosx-all -# 7147060 -com/sun/org/apache/xml/internal/security/transforms/ClassLoaderTest.java generic-all - # 8160071 sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java linux-all @@ -316,6 +313,8 @@ sun/security/krb5/auto/ReplayCacheTestProc.java solaris-sparcv9 security/infra/java/security/cert/CertPathValidator/certification/ActalisCA.java 8224768 generic-all +sun/security/mscapi/SignedObjectChain.java 8176183 windows-all + ############################################################################ # jdk_sound @@ -368,3 +367,6 @@ sun/tools/jps/TestJpsJarRelative.java generic-all # 8141370 com/sun/jndi/ldap/DeadSSLLdapTimeoutTest.java linux-i586,macosx-all + +sample/mergesort/MergeSortTest.java 8178912 generic-all +sample/chatserver/ChatTest.java 8178912 generic-all diff --git a/test/TEST.ROOT b/test/TEST.ROOT index 20343794a8a92b1788cfe21c4d112b496681d7bb..355b251e66c74b7728c1433a2d7f6ca54beb067c 100644 --- a/test/TEST.ROOT +++ b/test/TEST.ROOT @@ -12,7 +12,7 @@ # A "headful" test requires a graphical environment to meaningfully # run. Tests that are not headful are "headless." -keys=2d dnd i18n intermittent randomness headful +keys=2d dnd i18n intermittent randomness headful jfr # Tests that must run in othervm mode othervm.dirs=java/awt java/beans java/rmi javax/accessibility javax/imageio javax/sound javax/print javax/management com/sun/awt sun/awt sun/java2d sun/pisces sun/rmi diff --git a/test/TEST.groups b/test/TEST.groups index 920885746a8fb34ce965ebde90dc9d7feffec7b1..0e899de1f7aefae8d7b1dec281d1a939254215c5 100644 --- a/test/TEST.groups +++ b/test/TEST.groups @@ -59,6 +59,10 @@ jdk_lang = \ jdk/lambda \ vm +#JFR tests +jdk_jfr = \ + jdk/jfr + # All of the java.util package jdk_util = \ :jdk_util_other \ diff --git a/test/com/sun/crypto/provider/Cipher/PBE/TestCipherPBECons.java b/test/com/sun/crypto/provider/Cipher/PBE/TestCipherPBECons.java index c42952342e042abeb90b4b69c7e07c94991c88e3..e3167068029cc9bfff9e4ea2877ca0cc7283b63f 100644 --- a/test/com/sun/crypto/provider/Cipher/PBE/TestCipherPBECons.java +++ b/test/com/sun/crypto/provider/Cipher/PBE/TestCipherPBECons.java @@ -36,7 +36,6 @@ import javax.crypto.NoSuchPaddingException; * @author Yun Ke * @author Bill Situ * @author Yu-Ching (Valerie) PENG - * @run main TestCipherKeyWrapperPBEKey */ public class TestCipherPBECons { diff --git a/test/com/sun/crypto/provider/Cipher/RSA/TestOAEP.java b/test/com/sun/crypto/provider/Cipher/RSA/TestOAEP.java index 55b501ebf36e4ee0c71fdb9c3407d519d0ec386b..1f550c9d2344de8565a893cdbb3b1d2082d7b70d 100644 --- a/test/com/sun/crypto/provider/Cipher/RSA/TestOAEP.java +++ b/test/com/sun/crypto/provider/Cipher/RSA/TestOAEP.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * 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 4894151 + * @bug 4894151 8146293 * @summary encryption/decryption test for OAEP * @author Andreas Sterbenz */ @@ -62,6 +62,8 @@ public class TestOAEP { Cipher.getInstance("RSA/ECB/OAEPwithSHA-256andMGF1Padding"); Cipher.getInstance("RSA/ECB/OAEPwithSHA-384andMGF1Padding"); Cipher.getInstance("RSA/ECB/OAEPwithSHA-512andMGF1Padding"); + Cipher.getInstance("RSA/ECB/OAEPwithSHA-512/224andMGF1Padding"); + Cipher.getInstance("RSA/ECB/OAEPwithSHA-512/256andMGF1Padding"); // basic test using MD5 testEncryptDecrypt("MD5", 0); @@ -89,28 +91,32 @@ public class TestOAEP { // tests alias works testEncryptDecrypt("SHA-1", 16); - // basic test using SHA-224 - testEncryptDecrypt("SHA-224", 0); - testEncryptDecrypt("SHA-224", 16); - testEncryptDecrypt("SHA-224", 38); - try { - testEncryptDecrypt("SHA-224", 39); - throw new Exception("Unexpectedly completed call"); - } catch (IllegalBlockSizeException e) { - // ok - System.out.println(e); + String[] HASH_ALG_224 = { "SHA-224", "SHA-512/224" }; + for (String ha : HASH_ALG_224) { + testEncryptDecrypt(ha, 0); + testEncryptDecrypt(ha, 16); + testEncryptDecrypt(ha, 38); + try { + testEncryptDecrypt(ha, 39); + throw new Exception("Unexpectedly completed call"); + } catch (IllegalBlockSizeException e) { + // ok + System.out.println(e); + } } - // basic test using SHA-256 - testEncryptDecrypt("SHA-256", 0); - testEncryptDecrypt("SHA-256", 16); - testEncryptDecrypt("SHA-256", 30); - try { - testEncryptDecrypt("SHA-256", 31); - throw new Exception("Unexpectedly completed call"); - } catch (IllegalBlockSizeException e) { - // ok - System.out.println(e); + String[] HASH_ALG_256 = { "SHA-256", "SHA-512/256" }; + for (String ha : HASH_ALG_256) { + testEncryptDecrypt(ha, 0); + testEncryptDecrypt(ha, 16); + testEncryptDecrypt(ha, 30); + try { + testEncryptDecrypt(ha, 31); + throw new Exception("Unexpectedly completed call"); + } catch (IllegalBlockSizeException e) { + // ok + System.out.println(e); + } } // 768 bit key too short for OAEP with 64 byte digest diff --git a/test/com/sun/crypto/provider/Cipher/RSA/TestOAEPPadding.java b/test/com/sun/crypto/provider/Cipher/RSA/TestOAEPPadding.java index 3804253f8700e66c5aa7b961be12a9d61a89d923..becfcb09ca48d8777c9ee1a7e136971f84f3dde3 100644 --- a/test/com/sun/crypto/provider/Cipher/RSA/TestOAEPPadding.java +++ b/test/com/sun/crypto/provider/Cipher/RSA/TestOAEPPadding.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -130,6 +130,16 @@ public class TestOAEPPadding { MGF1ParameterSpec.SHA384, PSource.PSpecified.DEFAULT)); test(new OAEPParameterSpec("SHA-512", "MGF1", MGF1ParameterSpec.SHA512, PSource.PSpecified.DEFAULT)); + // SHA-512/224 and SHA-512/256 + test(new OAEPParameterSpec("SHA-512/224", "MGF1", + MGF1ParameterSpec.SHA224, PSource.PSpecified.DEFAULT)); + test(new OAEPParameterSpec("SHA-512/224", "MGF1", + MGF1ParameterSpec.SHA512_224, PSource.PSpecified.DEFAULT)); + test(new OAEPParameterSpec("SHA-512/256", "MGF1", + MGF1ParameterSpec.SHA384, PSource.PSpecified.DEFAULT)); + test(new OAEPParameterSpec("SHA-512/256", "MGF1", + MGF1ParameterSpec.SHA512, PSource.PSpecified.DEFAULT)); + if (failed) { throw new Exception("Test failed"); } @@ -154,9 +164,9 @@ public class TestOAEPPadding { dlen = 16; } else if (algo.equals("SHA1")) { dlen = 20; - } else if (algo.equals("SHA-224")) { + } else if (algo.equals("SHA-224") || algo.equals("SHA-512/224")) { dlen = 28; - } else if (algo.equals("SHA-256")) { + } else if (algo.equals("SHA-256") || algo.equals("SHA-512/256")) { dlen = 32; } else if (algo.equals("SHA-384")) { dlen = 48; diff --git a/test/com/sun/crypto/provider/Cipher/RSA/TestOAEPParameterSpec.java b/test/com/sun/crypto/provider/Cipher/RSA/TestOAEPParameterSpec.java index 1a152859f35817d5148376556cf529ab6f763792..412ec66144fc85171df3eb39e6fed403ca5db0ed 100644 --- a/test/com/sun/crypto/provider/Cipher/RSA/TestOAEPParameterSpec.java +++ b/test/com/sun/crypto/provider/Cipher/RSA/TestOAEPParameterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * 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 4923484 + * @bug 4923484 8146293 * @summary test ASN.1 encoding generation/parsing for the OAEPParameters * implementation in SunJCE provider. * @author Valerie Peng @@ -125,6 +125,8 @@ public class TestOAEPParameterSpec { status &= runTest("SHA-256", MGF1ParameterSpec.SHA256, p); status &= runTest("SHA-384", MGF1ParameterSpec.SHA384, p); status &= runTest("SHA-512", MGF1ParameterSpec.SHA512, p); + status &= runTest("SHA-512/224", MGF1ParameterSpec.SHA512_224, p); + status &= runTest("SHA-512/256", MGF1ParameterSpec.SHA512_256, p); status &= runTest("SHA", MGF1ParameterSpec.SHA1, new byte[0]); status &= runTest("SHA-1", MGF1ParameterSpec.SHA1, new byte[0]); status &= runTest("SHA1", MGF1ParameterSpec.SHA1, new byte[0]); diff --git a/test/com/sun/crypto/provider/Cipher/RSA/TestOAEPWithParams.java b/test/com/sun/crypto/provider/Cipher/RSA/TestOAEPWithParams.java index 13bdfe1a31b1cbecc392958906e0034ade4c6f2b..6e63a51aeb8b7df9078c27456c93ff982e5a3791 100644 --- a/test/com/sun/crypto/provider/Cipher/RSA/TestOAEPWithParams.java +++ b/test/com/sun/crypto/provider/Cipher/RSA/TestOAEPWithParams.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * 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 4923484 + * @bug 4923484 8146293 * @summary encryption/decryption test for using OAEPParameterSpec. * @author Valerie Peng */ @@ -47,10 +47,10 @@ public class TestOAEPWithParams { private static Random random = new Random(); private static String MD[] = { - "MD5", "SHA1", "SHA-224", "SHA-256" + "MD5", "SHA1", "SHA-224", "SHA-256", "SHA-512/224", "SHA-512/256" }; private static int DATA_LENGTH[] = { - 62, 54, 34, 30 + 62, 54, 34, 30, 34, 30 }; public static void main(String[] args) throws Exception { long start = System.currentTimeMillis(); diff --git a/test/com/sun/crypto/provider/KeyProtector/IterationCount.java b/test/com/sun/crypto/provider/KeyProtector/IterationCount.java new file mode 100644 index 0000000000000000000000000000000000000000..7dbcd9f48a8841df351b5044c1c08f831f1796b3 --- /dev/null +++ b/test/com/sun/crypto/provider/KeyProtector/IterationCount.java @@ -0,0 +1,182 @@ +/* + * Copyright (c) 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 + * 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 8233404 + * @library /lib/testlibrary + * @run main/othervm/timeout=30 IterationCount HOST 200000 + * @run main/othervm/timeout=30 IterationCount HOST 200000 1 + * @run main/othervm/timeout=30 IterationCount HOST 200000 6000000 + * @run main/othervm/timeout=30 IterationCount HOST 200000 invalid + * @run main/othervm/timeout=30 IterationCount HOST 30000 30000 + * @run main/othervm/timeout=30 IterationCount OVERRIDE + * @author Martin Balao (mbalao@redhat.com) + */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.lang.reflect.Field; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.ArrayList; +import java.util.List; + +import jdk.testlibrary.OutputAnalyzer; +import jdk.testlibrary.ProcessTools; + +public class IterationCount { + private static final String clientStr = "CLIENT"; + private static final String javaBinPath = + System.getProperty("java.home", ".") + File.separator + "bin" + + File.separator + "java"; + + public static void main(String[] args) throws Throwable { + if (args[0].equals("HOST")) { + String setValue = null; + if (args.length > 2) { + setValue = args[2]; + } + testSystem(args[1], setValue); + testSecurity(args[1], setValue); + } else if (args[0].equals(clientStr)) { + int expectedIterationCount = Integer.parseInt(args[1]); + int currentIterationCount = getCurrentIterationCountValue(); + System.out.println("Expected value: " + expectedIterationCount); + System.out.println("Current value: " + currentIterationCount); + if (currentIterationCount != expectedIterationCount) { + throw new Exception("Expected value different than current"); + } + } else if (args[0].equals("OVERRIDE")) { + testSystemOverridesSecurity(); + } + System.out.println("TEST PASS - OK"); + } + + private static List getBasicCommand() { + List cmd = new ArrayList<>(); + cmd.add(javaBinPath); + cmd.add("-cp"); + cmd.add(System.getProperty("test.classes", ".")); + return cmd; + } + + private static void executeCommand(List cmd, String expectedCount) + throws Throwable { + cmd.add(IterationCount.class.getName()); + cmd.add(clientStr); + cmd.add(expectedCount); + OutputAnalyzer out = ProcessTools.executeCommand( + cmd.toArray(new String[cmd.size()])); + out.shouldHaveExitValue(0); + } + + private static void testSystem(String expectedCount, String setValue) + throws Throwable { + System.out.println("Test setting " + + (setValue != null ? setValue : "nothing") + + " as a System property"); + List cmd = getBasicCommand(); + if (setValue != null) { + cmd.add("-Djdk.jceks.iterationCount=" + setValue); + } + executeCommand(cmd, expectedCount); + System.out.println("............................."); + } + + private static void testSecurity(String expectedCount, String setValue) + throws Throwable { + testSecurity(expectedCount, setValue, getBasicCommand()); + } + + private static void testSecurity(String expectedCount, String setValue, + List cmd) throws Throwable { + System.out.println("Test setting " + + (setValue != null ? setValue : "nothing") + + " as a Security property"); + Path tmpDirPath = Files.createTempDirectory("tmpdir"); + try { + if (setValue != null) { + String javaSecurityPath = tmpDirPath + + File.separator + "java.security"; + writeJavaSecurityProp(javaSecurityPath, setValue); + cmd.add("-Djava.security.properties=" + javaSecurityPath); + } + executeCommand(cmd, expectedCount); + System.out.println("............................."); + } finally { + deleteDir(tmpDirPath); + } + } + + private static void testSystemOverridesSecurity() throws Throwable { + System.out.println("Test that setting a System property overrides" + + " the Security one"); + String systemValue = Integer.toString(30000); + System.out.println("System value: " + systemValue); + List cmd = getBasicCommand(); + cmd.add("-Djdk.jceks.iterationCount=" + systemValue); + testSecurity(systemValue, Integer.toString(40000), cmd); + } + + private static void writeJavaSecurityProp(String javaSecurityPath, + String setValue) throws IOException { + try (FileOutputStream fos = new FileOutputStream( + new File(javaSecurityPath))) { + fos.write(("jdk.jceks.iterationCount=" + setValue).getBytes()); + } + } + + private static int getCurrentIterationCountValue() throws Exception { + Class KeyProtectorClass = + Class.forName("com.sun.crypto.provider.KeyProtector"); + Field iterationCountField = + KeyProtectorClass.getDeclaredField("ITERATION_COUNT"); + iterationCountField.setAccessible(true); + return iterationCountField.getInt(KeyProtectorClass); + } + + private static void deleteDir(Path directory) throws IOException { + Files.walkFileTree(directory, new SimpleFileVisitor() { + + @Override + public FileVisitResult visitFile(Path file, + BasicFileAttributes attrs) throws IOException { + Files.delete(file); + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException exc) + throws IOException { + Files.delete(dir); + return FileVisitResult.CONTINUE; + } + }); + } +} diff --git a/test/com/sun/org/apache/xml/internal/security/transforms/ClassLoaderTest.java b/test/com/sun/org/apache/xml/internal/security/transforms/ClassLoaderTest.java index d0a56b6c7b8c2890ba885298b71f4d64ddf1bc72..010cdd1004cce67782bdaf05be36752bab39c6ca 100644 --- a/test/com/sun/org/apache/xml/internal/security/transforms/ClassLoaderTest.java +++ b/test/com/sun/org/apache/xml/internal/security/transforms/ClassLoaderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -24,9 +24,9 @@ /** * @test * @author Sean Mullan - * @bug 6461674 8009217 + * @bug 6461674 8009217 7147060 * @compile -XDignore.symbol.file ClassLoaderTest.java MyTransform.java - * @run main ClassLoaderTest + * @run main/othervm ClassLoaderTest * @summary Ensure Transform.register works with transform implementations * loaded by class loader other than system/boot class loader */ diff --git a/test/demo/zipfs/ZFSTests.java b/test/demo/zipfs/ZFSTests.java index c5d6e8c9e9f80e526abc42d6f604fc25e3a1761e..6aaff7d59a7f9e9ce7d9c6020bee2cd4e550f06c 100644 --- a/test/demo/zipfs/ZFSTests.java +++ b/test/demo/zipfs/ZFSTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -22,20 +22,23 @@ */ /* @test - @bug 7156873 + @bug 7156873 8028480 8034773 @summary ZipFileSystem regression tests */ - +import java.io.OutputStream; import java.net.URI; +import java.nio.ByteBuffer; +import java.nio.channels.*; import java.nio.file.*; -import java.util.Map; -import java.util.HashMap; +import java.nio.file.spi.*; +import java.util.*; public class ZFSTests { public static void main(String[] args) throws Throwable { test7156873(); + testOpenOptions(); } static void test7156873() throws Throwable { @@ -53,4 +56,44 @@ public class ZFSTests { Files.deleteIfExists(dir); } } + + static void testOpenOptions() throws Throwable { + Path path = Paths.get("file.zip"); + try { + URI uri = URI.create("jar:" + path.toUri()); + Map env = new HashMap(); + env.put("create", "true"); + try (FileSystem fs = FileSystems.newFileSystem(uri, env)) { + FileSystemProvider fsp = fs.provider(); + Set options; + Path p = fs.getPath("test.txt"); + // 8028480 + options = EnumSet.of(StandardOpenOption.CREATE, + StandardOpenOption.WRITE, + StandardOpenOption.APPEND); + try (FileChannel ch = fsp.newFileChannel(p, options)) { + ch.write(ByteBuffer.wrap("Hello!".getBytes("ASCII"))); + } + // 8034773 + try (OutputStream os = fsp.newOutputStream(p, new OpenOption[0])) { + os.write("Hello2!".getBytes("ASCII")); + } + if (!"Hello2!".equals(new String( + Files.readAllBytes(fs.getPath("test.txt"))))) { + throw new RuntimeException("failed to open as truncate_existing"); + } + + options = EnumSet.of(StandardOpenOption.CREATE, + StandardOpenOption.APPEND, + StandardOpenOption.TRUNCATE_EXISTING); + try (FileChannel ch = fsp.newFileChannel(p, options)) { + throw new RuntimeException("expected IAE not thrown!"); + } catch (IllegalArgumentException x) { + // expected x.printStackTrace(); + } + } + } finally { + Files.deleteIfExists(path); + } + } } diff --git a/test/demo/zipfs/ZipFSPermissionsTest.java b/test/demo/zipfs/ZipFSPermissionsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..33a1700177fc051d8dfa4cca6760ac78a9dd2f61 --- /dev/null +++ b/test/demo/zipfs/ZipFSPermissionsTest.java @@ -0,0 +1,234 @@ +/* + * 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.SkipException; +import org.testng.annotations.*; + +import java.io.IOException; +import java.net.URI; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.spi.FileSystemProvider; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.attribute.PosixFileAttributeView; +import java.nio.file.attribute.PosixFileAttributes; +import java.nio.file.attribute.PosixFilePermission; +import java.nio.file.attribute.PosixFilePermissions; +import java.util.Arrays; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static java.nio.file.attribute.PosixFilePermission.*; +import static org.testng.Assert.assertEquals; + +/** + * @test + * @bug 8229888 + * @summary Updating an existing zip file does not preserve original permissions + * @modules jdk.zipfs + * @run testng/othervm ZipFSPermissionsTest + * @run testng/othervm/java.security.policy=ZipFSPermissionsTest.policy ZipFSPermissionsTest + */ +public class ZipFSPermissionsTest { + + // Files used for testing + private static final Path zipFile = Paths.get("zipPermsTest.zip"); + private static final Path entry0 = Paths.get("Entry-0.txt"); + // Path of 2nd file to add to the Zip file + private static final Path entry1 = Paths.get("Entry-1.txt"); + + // Enable for permissions output + private static final boolean DEBUG = false; + + /** + * Create the files used by the test + */ + @BeforeSuite + public void setUp() throws Exception { + boolean supportsPosix = FileSystems.getDefault() + .supportedFileAttributeViews().contains("posix"); + + // Check to see if File System supports POSIX permissions + if (supportsPosix) { + System.out.println("File Store Supports Posix"); + } else { + // As there is no POSIX permission support, skip running the test + throw new SkipException("Cannot set permissions on this File Store"); + } + Files.write(entry0, "Tennis Pro".getBytes(UTF_8)); + Files.write(entry1, "Tennis is a lifetime sport!".getBytes(UTF_8)); + } + + /** + * Re-create the initial Zip file prior to each run. + */ + @BeforeMethod + public void before() throws Exception { + Files.deleteIfExists(zipFile); + zip(zipFile, Collections.singletonMap("create", "true"), entry0); + } + + /** + * Remove Zip file used by test after each run. + */ + @AfterMethod + public void tearDown() throws Exception { + Files.deleteIfExists(zipFile); + } + + /** + * Remove files used by test as part of final test run clean-up + */ + @AfterSuite + public void suiteCleanUp() throws Exception { + Files.deleteIfExists(zipFile); + Files.deleteIfExists(entry0); + Files.deleteIfExists(entry1); + } + + /** + * Validate that the Zip file permissions are as expected after updating the + * Zip file + * @param newPerms The permissions to set on the Zip File before updating the + * file + * @throws Exception If an error occurs + */ + @Test(dataProvider = "posixPermissions") + public void testZipPerms(Set newPerms) throws Exception { + if (DEBUG) { + System.out.printf("Test Run with perms= %s%n", newPerms); + } + + PosixFileAttributes attrs = getPosixAttributes(zipFile); + + // Permissions used to verify the results of updating the Zip file + if (newPerms == null) { + // Use current Zip File permissions; + newPerms = attrs.permissions(); + } + displayPermissions("Original permissions", zipFile); + + // Now set the new permissions + Files.setPosixFilePermissions(zipFile, newPerms); + displayPermissions("Revised permissions", zipFile); + + // Update the Zip file + zip(zipFile, Collections.emptyMap(), entry1); + + // Validate that the permissions are as expected after updating the + // Zip file + PosixFileAttributes afterAttrs = getPosixAttributes(zipFile); + displayPermissions("Permissions after updating the Zip File", zipFile); + assertEquals(afterAttrs.permissions(), newPerms, + "Permissions were not updated as expected!"); + } + + /** + * Display the permissions for the specified Zip file when {@code DEBUG} + * is set to {@code true} + * + * @param msg String to include in the message + * @param zipFile Path to the Zip File + * @throws IOException If an error occurs obtaining the permissions + */ + public void displayPermissions(String msg, Path zipFile) throws IOException { + if (DEBUG) { + PosixFileAttributeView view = Files.getFileAttributeView(zipFile, + PosixFileAttributeView.class); + if (view == null) { + System.out.println("Could not obtain a PosixFileAttributeView!"); + return; + } + PosixFileAttributes attrs = view.readAttributes(); + System.out.printf("%s: %s, Owner: %s, Group:%s, permissions: %s%n", msg, + zipFile.getFileName(), attrs.owner().getName(), + attrs.group().getName(), PosixFilePermissions.toString(attrs.permissions())); + } + } + + /** + * Create a Zip File System using the specified properties and a Zip file + * with the specified number of entries + * + * @param zipFile Path to the Zip File to create/update + * @param env Properties used for creating the Zip Filesystem + * @param source The path of the file to add to the Zip File + * @throws Exception If an error occurs while creating/updating the Zip file + */ + public void zip(Path zipFile, Map env, Path source) throws Exception { + if (DEBUG) { + System.out.printf("File:%s, adding:%s%n", zipFile.toAbsolutePath(), source); + } + try (FileSystem zipfs = FileSystems.newFileSystem(new URI("jar", zipFile.toUri().toString(), null), env)) { + Files.copy(source, zipfs.getPath(source.getFileName().toString())); + } + } + + /** + * Returns a file's POSIX file attributes. + * + * @param path The path to the Zip file + * @return The POSIX file attributes for the specified file or + * null if the POSIX attribute view is not available + * @throws IOException If an error occurs obtaining the POSIX attributes for + * the specified file + */ + public PosixFileAttributes getPosixAttributes(Path path) throws IOException { + PosixFileAttributes attrs = null; + PosixFileAttributeView view = + Files.getFileAttributeView(path, PosixFileAttributeView.class); + // Return if the attribute view is not supported + if (view == null) { + return null; + } + attrs = view.readAttributes(); + return attrs; + } + + /* + * DataProvider used to verify the permissions on a Zip file + * are as expected after updating the Zip file + */ + @DataProvider(name = "posixPermissions") + private Object[][] posixPermissions() { + return new Object[][]{ + {null}, + {new LinkedHashSet<>(Arrays.asList(OWNER_READ, OWNER_WRITE, OTHERS_READ))}, + {new LinkedHashSet<>(Arrays.asList(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE))}, + {new LinkedHashSet<>(Arrays.asList(OWNER_READ, OWNER_WRITE, OTHERS_READ, OTHERS_WRITE))}, + {new LinkedHashSet<>(Arrays.asList(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE, OTHERS_READ, + OTHERS_WRITE, OTHERS_EXECUTE))}, + {new LinkedHashSet<>(Arrays.asList(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE, + GROUP_READ, GROUP_WRITE,GROUP_EXECUTE, OTHERS_READ, + OTHERS_WRITE, OTHERS_EXECUTE))}, + {new LinkedHashSet<>(Arrays.asList(OWNER_READ, OWNER_WRITE, GROUP_READ, GROUP_WRITE, + OTHERS_READ, OTHERS_WRITE))}, + }; + } + } diff --git a/test/demo/zipfs/ZipFSPermissionsTest.policy b/test/demo/zipfs/ZipFSPermissionsTest.policy new file mode 100644 index 0000000000000000000000000000000000000000..8bd0028ca8503e1ec3a163c58eafcf8e19316c99 --- /dev/null +++ b/test/demo/zipfs/ZipFSPermissionsTest.policy @@ -0,0 +1,5 @@ +grant { + permission java.io.FilePermission "<>","read,write,delete"; + permission java.util.PropertyPermission "user.dir","read"; + permission java.lang.RuntimePermission "accessUserInformation"; +}; diff --git a/test/java/awt/EventQueue/InvocationEventTest/InvocationEventTest.java b/test/java/awt/EventQueue/InvocationEventTest/InvocationEventTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a0d19940340b2856b8178f089fce7302602e6eba --- /dev/null +++ b/test/java/awt/EventQueue/InvocationEventTest/InvocationEventTest.java @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +import java.awt.*; +import java.awt.event.*; + +/* + * @test + * @summary To Test the following assertions in InvovationEvent. + * 1.InvocationEvent when dispatched, should invoke the + * run() method of the Runnable Interface. + * 2.If catchExceptions is false, Exception should be + * propagated up to the EventDispatchThread's dispatch loop. + * 3.If catchExceptions is true, InvocationEvent.getExceptions() + * should return the exception thrown inside thr run() method. + * 4.When InvocationEvent object is posted on to the EventQueue, + * InvocationEvent.dispatch() method should be invoked by the + * EventQueue. + * 5.If the notifier object is not null, notifyAll() of the + * notifier object should be invoked when the run() method returns. + * 6.To test whether the threads are invoked in the right order + * When InvocationEvents are nested. + * 7.The getWhen method should return timestamp which is less than + * current System time and greater than the time before it has + * actually happened + * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com) + * @run main InvocationEventTest + */ + +public class InvocationEventTest { + EventQueue eventQ1 = new EventQueue(); + + Object lock = new Object(); + + static final int delay = 5000; + + public volatile boolean notifierStatus = false; + public Object notifierLock = new Object(); + + public volatile boolean threadStatus = false; + public volatile boolean childInvoked = false; + + public synchronized void doTest() throws Exception { + // Testing assertions 1, 2 and 7: + // 1.InvocationEvent when dispatched, should invoke the + // run() method of the Runnable Interface. + // 2.If catchExceptions is false, Exception should be + // propagated up to the EventDispatchThread's dispatch loop. + // 7.The getWhen method should return timestamp which is less than + // current System time and greater than the time before it has + // actually happened + + long timeBeforeInvoking = System.currentTimeMillis(); + + Thread.sleep(10); + + InvocationEvent invoc = new InvocationEvent(this, () -> { threadStatus = true; }, lock, false); + invoc.dispatch(); + + Thread.sleep(10); + + if (!threadStatus) { + synchronized (lock) { + lock.wait(delay); + } + } + + // testing getException() when no exception is thrown + if (invoc.getWhen() <= timeBeforeInvoking || + invoc.getWhen() >= System.currentTimeMillis()) { + throw new RuntimeException("getWhen method is not getting the time at which event occured"); + } + + if (invoc.getException() != null) { + throw new RuntimeException("InvocationEvent.getException() does not return null " + + "when catchException is false"); + } + + // testing the normal behaviour of InvocationEvent + if (!threadStatus) { + throw new RuntimeException("InvocationEvent when dispatched, did not" + + " invoke the run() of the Runnable interface "); + } + threadStatus = false; + + // Testing assertion 3: + // 3.If catchExceptions is true, InvocationEvent.getExceptions() + // should return the exception thrown inside the run() method. + RuntimeException sampleExn = new RuntimeException(" test exception"); + + invoc = new InvocationEvent(this, () -> { threadStatus = true; throw sampleExn; }, lock, true); + invoc.dispatch(); + if (!threadStatus) { + synchronized (lock) { + lock.wait(delay); + } + } + // testing getException() when exception is thrown + // Should return the same exception thrown inside the run() method + if (!invoc.getException().equals(sampleExn)) { + throw new RuntimeException("getException() does not return " + + "the same Exception thrown inside the run() method "); + } + threadStatus = false; + + // Testing assertions 4 and 5: + // 4.When InvocationEvent object is posted on to the EventQueue, + // InvocationEvent.dispatch() method should be invoked by the + // EventQueue. + // 5.If the notifier object is not null, notifyAll() of the + // notifier object should be invoked when the run() method returns. + + Thread notify = new Thread(){ + public void run() { + synchronized (this) { + try { wait(); } catch (InterruptedException e) { throw new RuntimeException(e); } + } + notifierStatus = true; + synchronized (notifierLock) { + notifierLock.notifyAll(); + } + } + }; + notify.start(); + + while (notify.getState() != Thread.State.WAITING) + Thread.sleep(delay/5); + + InvocationEvent invocation = new InvocationEvent(this, () -> { }, (Object) notify, false); + eventQ1.postEvent(invocation); + + while(!invocation.isDispatched()) + synchronized (notifierLock) { + notifierLock.wait(delay); + } + + while (notify.getState() != Thread.State.TERMINATED) + Thread.sleep(delay/5); + + if (!notifierStatus) { + throw new RuntimeException("Notifier object did not get notified" + + " When the run method of the Runnable returns "); + } + + // Testing assertion 6: + // 6.To test whether the threads are invoked in the right order + // When InvocationEvents are nested. + Thread thread = new Thread(){ + public void run() { + InvocationEvent evt = new InvocationEvent(this, () -> { childInvoked = true; }, (Object) this, false); + new EventQueue().postEvent(evt); + synchronized (this) { + try { + wait(delay); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + threadStatus = true; + } + }; + + invocation = new InvocationEvent(this, thread, lock, false); + + eventQ1.postEvent(invocation); + + while (!invocation.isDispatched()) + synchronized (lock) { + lock.wait(delay); + } + + if (!threadStatus || !childInvoked) { + throw new RuntimeException("Nesting of InvocationEvents when dispatched," + + " did not invoke the run() of the Runnables properly "); + } + } + + public static void main(String[] args) throws Exception { + new InvocationEventTest().doTest(); + } +} + diff --git a/test/java/awt/FontMetrics/SpaceAdvance.java b/test/java/awt/FontMetrics/SpaceAdvance.java new file mode 100644 index 0000000000000000000000000000000000000000..e2c7acb6f969aabcde0a493607fd7ac548574116 --- /dev/null +++ b/test/java/awt/FontMetrics/SpaceAdvance.java @@ -0,0 +1,49 @@ +/* + * 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 8227662 + */ + +import java.awt.Font; +import java.awt.FontMetrics ; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; + +public class SpaceAdvance { + public static void main(String[] args) throws Exception { + + BufferedImage bi = new BufferedImage(1,1,1); + Graphics2D g2d = bi.createGraphics(); + Font font = new Font(Font.DIALOG, Font.PLAIN, 12); + if (!font.canDisplay(' ')) { + return; + } + g2d.setFont(font); + FontMetrics fm = g2d.getFontMetrics(); + if (fm.charWidth(' ') == 0) { + throw new RuntimeException("Space has char width of 0"); + } + } +} diff --git a/test/java/awt/Frame/DecoratedExceptions/DecoratedExceptions.java b/test/java/awt/Frame/DecoratedExceptions/DecoratedExceptions.java new file mode 100644 index 0000000000000000000000000000000000000000..b2a0ddc6fdcb06b313ced19f6c4d0deb094d86bf --- /dev/null +++ b/test/java/awt/Frame/DecoratedExceptions/DecoratedExceptions.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2011, 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. + */ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +import java.awt.*; + +/* + * @test + * @summary An attempt to set non-trivial background, shape, or translucency + * to a decorated toplevel should end with an exception. + * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com) + * @library ../../../../lib/testlibrary + * @build ExtendedRobot + * @run main DecoratedExceptions + */ +public class DecoratedExceptions { + public static void main(String args[]) throws Exception{ + ExtendedRobot robot = new ExtendedRobot(); + Toolkit.getDefaultToolkit().getSystemEventQueue().invokeAndWait(() -> { + Frame frame = new Frame("Frame"); + frame.setBounds(50,50,400,200); + try { + frame.setOpacity(0.5f); + throw new RuntimeException("No exception when Opacity set to a decorated Frame"); + }catch(IllegalComponentStateException e) { + } + try { + frame.setShape(new Rectangle(50,50,400,200)); + throw new RuntimeException("No exception when Shape set to a decorated Frame"); + }catch(IllegalComponentStateException e) { + } + try { + frame.setBackground(new Color(50, 50, 50, 100)); + throw new RuntimeException("No exception when Alpha background set to a decorated Frame"); + }catch(IllegalComponentStateException e) { + } + frame.setVisible(true); + Dialog dialog = new Dialog( frame ); + try { + dialog.setOpacity(0.5f); + throw new RuntimeException("No exception when Opacity set to a decorated Dialog"); + }catch(IllegalComponentStateException e) { + } + try { + dialog.setShape(new Rectangle(50,50,400,200)); + throw new RuntimeException("No exception when Shape set to a decorated Dialog"); + }catch(IllegalComponentStateException e) { + } + try { + dialog.setBackground(new Color(50, 50, 50, 100)); + throw new RuntimeException("No exception when Alpha background set to a decorated Dialog"); + }catch(IllegalComponentStateException e) { + } + dialog.setVisible(true); + }); + robot.waitForIdle(1000); + } +} diff --git a/test/java/awt/Graphics/DrawLineTest.java b/test/java/awt/Graphics/DrawLineTest.java new file mode 100644 index 0000000000000000000000000000000000000000..4f1da5274696617166e97a2b32c4dfecfe3379df --- /dev/null +++ b/test/java/awt/Graphics/DrawLineTest.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * 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 + @key headful + @bug 8235904 + @run main/othervm/timeout=60 DrawLineTest +*/ + +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; + +public class DrawLineTest extends Frame { + + volatile static boolean done = false; + + public static void main(String[] args) throws Exception { + + EventQueue.invokeLater(() -> { + DrawLineTest frame = new DrawLineTest(); + frame.setVisible(true); + Image img = frame.createVolatileImage(1000, 1000); + img.getGraphics().drawLine(0, 0, 34005, 34005); + done = true; + frame.setVisible(false); + frame.dispose(); + return; + }); + + int cnt=0; + while (!done && (cnt++ < 60)) { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + } + } + + if (!done) { + // jtreg will shutdown the test properly + if ((System.getProperty("test.src") != null)) { + throw new RuntimeException("Test Failed"); + } else { + // Not to be used in jtreg + System.out.println("Test failed."); + Runtime.getRuntime().halt(-1); + } + } + return; + } +} diff --git a/test/java/awt/Window/ShapedAndTranslucentWindows/Common.java b/test/java/awt/Window/ShapedAndTranslucentWindows/Common.java new file mode 100644 index 0000000000000000000000000000000000000000..8927642ecf8579189500e299e5aefb438c764fa9 --- /dev/null +++ b/test/java/awt/Window/ShapedAndTranslucentWindows/Common.java @@ -0,0 +1,316 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; +import java.awt.event.*; +import java.awt.geom.Area; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.security.SecureRandom; + + +/* + * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com) + */ +public abstract class Common { + + ExtendedRobot robot; + Class windowClass; + Frame background; + BufferedImage foreground; + Window window; + Container componentsContainer; + + float opacity = 1.0f; + static final int STATIC_STEP = 30; + static final int STATIC_WIDTH = 25; + static final int STATIC_BLOCKS = 30; + static final Color BG_COLOR = Color.BLUE; + static final Color FG_COLOR = Color.RED; + static final int delay = 1000; + static final SecureRandom random = new SecureRandom(); + static final int dl = 100; + static final Class[] WINDOWS_TO_TEST = { Window.class, Frame.class, Dialog.class }; + + public Common(Class windowClass, float opacity) throws Exception{ + this.opacity = opacity; + robot = new ExtendedRobot(); + this.windowClass = windowClass; + EventQueue.invokeAndWait(this::initBackgroundFrame); + EventQueue.invokeAndWait(this::initGUI); + } + + public Common(Class windowClass) throws Exception{ + this(windowClass, 1.0f); + } + + public void doTest() throws Exception { + robot.waitForIdle(delay); + }; + + public void dispose() { + window.dispose(); + background.dispose(); + } + + public abstract void applyShape(); + + public void applyDynamicShape() { + final Area a = new Area(); + Dimension size = window.getSize(); + for (int x = 0; x < 3; x++) { + for (int y = 0; y < 3; y++) { + a.add(new Area(new Rectangle2D.Double( + x * size.getWidth() / 17*6, y * size.getHeight() / 17*6, + size.getWidth() / 17*5, size.getHeight() / 17*5))); + } + } + window.setShape(a); + } + + public void applyStaticShape() { + final Area a = new Area(); + for (int x = 0; x < STATIC_BLOCKS; x++) { + for (int y = 0; y < STATIC_BLOCKS; y++) { + a.add(new Area(new Rectangle2D.Float( + x*STATIC_STEP, y*STATIC_STEP, + STATIC_WIDTH, STATIC_WIDTH))); + } + } + window.setShape(a); + } + + public BufferedImage getForegroundWindow() throws Exception { + final BufferedImage f[] = new BufferedImage[1]; + EventQueue.invokeAndWait( () -> { + f[0] = new BufferedImage(window.getWidth(), + window.getHeight(), BufferedImage.TYPE_INT_RGB); + window.printAll(f[0].createGraphics()); + }); + robot.waitForIdle(delay); + return f[0]; + } + + public static boolean checkTranslucencyMode(GraphicsDevice.WindowTranslucency mode) { + + if (!GraphicsEnvironment + .getLocalGraphicsEnvironment() + .getDefaultScreenDevice() + .isWindowTranslucencySupported(mode)){ + System.out.println(mode+" translucency mode isn't supported"); + return false; + } else { + return true; + } + + } + + public void applyAppDragNResizeSupport() { + MouseAdapter m = new MouseAdapter() { + + private Point dragOrigin = null; + private Dimension origSize = null; + private Point origLoc = null; + private boolean left = false; + private boolean top = false; + private boolean bottom = false; + private boolean right = false; + + public void mousePressed(MouseEvent e) { + dragOrigin = e.getLocationOnScreen(); + origSize = window.getSize(); + origLoc = window.getLocationOnScreen(); + right = (origLoc.x + window.getWidth() - dragOrigin.x) < 5; + left = !right && dragOrigin.x - origLoc.x < 5; + bottom = (origLoc.y + window.getHeight() - dragOrigin.y) < 5; + top = !bottom && dragOrigin.y - origLoc.y < 5; + } + + public void mouseReleased(MouseEvent e) { resize(e); } + public void mouseDragged(MouseEvent e) { resize(e); } + + void resize(MouseEvent e) { + Point dragDelta = e.getLocationOnScreen(); + dragDelta.translate(-dragOrigin.x, -dragOrigin.y); + Point newLoc = new Point(origLoc); + newLoc.translate(dragDelta.x, dragDelta.y); + Dimension newSize = new Dimension(origSize); + if (left || right) { + newSize.width += right ? dragDelta.x : -dragDelta.x; + } + if (top || bottom) { + newSize.height += bottom ? dragDelta.y : -dragDelta.y; + } + if (right || (top || bottom) && !left) { + newLoc.x = origLoc.x; + } + if (bottom || (left || right) && !top) { + newLoc.y = origLoc.y; + } + window.setBounds(newLoc.x, newLoc.y, newSize.width, newSize.height); + } + }; + for (Component comp : window.getComponents()) { + comp.addMouseListener(m); + comp.addMouseMotionListener(m); + } + + window.addMouseListener(m); + window.addMouseMotionListener(m); + } + + public void checkTranslucentShape() throws Exception { + foreground = getForegroundWindow(); + Point[] points = new Point[4]; + + Dimension size = window.getSize(); + Point location = window.getLocationOnScreen(); + + points[0] = new Point(20, 20); + points[1] = new Point(20, size.height-20); + points[2] = new Point(size.width-20, 20); + points[3] = new Point(size.width-20, size.height-20); + + for (Point p : points){ + p.translate(location.x, location.y); + Color actual = robot.getPixelColor(p.x, p.y); + if (actual.equals(BG_COLOR)|| actual.equals(FG_COLOR)) + throw new RuntimeException("Error in point "+p+": "+actual+" equals to foreground or background color"); + else + System.out.println("OK with foreground point "+p); + } + } + + public void checkStaticShape() throws Exception { + Point[] points = new Point[4]; + + Dimension size = window.getSize(); + int xFactor = (int) Math.floor(size.getWidth()/STATIC_STEP)-1; + int yFactor = (int) Math.floor(size.getHeight()/STATIC_STEP)-1; + + // background + points[0] = new Point((STATIC_STEP+STATIC_WIDTH)/2, (STATIC_STEP+STATIC_WIDTH)/2); + points[1] = new Point(STATIC_STEP*xFactor+(STATIC_STEP+STATIC_WIDTH)/2, STATIC_STEP*yFactor+(STATIC_STEP+STATIC_WIDTH)/2); + points[2] = new Point((STATIC_STEP+STATIC_WIDTH)/2, STATIC_STEP*yFactor+(STATIC_STEP+STATIC_WIDTH)/2); + points[3] = new Point(STATIC_STEP*xFactor+(STATIC_STEP+STATIC_WIDTH)/2, (STATIC_STEP+STATIC_WIDTH)/2); + checkShape(points, true); + + // foreground + if (opacity < 1.0f){ + checkTranslucentShape(); + } else { + points[0] = new Point((STATIC_WIDTH) / 2, (STATIC_WIDTH) / 2); + points[1] = new Point(STATIC_STEP * xFactor + (STATIC_WIDTH) / 2, STATIC_STEP * yFactor + (STATIC_WIDTH) / 2); + points[2] = new Point((STATIC_WIDTH) / 2, STATIC_STEP * yFactor + (STATIC_WIDTH) / 2); + points[3] = new Point(STATIC_STEP * xFactor + (STATIC_WIDTH) / 2, (STATIC_WIDTH) / 2); + checkShape(points, false); + } + } + + public void checkDynamicShape() throws Exception { + Point[] points = new Point[4]; + + Dimension size = window.getSize(); + + int blockSizeX = (int) (size.getWidth() / 17); + int blockSizeY = (int) (size.getHeight() / 17); + + // background + points[0] = new Point((int) (blockSizeX * 5.5), (int) (blockSizeY * 5.5)); + points[1] = new Point((int) (size.getWidth() - blockSizeX * 5.5), (int) (size.getHeight() - blockSizeY * 5.5)); + points[2] = new Point((int) (blockSizeX * 5.5), (int) (size.getHeight() - blockSizeY * 5.5)); + points[3] = new Point((int) (size.getWidth() - blockSizeX * 5.5), (int) (blockSizeY * 5.5)); + checkShape(points, true); + + // foreground + if (opacity < 1.0f){ + checkTranslucentShape(); + } else { + points[0] = new Point(3 * blockSizeX, 3 * blockSizeY); + points[1] = new Point(14 * blockSizeX, 14 * blockSizeY); + points[2] = new Point(3 * blockSizeX, 14 * blockSizeY); + points[3] = new Point(14 * blockSizeX, 3 * blockSizeY); + checkShape(points, false); + } + } + + public void checkShape(Point[] points, boolean areBackgroundPoints) throws Exception { + + Point location = window.getLocationOnScreen(); + + for (Point p : points) { + p.translate(location.x, location.y); + if (areBackgroundPoints) { + if (!robot.getPixelColor(p.x, p.y).equals(BG_COLOR)) + throw new RuntimeException("Background point " + p + " color " + robot.getPixelColor(p.x, p.y) + + " does not equal to background color " + BG_COLOR); + else + System.out.println("OK with background point " + p); + } else { + if (robot.getPixelColor(p.x, p.y).equals(BG_COLOR)) + throw new RuntimeException("Foreground point " + p + + " equals to background color " + BG_COLOR); + else + System.out.println("OK with foreground point " + p); + } + } + } + + public void initBackgroundFrame() { + background = new Frame(); + background.setUndecorated(true); + background.setBackground(BG_COLOR); + background.setSize(500, 500); + background.setLocation(dl, dl); + background.setVisible(true); + } + + public void initGUI() { + if (windowClass.equals(Frame.class)) { + window = new Frame(); + ((Frame) window).setUndecorated(true); + } else if (windowClass.equals(Dialog.class)) { + window = new Dialog(background); + ((Dialog) window).setUndecorated(true); + } else { + window = new Window(background); + } + + window.setBackground(FG_COLOR); + componentsContainer = new Panel(); + window.add(componentsContainer, BorderLayout.CENTER); + window.setLocation(2 * dl, 2 * dl); + window.setSize(255, 255); + if (opacity < 1.0f) + window.setOpacity(opacity); + window.addComponentListener(new ComponentAdapter() { + public void componentResized(ComponentEvent e) { + applyShape(); + } + }); + applyShape(); + window.setVisible(true); + applyAppDragNResizeSupport(); + window.toFront(); + } +} diff --git a/test/java/awt/Window/ShapedAndTranslucentWindows/FocusAWTTest.java b/test/java/awt/Window/ShapedAndTranslucentWindows/FocusAWTTest.java new file mode 100644 index 0000000000000000000000000000000000000000..81f94f7839c9442d441250527f8d8824cca9ec5d --- /dev/null +++ b/test/java/awt/Window/ShapedAndTranslucentWindows/FocusAWTTest.java @@ -0,0 +1,225 @@ +/* + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.event.WindowFocusListener; +import java.awt.geom.Area; +import java.awt.geom.GeneralPath; +import java.awt.geom.Rectangle2D; +import java.util.HashMap; + +/* + * @test + * @bug 8013450 + * @summary Check if the window events (Focus and Activation) are triggered correctly + * when clicked on visible and clipped areas. + * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com) + * @library ../../../../lib/testlibrary + * @build Common ExtendedRobot + * @run main FocusAWTTest + */ + +public class FocusAWTTest extends Common { + + ExtendedRobot robot; + int dx; + int dy; + static final int x = 20; + static final int y = 400; + + static volatile HashMap flags = new HashMap(); + static { + flags.put("backgroundWindowActivated", false); + flags.put("backgroundWindowDeactivated", false); + flags.put("backgroundWindowGotFocus", false); + flags.put("backgroundWindowLostFocus", false); + flags.put("foregroundWindowGotFocus", false); + flags.put("foregroundWindowLostFocus", false); + flags.put("foregroundWindowActivated", false); + flags.put("foregroundWindowDeactivated", false); + } + + public static void main(String[] ignored) throws Exception{ + if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT)) + for (Class windowClass: WINDOWS_TO_TEST) { + new FocusAWTTest(windowClass).doTest(); + } + } + + public FocusAWTTest(Class windowClass) throws Exception { + super(windowClass); + this.robot = new ExtendedRobot(); + robot.waitForIdle(); + EventQueue.invokeAndWait(() -> { + dx = background.getX() - x; + dy = background.getY() - y; + }); + robot.waitForIdle(); + } + + @Override + public void initBackgroundFrame() { + background = new Frame(); + background.setSize(300, 300); + background.setLocation(x, y); + background.setFocusable(true); + background.setFocusableWindowState(true); + + background.addWindowFocusListener(new WindowFocusListener() { + public void windowGainedFocus(WindowEvent e) { flags.put("backgroundWindowGotFocus", true); } + public void windowLostFocus(WindowEvent e) { flags.put("backgroundWindowLostFocus", true); } + }); + + background.addWindowListener(new WindowAdapter() { + public void windowActivated(WindowEvent e) { flags.put("backgroundWindowActivated", true); } + public void windowDeactivated(WindowEvent e) { flags.put("backgroundWindowDeactivated", true); } + }); + background.add(new TextArea()); + background.setVisible(true); + } + + @Override + public void initGUI() { + if (windowClass.equals(Frame.class)) { + window = new Frame() { + public void paint(Graphics g) { + g.setColor(Color.BLUE); + g.fillRect(0, 0, 200, 200); + } + }; + ((Frame) window).setUndecorated(true); + } else if (windowClass.equals(Dialog.class)) { + window = new Dialog(background) { + public void paint(Graphics g) { + g.setColor(Color.BLUE); + g.fillRect(0, 0, 200, 200); + } + }; + ((Dialog) window).setUndecorated(true); + } else { + window = new Window(background) { + public void paint(Graphics g) { + g.setColor(Color.BLUE); + g.fillRect(0, 0, 200, 200); + } + }; + window.setFocusable(true); + window.setFocusableWindowState(true); + } + + window.setPreferredSize(new Dimension(200, 200)); + window.setLocation(70 + dx, 450 + dy); + window.setLayout(new BorderLayout()); + + window.addWindowFocusListener(new WindowFocusListener() { + public void windowGainedFocus(WindowEvent e) { flags.put("foregroundWindowGotFocus", true); } + public void windowLostFocus(WindowEvent e) { flags.put("foregroundWindowLostFocus", true); } + }); + + window.addWindowListener(new WindowAdapter() { + public void windowActivated(WindowEvent e) { flags.put("foregroundWindowActivated", true); } + public void windowDeactivated(WindowEvent e) { flags.put("foregroundWindowDeactivated", true); } + }); + + applyShape(); + window.pack(); + window.setAlwaysOnTop(true); + window.setVisible(true); + } + + public void doTest() throws Exception { + super.doTest(); + final Point wls = new Point(); + final Dimension size = new Dimension(); + EventQueue.invokeAndWait(() -> { + window.requestFocus(); + wls.setLocation(window.getLocationOnScreen()); + window.getSize(size); + }); + + robot.waitForIdle(); + + check(wls.x + size.width - 5, wls.y + 5, wls.x + size.width / 3, wls.y + size.height / 3); + check(wls.x + size.width / 2, wls.y + size.height / 2, wls.x + size.width * 2 / 3, wls.y + size.height * 2 / 3); + + EventQueue.invokeAndWait(() -> { + background.dispose(); + window.dispose(); + }); + + robot.waitForIdle(); + } + + @Override + public void applyShape() { + Shape shape; + Area a = new Area(new Rectangle2D.Float(0, 0, 200, 200)); + GeneralPath gp; + gp = new GeneralPath(); + gp.moveTo(190, 0); + gp.lineTo(200, 0); + gp.lineTo(200, 10); + gp.lineTo(10, 200); + gp.lineTo(0, 200); + gp.lineTo(0, 190); + gp.closePath(); + a.subtract(new Area(gp)); + shape = a; + + window.setShape(shape); + } + + private void check(int xb, int yb, int xw, int yw) throws Exception { + checkClick(xb, yb, "backgroundWindowGotFocus"); + checkClick(xw, yw, "foregroundWindowGotFocus"); + checkClick(xb, yb, "foregroundWindowLostFocus"); + checkClick(xw, yw, "backgroundWindowLostFocus"); + + if (window instanceof Dialog || window instanceof Frame) { + checkClick(xb, yb, "backgroundWindowActivated"); + checkClick(xw, yw, "foregroundWindowActivated"); + checkClick(xb, yb, "foregroundWindowDeactivated"); + checkClick(xw, yw, "backgroundWindowDeactivated"); + } + + } + + private void checkClick(int x, int y, String flag) throws Exception { + System.out.println("Trying to click point " + x + ", " + y + ", looking for " + flag + " to trigger."); + + flags.put(flag, false); + + robot.mouseMove(x, y); + robot.click(); + int i = 0; + while (i < 5000 && !flags.get(flag)) { + robot.waitForIdle(50); + i += 50; + } + + if (!flags.get(flag)) + throw new RuntimeException(flag + " is not triggered for click on point " + x + ", " + y + " for " + windowClass + "!"); + } +} diff --git a/test/java/awt/Window/ShapedAndTranslucentWindows/Shaped.java b/test/java/awt/Window/ShapedAndTranslucentWindows/Shaped.java new file mode 100644 index 0000000000000000000000000000000000000000..8061465e51f0c1fc01e7ed8401b55f092810734c --- /dev/null +++ b/test/java/awt/Window/ShapedAndTranslucentWindows/Shaped.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + + +/* + * @test + * @summary Check if dynamically shaped window is moved and resized + * by robot correctly + * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com) + * @library ../../../../lib/testlibrary + * @build Common ExtendedRobot + * @run main Shaped + */ +public class Shaped extends Common{ + + public static void main(String[] args) throws Exception { + if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT)) + for (Class windowClass: WINDOWS_TO_TEST){ + new Shaped(windowClass).doTest(); + } + } + + public Shaped(Class windowClass) throws Exception{ + super(windowClass); + } + public void applyShape(){ applyDynamicShape(); } + + public void doTest() throws Exception{ + super.doTest(); + + checkDynamicShape(); + + // Drag + Point location = window.getLocationOnScreen(); + robot.dragAndDrop(location.x + dl, location.y + 5, location.x + dl + random.nextInt(dl), location.y + random.nextInt(dl)); + robot.waitForIdle(delay); + checkDynamicShape(); + + // Resize + location = window.getLocationOnScreen(); + robot.dragAndDrop(location.x + 4, location.y + 4, location.x + random.nextInt(2*dl)-dl, location.y + random.nextInt(2*dl)-dl); + robot.waitForIdle(delay); + checkDynamicShape(); + + dispose(); + } +} diff --git a/test/java/awt/Window/ShapedAndTranslucentWindows/ShapedByAPI.java b/test/java/awt/Window/ShapedAndTranslucentWindows/ShapedByAPI.java new file mode 100644 index 0000000000000000000000000000000000000000..00d5193740bea402ebe22ca34cc21fa2b1f7188b --- /dev/null +++ b/test/java/awt/Window/ShapedAndTranslucentWindows/ShapedByAPI.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + + +/* + * @test + * @summary Check if dynamically shaped window is moved and resized + * using API correctly + * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com) + * @library ../../../../lib/testlibrary + * @run main ShapedByAPI + */ +public class ShapedByAPI extends Common { + + public static void main(String[] args) throws Exception { + if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT)) + for (Class windowClass: WINDOWS_TO_TEST){ + new ShapedByAPI(windowClass).doTest(); + } + } + + public ShapedByAPI(Class windowClass) throws Exception{ + super(windowClass); + } + public void applyShape(){ applyDynamicShape(); } + + public void doTest() throws Exception{ + super.doTest(); + + checkDynamicShape(); + + EventQueue.invokeAndWait(() -> { + Point location = window.getLocationOnScreen(); + location.translate(random.nextInt(dl), random.nextInt(dl)); + window.setLocation(location); + }); + robot.waitForIdle(delay); + checkDynamicShape(); + + EventQueue.invokeAndWait(() -> { + Dimension size = window.getSize(); + window.setSize(size.width+random.nextInt(2*dl)-dl, size.height+random.nextInt(2*dl)-dl); + }); + robot.waitForIdle(delay); + checkDynamicShape(); + + dispose(); + } +} diff --git a/test/java/awt/Window/ShapedAndTranslucentWindows/ShapedTranslucent.java b/test/java/awt/Window/ShapedAndTranslucentWindows/ShapedTranslucent.java new file mode 100644 index 0000000000000000000000000000000000000000..cb98c4450e2b02406248433f47db9a490cbec16a --- /dev/null +++ b/test/java/awt/Window/ShapedAndTranslucentWindows/ShapedTranslucent.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check if a translucent shaped window is dragged and + * resized correctly. + * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com) + * @library ../../../../lib/testlibrary + * @build Common ExtendedRobot + * @run main ShapedTranslucent + */ +public class ShapedTranslucent extends Common { + + public static void main(String[] args) throws Exception { + if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.TRANSLUCENT) && + checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT)) + for (Class windowClass: WINDOWS_TO_TEST){ + new ShapedTranslucent(windowClass).doTest(); + } + } + + public ShapedTranslucent(Class windowClass) throws Exception{ + super(windowClass, 0.3f); + } + + public void applyShape(){ applyDynamicShape(); } + + public void doTest() throws Exception{ + super.doTest(); + + checkDynamicShape(); + + // Drag + Point location = window.getLocationOnScreen(); + robot.dragAndDrop(location.x + dl, location.y + 5, location.x + dl + random.nextInt(dl), location.y + random.nextInt(dl)); + robot.waitForIdle(delay); + checkDynamicShape(); + + // Resize + location = window.getLocationOnScreen(); + robot.dragAndDrop(location.x + 4, location.y + 4, location.x + random.nextInt(2*dl)-dl, location.y + random.nextInt(2*dl)-dl); + robot.waitForIdle(delay); + checkDynamicShape(); + + dispose(); + } +} diff --git a/test/java/awt/Window/ShapedAndTranslucentWindows/StaticallyShaped.java b/test/java/awt/Window/ShapedAndTranslucentWindows/StaticallyShaped.java new file mode 100644 index 0000000000000000000000000000000000000000..7d48847b682574f4ab7b4fa6e90c67602d4f63f5 --- /dev/null +++ b/test/java/awt/Window/ShapedAndTranslucentWindows/StaticallyShaped.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + + +/* + * @test + * @summary Check if statically shaped window is dragged and resized + * correctly. + * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com) + * @library ../../../../lib/testlibrary + * @build Common ExtendedRobot + * @run main StaticallyShaped + */ + +public class StaticallyShaped extends Common { + + public static void main(String[] args) throws Exception { + if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT)) + for (Class windowClass: WINDOWS_TO_TEST){ + new StaticallyShaped(windowClass).doTest(); + } + } + + public StaticallyShaped(Class windowClass) throws Exception{ super(windowClass); } + public void applyShape(){ applyStaticShape(); } + + public void doTest() throws Exception{ + super.doTest(); + + checkStaticShape(); + + // Drag + Point location = window.getLocationOnScreen(); + robot.dragAndDrop(location.x + dl, location.y + 5, location.x + dl + random.nextInt(dl), location.y + random.nextInt(dl)); + robot.waitForIdle(delay); + checkStaticShape(); + + // Resize + location = window.getLocationOnScreen(); + robot.dragAndDrop(location.x + 4, location.y + 4, location.x + random.nextInt(2*dl)-dl, location.y + random.nextInt(2*dl)-dl); + robot.waitForIdle(delay); + checkStaticShape(); + + dispose(); + } +} diff --git a/test/java/awt/Window/ShapedAndTranslucentWindows/Translucent.java b/test/java/awt/Window/ShapedAndTranslucentWindows/Translucent.java new file mode 100644 index 0000000000000000000000000000000000000000..024885362c98c959a1e3b9388b77d65cab829872 --- /dev/null +++ b/test/java/awt/Window/ShapedAndTranslucentWindows/Translucent.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.*; + +/* + * @test + * @summary Check if translucent window is dragged and resized + correctly. + * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com) + * @library ../../../../lib/testlibrary + * @build Common ExtendedRobot + * @run main Translucent + */ +public class Translucent extends Common { + + public static void main(String[] args) throws Exception { + if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.TRANSLUCENT) && + checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT)) + for (Class windowClass: WINDOWS_TO_TEST){ + new Translucent(windowClass).doTest(); + } + } + + public Translucent(Class windowClass) throws Exception{ + super(windowClass, 0.3f); + } + + public void applyShape(){ } + + public void doTest() throws Exception{ + super.doTest(); + + checkTranslucentShape(); + + // Drag + Point location = window.getLocationOnScreen(); + robot.dragAndDrop(location.x + dl, location.y + 5, location.x + dl + random.nextInt(dl), location.y + random.nextInt(dl)); + robot.waitForIdle(delay); + checkTranslucentShape(); + + // Resize + location = window.getLocationOnScreen(); + robot.dragAndDrop(location.x + 4, location.y + 4, location.x + random.nextInt(2*dl)-dl, location.y + random.nextInt(2*dl)-dl); + robot.waitForIdle(delay); + checkTranslucentShape(); + + dispose(); + robot.waitForIdle(delay); + } +} diff --git a/test/java/awt/event/MouseWheelEvent/WheelModifier/MouseWheelOnBackgroundComponent.java b/test/java/awt/event/MouseWheelEvent/WheelModifier/MouseWheelOnBackgroundComponent.java new file mode 100644 index 0000000000000000000000000000000000000000..f5c74a467858bea9c02ffa8ba0996f966ec163f3 --- /dev/null +++ b/test/java/awt/event/MouseWheelEvent/WheelModifier/MouseWheelOnBackgroundComponent.java @@ -0,0 +1,170 @@ +/* + * 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 + @key headful + @bug 8231991 + @summary Mouse wheel change focus on awt/swing windows + @run main MouseWheelOnBackgroundComponent +*/ + +import javax.swing.*; +import java.awt.*; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.WindowEvent; + +/** + * MouseWheelOnBackgroundComponent + * + * Tests that wheel events don't change focus on background components + */ +public class MouseWheelOnBackgroundComponent { + + private static final String FG = "Foreground"; + private static final String BG = "Background"; + + private static final String SCROLL_PANE = "scroller_"; + private static final String TEXT_PANE = "text_"; + + private static JFrame background; + private static JFrame foreground; + + private static final String LOREM_IPSUM = "Sed ut perspiciatis unde omnis iste natus " + + "error sit voluptatem accusantium doloremque laudantium, totam " + + "rem aperiam, eaque ipsa quae ab illo inventore veritatis et " + + "quasi architecto beatae vitae dicta sunt explicabo. Nemo enim " + + "ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, " + + "sed quia consequuntur magni dolores eos qui ratione voluptatem sequi " + + "nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit " + + "amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora " + + "incidunt ut labore et dolore magnam aliquam quaerat voluptatem. " + + "Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis " + + "suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis " + + "autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil " + + "molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla " + + "pariatur?"; + + private static class FocusReporter implements FocusListener { + + private JComponent pane; + + Component lastFocusedComponent; + + public FocusReporter() { + } + + @Override + public void focusGained(FocusEvent e) { + lastFocusedComponent = e.getComponent(); + } + + @Override + public void focusLost(FocusEvent e) { + lastFocusedComponent = null; + } + } + + private static FocusReporter reporter; + + public static void main(String[] args) throws Exception { + + boolean passed = false; + + SwingUtilities.invokeAndWait(() -> { + reporter = new FocusReporter(); + + foreground = createFrame(FG, 100, 0, reporter); + background = createFrame(BG, 0, 100, reporter); + + background.pack(); + background.setVisible(true); + + foreground.pack(); + foreground.setVisible(true); + }); + + SwingUtilities.invokeAndWait(() -> { + foreground.toFront(); + }); + + Robot robot = new Robot(); + robot.waitForIdle(); + + robot.mouseMove(50, 300); + robot.waitForIdle(); + + robot.mouseWheel(-100); + robot.waitForIdle(); + + String shouldBeFocusedComponentName = TEXT_PANE + FG; + Component actual = reporter.lastFocusedComponent; + if (reporter.lastFocusedComponent != null && + shouldBeFocusedComponentName.equals(actual.getName())) + { + passed = true; + } + + robot.waitForIdle(); + + SwingUtilities.invokeAndWait(() -> { + foreground.dispatchEvent(new WindowEvent(foreground, WindowEvent.WINDOW_CLOSING)); + background.dispatchEvent(new WindowEvent(background, WindowEvent.WINDOW_CLOSING)); + }); + + robot.waitForIdle(); + + if (!passed) { + throw new RuntimeException("Wrong component has focus: " + actual); + } + } + + private static JFrame createFrame(String name, int x, int y, FocusReporter reporter) { + JFrame frame = new JFrame(name); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.setBounds(x, y, 600, 600); + frame.setPreferredSize(new Dimension(600, 600)); + + JTextArea text = new JTextArea(); + text.setText(LOREM_IPSUM); + for (int i = 0; i < 10; i++) { + text.append(LOREM_IPSUM); + } + + text.setLineWrap(true); + text.setName(TEXT_PANE + name); + text.addFocusListener(reporter); + + JScrollPane scroller = new JScrollPane(text); + scroller.setName(SCROLL_PANE + name); + scroller.setWheelScrollingEnabled(true); + scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + scroller.addFocusListener(reporter); + + frame.add(scroller); + + return frame; + } +} diff --git a/test/java/awt/image/Raster/TestChildRasterOp.java b/test/java/awt/image/Raster/TestChildRasterOp.java new file mode 100644 index 0000000000000000000000000000000000000000..e56429af6a9ba38a5038cfd66060e79fbc272ad5 --- /dev/null +++ b/test/java/awt/image/Raster/TestChildRasterOp.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8130737 8172559 + * @summary test no exception rasterop for child raster with non-zero offset + */ + +import java.awt.geom.AffineTransform; +import java.awt.image.AffineTransformOp; +import java.awt.image.DataBuffer; +import java.awt.image.DataBufferByte; +import java.awt.image.DataBufferInt; +import java.awt.image.DataBufferUShort; +import java.awt.image.Raster; +import java.awt.image.WritableRaster; + +public class TestChildRasterOp { + + private static AffineTransform at = new AffineTransform(); + private static final AffineTransformOp rop = + new AffineTransformOp(at, AffineTransformOp.TYPE_NEAREST_NEIGHBOR); + private static int[] offsets = {0}; + + public static void main(String[] args) { + testByteRaster(); + testShortRaster(); + testIntRaster(); + } + + private static void testByteRaster() { + WritableRaster srcRaster, dstRaster; + + byte[] pixels = + { 11, 12, 13, 14, + 21, 22, 23, 24, + 31, 32, 33, 34, + 41, 42, 43, 44 }; + + DataBuffer db = new DataBufferByte(pixels, pixels.length); + srcRaster = + Raster.createInterleavedRaster(db, 4, 4, 4, 1, offsets, null); + srcRaster = srcRaster.createWritableChild(1, 1, 3, 3, 0, 0, null); + dstRaster = rop.filter(srcRaster, null); + } + + private static void testShortRaster() { + WritableRaster srcRaster, dstRaster; + + short[] pixels = + { 11, 12, 13, 14, + 21, 22, 23, 24, + 31, 32, 33, 34, + 41, 42, 43, 44 }; + + DataBuffer db = new DataBufferUShort(pixels, pixels.length); + srcRaster = + Raster.createInterleavedRaster(db, 4, 4, 4, 1, offsets, null); + srcRaster = srcRaster.createWritableChild(1, 1, 3, 3, 0, 0, null); + dstRaster = rop.filter(srcRaster, null); + } + + private static void testIntRaster() { + WritableRaster srcRaster, dstRaster; + + int[] pixels = + { 11, 12, 13, 14, + 21, 22, 23, 24, + 31, 32, 33, 34, + 41, 42, 43, 44 }; + + DataBuffer db = new DataBufferInt(pixels, pixels.length); + srcRaster = + Raster.createPackedRaster(db, 4, 4, 4, offsets, null); + srcRaster = srcRaster.createWritableChild(1, 1, 3, 3, 0, 0, null); + dstRaster = rop.filter(srcRaster, null); + } +} diff --git a/test/java/io/Serializable/serialFilter/SerialFilterTest.java b/test/java/io/Serializable/serialFilter/SerialFilterTest.java index 0f6d50ffe33c3811386739952dd10e23908ade30..1c2495a973e1b2c6fc1e38bb034155703c661340 100644 --- a/test/java/io/Serializable/serialFilter/SerialFilterTest.java +++ b/test/java/io/Serializable/serialFilter/SerialFilterTest.java @@ -51,8 +51,10 @@ import org.testng.annotations.Test; import org.testng.annotations.DataProvider; /* @test + * @bug 8234836 * @build SerialFilterTest * @run testng/othervm SerialFilterTest + * @run testng/othervm -Djdk.serialSetFilterAfterRead=true SerialFilterTest * * @summary Test ObjectInputFilters */ @@ -76,6 +78,10 @@ public class SerialFilterTest implements Serializable { */ private static final Object otherObject = Integer.valueOf(0); + // Cache value of jdk.serialSetFilterAfterRead property. + static final boolean SET_FILTER_AFTER_READ = + Boolean.getBoolean("jdk.serialSetFilterAfterRead"); + /** * DataProvider for the individual patterns to test. * Expand the patterns into cases for each of the Std and Compatibility APIs. @@ -297,6 +303,46 @@ public class SerialFilterTest implements Serializable { } } + /** + * After reading some objects from the stream, setting a filter is disallowed. + * If the filter was allowed to be set, it would have unpredictable behavior. + * Objects already read would not be checked again, including class descriptors. + * + * Note: To mitigate possible incompatibility a system property can be set + * to revert to the old behavior but it re-enables the incorrect use. + */ + @Test + static void testNonSettableAfterReadObject() throws IOException, ClassNotFoundException { + String expected1 = "text1"; + String expected2 = "text2"; + byte[] bytes = writeObjects(expected1, expected2); + + for (boolean toggle: new boolean[] {true, false}) { + try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes); + ObjectInputStream ois = new ObjectInputStream(bais)) { + Object actual1 = toggle ? ois.readObject() : ois.readUnshared(); + Assert.assertEquals(actual1, expected1, "unexpected string"); + // Attempt to set filter + ObjectInputFilter filter = new ObjectInputFilter() { + @Override + public Status checkInput(FilterInfo filterInfo) { + return null; + } + }; + ObjectInputFilter.Config.setObjectInputFilter(ois, filter); + if (!SET_FILTER_AFTER_READ) + Assert.fail("Should not be able to set filter after readObject has been called"); + } catch (IllegalStateException ise) { + // success, the exception was expected + if (SET_FILTER_AFTER_READ) + Assert.fail("With jdk.serialSetFilterAfterRead property set = true; " + + "should be able to set the filter after a read"); + } catch (EOFException eof) { + Assert.fail("Should not reach end-of-file", eof); + } + } + } + /** * Test that if an Objects readReadResolve method returns an array * that the callback to the filter includes the proper array length. diff --git a/test/java/lang/ProcessBuilder/Basic.java b/test/java/lang/ProcessBuilder/Basic.java index 7a9260acbf220e805db910a95ef23676423afd58..c8f2461c798808082a8629a1b3b39b9634c26b33 100644 --- a/test/java/lang/ProcessBuilder/Basic.java +++ b/test/java/lang/ProcessBuilder/Basic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -27,6 +27,7 @@ * 5026830 5023243 5070673 4052517 4811767 6192449 6397034 6413313 * 6464154 6523983 6206031 4960438 6631352 6631966 6850957 6850958 * 4947220 7018606 7034570 4244896 5049299 + * 8067796 * @summary Basic tests for Process and Environment Variable code * @run main/othervm/timeout=300 Basic * @run main/othervm/timeout=300 -Djdk.lang.Process.launchMechanism=fork Basic @@ -943,18 +944,13 @@ public class Basic { equal(pb.redirectError(), Redirect.to(efile)); THROWS(IllegalArgumentException.class, - new Fun(){void f() { - pb.redirectInput(Redirect.to(ofile)); }}, - new Fun(){void f() { - pb.redirectInput(Redirect.appendTo(ofile)); }}, - new Fun(){void f() { - pb.redirectOutput(Redirect.from(ifile)); }}, - new Fun(){void f() { - pb.redirectError(Redirect.from(ifile)); }}); + () -> pb.redirectInput(Redirect.to(ofile)), + () -> pb.redirectOutput(Redirect.from(ifile)), + () -> pb.redirectError(Redirect.from(ifile))); THROWS(IOException.class, // Input file does not exist - new Fun(){void f() throws Throwable { pb.start(); }}); + () -> pb.start()); setFileContents(ifile, "standard input"); //---------------------------------------------------------------- @@ -1090,18 +1086,15 @@ public class Basic { = new FilePermission("<>", "read,write,execute"); THROWS(SecurityException.class, - new Fun() { void f() throws IOException { - policy.setPermissions(xPermission); - redirectIO(pb, from(tmpFile), PIPE, PIPE); - pb.start();}}, - new Fun() { void f() throws IOException { - policy.setPermissions(rxPermission); - redirectIO(pb, PIPE, to(ofile), PIPE); - pb.start();}}, - new Fun() { void f() throws IOException { - policy.setPermissions(rxPermission); - redirectIO(pb, PIPE, PIPE, to(efile)); - pb.start();}}); + () -> { policy.setPermissions(xPermission); + redirectIO(pb, from(tmpFile), PIPE, PIPE); + pb.start();}, + () -> { policy.setPermissions(rxPermission); + redirectIO(pb, PIPE, to(ofile), PIPE); + pb.start();}, + () -> { policy.setPermissions(rxPermission); + redirectIO(pb, PIPE, PIPE, to(efile)); + pb.start();}); { policy.setPermissions(rxPermission); @@ -1212,10 +1205,10 @@ public class Basic { // System.getenv() is read-only. //---------------------------------------------------------------- THROWS(UnsupportedOperationException.class, - new Fun(){void f(){ getenv().put("FOO","BAR");}}, - new Fun(){void f(){ getenv().remove("PATH");}}, - new Fun(){void f(){ getenv().keySet().remove("PATH");}}, - new Fun(){void f(){ getenv().values().remove("someValue");}}); + () -> getenv().put("FOO","BAR"), + () -> getenv().remove("PATH"), + () -> getenv().keySet().remove("PATH"), + () -> getenv().values().remove("someValue")); try { Collection> c = getenv().entrySet(); @@ -1240,19 +1233,17 @@ public class Basic { { final Map m = new ProcessBuilder().environment(); THROWS(IllegalArgumentException.class, - new Fun(){void f(){ m.put("FOO=","BAR");}}, - new Fun(){void f(){ m.put("FOO\u0000","BAR");}}, - new Fun(){void f(){ m.put("FOO","BAR\u0000");}}); + () -> m.put("FOO=","BAR"), + () -> m.put("FOO\u0000","BAR"), + () -> m.put("FOO","BAR\u0000")); } //---------------------------------------------------------------- // Commands must never be null. //---------------------------------------------------------------- THROWS(NullPointerException.class, - new Fun(){void f(){ - new ProcessBuilder((List)null);}}, - new Fun(){void f(){ - new ProcessBuilder().command((List)null);}}); + () -> new ProcessBuilder((List)null), + () -> new ProcessBuilder().command((List)null)); //---------------------------------------------------------------- // Put in a command; get the same one back out. @@ -1277,25 +1268,18 @@ public class Basic { // Commands must contain at least one element. //---------------------------------------------------------------- THROWS(IndexOutOfBoundsException.class, - new Fun() { void f() throws IOException { - new ProcessBuilder().start();}}, - new Fun() { void f() throws IOException { - new ProcessBuilder(new ArrayList()).start();}}, - new Fun() { void f() throws IOException { - Runtime.getRuntime().exec(new String[]{});}}); + () -> new ProcessBuilder().start(), + () -> new ProcessBuilder(new ArrayList()).start(), + () -> Runtime.getRuntime().exec(new String[]{})); //---------------------------------------------------------------- // Commands must not contain null elements at start() time. //---------------------------------------------------------------- THROWS(NullPointerException.class, - new Fun() { void f() throws IOException { - new ProcessBuilder("foo",null,"bar").start();}}, - new Fun() { void f() throws IOException { - new ProcessBuilder((String)null).start();}}, - new Fun() { void f() throws IOException { - new ProcessBuilder(new String[]{null}).start();}}, - new Fun() { void f() throws IOException { - new ProcessBuilder(new String[]{"foo",null,"bar"}).start();}}); + () -> new ProcessBuilder("foo",null,"bar").start(), + () -> new ProcessBuilder((String)null).start(), + () -> new ProcessBuilder(new String[]{null}).start(), + () -> new ProcessBuilder(new String[]{"foo",null,"bar"}).start()); //---------------------------------------------------------------- // Command lists are growable. @@ -1312,15 +1296,13 @@ public class Basic { try { final Map env = new ProcessBuilder().environment(); THROWS(NullPointerException.class, - new Fun(){void f(){ env.put("foo",null);}}, - new Fun(){void f(){ env.put(null,"foo");}}, - new Fun(){void f(){ env.remove(null);}}, - new Fun(){void f(){ - for (Map.Entry e : env.entrySet()) - e.setValue(null);}}, - new Fun() { void f() throws IOException { - Runtime.getRuntime().exec(new String[]{"foo"}, - new String[]{null});}}); + () -> env.put("foo",null), + () -> env.put(null,"foo"), + () -> env.remove(null), + () -> { for (Map.Entry e : env.entrySet()) + e.setValue(null);}, + () -> Runtime.getRuntime().exec(new String[]{"foo"}, + new String[]{null})); } catch (Throwable t) { unexpected(t); } //---------------------------------------------------------------- @@ -1329,10 +1311,10 @@ public class Basic { try { final Map env = new ProcessBuilder().environment(); THROWS(ClassCastException.class, - new Fun(){void f(){ env.remove(TRUE);}}, - new Fun(){void f(){ env.keySet().remove(TRUE);}}, - new Fun(){void f(){ env.values().remove(TRUE);}}, - new Fun(){void f(){ env.entrySet().remove(TRUE);}}); + () -> env.remove(TRUE), + () -> env.keySet().remove(TRUE), + () -> env.values().remove(TRUE), + () -> env.entrySet().remove(TRUE)); } catch (Throwable t) { unexpected(t); } //---------------------------------------------------------------- @@ -1348,22 +1330,22 @@ public class Basic { // Nulls in environment queries are forbidden. //---------------------------------------------------------------- THROWS(NullPointerException.class, - new Fun(){void f(){ getenv(null);}}, - new Fun(){void f(){ env.get(null);}}, - new Fun(){void f(){ env.containsKey(null);}}, - new Fun(){void f(){ env.containsValue(null);}}, - new Fun(){void f(){ env.keySet().contains(null);}}, - new Fun(){void f(){ env.values().contains(null);}}); + () -> getenv(null), + () -> env.get(null), + () -> env.containsKey(null), + () -> env.containsValue(null), + () -> env.keySet().contains(null), + () -> env.values().contains(null)); //---------------------------------------------------------------- // Non-String types in environment queries are forbidden. //---------------------------------------------------------------- THROWS(ClassCastException.class, - new Fun(){void f(){ env.get(TRUE);}}, - new Fun(){void f(){ env.containsKey(TRUE);}}, - new Fun(){void f(){ env.containsValue(TRUE);}}, - new Fun(){void f(){ env.keySet().contains(TRUE);}}, - new Fun(){void f(){ env.values().contains(TRUE);}}); + () -> env.get(TRUE), + () -> env.containsKey(TRUE), + () -> env.containsValue(TRUE), + () -> env.keySet().contains(TRUE), + () -> env.values().contains(TRUE)); //---------------------------------------------------------------- // Illegal String values in environment queries are (grumble) OK @@ -1381,12 +1363,11 @@ public class Basic { final Set> entrySet = new ProcessBuilder().environment().entrySet(); THROWS(NullPointerException.class, - new Fun(){void f(){ entrySet.contains(null);}}); + () -> entrySet.contains(null)); THROWS(ClassCastException.class, - new Fun(){void f(){ entrySet.contains(TRUE);}}, - new Fun(){void f(){ - entrySet.contains( - new SimpleImmutableEntry(TRUE,""));}}); + () -> entrySet.contains(TRUE), + () -> entrySet.contains( + new SimpleImmutableEntry(TRUE,""))); check(! entrySet.contains (new SimpleImmutableEntry("", ""))); @@ -1856,8 +1837,7 @@ public class Basic { final ProcessBuilder pb = new ProcessBuilder(new String[]{"unliKely"}); pb.environment().put("PATH", "suBdiR"); - THROWS(IOException.class, - new Fun() {void f() throws Throwable {pb.start();}}); + THROWS(IOException.class, () -> pb.start()); } catch (Throwable t) { unexpected(t); } finally { new File("suBdiR/unliKely").delete(); @@ -1930,10 +1910,8 @@ public class Basic { equal(SIZE, p.getInputStream().available()); equal(SIZE, p.getErrorStream().available()); THROWS(IOException.class, - new Fun(){void f() throws IOException { - p.getOutputStream().write((byte) '!'); - p.getOutputStream().flush(); - }}); + () -> { p.getOutputStream().write((byte) '!'); + p.getOutputStream().flush();}); final byte[] bytes = new byte[SIZE + 1]; equal(SIZE, p.getInputStream().read(bytes)); @@ -1960,12 +1938,9 @@ public class Basic { InputStream[] streams = { p.getInputStream(), p.getErrorStream() }; for (final InputStream in : streams) { Fun[] ops = { - new Fun(){void f() throws IOException { - in.read(); }}, - new Fun(){void f() throws IOException { - in.read(bytes); }}, - new Fun(){void f() throws IOException { - in.available(); }} + () -> in.read(), + () -> in.read(bytes), + () -> in.available() }; for (Fun op : ops) { try { @@ -2169,21 +2144,17 @@ public class Basic { } catch (Throwable t) { unexpected(t); } THROWS(SecurityException.class, - new Fun() { void f() throws IOException { - policy.setPermissions(/* Nothing */); - System.getenv("foo");}}, - new Fun() { void f() throws IOException { - policy.setPermissions(/* Nothing */); - System.getenv();}}, - new Fun() { void f() throws IOException { - policy.setPermissions(/* Nothing */); - new ProcessBuilder("echo").start();}}, - new Fun() { void f() throws IOException { - policy.setPermissions(/* Nothing */); - Runtime.getRuntime().exec("echo");}}, - new Fun() { void f() throws IOException { - policy.setPermissions(new RuntimePermission("getenv.bar")); - System.getenv("foo");}}); + () -> { policy.setPermissions(/* Nothing */); + System.getenv("foo");}, + () -> { policy.setPermissions(/* Nothing */); + System.getenv();}, + () -> { policy.setPermissions(/* Nothing */); + new ProcessBuilder("echo").start();}, + () -> { policy.setPermissions(/* Nothing */); + Runtime.getRuntime().exec("echo");}, + () -> { policy.setPermissions( + new RuntimePermission("getenv.bar")); + System.getenv("foo");}); try { policy.setPermissions(new RuntimePermission("getenv.foo")); @@ -2200,18 +2171,16 @@ public class Basic { = new FilePermission("<>", "execute"); THROWS(SecurityException.class, - new Fun() { void f() throws IOException { - // environment permission by itself insufficient - policy.setPermissions(new RuntimePermission("getenv.*")); - ProcessBuilder pb = new ProcessBuilder("env"); - pb.environment().put("foo","bar"); - pb.start();}}, - new Fun() { void f() throws IOException { - // exec permission by itself insufficient - policy.setPermissions(execPermission); - ProcessBuilder pb = new ProcessBuilder("env"); - pb.environment().put("foo","bar"); - pb.start();}}); + () -> { // environment permission by itself insufficient + policy.setPermissions(new RuntimePermission("getenv.*")); + ProcessBuilder pb = new ProcessBuilder("env"); + pb.environment().put("foo","bar"); + pb.start();}, + () -> { // exec permission by itself insufficient + policy.setPermissions(execPermission); + ProcessBuilder pb = new ProcessBuilder("env"); + pb.environment().put("foo","bar"); + pb.start();}); try { // Both permissions? OK. @@ -2398,6 +2367,56 @@ public class Basic { p.destroy(); } catch (Throwable t) { unexpected(t); } + //---------------------------------------------------------------- + // Check that Process.waitFor(timeout, null) throws NPE. + //---------------------------------------------------------------- + try { + List childArgs = new ArrayList(javaChildArgs); + childArgs.add("sleep"); + final Process p = new ProcessBuilder(childArgs).start(); + THROWS(NullPointerException.class, + () -> p.waitFor(10L, null)); + THROWS(NullPointerException.class, + () -> p.waitFor(0L, null)); + THROWS(NullPointerException.class, + () -> p.waitFor(-1L, null)); + // Terminate process and recheck after it exits + p.destroy(); + p.waitFor(); + THROWS(NullPointerException.class, + () -> p.waitFor(10L, null)); + THROWS(NullPointerException.class, + () -> p.waitFor(0L, null)); + THROWS(NullPointerException.class, + () -> p.waitFor(-1L, null)); + } catch (Throwable t) { unexpected(t); } + + //---------------------------------------------------------------- + // Check that default implementation of Process.waitFor(timeout, null) throws NPE. + //---------------------------------------------------------------- + try { + List childArgs = new ArrayList(javaChildArgs); + childArgs.add("sleep"); + final Process proc = new ProcessBuilder(childArgs).start(); + final DelegatingProcess p = new DelegatingProcess(proc); + + THROWS(NullPointerException.class, + () -> p.waitFor(10L, null)); + THROWS(NullPointerException.class, + () -> p.waitFor(0L, null)); + THROWS(NullPointerException.class, + () -> p.waitFor(-1L, null)); + // Terminate process and recheck after it exits + p.destroy(); + p.waitFor(); + THROWS(NullPointerException.class, + () -> p.waitFor(10L, null)); + THROWS(NullPointerException.class, + () -> p.waitFor(0L, null)); + THROWS(NullPointerException.class, + () -> p.waitFor(-1L, null)); + } catch (Throwable t) { unexpected(t); } + //---------------------------------------------------------------- // Check the default implementation for // Process.waitFor(long, TimeUnit) @@ -2576,7 +2595,7 @@ public class Basic { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - private static abstract class Fun {abstract void f() throws Throwable;} + interface Fun {void f() throws Throwable;} static void THROWS(Class k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } diff --git a/test/java/lang/Runtime/loadLibrary/LoadLibraryTest.java b/test/java/lang/Runtime/loadLibrary/LoadLibraryTest.java deleted file mode 100644 index 62eac12e186aa3cacfc4f9308c8eedd3b0dcca21..0000000000000000000000000000000000000000 --- a/test/java/lang/Runtime/loadLibrary/LoadLibraryTest.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (c) 2018, Amazon and/or its affiliates. All rights reserved. - * Copyright (c) 2019, 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 - * @bug 8231584 - * @library /lib/testlibrary - * @run main/othervm LoadLibraryTest - */ - -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.nio.file.Path; -import java.net.MalformedURLException; -import java.net.URLClassLoader; -import java.net.URL; - -public class LoadLibraryTest { - static Thread thread1 = null; - static Thread thread2 = null; - - static volatile boolean thread1Ready = false; - - private static final String TEST_SRC = System.getProperty("test.src"); - private static final Path SRC_DIR = Paths.get(TEST_SRC, "src"); - private static final Path CLS_DIR = Paths.get("classes"); - - static TestClassLoader loader; - static void someLibLoad() { - try { -/* - FileSystems.getDefault(); - - // jdk/jdk: loads directly from Bootstrap Classloader (doesn't take lock on Runtime) - java.net.NetworkInterface.getNetworkInterfaces(); - - System.out.println(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA); -*/ - Class c = Class.forName("Target2", true, loader); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - static class TestClassLoader extends URLClassLoader { - boolean passed = false; - - public boolean passed() { - return passed; - } - - TestClassLoader() throws MalformedURLException { - super(new URL[] { new URL("file://" + CLS_DIR.toAbsolutePath().toString() + '/') }); - } - - public String findLibrary(String name) { - System.out.println("findLibrary " + name); - - if ("someLibrary".equals(name)) { - try { - synchronized(thread1) { - while(!thread1Ready) { - thread1.wait(); - } - thread1.notifyAll(); - } - - Thread.sleep(10000); - - System.out.println("Thread2 load"); - someLibLoad(); - - // no deadlock happened - passed = true; - } catch (Exception e) { - throw new RuntimeException(e); - } - return null; - } - - return super.findLibrary(name); - } - } - - - public static void main(String[] args) throws Exception { - loader = new TestClassLoader(); - - if (!CompilerUtils.compile(SRC_DIR, CLS_DIR)) { - throw new Exception("Can't compile"); - } - - thread1 = new Thread() { - public void run() { - try { - synchronized(this) { - thread1Ready = true; - thread1.notifyAll(); - thread1.wait(); - } - } catch(InterruptedException e) { - throw new RuntimeException(e); - } - - System.out.println("Thread1 load"); - someLibLoad(); - }; - }; - - thread2 = new Thread() { - public void run() { - try { - Class c = Class.forName("Target", true, loader); - System.out.println(c); - } catch (Exception e) { - throw new RuntimeException(e); - } - }; - }; - - thread1.setDaemon(true); - thread2.setDaemon(true); - - thread1.start(); - thread2.start(); - - thread1.join(); - thread2.join(); - - if (!loader.passed()) { - throw new RuntimeException("FAIL"); - } - } -} diff --git a/test/java/lang/SecurityManager/CheckPackageAccess.java b/test/java/lang/SecurityManager/CheckPackageAccess.java index 73a2d706830557e0c603e58d0c7788e5c6d0f345..3365ae6a072ffbbaf418144c6bb8dbb65f9186b6 100644 --- a/test/java/lang/SecurityManager/CheckPackageAccess.java +++ b/test/java/lang/SecurityManager/CheckPackageAccess.java @@ -86,6 +86,9 @@ public class CheckPackageAccess { "oracle.jrockit.jfr.", "org.jcp.xml.dsig.internal.", "jdk.internal.", + "jdk.jfr.events.", + "jdk.jfr.internal.", + "jdk.management.jfr.internal.", "jdk.nashorn.internal.", "jdk.nashorn.tools.", "jdk.xml.internal.", diff --git a/test/java/math/BigInteger/ModInvTime.java b/test/java/math/BigInteger/ModInvTime.java new file mode 100644 index 0000000000000000000000000000000000000000..84b4f927fb8a4a1eeeb20f05c1485efbb169ecec --- /dev/null +++ b/test/java/math/BigInteger/ModInvTime.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * 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 8225603 + * @summary Tests whether modInverse() completes in a reasonable time + * @run main/othervm ModInvTime + */ +import java.math.BigInteger; + +public class ModInvTime { + public static void main(String[] args) throws InterruptedException { + BigInteger prime = new BigInteger("39402006196394479212279040100143613805079739270465446667946905279627659399113263569398956308152294913554433653942643"); + BigInteger s = new BigInteger("9552729729729327851382626410162104591956625415831952158766936536163093322096473638446154604799898109762512409920799"); + System.out.format("int length: %d, modulus length: %d%n", + s.bitLength(), prime.bitLength()); + + System.out.println("Computing modular inverse ..."); + BigInteger mi = s.modInverse(prime); + System.out.format("Modular inverse: %s%n", mi); + check(s, prime, mi); + + BigInteger ns = s.negate(); + BigInteger nmi = ns.modInverse(prime); + System.out.format("Modular inverse of negation: %s%n", nmi); + check(ns, prime, nmi); + } + + public static void check(BigInteger val, BigInteger mod, BigInteger inv) { + BigInteger r = inv.multiply(val).remainder(mod); + if (r.signum() == -1) + r = r.add(mod); + if (!r.equals(BigInteger.ONE)) + throw new RuntimeException("Numerically incorrect modular inverse"); + } +} diff --git a/test/java/net/MulticastSocket/TestInterfaces.java b/test/java/net/MulticastSocket/TestInterfaces.java index cb8c6b00f0fc2e77ebf5d06ebb0d5eccefe799e4..1d87d8d062f67bd9a2dd8b190136f55e1af1e107 100644 --- a/test/java/net/MulticastSocket/TestInterfaces.java +++ b/test/java/net/MulticastSocket/TestInterfaces.java @@ -87,8 +87,9 @@ public class TestInterfaces { continue; } - // JDK-8022963, Skip (Windows) Teredo Tunneling seudo-Interface - if (isWindows && ni.getDisplayName().contains("Teredo")) + // JDK-8022963, Skip (Windows) Teredo Tunneling Pseudo-Interface + String dName = ni.getDisplayName(); + if (isWindows && dName != null && dName.contains("Teredo")) continue; NetworkInterface curr = soc.getNetworkInterface(); diff --git a/test/java/net/NetworkInterface/Equals.java b/test/java/net/NetworkInterface/Equals.java index 13dc5fc48e01aa71870ad9c4441d495aff45bbdb..8cc81f825a0d85dbb83b7ae5945577dcfee8014b 100644 --- a/test/java/net/NetworkInterface/Equals.java +++ b/test/java/net/NetworkInterface/Equals.java @@ -62,8 +62,9 @@ public class Equals { while (nifs2.hasMoreElements()) { NetworkInterface ni = nifs2.nextElement(); - // JDK-8022963, Skip (Windows)Teredo Tunneling seudo-Interface - if (isWindows && ni.getDisplayName().contains("Teredo")) + // JDK-8022963, Skip (Windows)Teredo Tunneling Pseudo-Interface + String dName = ni.getDisplayName(); + if (isWindows && dName != null && dName.contains("Teredo")) continue; NetworkInterface niOrig = nicMap.get(ni.getName()); diff --git a/test/java/net/NetworkInterface/IndexTest.java b/test/java/net/NetworkInterface/IndexTest.java index 58ebb1690f1e2d296b46e88e48b05206c379248f..a1c65aa920c11c814b414865d6819864fc67d0a5 100644 --- a/test/java/net/NetworkInterface/IndexTest.java +++ b/test/java/net/NetworkInterface/IndexTest.java @@ -40,8 +40,9 @@ public class IndexTest { NetworkInterface nif; while (netifs.hasMoreElements()) { nif = netifs.nextElement(); - // JDK-8022212, Skip (Windows) Teredo Tunneling seudo-Interface - if (nif.getDisplayName().contains("Teredo") && isWindows) + // JDK-8022212, Skip (Windows) Teredo Tunneling Pseudo-Interface + String dName = nif.getDisplayName(); + if (isWindows && dName != null && dName.contains("Teredo")) continue; int index = nif.getIndex(); if (index >= 0) { diff --git a/test/java/nio/channels/AsyncCloseAndInterrupt.java b/test/java/nio/channels/AsyncCloseAndInterrupt.java index 4172efe0dafd606c2ed60215bcb730d6ebfe2f45..d897fa0ea5570961092a8b4ebaf3a44b265d3c09 100644 --- a/test/java/nio/channels/AsyncCloseAndInterrupt.java +++ b/test/java/nio/channels/AsyncCloseAndInterrupt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -23,6 +23,7 @@ /* @test * @bug 4460583 4470470 4840199 6419424 6710579 6596323 6824135 6395224 7142919 + * 8151582 * @run main/othervm AsyncCloseAndInterrupt * @summary Comprehensive test of asynchronous closing and interruption * @author Mark Reinhold @@ -89,7 +90,7 @@ public class AsyncCloseAndInterrupt { private static void initRefuser() throws IOException { refuser = ServerSocketChannel.open(); - refuser.socket().bind(wildcardAddress); + refuser.bind(wildcardAddress, 1); // use minimum backlog } // Dead pipe source and sink @@ -349,7 +350,7 @@ public class AsyncCloseAndInterrupt { static final Op CONNECT = new Op("connect") { void setup() { - waitPump("connect wait for pumping refuser ..."); + waitPump("connect waiting for pumping refuser ..."); } void doIO(InterruptibleChannel ich) throws IOException { SocketChannel sc = (SocketChannel)ich; @@ -361,7 +362,7 @@ public class AsyncCloseAndInterrupt { static final Op FINISH_CONNECT = new Op("finishConnect") { void setup() { - waitPump("finishConnect wait for pumping refuser ..."); + waitPump("finishConnect waiting for pumping refuser ..."); } void doIO(InterruptibleChannel ich) throws IOException { SocketChannel sc = (SocketChannel)ich; @@ -498,12 +499,11 @@ public class AsyncCloseAndInterrupt { private static volatile boolean pumpReady = false; private static void waitPump(String msg){ - pumpReady = false; log.println(msg); - while (!pumpReady){ sleep(200); } + log.println(msg + " done"); } // Create a pump thread dedicated to saturate refuser's connection backlog @@ -520,28 +520,34 @@ public class AsyncCloseAndInterrupt { // Saturate the refuser's connection backlog so that further connection // attempts will be blocked + pumpReady = false; while (!pumpDone) { SocketChannel sc = SocketChannel.open(); sc.configureBlocking(false); boolean connected = sc.connect(refuser.socket().getLocalSocketAddress()); // Assume that the connection backlog is saturated if a - // client cannot connect to the refuser within 50 miliseconds + // client cannot connect to the refuser within 50 milliseconds long start = System.currentTimeMillis(); - while (!connected && (System.currentTimeMillis() - start < 50)) { + while (!pumpReady && !connected + && (System.currentTimeMillis() - start < 50)) { connected = sc.finishConnect(); } if (connected) { // Retain so that finalizer doesn't close refuserClients.add(sc); - pumpReady = false; } else { sc.close(); pumpReady = true; } } + for (SocketChannel sc : refuserClients) { + sc.close(); + } + refuser.close(); + log.println("Stop pumping refuser ..."); return refuserClients.size(); } @@ -565,8 +571,6 @@ public class AsyncCloseAndInterrupt { sleep(50); } while (!t.ready); - sleep(100); - switch (test) { case TEST_INTR: diff --git a/test/java/nio/channels/Selector/StackOverflowTest.java b/test/java/nio/channels/Selector/StackOverflowTest.java new file mode 100644 index 0000000000000000000000000000000000000000..9ca0a67b5fb5e31757c477800760c36e75b8c4e6 --- /dev/null +++ b/test/java/nio/channels/Selector/StackOverflowTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2019, Red Hat, Inc. and/or its affiliates. + * 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 8216472 + * @summary native call in WindowsSelectorImpl.SubSelector.poll can use + * more stack space than available in a shadow zone, this can cause + * a crash if selector is called from a deep recursive java call + * @requires (os.family == "windows") + */ + +import java.nio.channels.Selector; + +public class StackOverflowTest { + + public static void main(String[] args) throws Exception { + try (Selector sel = Selector.open()) { + recursiveSelect(sel); + } catch (StackOverflowError e) { + // ignore SOE from java calls + } + } + + static void recursiveSelect(Selector sel) throws Exception { + sel.selectNow(); + recursiveSelect(sel); + } +} diff --git a/test/java/nio/charset/StandardCharsets/Standard.java b/test/java/nio/charset/StandardCharsets/Standard.java index 66d1b112a1b21fabe52a291026c4e77fdeeafe60..c570a9558577d543a683e2664a5249814ba05ca3 100644 --- a/test/java/nio/charset/StandardCharsets/Standard.java +++ b/test/java/nio/charset/StandardCharsets/Standard.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -99,13 +99,6 @@ public class Standard { System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new Exception("Some tests failed"); } - private static abstract class Fun {abstract void f() throws Throwable;} - private static void THROWS(Class k, Fun... fs) { - for (Fun f : fs) - try { f.f(); fail("Expected " + k.getName() + " not thrown"); } - catch (Throwable t) { - if (k.isAssignableFrom(t.getClass())) pass(); - else unexpected(t);}} static byte[] serializedForm(Object obj) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); diff --git a/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/TCPEndpointReadBug.java b/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/TCPEndpointReadBug.java new file mode 100644 index 0000000000000000000000000000000000000000..9c29aad9548497d59f2093e88ac24ef4dc5868d3 --- /dev/null +++ b/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/TCPEndpointReadBug.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * 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.io.Serializable; +import java.io.ObjectInputStream; +import java.net.Socket; +import java.rmi.Remote; +import java.rmi.RemoteException; +import java.rmi.server.RMIClientSocketFactory; +import java.rmi.server.RMISocketFactory; +import java.rmi.server.UnicastRemoteObject; + +/* @test + * @bug 8237368 + * @summary Allow custom socket factory to be null in TCPEndpoint. + * @run main/othervm TCPEndpointReadBug + */ +public class TCPEndpointReadBug { + + public static void main(String[] args) throws Exception { + final I implC = new C(); + final I remoteC = (I)UnicastRemoteObject.exportObject( + implC, 0, new CSF(), RMISocketFactory.getDefaultSocketFactory()); + + // Pass a remote object with a custom socket factory as an argument + remoteC.echo(remoteC); + + // Pass nothing and get an object with a custom socket factory in return + remoteC.echo(null); + } + + interface I extends Remote { + I echo(I intf) throws RemoteException; + } + + static class C implements I { + @Override + public I echo(I intf) { + try { + return (I)UnicastRemoteObject + .exportObject(new C(),0, new CSF(), RMISocketFactory.getDefaultSocketFactory()); + } catch (RemoteException e) { + e.printStackTrace(); + } + return null; + } + } + + /** + * A configurable socket factory in which for test purposes supplies null. + */ + static class CSF implements Serializable, RMIClientSocketFactory { + private static final long serialVersionUID = 1; + + @Override + public boolean equals(Object object) { + return object instanceof CSF; + } + + @Override + public int hashCode() { + return 424242; + } + + @Override + public Socket createSocket(String host, int port) + throws IOException { + + final RMIClientSocketFactory defaultFactory = + RMISocketFactory.getDefaultSocketFactory(); + return defaultFactory.createSocket(host, port); + } + + /** + * Use writeReplace to use a different client socket factory. In the + * problematic case, the replacement is null. + */ + private Object writeReplace() { + return null; + } + + /** + * Instances of this class should never be deserialized because they + * are always replaced during serialization. + */ + @SuppressWarnings("unused") + private void readObject(ObjectInputStream in) { + throw new AssertionError(); + } + } +} diff --git a/test/java/rmi/transport/runtimeThreadInheritanceLeak/RuntimeThreadInheritanceLeak.java b/test/java/rmi/transport/runtimeThreadInheritanceLeak/RuntimeThreadInheritanceLeak.java index 05be7b61f6fb2f18a52260f480520d96797f8fc1..dd39b6a629e85e448f27edf1cefac350a12a3a23 100644 --- a/test/java/rmi/transport/runtimeThreadInheritanceLeak/RuntimeThreadInheritanceLeak.java +++ b/test/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 class RuntimeThreadInheritanceLeak implements Remote { * 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/test/java/security/KeyPairGenerator/FinalizeHalf.java b/test/java/security/KeyPairGenerator/FinalizeHalf.java index a2a1eb36194f9c003e24e219f4a51730fb57cfe2..4a8fa1e7adbe7a43c74857ceac25d8db921599bb 100644 --- a/test/java/security/KeyPairGenerator/FinalizeHalf.java +++ b/test/java/security/KeyPairGenerator/FinalizeHalf.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. * 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 8163896 + * @bug 8163896 8223003 * @summary Finalizing one key of a KeyPair invalidates the other key */ diff --git a/test/java/security/Signature/Offsets.java b/test/java/security/Signature/Offsets.java index 1db510dd6c41d51eef559fc520b87f71b892aaa4..9d24084250a3270fdb090ba3a2ba4adb41d5fa68 100644 --- a/test/java/security/Signature/Offsets.java +++ b/test/java/security/Signature/Offsets.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. * 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,20 +21,13 @@ * questions. */ -import java.security.InvalidKeyException; -import java.security.KeyPair; -import java.security.KeyPairGenerator; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.PrivateKey; -import java.security.PublicKey; -import java.security.Signature; -import java.security.SignatureException; +import java.security.*; +import java.security.spec.*; import jdk.testlibrary.RandomFactory; /* * @test - * @bug 8050374 8181048 + * @bug 8050374 8181048 8146293 * @key randomness * @summary This test validates signature verification * Signature.verify(byte[], int, int). The test uses RandomFactory to @@ -46,6 +39,12 @@ import jdk.testlibrary.RandomFactory; * @run main Offsets SUN SHA1withDSA * @run main Offsets SUN SHA224withDSA * @run main Offsets SUN SHA256withDSA + * @run main Offsets SunRsaSign SHA224withRSA + * @run main Offsets SunRsaSign SHA256withRSA + * @run main Offsets SunRsaSign SHA384withRSA + * @run main Offsets SunRsaSign SHA512withRSA + * @run main Offsets SunRsaSign SHA512/224withRSA + * @run main Offsets SunRsaSign SHA512/256withRSA */ public class Offsets { @@ -58,11 +57,13 @@ public class Offsets { private Offsets(Signature signature, PublicKey pubkey, PrivateKey privkey, int size, byte[] cleartext) throws InvalidKeyException, SignatureException { + System.out.println("Testing signature " + signature.getAlgorithm()); this.pubkey = pubkey; this.signature = signature; this.size = size; this.cleartext = cleartext; + String sigAlg = signature.getAlgorithm(); signature.initSign(privkey); signature.update(cleartext, 0, size); signed = signature.sign(); @@ -85,7 +86,7 @@ public class Offsets { boolean verifySignature(byte[] sigData, int sigOffset, int sigLength, int updateOffset, int updateLength) - throws InvalidKeyException, SignatureException { + throws InvalidKeyException, SignatureException { signature.initVerify(pubkey); signature.update(cleartext, updateOffset, updateLength); return signature.verify(sigData, sigOffset, sigLength); diff --git a/test/java/security/Signature/SignatureGetInstance.java b/test/java/security/Signature/SignatureGetInstance.java new file mode 100644 index 0000000000000000000000000000000000000000..1c1d796af631a558cef69db05f0b1ea5934b7ff3 --- /dev/null +++ b/test/java/security/Signature/SignatureGetInstance.java @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * 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 + * @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.0d, "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/test/java/security/SignedObject/Chain.java b/test/java/security/SignedObject/Chain.java index 3c9bad3dd18cb8d5b4ff7a27ccd740054058f182..ff922ba8adec70bc899c225d6ff930b4242561ed 100644 --- a/test/java/security/SignedObject/Chain.java +++ b/test/java/security/SignedObject/Chain.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. * 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,12 +28,18 @@ import java.security.KeyPair; import java.security.NoSuchProviderException; import java.security.PrivateKey; import java.security.PublicKey; -import java.util.Arrays; +import java.security.spec.*; +import java.util.*; +import jdk.test.lib.SigTestUtil; +import static jdk.test.lib.SigTestUtil.SignatureType; /* * @test - * @bug 8050374 8181048 + * @bug 8050374 8181048 8146293 * @summary Verify a chain of signed objects + * @library /lib + * @build jdk.test.lib.SigTestUtil + * @run main Chain */ public class Chain { @@ -77,6 +83,8 @@ public class Chain { SHA256withRSA("SHA256withRSA"), SHA384withRSA("SHA384withRSA"), SHA512withRSA("SHA512withRSA"), + SHA512_224withRSA("SHA512/224withRSA"), + SHA512_256withRSA("SHA512/256withRSA"), SHA1withECDSA("SHA1withECDSA"), SHA256withECDSA("SHA256withECDSA"), @@ -84,7 +92,9 @@ public class Chain { SHA384withECDSA("SHA384withECDSA"), SHA512withECDSA("SHA512withECDSA"), - MD5andSHA1withRSA("MD5andSHA1withRSA"); + MD5andSHA1withRSA("MD5andSHA1withRSA"), + + RSASSA_PSS("RSASSA-PSS"); final String name; @@ -98,16 +108,44 @@ public class Chain { final KeyAlg keyAlg; final SigAlg sigAlg; final int keySize; + final AlgorithmParameterSpec sigParams; Test(SigAlg sigAlg, KeyAlg keyAlg, Provider provider) { - this(sigAlg, keyAlg, provider, -1); + this(sigAlg, keyAlg, provider, -1, null); } Test(SigAlg sigAlg, KeyAlg keyAlg, Provider provider, int keySize) { + this(sigAlg, keyAlg, provider, keySize, null); + } + + Test(SigAlg sigAlg, KeyAlg keyAlg, Provider provider, int keySize, + AlgorithmParameterSpec sigParams) { this.provider = provider; this.keyAlg = keyAlg; this.sigAlg = sigAlg; this.keySize = keySize; + this.sigParams = sigParams; + } + + private static String formatParams(AlgorithmParameterSpec aps) { + if (aps == null) return "null"; + if (aps instanceof PSSParameterSpec) { + PSSParameterSpec p = (PSSParameterSpec) aps; + return String.format("PSSParameterSpec (%s, %s, %s, %s)", + p.getDigestAlgorithm(), formatParams(p.getMGFParameters()), + p.getSaltLength(), p.getTrailerField()); + } else if (aps instanceof MGF1ParameterSpec) { + return "MGF1" + + ((MGF1ParameterSpec)aps).getDigestAlgorithm(); + } else { + return aps.toString(); + } + } + + public String toString() { + return String.format("Test: provider = %s, signature alg = %s, " + + " w/ %s, key alg = %s", provider, sigAlg, + formatParams(sigParams), keyAlg); } } @@ -126,17 +164,29 @@ public class Chain { public static void main(String argv[]) { boolean result = Arrays.stream(tests).allMatch((test) -> runTest(test)); - if(result) { + result &= runTestPSS(2048); + if (result) { System.out.println("All tests passed"); } else { throw new RuntimeException("Some tests failed"); } } + private static boolean runTestPSS(int keysize) { + boolean result = true; + SigAlg pss = SigAlg.RSASSA_PSS; + Iterator mdAlgs = SigTestUtil.getDigestAlgorithms + (SignatureType.RSASSA_PSS, keysize).iterator(); + while (mdAlgs.hasNext()) { + result &= runTest(new Test(pss, KeyAlg.RSA, Provider.SunRsaSign, + keysize, SigTestUtil.generateDefaultParameter + (SignatureType.RSASSA_PSS, mdAlgs.next()))); + } + return result; + } + static boolean runTest(Test test) { - System.out.format("Test: provider = %s, signature algorithm = %s, " - + "key algorithm = %s\n", - test.provider, test.sigAlg, test.keyAlg); + System.out.println(test); try { // Generate all private/public key pairs PrivateKey[] privKeys = new PrivateKey[N]; @@ -153,6 +203,10 @@ public class Chain { signature = Signature.getInstance(test.sigAlg.name); kpg = KeyPairGenerator.getInstance(test.keyAlg.name); } + if (test.sigParams != null) { + signature.setParameter(test.sigParams); + } + for (int j=0; j < N; j++) { if (test.keySize != -1) { kpg.initialize(test.keySize); @@ -187,7 +241,6 @@ public class Chain { System.out.println("Failed: verification failed, n = " + n); return false; } - if (object.verify(anotherPubKeys[n], signature)) { System.out.println("Failed: verification should not " + "succeed with wrong public key, n = " + n); diff --git a/test/java/security/cert/X509CRL/VerifyDefault.java b/test/java/security/cert/X509CRL/VerifyDefault.java new file mode 100644 index 0000000000000000000000000000000000000000..c20f73bc4b122d51dab33ad510849e9ff61c337f --- /dev/null +++ b/test/java/security/cert/X509CRL/VerifyDefault.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * 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 8175029 + * @library ../../testlibrary + * @summary check that default implementation of + * X509CRL.verify(PublicKey, Provider) works on custom X509CRL impl. + */ + +import java.math.BigInteger; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.Principal; +import java.security.Provider; +import java.security.PublicKey; +import java.security.SignatureException; +import java.security.cert.Certificate; +import java.security.cert.CRLException; +import java.security.cert.X509Certificate; +import java.security.cert.X509CRL; +import java.security.cert.X509CRLEntry; +import java.util.Date; +import java.util.Set; + +public class VerifyDefault { + private static final String TEST_CRL = + "-----BEGIN X509 CRL-----\n" + + "MIIBGzCBhQIBATANBgkqhkiG9w0BAQQFADAfMQswCQYDVQQGEwJVUzEQMA4GA1UE\n" + + "ChMHRXhhbXBsZRcNMDkwNDI3MDIzODA0WhcNMjgwNjI2MDIzODA0WjAiMCACAQUX\n" + + "DTA5MDQyNzAyMzgwMFowDDAKBgNVHRUEAwoBBKAOMAwwCgYDVR0UBAMCAQIwDQYJ\n" + + "KoZIhvcNAQEEBQADgYEAoarfzXEtw3ZDi4f9U8eSvRIipHSyxOrJC7HR/hM5VhmY\n" + + "CErChny6x9lBVg9s57tfD/P9PSzBLusCcHwHMAbMOEcTltVVKUWZnnbumpywlYyg\n" + + "oKLrE9+yCOkYUOpiRlz43/3vkEL5hjIKMcDSZnPKBZi1h16Yj2hPe9GMibNip54=\n" + + "-----END X509 CRL-----"; + + private static final String TEST_CERT = + "-----BEGIN CERTIFICATE-----\n" + + "MIICKzCCAZSgAwIBAgIBAjANBgkqhkiG9w0BAQQFADAfMQswCQYDVQQGEwJVUzEQ\n" + + "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA0MjcwMjI0MzNaFw0yOTAxMTIwMjI0MzNa\n" + + "MB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMIGfMA0GCSqGSIb3DQEB\n" + + "AQUAA4GNADCBiQKBgQDMJeBMBybHykI/YpwUJ4O9euqDSLb1kpWpceBS8TVqvgBC\n" + + "SgUJWtFZL0i6bdvF6mMdlbuBkGzhXqHiVAi96/zRLbUC9F8SMEJ6MuD+YhQ0ZFTQ\n" + + "atKy8zf8O9XzztelLJ26Gqb7QPV133WY3haAqHtCXOhEKkCN16NOYNC37DTaJwID\n" + + "AQABo3cwdTAdBgNVHQ4EFgQULXSWzXzUOIpOJpzbSCpW42IJUugwRwYDVR0jBEAw\n" + + "PoAUgiXdIaZeT3QA/SGUvh854OJVyxuhI6QhMB8xCzAJBgNVBAYTAlVTMRAwDgYD\n" + + "VQQKEwdFeGFtcGxlggEAMAsGA1UdDwQEAwIBAjANBgkqhkiG9w0BAQQFAAOBgQAY\n" + + "eMnf5AHSNlyUlzXk8o2S0h4gCuvKX6C3kFfKuZcWvFAbx4yQOWLS2s15/nzR4+AP\n" + + "FGX3lgJjROyAh7fGedTQK+NFWwkM2ag1g3hXktnlnT1qHohi0w31nVBJxXEDO/Ck\n" + + "uJTpJGt8XxxbFaw5v7cHy7XuTAeU/sekvjEiNHW00Q==\n" + + "-----END CERTIFICATE-----"; + + private static class TestX509CRL extends X509CRL { + private final X509CRL crl; + TestX509CRL(X509CRL crl) { + this.crl = crl; + } + public Set getCriticalExtensionOIDs() { + return crl.getCriticalExtensionOIDs(); + } + public byte[] getExtensionValue(String oid) { + return crl.getExtensionValue(oid); + } + public Set getNonCriticalExtensionOIDs() { + return crl.getNonCriticalExtensionOIDs(); + } + public boolean hasUnsupportedCriticalExtension() { + return crl.hasUnsupportedCriticalExtension(); + } + public Set getRevokedCertificates() { + return crl.getRevokedCertificates(); + } + public X509CRLEntry getRevokedCertificate(BigInteger serialNumber) { + return crl.getRevokedCertificate(serialNumber); + } + public boolean isRevoked(Certificate cert) { + return crl.isRevoked(cert); + } + public Date getNextUpdate() { return crl.getNextUpdate(); } + public Date getThisUpdate() { return crl.getThisUpdate(); } + public int getVersion() { return crl.getVersion(); } + public Principal getIssuerDN() { return crl.getIssuerDN(); } + public byte[] getTBSCertList() throws CRLException { + return crl.getTBSCertList(); + } + public byte[] getSignature() { return crl.getSignature(); } + public String getSigAlgName() { return crl.getSigAlgName(); } + public String getSigAlgOID() { return crl.getSigAlgOID(); } + public byte[] getSigAlgParams() { return crl.getSigAlgParams(); } + public byte[] getEncoded() throws CRLException { + return crl.getEncoded(); + } + public void verify(PublicKey key) throws CRLException, + InvalidKeyException, NoSuchAlgorithmException, + NoSuchProviderException, SignatureException { + crl.verify(key); + } + public void verify(PublicKey key, String sigProvider) throws + CRLException, InvalidKeyException, NoSuchAlgorithmException, + NoSuchProviderException, SignatureException { + crl.verify(key, sigProvider); + } + public String toString() { return crl.toString(); } + } + + public static void main(String[] args) throws Exception { + X509Certificate cert = CertUtils.getCertFromString(TEST_CERT); + X509CRL crl = CertUtils.getCRLFromString(TEST_CRL); + new TestX509CRL(crl).verify(cert.getPublicKey(), (Provider)null); + } +} diff --git a/test/java/security/cert/X509Certificate/VerifyDefault.java b/test/java/security/cert/X509Certificate/VerifyDefault.java new file mode 100644 index 0000000000000000000000000000000000000000..6a46a7d51b3ab0e051d8366a22f0d4eb8b31c14b --- /dev/null +++ b/test/java/security/cert/X509Certificate/VerifyDefault.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * 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 8175029 + * @library ../../testlibrary + * @summary check that default implementation of + * X509Certificate.verify(PublicKey, Provider) works on custom + * X509Certificate impl. + */ + +import java.math.BigInteger; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.Principal; +import java.security.Provider; +import java.security.PublicKey; +import java.security.SignatureException; +import java.security.cert.CertificateEncodingException; +import java.security.cert.CertificateException; +import java.security.cert.CertificateExpiredException; +import java.security.cert.CertificateNotYetValidException; +import java.security.cert.X509Certificate; +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Set; + +public class VerifyDefault { + private static final String TEST_CERT = + "-----BEGIN CERTIFICATE-----\n" + + "MIICvTCCAaWgAwIBAgIEGYqL9TANBgkqhkiG9w0BAQsFADAPMQ0wCwYDVQQDEwRT\n" + + "ZWxmMB4XDTE3MDMyODE2NDcyNloXDTE3MDYyNjE2NDcyNlowDzENMAsGA1UEAxME\n" + + "U2VsZjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL1pfSJljFVSABOL\n" + + "tJbIVPEkz1+2AFgzY1hqwE0EH80lvhOEkiPPYCKwBE5VTZdyFfwFjpyx7eEeJMNT\n" + + "o7cixfmkQaiXHr/S1AS4BRTqLG/zgLzoJpVbzi45rnVEZc0oTm11KG3uUxkZTRr3\n" + + "5ORbYyZpkscKwHL2M0J/1GmnA1hmhQdwUQyIKxg4eKQwyE+/TdbFlCWVNnOlb+91\n" + + "eXvS11nIJ1oaBgn7u4qihuVmFmngLMxExnLYKV6AwdkwFD6pERObclRD9vAl5eUk\n" + + "+sM6zQYwfLdyC2i8e+ETBeOg1ijptM4KT5Uaq89zxjLR0DPH4S+aILp3gYHGrW5r\n" + + "eMxZAEMCAwEAAaMhMB8wHQYDVR0OBBYEFOME39JtbjzQaK3ufpKo/Pl4sZ8XMA0G\n" + + "CSqGSIb3DQEBCwUAA4IBAQCDcw0+Sf0yeVROVlb2/VV3oIblHkGQheXeIurW64k7\n" + + "tEzHtx9i8dnj5lzTZNH6hU4GRlyULbSDzjcM3P2XFRsM+0a/kEJZVqnLz5ji//7/\n" + + "ZXaRX0TiE2IfFOTGbO6LusO3yR4tOER/WHllz2H21C2SbW3+92Ou28glTZa42AAZ\n" + + "mUj9j+p6mZqD4/tUBqAEqqQoMIhw9CNjc46STNayBjt/0/+I2pfy6LagrMbjBzZ0\n" + + "A5kXg9WjnywGk8XFr/3RZz8DrUmCYs2qCYLCHQHsuCE6gCuf9wKhKyD51MFXXRr0\n" + + "cyG6LYQjrreMHYk4ZfN2NPC6lGjWxB5mIbV/DuikCnYu\n" + + "-----END CERTIFICATE-----"; + + private static class TestX509Certificate extends X509Certificate { + private final X509Certificate cert; + TestX509Certificate(X509Certificate cert) { + this.cert = cert; + } + public Set getCriticalExtensionOIDs() { + return cert.getCriticalExtensionOIDs(); + } + public byte[] getExtensionValue(String oid) { + return cert.getExtensionValue(oid); + } + public Set getNonCriticalExtensionOIDs() { + return cert.getNonCriticalExtensionOIDs(); + } + public boolean hasUnsupportedCriticalExtension() { + return cert.hasUnsupportedCriticalExtension(); + } + public void checkValidity() throws CertificateExpiredException, + CertificateNotYetValidException { + cert.checkValidity(); + } + public void checkValidity(Date date) throws CertificateExpiredException, + CertificateNotYetValidException { + cert.checkValidity(date); + } + public int getVersion() { return cert.getVersion(); } + public BigInteger getSerialNumber() { return cert.getSerialNumber(); } + public Principal getIssuerDN() { return cert.getIssuerDN(); } + public Principal getSubjectDN() { return cert.getSubjectDN(); } + public Date getNotBefore() { return cert.getNotBefore(); } + public Date getNotAfter() { return cert.getNotAfter(); } + public byte[] getTBSCertificate() throws CertificateEncodingException { + return cert.getTBSCertificate(); + } + public byte[] getSignature() { return cert.getSignature(); } + public String getSigAlgName() { return cert.getSigAlgName(); } + public String getSigAlgOID() { return cert.getSigAlgOID(); } + public byte[] getSigAlgParams() { return cert.getSigAlgParams(); } + public boolean[] getIssuerUniqueID() { + return cert.getIssuerUniqueID(); + } + public boolean[] getSubjectUniqueID() { + return cert.getSubjectUniqueID(); + } + public boolean[] getKeyUsage() { return cert.getKeyUsage(); } + public int getBasicConstraints() { return cert.getBasicConstraints(); } + public byte[] getEncoded() throws CertificateEncodingException { + return cert.getEncoded(); + } + public void verify(PublicKey key) throws CertificateException, + InvalidKeyException, NoSuchAlgorithmException, + NoSuchProviderException, SignatureException { + cert.verify(key); + } + public void verify(PublicKey key, String sigProvider) throws + CertificateException, InvalidKeyException, NoSuchAlgorithmException, + NoSuchProviderException, SignatureException { + cert.verify(key, sigProvider); + } + public PublicKey getPublicKey() { return cert.getPublicKey(); } + public String toString() { return cert.toString(); } + } + + public static void main(String[] args) throws Exception { + X509Certificate cert = CertUtils.getCertFromString(TEST_CERT); + new TestX509Certificate(cert).verify(cert.getPublicKey(), + (Provider)null); + } +} diff --git a/test/java/security/cert/X509Certificate/X509BadCertificate.java b/test/java/security/cert/X509Certificate/X509BadCertificate.java new file mode 100644 index 0000000000000000000000000000000000000000..c2b4a8832ccfd72225e2d2ecca61fe4b3ccfcaad --- /dev/null +++ b/test/java/security/cert/X509Certificate/X509BadCertificate.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 8028431 8028591 + * @summary Make sure that proper CertificateException is thrown + * when loading bad x509 certificate + * @author Artem Smotrakov + */ + +import java.io.File; +import java.io.FileInputStream; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; +import java.security.cert.CertificateException; + +public class X509BadCertificate { + + public static void main(String[] args) throws Exception { + test("bad-cert-1.pem"); + test("bad-cert-2.pem"); + } + + /** + * Parse X509 certificates. + */ + static void test(String filename) throws Exception { + try { + System.out.println("Parse file " + filename); + File f = new File(System.getProperty("test.src", "."), filename); + try (FileInputStream fis = new FileInputStream(f)) { + CertificateFactory cf = CertificateFactory.getInstance("X509"); + X509Certificate cert = (X509Certificate) + cf.generateCertificate(fis); + } + throw new Exception("Test failed: " + + "expected CertificateParsingException was not thrown"); + } catch (CertificateException e) { + System.out.println("Test passed: expected exception was thrown: " + + e.toString()); + } + } +} diff --git a/test/java/security/cert/X509Certificate/bad-cert-1.pem b/test/java/security/cert/X509Certificate/bad-cert-1.pem new file mode 100644 index 0000000000000000000000000000000000000000..0e6c355d0fd78052ff67e91de1de1cdac13ecc66 --- /dev/null +++ b/test/java/security/cert/X509Certificate/bad-cert-1.pem @@ -0,0 +1,21 @@ +-----BEGIN CERTIFICATE----- +MIIDZzCCAk+gAwIBAgIJAJYB3qu9C2kiMA0GCSqGSIb3DQEBBQUAMEoxDTALBgNV +BAMMBFRlc3QxDTALBgNVBAsMBEphdmExDzANBgNVBAoMBk9yYWNsZTEMMAoGA1UE +BwwDU1BCMQswCQYDVQQGEwJSVTAeFw0xMzEyMjMwNzA4MDhaFw0yMzEyMjEwNzA4 +MDhaMEoxDTALBgNVBAMMBFRlc3QxDTALBgNVBAsMBEphdmExDzANBgNVBAoMBk9y +YWNsZTEMMAoGA1UMBwwDU1BCMQswCQYDVQQGEwJSVTCCASIwDQYJKoZIhvcNAQEB +BQADggEPADCCAQoCggEBAOqiCN4gFxehl547Q7/VNGbGApr+wszLdanHPucAH6Wf +LtcRhKNUSqtBAQxEpFrTpMNEqm2GElAjiPa6m48qIjLVSvOb/9w3G/yXB8zyZbIm +/Nfp2sT4OEaa1JSEZSpolhS4FfqYzjGQp5cn4Xn4zKjDgiceHgfLls5x2dRydQZO +Yf91qSIioZxVHUtlo8yztkieiSaqPWt3nJ4PIwhFbsu1HVmWaYZD+nBYCKgVHqrS +cueO98Ca4Doz73O27X1dVbQBdLS0JI7qVAG8LD388iPL8qbsOkgWPzmEQ+kLRKO4 +g7RpuwlXuwaMSh95NWaxlu4Ob6GRJQmpconYoe13+7ECAwEAAaNQME4wHQYDVR0O +BBYEFIG8TPobXcbNbDi+zKudd9whpxoNMB8GA1UdIwQYMBaAFIG8TPobXcbNbDi+ +zKudd9whpxoNMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFRQADggEBAAynN+e7 +h+ufT5SBKN/gBuJAnF1mKIPESiipuv5KoYUGZOY8ShgYLcwY+qnbuHYFUlvq6Zns +K4/e+x/16h32vD7dEPkNvukbvER4YJQQiN6osDfXpTPzixYftWdmtX0u8xQfwb/g +R8DS7bazz99jVXk+jTK4yWBY+gMwEat+LyNQ5cyq8Qhi1oBKUbGRbiOts19B97fn +Rv8TsyXN3INLGYhdVxZoD7E5tyG1ydSFmOMadulAC2epBXDHOXZnz2UWauJc0XW5 +1L/YQVri47VkdHS3tisBzELEJdLmdMDb+5tAU+lItXmTXe2/PB53WIvsEIb4t+eQ +wY0hCj9lVJlajTQ= +-----END CERTIFICATE----- diff --git a/test/java/security/cert/X509Certificate/bad-cert-2.pem b/test/java/security/cert/X509Certificate/bad-cert-2.pem new file mode 100644 index 0000000000000000000000000000000000000000..6b92ced2e097ea275df810f973589998552cd76c --- /dev/null +++ b/test/java/security/cert/X509Certificate/bad-cert-2.pem @@ -0,0 +1,21 @@ +-----BEGIN CERTIFICATE----- +MIIDZzCCAk+gAwIBAgIJAJYB3qu9C2kiMA0GCSqGSIb3DQEBBQUAMEoxDTALBgNV +BAMMBFRlc3QxDTALBgNVBAsMBEphdmExDzANBgNVBAoMBk9yYWNsZTEMMAoGA1UE +BwwDU1BCMQswCQYDVQQGEwJSVTAeFw0xMzEyMjMwNzA4MDhaFw0yMzEyMjEwNzA4 +MDhaMEoxDTALBgNVBAMMBFRlc3QxDTALBgNVBAsMBEphdmExDzANBgNVBAoMBk9y +YWNsZTEMMAoGA1UEBwwDU1BCMQswCQYDVQQGEwJSVTCCASIwDQYJKoZIhvcNAQEB +BQADgGEPADCCAQoCggEBAOqiCN4gFxehl547Q7/VNGbGApr+wszLdanHPucAH6Wf +LtcRhKNUSqtBAQxEpFrTpMNEqm2GElAjiPa6m48qIjLVSvOb/9w3G/yXB8zyZbIm +/Nfp2sT4OEaa1JSEZSpolhS4FfqYzjGQp5cn4Xn4zKjDgiceHgfLls5x2dRydQZO +Yf91qSIioZxVHUtlo8yztkieiSaqPWt3nJ4PIwhFbsu1HVmWaYZD+nBYCKgVHqrS +cueO98Ca4Doz73O27X1dVbQBdLS0JI7qVAG8LD388iPL8qbsOkgWPzmEQ+kLRKO4 +g7RpuwlXuwaMSh95NWaxlu4Ob6GRJQmpconYoe13+7ECAwEAAaNQME4wHQYDVR0O +BBYEFIG8TPobXcbNbDi+zKudd9whpxoNMB8GA1UdIwQYMBaAFIG8TPobXcbNbDi+ +zKudd9whpxoNMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAAynN+e7 +h+ufT5SBKN/gBuJAnF1mKIPESiipuv5KoYUGZOY8ShgYLcwY+qnbuHYFUlvq6Zns +K4/e+x/16h32vD7dEPkNvukbvER4YJQQiN6osDfXpTPzixYftWdmtX0u8xQfwb/g +R8DS7bazz99jVXk+jTK4yWBY+gMwEat+LyNQ5cyq8Qhi1oBKUbGRbiOts19B97fn +Rv8TsyXN3INLGYhdVxZoD7E5tyG1ydSFmOMadulAC2epBXDHOXZnz2UWauJc0XW5 +1L/YQVri47VkdHS3tisBzELEJdLmdMDb+5tAU+lItXmTXe2/PB53WIvsEIb4t+eQ +wY0hCj9lVJlajTQ= +-----END CERTIFICATE----- diff --git a/test/java/security/testlibrary/CertUtils.java b/test/java/security/testlibrary/CertUtils.java index e850ed1273dafed1df03be7638645c40dd0130b6..060570683157a0229c42f9bb2cd4ab973fd7b7fd 100644 --- a/test/java/security/testlibrary/CertUtils.java +++ b/test/java/security/testlibrary/CertUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * 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,17 +27,20 @@ * @author Steve Hanna * */ +import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.io.IOException; +import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.security.cert.CertPath; import java.security.cert.CertPathBuilder; import java.security.cert.CertPathValidator; import java.security.cert.CertStore; import java.security.cert.CollectionCertStoreParameters; +import java.security.cert.CRLException; import java.security.cert.PKIXBuilderParameters; import java.security.cert.PKIXCertPathBuilderResult; import java.security.cert.PKIXCertPathValidatorResult; @@ -60,59 +63,71 @@ public class CertUtils { * Get a DER-encoded X.509 certificate from a file. * * @param certFilePath path to file containing DER-encoded certificate - * @return X509Certificate - * @throws IOException on error + * @return the X509Certificate + * @throws CertificateException if the certificate type is not supported + * or cannot be parsed + * @throws IOException if the file cannot be opened */ public static X509Certificate getCertFromFile(String certFilePath) - throws IOException { - X509Certificate cert = null; - try { - File certFile = new File(System.getProperty("test.src", "."), - certFilePath); - if (!certFile.canRead()) - throw new IOException("File " + - certFile.toString() + - " is not a readable file."); - FileInputStream certFileInputStream = - new FileInputStream(certFile); - CertificateFactory cf = CertificateFactory.getInstance("X509"); - cert = (X509Certificate) - cf.generateCertificate(certFileInputStream); - } catch (Exception e) { - e.printStackTrace(); - throw new IOException("Can't construct X509Certificate: " + - e.getMessage()); - } - return cert; + throws CertificateException, IOException { + File certFile = new File(System.getProperty("test.src", "."), + certFilePath); + try (FileInputStream fis = new FileInputStream(certFile)) { + return (X509Certificate) + CertificateFactory.getInstance("X.509") + .generateCertificate(fis); + } } + /** + * Get a PEM-encoded X.509 certificate from a string. + * + * @param cert string containing the PEM-encoded certificate + * @return the X509Certificate + * @throws CertificateException if the certificate type is not supported + * or cannot be parsed + */ + public static X509Certificate getCertFromString(String cert) + throws CertificateException { + byte[] certBytes = cert.getBytes(); + ByteArrayInputStream bais = new ByteArrayInputStream(certBytes); + return (X509Certificate) + CertificateFactory.getInstance("X.509").generateCertificate(bais); + } + /** * Get a DER-encoded X.509 CRL from a file. * * @param crlFilePath path to file containing DER-encoded CRL - * @return X509CRL - * @throws IOException on error + * @return the X509CRL + * @throws CertificateException if the crl type is not supported + * @throws CRLException if the crl cannot be parsed + * @throws IOException if the file cannot be opened */ public static X509CRL getCRLFromFile(String crlFilePath) - throws IOException { - X509CRL crl = null; - try { - File crlFile = new File(System.getProperty("test.src", "."), - crlFilePath); - if (!crlFile.canRead()) - throw new IOException("File " + - crlFile.toString() + - " is not a readable file."); - FileInputStream crlFileInputStream = - new FileInputStream(crlFile); - CertificateFactory cf = CertificateFactory.getInstance("X509"); - crl = (X509CRL) cf.generateCRL(crlFileInputStream); - } catch (Exception e) { - e.printStackTrace(); - throw new IOException("Can't construct X509CRL: " + - e.getMessage()); - } - return crl; + throws CertificateException, CRLException, IOException { + File crlFile = new File(System.getProperty("test.src", "."), + crlFilePath); + try (FileInputStream fis = new FileInputStream(crlFile)) { + return (X509CRL) + CertificateFactory.getInstance("X.509").generateCRL(fis); + } + } + + /** + * Get a PEM-encoded X.509 crl from a string. + * + * @param crl string containing the PEM-encoded crl + * @return the X509CRL + * @throws CertificateException if the crl type is not supported + * @throws CRLException if the crl cannot be parsed + */ + public static X509CRL getCRLFromString(String crl) + throws CertificateException, CRLException { + byte[] crlBytes = crl.getBytes(); + ByteArrayInputStream bais = new ByteArrayInputStream(crlBytes); + return (X509CRL) + CertificateFactory.getInstance("X.509").generateCRL(bais); } /** diff --git a/test/java/time/test/java/time/format/ZoneName.java b/test/java/time/test/java/time/format/ZoneName.java index a94f1466dea7c03b33135e236eeb696a8fd4c368..31c5902b3c4fdc16c4aca19d7f028a33926632a5 100644 --- a/test/java/time/test/java/time/format/ZoneName.java +++ b/test/java/time/test/java/time/format/ZoneName.java @@ -748,6 +748,7 @@ class ZoneName { "Asia/Tel_Aviv", "Asia/Jerusalem", "Hongkong", "Asia/Hong_Kong", "Asia/Rangoon", "Asia/Yangon", + "America/Godthab", "America/Nuuk", }; private static final Map zidToMzone = new HashMap<>(); diff --git a/test/java/util/Collection/BiggernYours.java b/test/java/util/Collection/BiggernYours.java index 24ce930e71320be2ad77a00252061a2bc7290df9..37bbe072c7afcd973aa2a285809b2a34e7d3721b 100644 --- a/test/java/util/Collection/BiggernYours.java +++ b/test/java/util/Collection/BiggernYours.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -236,13 +236,6 @@ public class BiggernYours { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - private static abstract class Fun {abstract void f() throws Throwable;} - static void THROWS(Class k, Fun... fs) { - for (Fun f : fs) - try { f.f(); fail("Expected " + k.getName() + " not thrown"); } - catch (Throwable t) { - if (k.isAssignableFrom(t.getClass())) pass(); - else unexpected(t);}} private static abstract class CheckedThread extends Thread { abstract void realRun() throws Throwable; public void run() { diff --git a/test/java/util/Collection/IteratorAtEnd.java b/test/java/util/Collection/IteratorAtEnd.java index fffc7f70fa15889932e41406e5e16da1f5c16fa8..be3a7e116cc9ff9df561ee7437ef37c994c68c52 100644 --- a/test/java/util/Collection/IteratorAtEnd.java +++ b/test/java/util/Collection/IteratorAtEnd.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -84,9 +84,9 @@ public class IteratorAtEnd { try { final Iterator it = c.iterator(); THROWS(NoSuchElementException.class, - new Fun() {void f() { while (true) it.next(); }}); + () -> { while (true) it.next(); }); try { it.remove(); } - catch (UnsupportedOperationException _) { return; } + catch (UnsupportedOperationException exc) { return; } pass(); } catch (Throwable t) { unexpected(t); } @@ -96,10 +96,9 @@ public class IteratorAtEnd { final ListIterator it = list.listIterator(0); it.next(); final Object x = it.previous(); - THROWS(NoSuchElementException.class, - new Fun() {void f() { it.previous(); }}); + THROWS(NoSuchElementException.class, () -> it.previous()); try { it.remove(); } - catch (UnsupportedOperationException _) { return; } + catch (UnsupportedOperationException exc) { return; } pass(); check(! list.get(0).equals(x)); } catch (Throwable t) { unexpected(t); } @@ -108,10 +107,9 @@ public class IteratorAtEnd { final ListIterator it = list.listIterator(list.size()); it.previous(); final Object x = it.next(); - THROWS(NoSuchElementException.class, - new Fun() {void f() { it.next(); }}); + THROWS(NoSuchElementException.class, () -> it.next()); try { it.remove(); } - catch (UnsupportedOperationException _) { return; } + catch (UnsupportedOperationException exc) { return; } pass(); check(! list.get(list.size()-1).equals(x)); } catch (Throwable t) { unexpected(t); } @@ -132,7 +130,7 @@ public class IteratorAtEnd { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - private static abstract class Fun {abstract void f() throws Throwable;} + interface Fun {void f() throws Throwable;} static void THROWS(Class k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } diff --git a/test/java/util/Collection/MOAT.java b/test/java/util/Collection/MOAT.java index 889149527995498dfe476c2b0f8e40bc250f0088..2cd16e2b46c13893e252ef2e53b53a6350226eeb 100644 --- a/test/java/util/Collection/MOAT.java +++ b/test/java/util/Collection/MOAT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -116,10 +116,8 @@ public class MOAT { final List emptyArray = Arrays.asList(new Integer[]{}); testCollection(emptyArray); testEmptyList(emptyArray); - THROWS(IndexOutOfBoundsException.class, - new Fun(){void f(){ emptyArray.set(0,1); }}); - THROWS(UnsupportedOperationException.class, - new Fun(){void f(){ emptyArray.add(0,1); }}); + THROWS(IndexOutOfBoundsException.class, () -> emptyArray.set(0,1)); + THROWS(UnsupportedOperationException.class, () -> emptyArray.add(0,1)); List noOne = nCopies(0,1); testCollection(noOne); @@ -203,8 +201,7 @@ public class MOAT { if (rnd.nextBoolean()) check(! it.hasNext()); - THROWS(NoSuchElementException.class, - new Fun(){void f(){ it.next(); }}); + THROWS(NoSuchElementException.class, () -> it.next()); try { it.remove(); } catch (IllegalStateException ignored) { pass(); } @@ -231,16 +228,15 @@ public class MOAT { private static void testImmutableCollection(final Collection c) { THROWS(UnsupportedOperationException.class, - new Fun(){void f(){ c.add(99); }}, - new Fun(){void f(){ c.addAll(singleton(99)); }}); + () -> c.add(99), + () -> c.addAll(singleton(99))); if (! c.isEmpty()) { final Integer first = c.iterator().next(); THROWS(UnsupportedOperationException.class, - new Fun(){void f(){ c.clear(); }}, - new Fun(){void f(){ c.remove(first); }}, - new Fun(){void f(){ c.removeAll(singleton(first)); }}, - new Fun(){void f(){ c.retainAll(emptyList()); }} - ); + () -> c.clear(), + () -> c.remove(first), + () -> c.removeAll(singleton(first)), + () -> c.retainAll(emptyList())); } } @@ -252,17 +248,17 @@ public class MOAT { testList(c); testImmutableCollection(c); THROWS(UnsupportedOperationException.class, - new Fun(){void f(){ c.set(0,42); }}, - new Fun(){void f(){ c.add(0,42); }}, - new Fun(){void f(){ c.addAll(0,singleton(86)); }}); + () -> c.set(0,42), + () -> c.add(0,42), + () -> c.addAll(0,singleton(86))); if (! c.isEmpty()) THROWS(UnsupportedOperationException.class, - new Fun(){void f(){ - Iterator it = c.iterator(); - it.next(); it.remove();}}, - new Fun(){void f(){ - ListIterator it = c.listIterator(); - it.next(); it.remove();}}); + () -> { Iterator it = c.iterator(); + it.next(); + it.remove(); }, + () -> { ListIterator it = c.listIterator(); + it.next(); + it.remove(); }); } private static void clear(Collection c) { @@ -289,19 +285,19 @@ public class MOAT { private static void testImmutableMap(final Map m) { THROWS(UnsupportedOperationException.class, - new Fun(){void f(){ m.put(1,1); }}, - new Fun(){void f(){ m.putAll(singletonMap(1,1)); }}); + () -> m.put(1,1), + () -> m.putAll(singletonMap(1,1))); if (! m.isEmpty()) { final Integer first = m.keySet().iterator().next(); THROWS(UnsupportedOperationException.class, - new Fun(){void f(){ m.remove(first); }}, - new Fun(){void f(){ m.clear(); }}); + () -> m.remove(first), + () -> m.clear()); final Map.Entry me = m.entrySet().iterator().next(); Integer key = me.getKey(); Integer val = me.getValue(); THROWS(UnsupportedOperationException.class, - new Fun(){void f(){ me.setValue(3); }}); + () -> me.setValue(3)); equal(key, me.getKey()); equal(val, me.getValue()); } @@ -491,9 +487,9 @@ public class MOAT { // insert, query, remove element at head if (isEmpty) { THROWS(NoSuchElementException.class, - new Fun(){void f(){ deq.getFirst(); }}, - new Fun(){void f(){ deq.element(); }}, - new Fun(){void f(){ deq.iterator().next(); }}); + () -> deq.getFirst(), + () -> deq.element(), + () -> deq.iterator().next()); check(deq.peekFirst() == null); check(deq.peek() == null); } else { @@ -545,9 +541,9 @@ public class MOAT { } if (isEmpty) { THROWS(NoSuchElementException.class, - new Fun(){void f(){ deq.getFirst(); }}, - new Fun(){void f(){ deq.element(); }}, - new Fun(){void f(){ deq.iterator().next(); }}); + () -> deq.getFirst(), + () -> deq.element(), + () -> deq.iterator().next()); check(deq.peekFirst() == null); check(deq.peek() == null); } else { @@ -570,8 +566,7 @@ public class MOAT { // insert, query, remove element at tail if (isEmpty) { check(deq.peekLast() == null); - THROWS(NoSuchElementException.class, - new Fun(){void f(){ deq.getLast(); }}); + THROWS(NoSuchElementException.class, () -> deq.getLast()); } else { check(deq.peekLast() != e); check(deq.getLast() != e); @@ -614,8 +609,7 @@ public class MOAT { } if (isEmpty) { check(deq.peekLast() == null); - THROWS(NoSuchElementException.class, - new Fun(){void f(){ deq.getLast(); }}); + THROWS(NoSuchElementException.class, () -> deq.getLast()); } else { check(deq.peekLast() != e); check(deq.getLast() != e); @@ -648,17 +642,17 @@ public class MOAT { if (isList) { check(!asList.listIterator().hasPrevious()); THROWS(NoSuchElementException.class, - new Fun(){void f(){ asList.listIterator().previous(); }}); + () -> asList.listIterator().previous()); } THROWS(NoSuchElementException.class, - new Fun(){void f(){ deq.iterator().next(); }}, - new Fun(){void f(){ deq.element(); }}, - new Fun(){void f(){ deq.getFirst(); }}, - new Fun(){void f(){ deq.getLast(); }}, - new Fun(){void f(){ deq.pop(); }}, - new Fun(){void f(){ deq.remove(); }}, - new Fun(){void f(){ deq.removeFirst(); }}, - new Fun(){void f(){ deq.removeLast(); }}); + () -> deq.iterator().next(), + () -> deq.element(), + () -> deq.getFirst(), + () -> deq.getLast(), + () -> deq.pop(), + () -> deq.remove(), + () -> deq.removeFirst(), + () -> deq.removeLast()); check(deq.poll() == null); check(deq.pollFirst() == null); @@ -981,22 +975,22 @@ public class MOAT { ? (ConcurrentMap) m : null; List fs = new ArrayList(); - fs.add(new Fun(){void f(){ check(! m.containsKey(null));}}); - fs.add(new Fun(){void f(){ equal(m.remove(null), null);}}); - fs.add(new Fun(){void f(){ equal(m.get(null), null);}}); - if (cm != null) { - fs.add(new Fun(){void f(){ check(! cm.remove(null,null));}});} + fs.add(() -> check(! m.containsKey(null))); + fs.add(() -> equal(m.remove(null), null)); + fs.add(() -> equal(m.get(null), null)); + if (cm != null) + fs.add(() -> check(! cm.remove(null,null))); throwsConsistently(NullPointerException.class, fs); fs.clear(); final Map sm = singletonMap(null,1); - fs.add(new Fun(){void f(){ equal(m.put(null,1), null); m.clear();}}); - fs.add(new Fun(){void f(){ m.putAll(sm); m.clear();}}); + fs.add(() -> { equal(m.put(null,1), null); m.clear();}); + fs.add(() -> { m.putAll(sm); m.clear();}); if (cm != null) { - fs.add(new Fun(){void f(){ check(! cm.remove(null,null));}}); - fs.add(new Fun(){void f(){ equal(cm.putIfAbsent(null,1), 1);}}); - fs.add(new Fun(){void f(){ equal(cm.replace(null,1), null);}}); - fs.add(new Fun(){void f(){ equal(cm.replace(null,1, 1), 1);}}); + fs.add(() -> check(! cm.remove(null,null))); + fs.add(() -> equal(cm.putIfAbsent(null,1), 1)); + fs.add(() -> equal(cm.replace(null,1), null)); + fs.add(() -> equal(cm.replace(null,1, 1), 1)); } throwsConsistently(NullPointerException.class, fs); } @@ -1157,8 +1151,7 @@ public class MOAT { equalNext(it, 3); equalNext(it, 1); check(! it.hasNext()); - THROWS(NoSuchElementException.class, - new Fun(){void f(){it.next();}}); + THROWS(NoSuchElementException.class, () -> it.next()); } { @@ -1168,8 +1161,7 @@ public class MOAT { check(it.hasNext()); equal(it.next().getKey(), 3); check(it.hasNext()); equal(it.next().getKey(), 1); check(! it.hasNext()); - THROWS(NoSuchElementException.class, - new Fun(){void f(){it.next();}}); + THROWS(NoSuchElementException.class, () -> it.next()); } prepMapForDescItrTests(m); @@ -1239,8 +1231,7 @@ public class MOAT { equalNext(it, 3); equalNext(it, 1); check(! it.hasNext()); - THROWS(NoSuchElementException.class, - new Fun(){void f(){it.next();}}); + THROWS(NoSuchElementException.class, () -> it.next()); } prepSetForDescItrTests(s); @@ -1342,7 +1333,7 @@ public class MOAT { System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new Exception("Some tests failed"); } - private static abstract class Fun {abstract void f() throws Throwable;} + interface Fun {void f() throws Throwable;} private static void THROWS(Class k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } diff --git a/test/java/util/Collections/AsLifoQueue.java b/test/java/util/Collections/AsLifoQueue.java index ddb98a745178e6cd7c8adb9b3c317d40e618dd9d..59c08e85c758b608e63dd7f5da230dc01768e290 100644 --- a/test/java/util/Collections/AsLifoQueue.java +++ b/test/java/util/Collections/AsLifoQueue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -56,8 +56,7 @@ public class AsLifoQueue { equal(q.size(), 3); check(! q.offer("d")); equal(q.size(), 3); - THROWS(IllegalStateException.class, - new Fun(){void f(){ q.add("d"); }}); + THROWS(IllegalStateException.class, () -> q.add("d")); equal(q.size(), 3); equal(q.toString(), "[c, b, a]"); equal(q.peek(), "c"); @@ -66,8 +65,7 @@ public class AsLifoQueue { equal(q.poll(), "b"); equal(q.peek(), "a"); equal(q.remove(), "a"); - THROWS(NoSuchElementException.class, - new Fun(){void f(){ q.remove(); }}); + THROWS(NoSuchElementException.class, () -> q.remove()); equal(q.poll(), null); check(q.isEmpty()); equal(q.size(), 0); @@ -88,7 +86,7 @@ public class AsLifoQueue { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - static abstract class Fun { abstract void f() throws Throwable; } + interface Fun {void f() throws Throwable;} private static void THROWS(Class k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } diff --git a/test/java/util/Locale/LocaleProviders.sh b/test/java/util/Locale/LocaleProviders.sh index 58cd9c82060dfeb78879f4c9adb0ac3ec968fe1e..d750c43d7e8baf0c749c4bf30eba47fd2b9c656b 100644 --- a/test/java/util/Locale/LocaleProviders.sh +++ b/test/java/util/Locale/LocaleProviders.sh @@ -24,7 +24,7 @@ # # @test # @bug 6336885 7196799 7197573 7198834 8000245 8000615 8001440 8010666 -# 8013086 8013233 8013903 8015960 8028771 +# 8013086 8013233 8013903 8015960 8028771 8150432 # @summary tests for "java.locale.providers" system property # @compile -XDignore.symbol.file LocaleProviders.java # @run shell/timeout=600 LocaleProviders.sh @@ -163,7 +163,7 @@ case "$OS" in PARAM1=HOST fi ;; - CYGWIN_NT-6* | Darwin ) + CYGWIN_NT-6* | CYGWIN_NT-10* | Darwin ) PARAM1=HOST ;; * ) diff --git a/test/java/util/NavigableMap/LockStep.java b/test/java/util/NavigableMap/LockStep.java index adb8b1978c9266093aa06857d9284052eac91529..62ffc72877d2eb6dbef36aa26d2d1c6fb37348ff 100644 --- a/test/java/util/NavigableMap/LockStep.java +++ b/test/java/util/NavigableMap/LockStep.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -236,8 +236,8 @@ public class LockStep { Comparator cmp = comparator(s); if (s.isEmpty()) { THROWS(NoSuchElementException.class, - new Fun(){void f(){ s.first(); }}, - new Fun(){void f(){ s.last(); }}); + () -> s.first(), + () -> s.last()); equal(null, s.lower(1)); equal(null, s.floor(1)); equal(null, s.ceiling(1)); @@ -265,8 +265,7 @@ public class LockStep { }; for (final Iterator it : its) if (maybe(4)) - THROWS(IllegalStateException.class, - new Fun(){void f(){ it.remove(); }}); + THROWS(IllegalStateException.class, () -> it.remove()); Object prev = null; for (Object e : s) { check(s.contains(e)); @@ -284,7 +283,7 @@ public class LockStep { for (final Iterator it : its) { if (maybe(2)) check(! it.hasNext()); - Fun fun = new Fun(){void f(){ it.next(); }}; + Fun fun = () -> it.next(); THROWS(NoSuchElementException.class, fun, fun, fun); } } @@ -380,8 +379,8 @@ public class LockStep { Comparator cmp = comparator(m); if (m.isEmpty()) { THROWS(NoSuchElementException.class, - new Fun(){void f(){ m.firstKey(); }}, - new Fun(){void f(){ m.lastKey(); }}); + () -> m.firstKey(), + () -> m.lastKey()); equal(null, m.firstEntry()); equal(null, m.lastEntry()); equal(null, m.pollFirstEntry()); @@ -430,8 +429,7 @@ public class LockStep { Iterator[] its = concat(kits, vits, eits); for (final Iterator it : its) if (maybe(4)) - THROWS(IllegalStateException.class, - new Fun(){void f(){ it.remove(); }}); + THROWS(IllegalStateException.class, () -> it.remove()); Map.Entry prev = null; for (Map.Entry e : (Set) m.entrySet()) { Object k = e.getKey(); @@ -459,7 +457,7 @@ public class LockStep { for (final Iterator it : its) { if (maybe(2)) check(! it.hasNext()); - Fun fun = new Fun(){void f(){ it.next(); }}; + Fun fun = () -> it.next(); THROWS(NoSuchElementException.class, fun, fun, fun); } } @@ -633,7 +631,7 @@ public class LockStep { } static Fun remover(final Iterator it) { - return new Fun(){void f(){ it.remove(); }}; + return () -> it.remove(); } static MapFrobber randomRemover(NavigableMap m) { @@ -663,7 +661,7 @@ public class LockStep { it.remove(); if (maybe(2)) THROWS(IllegalStateException.class, - new Fun(){void f(){ it.remove(); }}); + () -> it.remove()); } checkUnusedKey(m, k);}}, new MapFrobber() {void frob(NavigableMap m) { @@ -673,7 +671,7 @@ public class LockStep { it.remove(); if (maybe(2)) THROWS(IllegalStateException.class, - new Fun(){void f(){ it.remove(); }}); + () -> it.remove()); } checkUnusedKey(m, k);}}, new MapFrobber() {void frob(NavigableMap m) { @@ -718,7 +716,7 @@ public class LockStep { it.remove(); if (maybe(2)) THROWS(IllegalStateException.class, - new Fun(){void f(){ it.remove(); }}); + () -> it.remove()); } checkUnusedElt(s, e);}}, new SetFrobber() {void frob(NavigableSet s) { @@ -728,7 +726,7 @@ public class LockStep { it.remove(); if (maybe(2)) THROWS(IllegalStateException.class, - new Fun(){void f(){ it.remove(); }}); + () -> it.remove()); } checkUnusedElt(s, e);}}, new SetFrobber() {void frob(NavigableSet s) { @@ -738,7 +736,7 @@ public class LockStep { it.remove(); if (maybe(2)) THROWS(IllegalStateException.class, - new Fun(){void f(){ it.remove(); }}); + () -> it.remove()); } checkUnusedElt(s, e);}} }; @@ -769,12 +767,12 @@ public class LockStep { for (final NavigableMap m : maps) { final Object e = usedKey(m); THROWS(IllegalArgumentException.class, - new Fun(){void f(){m.subMap(e,true,e,false) - .subMap(e,true,e,true);}}, - new Fun(){void f(){m.subMap(e,false,e,true) - .subMap(e,true,e,true);}}, - new Fun(){void f(){m.tailMap(e,false).tailMap(e,true);}}, - new Fun(){void f(){m.headMap(e,false).headMap(e,true);}}); + () -> {m.subMap(e,true,e,false) + .subMap(e,true,e,true);}, + () -> {m.subMap(e,false,e,true) + .subMap(e,true,e,true);}, + () -> m.tailMap(e,false).tailMap(e,true), + () -> m.headMap(e,false).headMap(e,true)); } //System.out.printf("%s%n", m1); for (int i = size; i > 0; i--) { @@ -811,12 +809,12 @@ public class LockStep { for (final NavigableSet s : sets) { final Object e = usedElt(s); THROWS(IllegalArgumentException.class, - new Fun(){void f(){s.subSet(e,true,e,false) - .subSet(e,true,e,true);}}, - new Fun(){void f(){s.subSet(e,false,e,true) - .subSet(e,true,e,true);}}, - new Fun(){void f(){s.tailSet(e,false).tailSet(e,true);}}, - new Fun(){void f(){s.headSet(e,false).headSet(e,true);}}); + () -> {s.subSet(e,true,e,false) + .subSet(e,true,e,true);}, + () -> {s.subSet(e,false,e,true) + .subSet(e,true,e,true);}, + () -> s.tailSet(e,false).tailSet(e,true), + () -> s.headSet(e,false).headSet(e,true)); } //System.out.printf("%s%n", s1); for (int i = size; i > 0; i--) { @@ -847,7 +845,7 @@ public class LockStep { System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new Exception("Some tests failed"); } - static abstract class Fun {abstract void f() throws Throwable;} + interface Fun {void f() throws Throwable;} static void THROWS(Class k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } diff --git a/test/java/util/PriorityQueue/ForgetMeNot.java b/test/java/util/PriorityQueue/ForgetMeNot.java index f6970fa73f7c4e7c8c23e55c1da7d1dce84e7415..7778d1d793d4e11cfcf1603c7a8823698d745af1 100644 --- a/test/java/util/PriorityQueue/ForgetMeNot.java +++ b/test/java/util/PriorityQueue/ForgetMeNot.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -37,16 +37,14 @@ public class ForgetMeNot { private static void noMoreElements(final Iterator it) { for (int j = 0; j < 2; j++) { - THROWS(NoSuchElementException.class, - new Fun() { void f() { it.next(); }}); + THROWS(NoSuchElementException.class, () -> it.next()); check(! it.hasNext()); } } private static void removeIsCurrentlyIllegal(final Iterator it) { for (int j = 0; j < 2; j++) { - THROWS(IllegalStateException.class, - new Fun() { void f() { it.remove(); }}); + THROWS(IllegalStateException.class, () -> it.remove()); } } @@ -146,7 +144,7 @@ public class ForgetMeNot { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - private static abstract class Fun {abstract void f() throws Throwable;} + interface Fun {void f() throws Throwable;} static void THROWS(Class k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } diff --git a/test/java/util/Timer/NameConstructors.java b/test/java/util/Timer/NameConstructors.java index bc74522e473e4bec9277bcbd9366a72070d623ac..fbf1649ef0621f452f60b2a5041eeedf26634fef 100644 --- a/test/java/util/Timer/NameConstructors.java +++ b/test/java/util/Timer/NameConstructors.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -23,37 +23,42 @@ /* * @test - * @bug 4279061 + * @bug 4279061 8056313 * @summary Basic test for constructors with thread name */ -import java.util.*; +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.LinkedTransferQueue; public class NameConstructors { private static final String NAME1 = "Norm D. Plume"; private static final String NAME2 = "Ann Onymous"; - public static void main (String[] args) throws Exception { - Random rnd = new Random(); + public static void main (String[] args) throws InterruptedException { test(new Timer(NAME1), NAME1); test(new Timer(NAME2, true), NAME2); } - private static boolean done, passed; + public static void test(Timer timer, String expected) throws InterruptedException { + try { + LinkedTransferQueue queue = new LinkedTransferQueue<>(); - public static void test(Timer timer, final String name) throws Exception { - done = passed = false; + TimerTask task = new TimerTask() { + public void run() { + queue.put(Thread.currentThread().getName()); + } + }; - TimerTask task = new TimerTask() { - public void run() { - passed = Thread.currentThread().getName().equals(name); - done = true; + timer.schedule(task, 0L); // immediately + String actual = queue.take(); + + if (!expected.equals(actual)) { + throw new AssertionError( + String.format("expected='%s', actual='%s'", expected, actual)); } - }; - timer.schedule(task, 0); // Immediate - Thread.sleep(500); - if (!(done && passed)) - throw new RuntimeException(done + " : " + passed); - timer.cancel(); + } finally { + timer.cancel(); + } } } diff --git a/test/java/util/concurrent/BlockingQueue/Interrupt.java b/test/java/util/concurrent/BlockingQueue/Interrupt.java index d8d55d9902b78f49c17c99ea58659ef403d8f315..10b85ca79ef35b4218a66711d2b33c8ba1a3fef2 100644 --- a/test/java/util/concurrent/BlockingQueue/Interrupt.java +++ b/test/java/util/concurrent/BlockingQueue/Interrupt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -70,19 +70,13 @@ public class Interrupt { (BlockingDeque) q : null; q.clear(); List fs = new ArrayList(); - fs.add(new Fun() { void f() throws Throwable - { q.take(); }}); - fs.add(new Fun() { void f() throws Throwable - { q.poll(60, SECONDS); }}); + fs.add(() -> q.take()); + fs.add(() -> q.poll(60, SECONDS)); if (deq != null) { - fs.add(new Fun() { void f() throws Throwable - { deq.takeFirst(); }}); - fs.add(new Fun() { void f() throws Throwable - { deq.takeLast(); }}); - fs.add(new Fun() { void f() throws Throwable - { deq.pollFirst(7, SECONDS); }}); - fs.add(new Fun() { void f() throws Throwable - { deq.pollLast(7, SECONDS); }}); + fs.add(() -> deq.takeFirst()); + fs.add(() -> deq.takeLast()); + fs.add(() -> deq.pollFirst(7, SECONDS)); + fs.add(() -> deq.pollLast(7, SECONDS)); } checkInterrupted(fs); @@ -93,19 +87,13 @@ public class Interrupt { catch (Throwable t) { unexpected(t); } fs.clear(); - fs.add(new Fun() { void f() throws Throwable - { q.put(1); }}); - fs.add(new Fun() { void f() throws Throwable - { q.offer(1, 7, SECONDS); }}); + fs.add(() -> q.put(1)); + fs.add(() -> q.offer(1, 7, SECONDS)); if (deq != null) { - fs.add(new Fun() { void f() throws Throwable - { deq.putFirst(1); }}); - fs.add(new Fun() { void f() throws Throwable - { deq.putLast(1); }}); - fs.add(new Fun() { void f() throws Throwable - { deq.offerFirst(1, 7, SECONDS); }}); - fs.add(new Fun() { void f() throws Throwable - { deq.offerLast(1, 7, SECONDS); }}); + fs.add(() -> deq.putFirst(1)); + fs.add(() -> deq.putLast(1)); + fs.add(() -> deq.offerFirst(1, 7, SECONDS)); + fs.add(() -> deq.offerLast(1, 7, SECONDS)); } checkInterrupted(fs); } catch (Throwable t) { @@ -136,5 +124,5 @@ public class Interrupt { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - private abstract static class Fun {abstract void f() throws Throwable;} + interface Fun {void f() throws Throwable;} } diff --git a/test/java/util/concurrent/CyclicBarrier/Basic.java b/test/java/util/concurrent/CyclicBarrier/Basic.java index 123481985b255df013991e67ea206f8b8e985edc..b6b8d637b2ff2d007726de84e37680414c4cdc94 100644 --- a/test/java/util/concurrent/CyclicBarrier/Basic.java +++ b/test/java/util/concurrent/CyclicBarrier/Basic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -40,10 +40,8 @@ public class Basic { equal(barrier.getNumberWaiting(), 0); THROWS(BrokenBarrierException.class, - new Fun() { public void f() throws Throwable { - barrier.await(); }}, - new Fun() { public void f() throws Throwable { - barrier.await(100, MILLISECONDS); }}); + () -> barrier.await(), + () -> barrier.await(100, MILLISECONDS)); } private static void reset(CyclicBarrier barrier) { @@ -417,7 +415,7 @@ public class Basic { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - abstract static class Fun { abstract void f() throws Throwable; } + interface Fun {void f() throws Throwable;} private static void THROWS(Class k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } diff --git a/test/java/util/concurrent/Executors/Throws.java b/test/java/util/concurrent/Executors/Throws.java index 424b60d6d727cfe2cbd891ce880de64de87dca15..402472df366d167058504421b6c478dfb872c6a4 100644 --- a/test/java/util/concurrent/Executors/Throws.java +++ b/test/java/util/concurrent/Executors/Throws.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -45,33 +45,31 @@ public class Throws { ThreadPoolExecutor executor) {}}; final RejectedExecutionHandler nullHandler = null; - THROWS( - NullPointerException.class, - new Fun(){void f(){ newFixedThreadPool(3, null); }}, - new Fun(){void f(){ newCachedThreadPool(null); }}, - new Fun(){void f(){ newSingleThreadScheduledExecutor(null); }}, - new Fun(){void f(){ newScheduledThreadPool(0, null); }}, - new Fun(){void f(){ unconfigurableExecutorService(null); }}, - new Fun(){void f(){ unconfigurableScheduledExecutorService(null); }}, - new Fun(){void f(){ callable(null, "foo"); }}, - new Fun(){void f(){ callable((Runnable) null); }}, - new Fun(){void f(){ callable((PrivilegedAction) null); }}, - new Fun(){void f(){ callable((PrivilegedExceptionAction) null); }}, - new Fun(){void f(){ privilegedCallable((Callable) null); }}, - new Fun(){void f(){ new ScheduledThreadPoolExecutor(0, nullFactory); }}, - new Fun(){void f(){ new ScheduledThreadPoolExecutor(0, nullFactory, reh); }}, - new Fun(){void f(){ new ScheduledThreadPoolExecutor(0, fac, nullHandler); }}); - - THROWS( - IllegalArgumentException.class, - new Fun(){void f(){ newFixedThreadPool(-42); }}, - new Fun(){void f(){ newFixedThreadPool(0) ; }}, - new Fun(){void f(){ newFixedThreadPool(-42, fac); }}, - new Fun(){void f(){ newFixedThreadPool(0, fac); }}, - new Fun(){void f(){ newScheduledThreadPool(-42); }}, - new Fun(){void f(){ new ScheduledThreadPoolExecutor(-42); }}, - new Fun(){void f(){ new ScheduledThreadPoolExecutor(-42, reh); }}, - new Fun(){void f(){ new ScheduledThreadPoolExecutor(-42, fac, reh); }}); + THROWS(NullPointerException.class, + () -> newFixedThreadPool(3, null), + () -> newCachedThreadPool(null), + () -> newSingleThreadScheduledExecutor(null), + () -> newScheduledThreadPool(0, null), + () -> unconfigurableExecutorService(null), + () -> unconfigurableScheduledExecutorService(null), + () -> callable(null, "foo"), + () -> callable((Runnable) null), + () -> callable((PrivilegedAction) null), + () -> callable((PrivilegedExceptionAction) null), + () -> privilegedCallable((Callable) null), + () -> new ScheduledThreadPoolExecutor(0, nullFactory), + () -> new ScheduledThreadPoolExecutor(0, nullFactory, reh), + () -> new ScheduledThreadPoolExecutor(0, fac, nullHandler)); + + THROWS(IllegalArgumentException.class, + () -> newFixedThreadPool(-42), + () -> newFixedThreadPool(0), + () -> newFixedThreadPool(-42, fac), + () -> newFixedThreadPool(0, fac), + () -> newScheduledThreadPool(-42), + () -> new ScheduledThreadPoolExecutor(-42), + () -> new ScheduledThreadPoolExecutor(-42, reh), + () -> new ScheduledThreadPoolExecutor(-42, fac, reh)); try { newFixedThreadPool(1).shutdownNow(); pass(); } catch (Throwable t) { unexpected(t); } @@ -122,7 +120,7 @@ public class Throws { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - private abstract static class Fun {abstract void f() throws Throwable;} + interface Fun {void f() throws Throwable;} static void THROWS(Class k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } diff --git a/test/java/util/concurrent/FutureTask/Customized.java b/test/java/util/concurrent/FutureTask/Customized.java index 15159ca0aabb68e28e4479584335a9cae28118e2..a1afd9015a1cb9838f0995d3b9413a8626192d5e 100644 --- a/test/java/util/concurrent/FutureTask/Customized.java +++ b/test/java/util/concurrent/FutureTask/Customized.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -70,8 +70,7 @@ public class Customized { check(! task.isDone()); check(! task.isCancelled()); THROWS(TimeoutException.class, - new Fun(){void f() throws Throwable { - task.get(0L, TimeUnit.SECONDS); }}); + () -> task.get(0L, TimeUnit.SECONDS)); } static void checkDone(final FutureTask task) { @@ -86,20 +85,16 @@ public class Customized { check(task.isDone()); check(task.isCancelled()); THROWS(CancellationException.class, - new Fun(){void f() throws Throwable { - task.get(0L, TimeUnit.SECONDS); }}, - new Fun(){void f() throws Throwable { - task.get(); }}); + () -> task.get(0L, TimeUnit.SECONDS), + () -> task.get()); } static void checkThrew(final FutureTask task) { check(task.isDone()); check(! task.isCancelled()); THROWS(ExecutionException.class, - new Fun(){void f() throws Throwable { - task.get(0L, TimeUnit.SECONDS); }}, - new Fun(){void f() throws Throwable { - task.get(); }}); + () -> task.get(0L, TimeUnit.SECONDS), + () -> task.get()); } static void cancel(FutureTask task, boolean mayInterruptIfRunning) { @@ -203,7 +198,7 @@ public class Customized { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - private abstract static class Fun {abstract void f() throws Throwable;} + interface Fun {void f() throws Throwable;} static void THROWS(Class k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } diff --git a/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java b/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java index aed43ac68a8d4eb167fe4c6398bc02777f026ade..d89ee28333ebb5d689c4627c9ddbb88b7554a2ee 100644 --- a/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java +++ b/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -72,7 +72,7 @@ public class ConfigChanges { check(((ThreadPoolExecutor) es).isTerminating() || es.isTerminated()); THROWS(RejectedExecutionException.class, - new Fun() {void f() {es.execute(nop);}}); + () -> es.execute(nop)); } } catch (Throwable t) { unexpected(t); } } @@ -241,7 +241,7 @@ public class ConfigChanges { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - private abstract static class Fun {abstract void f() throws Throwable;} + interface Fun {void f() throws Throwable;} static void THROWS(Class k, Fun... fs) { for (Fun f : fs) try { f.f(); fail("Expected " + k.getName() + " not thrown"); } diff --git a/test/java/util/concurrent/ThreadPoolExecutor/ShutdownNowExecuteRace.java b/test/java/util/concurrent/ThreadPoolExecutor/ShutdownNowExecuteRace.java index dbf82f22ece1ce1f92df7fa7724628fa3f7db509..780aa4eeb06aa01cd36a219ed38e5310e5d41a0c 100644 --- a/test/java/util/concurrent/ThreadPoolExecutor/ShutdownNowExecuteRace.java +++ b/test/java/util/concurrent/ThreadPoolExecutor/ShutdownNowExecuteRace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -81,13 +81,6 @@ public class ShutdownNowExecuteRace { try {realMain(args);} catch (Throwable t) {unexpected(t);} System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); if (failed > 0) throw new AssertionError("Some tests failed");} - private abstract static class Fun {abstract void f() throws Throwable;} - static void THROWS(Class k, Fun... fs) { - for (Fun f : fs) - try { f.f(); fail("Expected " + k.getName() + " not thrown"); } - catch (Throwable t) { - if (k.isAssignableFrom(t.getClass())) pass(); - else unexpected(t);}} private abstract static class CheckedThread extends Thread { abstract void realRun() throws Throwable; public void run() { diff --git a/test/javax/accessibility/AccessibleName/GetAccessibleNameTest.java b/test/javax/accessibility/AccessibleName/GetAccessibleNameTest.java new file mode 100644 index 0000000000000000000000000000000000000000..001e383a983b5a3e62f6e6b0f588fb5b7dd36cf4 --- /dev/null +++ b/test/javax/accessibility/AccessibleName/GetAccessibleNameTest.java @@ -0,0 +1,137 @@ +/* + * 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 javax.accessibility.AccessibleContext; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.JRadioButton; +import javax.swing.JRadioButtonMenuItem; +import javax.swing.JToggleButton; +import javax.swing.SwingUtilities; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; + +/* + * @test + * @bug 4949105 + * @summary Access Bridge lacks html tags parsing + * @run main GetAccessibleNameTest + */ + +public class GetAccessibleNameTest { + + public static void main(String[] args) throws Exception { + testConstructor(); + testSetText(); + testAccessibleProperty(); + } + + private static void testConstructor() { + Class[] testClass = new Class[] { + JLabel.class, JButton.class, JMenuItem.class, + JMenu.class, JCheckBoxMenuItem.class, JRadioButtonMenuItem.class, + JToggleButton.class, JRadioButton.class, JCheckBox.class }; + + Class[] ctorArg = new Class[1]; + ctorArg[0] = String.class; + String expectedText = "bold italic em mark del small big sup sub ins strong code strike"; + String inputText = "" + + "bold italic em mark del " + + "small big sup sub ins " + + "strong code strike" + + ""; + + for (Class aClass : testClass) { + try { + Constructor constructor = aClass.getDeclaredConstructor(ctorArg); + JComponent comp = (JComponent) constructor.newInstance(inputText); + if (!expectedText.equals(comp.getAccessibleContext().getAccessibleName())) { + throw new RuntimeException("AccessibleName of " + aClass.getName() + " is incorrect." + + " Expected: " + expectedText + + " Actual: " + comp.getAccessibleContext().getAccessibleName()); + } + } catch (NoSuchMethodException e) { + throw new RuntimeException(aClass.getName() + " does not have a constructor accepting" + + "String parameter.", e.getCause()); + } catch (InstantiationException e) { + throw new RuntimeException(aClass.getName() + " could not be instantiated.", + e.getCause()); + } catch (IllegalAccessException e) { + throw new RuntimeException(aClass.getName() + " constructor cannot be accessed.", + e.getCause()); + } catch (InvocationTargetException e) { + throw new RuntimeException(aClass.getName() + " constructor cannot be invoked.", + e.getCause()); + } + } + } + + private static void testSetText() { + String text = "html text"; + JLabel testLabel = new JLabel("" + text + ""); + if (!text.equals(testLabel.getAccessibleContext().getAccessibleName())) { + throw new RuntimeException("Incorrect AccessibleName," + + " Expected: " + text + + " Actual: " + testLabel.getAccessibleContext().getAccessibleName()); + } + + text = "Non html text"; + testLabel.setText(text); + if (!text.equals(testLabel.getAccessibleContext().getAccessibleName())) { + throw new RuntimeException("Incorrect AccessibleName," + + " Expected: " + text + + " Actual: " + testLabel.getAccessibleContext().getAccessibleName()); + } + } + + private static void testAccessibleProperty() { + String text = "html text"; + JLabel testLabel = new JLabel("" + text + ""); + if (!text.equals(testLabel.getClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY))) { + throw new RuntimeException("Incorrect ACCESSIBLE_NAME_PROPERTY," + + " Expected: " + text + + " Actual: " + testLabel.getClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY)); + } + + String namePropertyText = "name property"; + testLabel.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, namePropertyText); + if (!namePropertyText.equals(testLabel.getClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY))) { + throw new RuntimeException("Incorrect ACCESSIBLE_NAME_PROPERTY," + + " Expected: " + namePropertyText + + " Actual: " + testLabel.getClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY)); + } + + text = "different html text"; + testLabel.setText("" + text + ""); + if (!namePropertyText.equals(testLabel.getClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY))) { + throw new RuntimeException("Incorrect ACCESSIBLE_NAME_PROPERTY," + + " Expected: " + namePropertyText + + " Actual: " + testLabel.getClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY)); + } + } +} diff --git a/test/javax/crypto/CipherSpi/TestGCMWithByteBuffer.java b/test/javax/crypto/CipherSpi/TestGCMWithByteBuffer.java new file mode 100644 index 0000000000000000000000000000000000000000..0c07fcb35bf37ab338f11feb2bfc79e029d31838 --- /dev/null +++ b/test/javax/crypto/CipherSpi/TestGCMWithByteBuffer.java @@ -0,0 +1,165 @@ +/* + * 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 8178374 + * @summary Test GCM decryption with various types of input/output + * ByteBuffer objects + * @key randomness + */ + +import java.nio.ByteBuffer; +import java.security.*; +import java.util.Random; + +import javax.crypto.Cipher; +import javax.crypto.SecretKey; +import javax.crypto.AEADBadTagException; +import javax.crypto.spec.*; + +public class TestGCMWithByteBuffer { + + private static Random random = new SecureRandom(); + private static int dataSize = 4096; // see javax.crypto.CipherSpi + private static int multiples = 3; + + public static void main(String args[]) throws Exception { + Provider[] provs = Security.getProviders(); + for (Provider p : provs) { + try { + Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding", p); + test(cipher); + } catch (NoSuchAlgorithmException nsae) { + // skip testing due to no support + continue; + } + } + } + + private static void test(Cipher cipher) throws Exception { + System.out.println("Testing " + cipher.getProvider()); + + boolean failedOnce = false; + Exception failedReason = null; + + int tagLen = 96; // in bits + byte[] keyBytes = new byte[16]; + random.nextBytes(keyBytes); + byte[] dataChunk = new byte[dataSize]; + random.nextBytes(dataChunk); + + SecretKey key = new SecretKeySpec(keyBytes, "AES"); + // re-use key bytes as IV as the real test is buffer calculation + GCMParameterSpec s = new GCMParameterSpec(tagLen, keyBytes); + + /* + * Iterate through various sizes to make sure that the code works with + * internal temp buffer size 4096. + */ + for (int t = 1; t <= multiples; t++) { + int size = t * dataSize; + + System.out.println("\nTesting data size: " + size); + + try { + decrypt(cipher, key, s, dataChunk, t, + ByteBuffer.allocate(dataSize), + ByteBuffer.allocate(size), + ByteBuffer.allocateDirect(dataSize), + ByteBuffer.allocateDirect(size)); + } catch (Exception e) { + System.out.println("\tFailed with data size " + size); + failedOnce = true; + failedReason = e; + } + } + if (failedOnce) { + throw failedReason; + } + System.out.println("\n=> Passed..."); + } + + private enum TestVariant { + HEAP_HEAP, HEAP_DIRECT, DIRECT_HEAP, DIRECT_DIRECT + }; + + private static void decrypt(Cipher cipher, SecretKey key, + GCMParameterSpec s, byte[] dataChunk, int multiples, + ByteBuffer heapIn, ByteBuffer heapOut, ByteBuffer directIn, + ByteBuffer directOut) throws Exception { + + ByteBuffer inBB = null; + ByteBuffer outBB = null; + + // try various combinations of input/output + for (TestVariant tv : TestVariant.values()) { + System.out.println(" " + tv); + + switch (tv) { + case HEAP_HEAP: + inBB = heapIn; + outBB = heapOut; + break; + case HEAP_DIRECT: + inBB = heapIn; + outBB = directOut; + break; + case DIRECT_HEAP: + inBB = directIn; + outBB = heapOut; + break; + case DIRECT_DIRECT: + inBB = directIn; + outBB = directOut; + break; + } + + // prepare input and output buffers + inBB.clear(); + inBB.put(dataChunk); + + outBB.clear(); + + try { + // Always re-init the Cipher object so cipher is in + // a good state for future testing + cipher.init(Cipher.DECRYPT_MODE, key, s); + + for (int i = 0; i < multiples; i++) { + inBB.flip(); + cipher.update(inBB, outBB); + if (inBB.hasRemaining()) { + throw new Exception("buffer not empty"); + } + } + // finish decryption and process all data buffered + cipher.doFinal(inBB, outBB); + throw new RuntimeException("Error: doFinal completed without exception"); + } catch (AEADBadTagException ex) { + System.out.println("Expected AEADBadTagException thrown"); + continue; + } + } + } +} diff --git a/test/javax/imageio/plugins/gif/GIFCodeSizeTest.java b/test/javax/imageio/plugins/gif/GIFCodeSizeTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d72508716f2507bb2f4a1cd543b15ef40b0ae2b2 --- /dev/null +++ b/test/javax/imageio/plugins/gif/GIFCodeSizeTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * 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 8238842 + * @summary Test incorrect code size results in IOException + */ + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import javax.imageio.ImageIO; + +public class GIFCodeSizeTest { + + static final byte[] DATA = { + (byte)0x47, (byte)0x49, (byte)0x46, (byte)0x38, (byte)0x37, + (byte)0x61, (byte)0x02, (byte)0x00, (byte)0x02, (byte)0x00, + (byte)0x80, (byte)0x00, (byte)0x80, (byte)0x00, (byte)0xff, + (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x2c, + (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x00, (byte)0x02, + (byte)0x00, (byte)0x02, (byte)0x00, (byte)0x00, (byte)0x12, + (byte)0x02, (byte)0x84, (byte)0x51, (byte)0x00, (byte)0x3b + }; + + public static void main(String[] args) /*throws Exception */{ + try { + ImageIO.read(new ByteArrayInputStream(DATA)); + } catch (IOException e) { + } + } +} diff --git a/test/javax/security/sasl/Sasl/DisabledMechanisms.java b/test/javax/security/sasl/Sasl/DisabledMechanisms.java new file mode 100644 index 0000000000000000000000000000000000000000..428cc3ad4896cbc2563bd51b1a086c5cb711e4bc --- /dev/null +++ b/test/javax/security/sasl/Sasl/DisabledMechanisms.java @@ -0,0 +1,85 @@ +/* + * 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 + * @library /lib/testlibrary + * @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.testlibrary.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/test/javax/swing/JRadioButton/8033699/bug8033699.java b/test/javax/swing/JRadioButton/8033699/bug8033699.java index 63409dead6dcbfa2729e3614b3d58769d9ce2a1b..15b9c6526b443462d25fd968054f0fca4a7b9821 100644 --- a/test/javax/swing/JRadioButton/8033699/bug8033699.java +++ b/test/javax/swing/JRadioButton/8033699/bug8033699.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 @@ -25,7 +25,7 @@ * @test * @library ../../regtesthelpers * @build Util - * @bug 8033699 + * @bug 8033699 8226892 * @summary Incorrect radio button behavior when pressing tab key * @author Vivi An * @run main bug8033699 @@ -86,6 +86,9 @@ public class bug8033699 { // down key circle back to first button in grouped radio button runTest8(); + + // Verify that ActionListener is called when a RadioButton is selected using arrow key. + runTest9(); } private static void createAndShowGUI() { @@ -239,6 +242,45 @@ public class bug8033699 { }); } + private static Boolean actRB1 = false; + private static Boolean actRB2 = false; + private static Boolean actRB3 = false; + + // JDK-8226892: Verify that ActionListener is called when a RadioButton is selected using arrow key. + private static void runTest9() throws Exception { + SwingUtilities.invokeAndWait(() -> { + radioBtn1.setSelected(true); + radioBtn1.requestFocusInWindow(); + }); + + ActionListener actLrRB1 = e -> actRB1 = true; + ActionListener actLrRB2 = e -> actRB2 = true; + ActionListener actLrRB3 = e -> actRB3 = true; + + radioBtn1.addActionListener(actLrRB1); + radioBtn2.addActionListener(actLrRB2); + radioBtn3.addActionListener(actLrRB3); + + hitKey(robot, KeyEvent.VK_DOWN); + hitKey(robot, KeyEvent.VK_DOWN); + hitKey(robot, KeyEvent.VK_DOWN); + + String failMessage = "ActionListener not invoked when selected using arrow key."; + if (!actRB2) { + throw new RuntimeException("RadioButton 2: " + failMessage); + } + if (!actRB3) { + throw new RuntimeException("RadioButton 3: " + failMessage); + } + if (!actRB1) { + throw new RuntimeException("RadioButton 1: " + failMessage); + } + + radioBtn1.removeActionListener(actLrRB1); + radioBtn2.removeActionListener(actLrRB2); + radioBtn3.removeActionListener(actLrRB3); + } + private static void hitKey(Robot robot, int keycode) { robot.keyPress(keycode); robot.keyRelease(keycode); diff --git a/test/javax/swing/JTextPane/TestJTextPaneHTMLRendering.java b/test/javax/swing/JTextPane/TestJTextPaneHTMLRendering.java new file mode 100644 index 0000000000000000000000000000000000000000..a0b889ada51537852d8b263df81e29aafb94763e --- /dev/null +++ b/test/javax/swing/JTextPane/TestJTextPaneHTMLRendering.java @@ -0,0 +1,173 @@ +/* + * 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 8224475 + * @summary Verify that JTextPane renders images properly for HTML text + * @run main/manual TestJTextPaneHTMLRendering + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.Image; +import java.net.URL; +import java.util.Dictionary; +import java.util.Hashtable; +import javax.swing.JButton; +import javax.swing.JTextArea; +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JTextPane; +import javax.swing.text.EditorKit; +import javax.swing.SwingUtilities; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + + +public class TestJTextPaneHTMLRendering { + private static JFrame mainFrame = new JFrame(); + private static Dictionary cache; + private static JTextPane textPane; + private static URL urlArrow; + + private static volatile boolean testResult = false; + private static volatile CountDownLatch countDownLatch; + private static final String INSTRUCTIONS = "INSTRUCTIONS:\n\n" + + "Verify that the JTextPane is filled with green arrow images.\n" + + "There should be 200 images (10 rows of 20 images each).\n" + + "This test will run for 10 iterations and the current iteration\n" + + "is being displayed at top of JTextPane. JTextpane will be\n" + + "repainted each time and should have same output\n"+ + "If yes, Press Pass, Otherwise, Press Fail.\n"; + + public static void main(String args[]) throws Exception { + urlArrow = new URL("http:\\arrow.png"); + countDownLatch = new CountDownLatch(1); + + SwingUtilities.invokeLater(TestJTextPaneHTMLRendering::createUI); + countDownLatch.await(15, TimeUnit.MINUTES); + SwingUtilities.invokeLater(mainFrame::dispose); + + if (!testResult) { + throw new RuntimeException("Test failed!"); + } + } + + private static void createUI() { + JPanel mainControlPanel = new JPanel(new BorderLayout(20, 20)); + JPanel resultButtonPanel = new JPanel(new GridBagLayout()); + + createTestUI(mainControlPanel); + + JTextArea instructionTextArea = new JTextArea(); + instructionTextArea.setText(INSTRUCTIONS); + instructionTextArea.setEditable(false); + instructionTextArea.setBackground(Color.white); + mainControlPanel.add(instructionTextArea, BorderLayout.NORTH); + + JButton passButton = new JButton("Pass"); + passButton.setActionCommand("Pass"); + passButton.addActionListener((ActionEvent e) -> { + testResult = true; + countDownLatch.countDown(); + + }); + + JButton failButton = new JButton("Fail"); + failButton.setActionCommand("Fail"); + failButton.addActionListener(e -> { + countDownLatch.countDown(); + }); + + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + + resultButtonPanel.add(passButton, gbc); + + gbc.gridx = 1; + gbc.gridy = 0; + resultButtonPanel.add(failButton, gbc); + + mainControlPanel.add(resultButtonPanel, BorderLayout.SOUTH); + + mainFrame.add(mainControlPanel); + mainFrame.pack(); + + mainFrame.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + mainFrame.dispose(); + countDownLatch.countDown(); + } + }); + mainFrame.setVisible(true); + } + + static void createTestUI(JPanel panel) { + textPane = new JTextPane(); + panel.add(textPane, BorderLayout.CENTER); + + final EditorKit l_kit = textPane.getEditorKitForContentType("text/html"); + textPane.setEditable(false); + textPane.setEditorKit(l_kit); + cache = (Dictionary)textPane.getDocument().getProperty("imageCache"); + if (cache==null) { + cache=new Hashtable(); + textPane.getDocument().putProperty("imageCache",cache); + } + + URL arrowLocationUrl = TestJTextPaneHTMLRendering.class.getResource("arrow.png"); + ImageIcon imageIcon = new ImageIcon(arrowLocationUrl); + Image image = imageIcon.getImage(); + Image scaledImage = image.getScaledInstance(24, 24, java.awt.Image.SCALE_SMOOTH); + cache.put(urlArrow, scaledImage); + new Thread(TestJTextPaneHTMLRendering::runTest).start(); + } + + static void runTest() { + for (int i=0; i < 10; i++) + { + StringBuffer sb = new StringBuffer(); + sb.append("
    Iteration " + (i+1) + " -> " + "
    "); + for (int j=1;j<201;j++) + { + sb.append(""); + if (j%20 == 0) sb.append("
    "); + } + textPane.setText(sb.toString()); + textPane.validate(); + textPane.repaint(); + try { + Thread.currentThread().sleep(1000); + } catch (InterruptedException e) { System.err.println(e); } + } + } +} diff --git a/test/javax/swing/JTextPane/arrow.png b/test/javax/swing/JTextPane/arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..472d385331d84173d00c8b26adecea838823d58f Binary files /dev/null and b/test/javax/swing/JTextPane/arrow.png differ diff --git a/test/javax/swing/text/html/TestJLabelWithHTMLText.java b/test/javax/swing/text/html/TestJLabelWithHTMLText.java new file mode 100644 index 0000000000000000000000000000000000000000..6fa70df83cc8050e0654e0b99ee62e18ee4286a1 --- /dev/null +++ b/test/javax/swing/text/html/TestJLabelWithHTMLText.java @@ -0,0 +1,51 @@ +/* + * 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 8230235 8235744 + * @summary Tests if JLabel with HTML text having empty img tag and + * documentBaseKey set renders properly without NPE + * @run main TestJLabelWithHTMLText + */ +import java.net.MalformedURLException; +import java.net.URL; +import javax.swing.JLabel; +import javax.swing.SwingUtilities; +import javax.swing.plaf.basic.BasicHTML; + +public class TestJLabelWithHTMLText { + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(() -> { + JLabel label = new JLabel(); + try { + label.putClientProperty(BasicHTML.documentBaseKey, + new URL("http://localhost")); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + label.setText(""); + }); + } +} diff --git a/test/javax/swing/text/html/parser/Parser/8078268/bug8078268.java b/test/javax/swing/text/html/parser/Parser/8078268/bug8078268.java index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..216919b21372373865ea2976bb6a95513b691a40 100644 --- a/test/javax/swing/text/html/parser/Parser/8078268/bug8078268.java +++ b/test/javax/swing/text/html/parser/Parser/8078268/bug8078268.java @@ -0,0 +1,72 @@ +/* +* 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. +*/ + + +import java.io.File; +import java.io.FileReader; +import javax.swing.SwingUtilities; +import javax.swing.text.Document; +import javax.swing.text.html.HTMLEditorKit; + +/* @test + @bug 8078268 + @summary javax.swing.text.html.parser.Parser parseScript incorrectly optimized + @author Mikhail Cherkasov + @run main bug8078268 +*/ +public class bug8078268 { + static volatile boolean parsingDone = false; + static volatile Exception exception; + + public static void main(String[] args) throws Exception { + long s = System.currentTimeMillis(); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + HTMLEditorKit htmlKit = new HTMLEditorKit(); + Document doc = htmlKit.createDefaultDocument(); + try { + htmlKit.read(new FileReader(getDirURL() + "slowparse.html"), doc, 0); + parsingDone = true; + } catch (Exception e) { + exception = e; + } + } + }); + while (!parsingDone && exception == null && System.currentTimeMillis() - s < 5_000) { + Thread.sleep(200); + } + final long took = System.currentTimeMillis() - s; + if (exception != null) { + throw exception; + } + if (took > 5_000) { + throw new RuntimeException("Parsing takes too long."); + } + } + + static String getDirURL() { + return new File(System.getProperty("test.src", ".")).getAbsolutePath() + + File.separator; + } +} diff --git a/test/javax/swing/text/html/parser/Parser/8078268/slowparse.html b/test/javax/swing/text/html/parser/Parser/8078268/slowparse.html index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e6c446c49001bbb15a67140f372b5541c3b84c04 100644 --- a/test/javax/swing/text/html/parser/Parser/8078268/slowparse.html +++ b/test/javax/swing/text/html/parser/Parser/8078268/slowparse.html @@ -0,0 +1,3539 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + --> + var b = 2; + + + + + diff --git a/test/javax/xml/crypto/dsig/ErrorHandlerPermissions.java b/test/javax/xml/crypto/dsig/ErrorHandlerPermissions.java new file mode 100644 index 0000000000000000000000000000000000000000..1231d3cfe3352e439398b6612d317777da9410cc --- /dev/null +++ b/test/javax/xml/crypto/dsig/ErrorHandlerPermissions.java @@ -0,0 +1,121 @@ +/* + * 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. 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.io.ByteArrayInputStream; +import java.io.File; +import java.security.KeyFactory; +import java.security.PublicKey; +import java.security.spec.X509EncodedKeySpec; +import java.util.Base64; +import javax.xml.XMLConstants; +import javax.xml.crypto.Data; +import javax.xml.crypto.KeySelector; +import javax.xml.crypto.OctetStreamData; +import javax.xml.crypto.URIDereferencer; +import javax.xml.crypto.URIReference; +import javax.xml.crypto.URIReferenceException; +import javax.xml.crypto.XMLCryptoContext; +import javax.xml.crypto.dsig.XMLSignature; +import javax.xml.crypto.dsig.XMLSignatureFactory; +import javax.xml.crypto.dsig.dom.DOMValidateContext; +import javax.xml.parsers.DocumentBuilderFactory; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +/** + * @test + * @bug 8079140 + * @summary Check if IgnoreAllErrorHandler doesn't require additional permission + * @run main/othervm/java.security.policy=ErrorHandlerPermissions.policy + * ErrorHandlerPermissions + */ +public class ErrorHandlerPermissions { + + private final static String FS = System.getProperty("file.separator"); + private final static String DIR = System.getProperty("test.src", "."); + private final static String DATA_DIR = DIR + FS + "data"; + private final static String SIGNATURE = DATA_DIR + FS + + "signature-external-rsa.xml"; + + private static final String validationKey = + "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCnx4TdvPSA5vcsPi0OJZi9Ox0Z" + + "2FRz2oeUCtuWoyEg0kUCeFd+jJZMstDJUiZNSOeuCO3FWSpdJgAwI4zlveHvuU/o" + + "qHSa1eYTObOCvxfVYGGflWsSvGXyiANtRWVUrYODBeyL+2pWxDYh+Fi5EKizPfTG" + + "wRjBVRSkRZKTnSjnQwIDAQAB"; + + private static final URIDereferencer dereferencer = + new DummyURIDereferencer(); + + public static void main(String[] args) throws Exception { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setNamespaceAware(true); + dbf.setValidating(false); + dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE); + Document doc = dbf.newDocumentBuilder().parse(new File(SIGNATURE)); + NodeList nl = doc.getElementsByTagNameNS(XMLSignature.XMLNS, + "Signature"); + if (nl.getLength() == 0) { + throw new RuntimeException("Couldn't find 'Signature' element"); + } + Element element = (Element) nl.item(0); + + byte[] keyBytes = Base64.getDecoder().decode(validationKey); + X509EncodedKeySpec spec = new X509EncodedKeySpec(keyBytes); + KeyFactory kf = KeyFactory.getInstance("RSA"); + PublicKey key = kf.generatePublic(spec); + KeySelector ks = KeySelector.singletonKeySelector(key); + + DOMValidateContext vc = new DOMValidateContext(ks, element); + + // disable secure validation mode + vc.setProperty("org.jcp.xml.dsig.secureValidation", Boolean.FALSE); + + // set a dummy dereferencer to be able to get content by references + vc.setURIDereferencer(dereferencer); + + XMLSignatureFactory factory = XMLSignatureFactory.getInstance(); + XMLSignature signature = factory.unmarshalXMLSignature(vc); + + // run validation + signature.validate(vc); + } + + /** + * This URIDereferencer returns a static XML document. + */ + private static class DummyURIDereferencer implements URIDereferencer { + + @Override + public Data dereference(final URIReference ref, XMLCryptoContext ctx) + throws URIReferenceException { + // return static content + return new OctetStreamData(new ByteArrayInputStream( + "test".getBytes()), ref.getURI(), + ref.getType()); + } + } + +} diff --git a/test/javax/xml/crypto/dsig/ErrorHandlerPermissions.policy b/test/javax/xml/crypto/dsig/ErrorHandlerPermissions.policy new file mode 100644 index 0000000000000000000000000000000000000000..8db9c01c3c805b424221794a38bfc3042d521292 --- /dev/null +++ b/test/javax/xml/crypto/dsig/ErrorHandlerPermissions.policy @@ -0,0 +1,5 @@ +grant { + permission java.util.PropertyPermission "test.src", "read"; + permission java.util.PropertyPermission "file.separator", "read"; + permission java.io.FilePermission "${test.src}/-", "read"; +}; diff --git a/test/javax/xml/crypto/dsig/GenerationTests.java b/test/javax/xml/crypto/dsig/GenerationTests.java index 4a3e1919a303a5afeda253762a879d78994330c2..1a2184ae711a0d32e6465f5083331b1cbefd4fb0 100644 --- a/test/javax/xml/crypto/dsig/GenerationTests.java +++ b/test/javax/xml/crypto/dsig/GenerationTests.java @@ -24,7 +24,7 @@ /** * @test * @bug 4635230 6283345 6303830 6824440 6867348 7094155 8038184 - * 8038349 8074784 8210736 + * 8038349 8046724 8074784 8079693 8210736 * @summary Basic unit tests for generating XML Signatures with JSR 105 * @compile -XDignore.symbol.file KeySelectors.java SignatureValidator.java * X509KeySelector.java GenerationTests.java @@ -54,6 +54,13 @@ import java.security.cert.X509CRL; import java.security.spec.KeySpec; import java.security.spec.DSAPrivateKeySpec; import java.security.spec.DSAPublicKeySpec; +import java.security.spec.ECField; +import java.security.spec.ECFieldFp; +import java.security.spec.ECParameterSpec; +import java.security.spec.ECPoint; +import java.security.spec.ECPrivateKeySpec; +import java.security.spec.ECPublicKeySpec; +import java.security.spec.EllipticCurve; import java.security.spec.RSAPrivateKeySpec; import java.security.spec.RSAPublicKeySpec; import java.util.*; @@ -91,9 +98,11 @@ public class GenerationTests { private static DocumentBuilder db; private static CanonicalizationMethod withoutComments; private static SignatureMethod dsaSha1, dsaSha256, rsaSha1, - rsaSha256, rsaSha384, rsaSha512; + rsaSha256, rsaSha384, rsaSha512, + ecdsaSha1; private static DigestMethod sha1, sha256, sha384, sha512; - private static KeyInfo dsa1024, dsa2048, rsa, rsa1024; + private static KeyInfo dsa1024, dsa2048, rsa, rsa1024, + p256ki, p384ki, p521ki; private static KeySelector kvks = new KeySelectors.KeyValueKeySelector(); private static KeySelector sks; private static Key signingKey; @@ -201,6 +210,9 @@ public class GenerationTests { test_create_signature_enveloping_hmac_sha384(); test_create_signature_enveloping_hmac_sha512(); test_create_signature_enveloping_rsa(); + test_create_signature_enveloping_p256_sha1(); + test_create_signature_enveloping_p384_sha1(); + test_create_signature_enveloping_p521_sha1(); test_create_signature_external_b64_dsa(); test_create_signature_external_dsa(); test_create_signature_keyname(); @@ -346,6 +358,12 @@ public class GenerationTests { (kifac.newKeyValue(getPublicKey("RSA", 512)))); rsa1024 = kifac.newKeyInfo(Collections.singletonList (kifac.newKeyValue(getPublicKey("RSA", 1024)))); + p256ki = kifac.newKeyInfo(Collections.singletonList + (kifac.newKeyValue(getECPublicKey("P256")))); + p384ki = kifac.newKeyInfo(Collections.singletonList + (kifac.newKeyValue(getECPublicKey("P384")))); + p521ki = kifac.newKeyInfo(Collections.singletonList + (kifac.newKeyValue(getECPublicKey("P521")))); rsaSha1 = fac.newSignatureMethod(SignatureMethod.RSA_SHA1, null); rsaSha256 = fac.newSignatureMethod ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256", null); @@ -353,6 +371,8 @@ public class GenerationTests { ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha384", null); rsaSha512 = fac.newSignatureMethod ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha512", null); + ecdsaSha1 = fac.newSignatureMethod + ("http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1", null); sks = new KeySelectors.SecretKeySelector("secret".getBytes("ASCII")); httpUd = new HttpURIDereferencer(); @@ -513,6 +533,27 @@ public class GenerationTests { System.out.println(); } + static void test_create_signature_enveloping_p256_sha1() throws Exception { + System.out.println("* Generating signature-enveloping-p256-sha1.xml"); + test_create_signature_enveloping(sha1, ecdsaSha1, p256ki, + getECPrivateKey("P256"), kvks, false); + System.out.println(); + } + + static void test_create_signature_enveloping_p384_sha1() throws Exception { + System.out.println("* Generating signature-enveloping-p384-sha1.xml"); + test_create_signature_enveloping(sha1, ecdsaSha1, p384ki, + getECPrivateKey("P384"), kvks, false); + System.out.println(); + } + + static void test_create_signature_enveloping_p521_sha1() throws Exception { + System.out.println("* Generating signature-enveloping-p521-sha1.xml"); + test_create_signature_enveloping(sha1, ecdsaSha1, p521ki, + getECPrivateKey("P521"), kvks, false); + System.out.println(); + } + static void test_create_signature_external_b64_dsa() throws Exception { System.out.println("* Generating signature-external-b64-dsa.xml"); test_create_signature_external(dsaSha1, dsa1024, signingKey, kvks, true); @@ -1526,7 +1567,68 @@ public class GenerationTests { "237008997971129772408397621801631622129297063463868593083106979716" + "204903524890556839550490384015324575598723478554854070823335021842" + "210112348400928769"; + private static final String EC_P256_X = + "335863644451761614592446380116804721648611739647823420286081723541" + + "6166183710"; + private static final String EC_P256_Y = + "951559601159729477487064127150143688502130342917782252098602422796" + + "95457910701"; + private static final String EC_P256_S = + "425976209773168452211813225517384419928639977904006759709292218082" + + "7440083936"; + private static final ECParameterSpec EC_P256_PARAMS = initECParams( + "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF", + "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC", + "5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B", + "6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296", + "4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5", + "FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551", + 1 + ); + private static final String EC_P384_X = + "12144058647679082341340699736608428955270957565259459672517275506071643671835484144490620216582303669654008841724053"; + private static final String EC_P384_Y = + "18287745972107701566600963632634101287058332546756092926848497481238534346489545826483592906634896557151987868614320"; + private static final String EC_P384_S = + "10307785759830534742680442271492590599236624208247590184679565032330507874096079979152605984203102224450595283943382"; + private static final ECParameterSpec EC_P384_PARAMS = initECParams( + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF", + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC", + "B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF", + "AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7", + "3617DE4A96262C6F5D9E98BF9292DC29F8F41DBD289A147CE9DA3113B5F0B8C00A60B1CE1D7E819D7A431D7C90EA0E5F", + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973", + 1 + ); + private static final String EC_P521_X = + "4157918188927862838251799402582135611021257663417126086145819679867926857146776190737187582274664373117054717389603317411991660346043842712448912355335343997"; + private static final String EC_P521_Y = + "4102838062751704796157456866854813794620023146924181568434486703918224542844053923233919899911519054998554969832861957437850996213216829205401947264294066288"; + private static final String EC_P521_S = + "4857798533181496041050215963883119936300918353498701880968530610687256097257307590162398707429640390843595868713096292822034014722985178583665959048714417342"; + private static final ECParameterSpec EC_P521_PARAMS = initECParams( + "01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", + "01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC", + "0051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00", + "00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66", + "011839296A789A3BC0045C8A5FB42C7D1BD998F54449579B446817AFBD17273E662C97EE72995EF42640C550B9013FAD0761353C7086A272C24088BE94769FD16650", + "01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409", + 1 + ); + + private static ECParameterSpec initECParams( + String sfield, String a, String b, String gx, String gy, + String n, int h) { + ECField field = new ECFieldFp(bigInt(sfield)); + EllipticCurve curve = new EllipticCurve(field, + bigInt(a), bigInt(b)); + ECPoint g = new ECPoint(bigInt(gx), bigInt(gy)); + return new ECParameterSpec(curve, g, bigInt(n), h); + } + private static BigInteger bigInt(String s) { + return new BigInteger(s, 16); + } private static PublicKey getPublicKey(String algo, int keysize) throws Exception { KeyFactory kf = KeyFactory.getInstance(algo); @@ -1555,6 +1657,35 @@ public class GenerationTests { return kf.generatePublic(kspec); } + private static PublicKey getECPublicKey(String curve) throws Exception { + KeyFactory kf = KeyFactory.getInstance("EC"); + String x, y; + ECParameterSpec params; + switch (curve) { + case "P256": + x = EC_P256_X; + y = EC_P256_Y; + params = EC_P256_PARAMS; + break; + case "P384": + x = EC_P384_X; + y = EC_P384_Y; + params = EC_P384_PARAMS; + break; + case "P521": + x = EC_P521_X; + y = EC_P521_Y; + params = EC_P521_PARAMS; + break; + default: + throw new Exception("Unsupported curve: " + curve); + } + KeySpec kspec = new ECPublicKeySpec(new ECPoint(new BigInteger(x), + new BigInteger(y)), + params); + return kf.generatePublic(kspec); + } + private static PrivateKey getPrivateKey(String algo, int keysize) throws Exception { KeyFactory kf = KeyFactory.getInstance(algo); @@ -1581,6 +1712,30 @@ public class GenerationTests { return kf.generatePrivate(kspec); } + private static PrivateKey getECPrivateKey(String curve) throws Exception { + String s; + ECParameterSpec params; + switch (curve) { + case "P256": + s = EC_P256_S; + params = EC_P256_PARAMS; + break; + case "P384": + s = EC_P384_S; + params = EC_P384_PARAMS; + break; + case "P521": + s = EC_P521_S; + params = EC_P521_PARAMS; + break; + default: + throw new Exception("Unsupported curve: " + curve); + } + KeyFactory kf = KeyFactory.getInstance("EC"); + KeySpec kspec = new ECPrivateKeySpec(new BigInteger(s), params); + return kf.generatePrivate(kspec); + } + private static SecretKey getSecretKey(final byte[] secret) { return new SecretKey() { public String getFormat() { return "RAW"; } diff --git a/test/javax/xml/crypto/dsig/KeySelectors.java b/test/javax/xml/crypto/dsig/KeySelectors.java index 290c55b89dac329f725b39800052d7cd9ed25710..2195b8ce2a3f3a350612147b895b84ae8da0fda3 100644 --- a/test/javax/xml/crypto/dsig/KeySelectors.java +++ b/test/javax/xml/crypto/dsig/KeySelectors.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -172,7 +172,6 @@ class KeySelectors { throw new KeySelectorException("No KeyValue element found!"); } - //@@@FIXME: this should also work for key types other than DSA/RSA static boolean algEquals(String algURI, String algName) { if (algName.equalsIgnoreCase("DSA") && algURI.equals(SignatureMethod.DSA_SHA1) || @@ -187,6 +186,10 @@ class KeySelectors { algURI.equals ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha512"))) { return true; + } else if (algName.equalsIgnoreCase("EC") && + (algURI.equals + ("http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1"))) { + return true; } else { return false; } diff --git a/test/javax/xml/crypto/dsig/ValidationTests.java b/test/javax/xml/crypto/dsig/ValidationTests.java index 278d64c324151ea0aee991c41b35f2d04f2736b7..5413d28d2151c7ee292a1c9b17f84028a3246c7e 100644 --- a/test/javax/xml/crypto/dsig/ValidationTests.java +++ b/test/javax/xml/crypto/dsig/ValidationTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -23,7 +23,7 @@ /** * @test - * @bug 4635230 6365103 6366054 6824440 7131084 + * @bug 4635230 6365103 6366054 6824440 7131084 8046724 8079693 * @summary Basic unit tests for validating XML Signatures with JSR 105 * @compile -XDignore.symbol.file KeySelectors.java SignatureValidator.java * X509KeySelector.java ValidationTests.java @@ -99,6 +99,9 @@ public class ValidationTests { new Test("signature-enveloping-b64-dsa.xml", KVKS), new Test("signature-enveloping-dsa.xml", KVKS), new Test("signature-enveloping-rsa.xml", KVKS), + new Test("signature-enveloping-p256-sha1.xml", KVKS), + new Test("signature-enveloping-p384-sha1.xml", KVKS), + new Test("signature-enveloping-p521-sha1.xml", KVKS), new Test("signature-enveloping-hmac-sha1.xml", SKKS), new Test("signature-external-dsa.xml", KVKS), new Test("signature-external-b64-dsa.xml", KVKS), diff --git a/test/javax/xml/crypto/dsig/data/signature-enveloping-p256-sha1.xml b/test/javax/xml/crypto/dsig/data/signature-enveloping-p256-sha1.xml new file mode 100644 index 0000000000000000000000000000000000000000..0ace1157be583b57716ce61c33011a7a58fa9093 --- /dev/null +++ b/test/javax/xml/crypto/dsig/data/signature-enveloping-p256-sha1.xml @@ -0,0 +1,3 @@ +7/XTsHaBSOnJ/jXD5v0zL6VKYsk=WiF/Hd0s7BiH36Ds/1iJcbKiXOUVBSGFteuTjXwBbezR43NAwpMmMX5c1su0A9hG9rVVzE/1DOlO +vuDVLBBblg==BAds672US3sCYunM2k2bEQLbuRxdQlNTvq+5fitOpDMe0mBdZV4J3yZaG0taziYIuAT9GJGfds+q +xtXOCNWe/60=some text \ No newline at end of file diff --git a/test/javax/xml/crypto/dsig/data/signature-enveloping-p384-sha1.xml b/test/javax/xml/crypto/dsig/data/signature-enveloping-p384-sha1.xml new file mode 100644 index 0000000000000000000000000000000000000000..115a5ae5c0a57136ce8f093c51013ea9b015765e --- /dev/null +++ b/test/javax/xml/crypto/dsig/data/signature-enveloping-p384-sha1.xml @@ -0,0 +1,3 @@ +7/XTsHaBSOnJ/jXD5v0zL6VKYsk=s15F4ng4a+TfNHlK+y18igexSe3wRspeyQi8hwhyMUh6I6kyzxO1wcqRulFyBNwh/Dplht+WS9dO +GwL4xfDfozKss36ZsHACI3EYe0QI6pN7hcKp511muPI+cmoZzIN/BE7my2bSrGpZ3jNFQ1I6baGP9CE4AIMIyN/ugWhbsCQz8ntwXf15NStBt9MBXolglXbRYMqV8vYB +f7UJ1ixum8hzcEvgShn0L9l1VkWaU4bYr/Ss9ApimDvbF2g6Mw++sA==some text \ No newline at end of file diff --git a/test/javax/xml/crypto/dsig/data/signature-enveloping-p521-sha1.xml b/test/javax/xml/crypto/dsig/data/signature-enveloping-p521-sha1.xml new file mode 100644 index 0000000000000000000000000000000000000000..a4b60282cba1c18fb24f33dab8962e8fd4d4152b --- /dev/null +++ b/test/javax/xml/crypto/dsig/data/signature-enveloping-p521-sha1.xml @@ -0,0 +1,5 @@ +7/XTsHaBSOnJ/jXD5v0zL6VKYsk=AaVkRumHXD0vVtkn2ogcAoByVge1KWGVWE6vph+xr/hcZTqNNaiIyXb7Itu0FBHD9M47T/CuM7y4 +m60zEssaaHl0AUNm7xGpZy7Heqaoibb/gMU1ErrfSNs7yuPG/TCqs8YAd3RGnc6ZbloitWpycGCU +LS4xxKms0KeRnbVpjk5OeVfKBAE2HJjBQRbl0sdGa1+1cJwxtPJXcnrRdmRXs6TEQmU97US+CK0vsoDQtlnXxDx37mawN7Sh4Atp +CUeYBbzvBmwPfQEyAO600W9xn4s5wSQvXod8v8brh5ISXhxYPFy3SCcGUxbQYqrVUnBrIXH8WEQX +K0/T+FdF4CzlQswJY0UZGeQYcA==some text \ No newline at end of file diff --git a/test/javax/xml/crypto/dsig/data/signature-external-rsa.xml b/test/javax/xml/crypto/dsig/data/signature-external-rsa.xml new file mode 100644 index 0000000000000000000000000000000000000000..fb3a0f4f986b445ca0d43d5cfa03b031b81879ac --- /dev/null +++ b/test/javax/xml/crypto/dsig/data/signature-external-rsa.xml @@ -0,0 +1,3 @@ +test1Bq8FsjajUBYPD7stQeJSc66GlM=f6trDCcPsLLkIV/V4DGFbRf8b9Jwal8xGBDshNzEXwPmym2ChN85rbKIg/cbunf04F89/SXLo2v9 +AYjLcUr3G/Vz5YUmqNhnBvJukXgsIG0ddWl3mFi9Tk+CLINlbgfsaFqU9pQwFjmDyAqIrvZYqW7p +rTHLetv218mbUVBBAkc= \ No newline at end of file diff --git a/test/javax/xml/jaxp/parsers/8213734/SAXParserTest.java b/test/javax/xml/jaxp/parsers/8213734/SAXParserTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2b93ff9e7215e804eaa09874a99acdf3925555f0 --- /dev/null +++ b/test/javax/xml/jaxp/parsers/8213734/SAXParserTest.java @@ -0,0 +1,79 @@ +/* + * 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.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +/* + * @test + * @bug 8213734 + * @run main/othervm SAXParserTest + * @summary Verifies that files opened by the SAXParser is closed when Exception + */ +public class SAXParserTest { + + public void testCloseReaders() throws Exception { + if (!System.getProperty("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.newInstance(); + 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 = "" + .getBytes(StandardCharsets.UTF_8); + + Files.write(path, bytes); + return path; + } + + public static void main(String[] args) throws Exception { + SAXParserTest test = new SAXParserTest(); + test.testCloseReaders(); + } +} diff --git a/test/jdk/java/awt/FontClass/GlyphRotationTest.java b/test/jdk/java/awt/FontClass/GlyphRotationTest.java deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/test/jdk/java/awt/font/Rotate/RotatedFontMetricsTest.java b/test/jdk/java/awt/font/Rotate/RotatedFontMetricsTest.java deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/test/jdk/jfr/TEST.properties b/test/jdk/jfr/TEST.properties new file mode 100644 index 0000000000000000000000000000000000000000..826f997c3c5c08a27397919324c41528ef4265c2 --- /dev/null +++ b/test/jdk/jfr/TEST.properties @@ -0,0 +1,2 @@ +modules = jdk.jfr + diff --git a/test/jdk/jfr/api/consumer/TEST.properties b/test/jdk/jfr/api/consumer/TEST.properties new file mode 100644 index 0000000000000000000000000000000000000000..81cb3fce7197da13f7b9a0d3ff86693188e12c9c --- /dev/null +++ b/test/jdk/jfr/api/consumer/TEST.properties @@ -0,0 +1,2 @@ +modules = java.management + diff --git a/test/jdk/jfr/api/consumer/TestFieldAccess.java b/test/jdk/jfr/api/consumer/TestFieldAccess.java new file mode 100644 index 0000000000000000000000000000000000000000..a545bf9c264e2aa312d4c912ff369b58399b2943 --- /dev/null +++ b/test/jdk/jfr/api/consumer/TestFieldAccess.java @@ -0,0 +1,151 @@ +/* + * 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.api.consumer; + +import java.util.List; + +import jdk.jfr.Event; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedClass; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedThread; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.consumer.TestFieldAccess + */ +public class TestFieldAccess { + + private static class MyEvent extends Event { + String stringField = "Hello"; + int intField = 4711; + long longField = 4712L; + short shortField = (short)67; + double doubleField = Double.NaN; + float floatField = Float.MIN_VALUE; + boolean booleanField = false; + Thread threadField = Thread.currentThread(); + Class classField = MyEvent.class; + } + + public static void main(String[] args) throws Throwable { + try (Recording r = new Recording()) { + r.enable(MyEvent.class); + r.start(); + MyEvent myEvent = new MyEvent(); + myEvent.commit(); + r.stop(); + List events = Events.fromRecording(r); + Events.hasEvents(events); + RecordedEvent event = events.get(0); + testHasField(event); + testGetField(event, myEvent); + } + } + + private static void testGetField(RecordedEvent event, MyEvent myEvent) { + String stringField = event.getValue("stringField"); + Asserts.assertEquals(stringField, myEvent.stringField); + + int intField = event.getValue("intField"); + Asserts.assertEquals(intField, myEvent.intField); + + long longField = event.getValue("longField"); + Asserts.assertEquals(longField, myEvent.longField); + + short shortField = event.getValue("shortField"); + Asserts.assertEquals(shortField, myEvent.shortField); + + double doubleField = event.getValue("doubleField"); + Asserts.assertEquals(doubleField, myEvent.doubleField); + + float floatField = event.getValue("floatField"); + Asserts.assertEquals(floatField, myEvent.floatField); + + boolean booleanField = event.getValue("booleanField"); + Asserts.assertEquals(booleanField, myEvent.booleanField); + + RecordedThread threadField = event.getValue("eventThread"); + Asserts.assertEquals(threadField.getJavaName(), myEvent.threadField.getName()); + String threadGroupName = event.getValue("eventThread.group.name"); + Asserts.assertEquals(threadField.getThreadGroup().getName(), threadGroupName); + + RecordedClass classField = event.getValue("classField"); + Asserts.assertEquals(classField.getName(), myEvent.classField.getName()); + String className = event.getValue("classField.name"); + Asserts.assertEquals(classField.getName(), className.replace("/", ".")); + + + try { + event.getValue("doesnotexist"); + } catch (IllegalArgumentException iae) { + // as expected + } + + try { + event.getValue("classField.doesnotexist"); + } catch (IllegalArgumentException iae) { + // as expected + } + + try { + event.getValue(null); + } catch (NullPointerException npe) { + // as expected + } + } + + private static void testHasField(RecordedEvent event) { + System.out.println(event); + Asserts.assertTrue(event.hasField("stringField")); + Asserts.assertTrue(event.hasField("intField")); + Asserts.assertTrue(event.hasField("longField")); + Asserts.assertTrue(event.hasField("shortField")); + Asserts.assertTrue(event.hasField("doubleField")); + Asserts.assertTrue(event.hasField("floatField")); + Asserts.assertTrue(event.hasField("threadField")); + Asserts.assertTrue(event.hasField("classField")); + Asserts.assertTrue(event.hasField("classField.name")); + Asserts.assertTrue(event.hasField("eventThread")); + Asserts.assertTrue(event.hasField("eventThread.group.name")); + Asserts.assertTrue(event.hasField("startTime")); + Asserts.assertTrue(event.hasField("stackTrace")); + Asserts.assertTrue(event.hasField("duration")); + Asserts.assertFalse(event.hasField("doesNotExist")); + Asserts.assertFalse(event.hasField("classField.doesNotExist")); + Asserts.assertFalse(event.hasField("")); + try { + event.hasField(null); + } catch (NullPointerException npe) { + // as expected + } + } +} diff --git a/test/jdk/jfr/api/consumer/TestGetStackTrace.java b/test/jdk/jfr/api/consumer/TestGetStackTrace.java new file mode 100644 index 0000000000000000000000000000000000000000..93a10c8f1eac6d48149f52ab80d2a724be924bf7 --- /dev/null +++ b/test/jdk/jfr/api/consumer/TestGetStackTrace.java @@ -0,0 +1,103 @@ +/* + * 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.api.consumer; + +import static jdk.test.lib.Asserts.assertEquals; +import static jdk.test.lib.Asserts.assertNotNull; +import static jdk.test.lib.Asserts.assertNull; +import static jdk.test.lib.Asserts.assertTrue; + +import java.util.List; +import java.util.function.Consumer; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedFrame; +import jdk.jfr.consumer.RecordedMethod; +import jdk.jfr.consumer.RecordedStackTrace; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.SimpleEvent; + +/** + * @test + * @summary Verifies that a recorded JFR event has the correct stack trace info + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.consumer.TestGetStackTrace + */ +public class TestGetStackTrace { + + public static void main(String[] args) throws Throwable { + testStackTrace(r -> r.enable(SimpleEvent.class), TestGetStackTrace::assertNoStackTrace); + testStackTrace(r -> r.enable(SimpleEvent.class).withoutStackTrace(), TestGetStackTrace::assertStackTrace); + } + + private static void testStackTrace(Consumer recordingConfigurer, Consumer asserter) throws Throwable { + Recording r = new Recording(); + recordingConfigurer.accept(r); + r.start(); + SimpleEvent event = new SimpleEvent(); + event.commit(); + r.stop(); + List events = Events.fromRecording(r); + r.close(); + Events.hasEvents(events); + } + + private static void assertNoStackTrace(RecordedEvent re) { + assertNull(re.getStackTrace()); + } + + private static void assertStackTrace(RecordedEvent re) { + assertNotNull(re.getStackTrace()); + RecordedStackTrace strace = re.getStackTrace(); + assertEquals(strace.isTruncated(), false); + List frames = strace.getFrames(); + assertTrue(frames.size() > 0); + for (RecordedFrame frame : frames) { + assertFrame(frame); + } + } + + private static void assertFrame(RecordedFrame frame) { + int bci = frame.getBytecodeIndex(); + int line = frame.getLineNumber(); + boolean javaFrame = frame.isJavaFrame(); + RecordedMethod method = frame.getMethod(); + String type = frame.getType(); + System.out.println("*** Frame Info ***"); + System.out.println("bci=" + bci); + System.out.println("line=" + line); + System.out.println("type=" + type); + System.out.println("method=" + method); + System.out.println("***"); + Asserts.assertTrue(javaFrame, "Only Java frame are currently supported"); + Asserts.assertGreaterThanOrEqual(bci, -1); + Asserts.assertNotNull(method, "Method should not be null"); + } +} diff --git a/test/jdk/jfr/api/consumer/TestHiddenMethod.java b/test/jdk/jfr/api/consumer/TestHiddenMethod.java new file mode 100644 index 0000000000000000000000000000000000000000..e1bdc54668e41e9bdb0921cf55f588e8167d1e7d --- /dev/null +++ b/test/jdk/jfr/api/consumer/TestHiddenMethod.java @@ -0,0 +1,112 @@ +/* + * 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 + * 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.api.consumer; + +import static jdk.test.lib.Asserts.assertEquals; +import static jdk.test.lib.Asserts.assertFalse; +import static jdk.test.lib.Asserts.assertTrue; + +import java.time.Duration; +import java.util.List; + +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; + +import jdk.jfr.Event; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedFrame; +import jdk.jfr.consumer.RecordedStackTrace; +import jdk.test.lib.jfr.Events; + + +/** + * @test + * @key jfr + * + * + * @library /lib / + * + + * + * @run main/othervm jdk.jfr.api.consumer.TestHiddenMethod + */ +public final class TestHiddenMethod { + + public static void main(String[] args) throws Throwable { + Recording recording = new Recording(); + recording.enable(MyEvent.class).withThreshold(Duration.ofMillis(0)); + recording.start(); + + // Commit event with hidden methods + ScriptEngineManager manager = new ScriptEngineManager(); + ScriptEngine engine = manager.getEngineByName("nashorn"); + engine.eval( + "function emit() {" + + " print('About to emit event from Javascript');" + + " var TestEvent = Java.type(\"jdk.jfr.api.consumer.TestHiddenMethod$MyEvent\");" + + " var event = new TestEvent;" + + " event.begin();" + + " event.end();" + + " event.commit();" + + " print('Event emitted from Javascript!');" + + "}" + + "emit();"); + + // Commit event with visible method + MyEvent visible = new MyEvent(); + visible.begin(); + visible.end(); + visible.commit(); + recording.stop(); + + List events = Events.fromRecording(recording); + assertEquals(2, events.size(), "Expected two events"); + RecordedEvent hiddenEvent = events.get(0); + RecordedEvent visibleEvent = events.get(1); + + System.out.println("hiddenEvent:" + hiddenEvent); + System.out.println("visibleEvent:" + visibleEvent); + + assertTrue(hasHiddenStackFrame(hiddenEvent), "No hidden frame in hidden event: " + hiddenEvent); + assertFalse(hasHiddenStackFrame(visibleEvent), "Hidden frame in visible event: " + visibleEvent); + } + + private static boolean hasHiddenStackFrame(RecordedEvent event) throws Throwable { + RecordedStackTrace stacktrace = event.getStackTrace(); + List frames = stacktrace.getFrames(); + assertFalse(frames.isEmpty(), "Stacktrace frames was empty"); + for (RecordedFrame frame : frames) { + if (frame.getMethod().isHidden()) { + return true; + } + } + return false; + } + + public static class MyEvent extends Event { + } + +} diff --git a/test/jdk/jfr/api/consumer/TestMethodGetModifiers.java b/test/jdk/jfr/api/consumer/TestMethodGetModifiers.java new file mode 100644 index 0000000000000000000000000000000000000000..0d375f0d3eef42bf962c3ea0dfb8d6d0e98d6b31 --- /dev/null +++ b/test/jdk/jfr/api/consumer/TestMethodGetModifiers.java @@ -0,0 +1,81 @@ +/* + * 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. 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.api.consumer; + +import static jdk.test.lib.Asserts.assertNotNull; + +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedClass; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedFrame; +import jdk.jfr.consumer.RecordedMethod; +import jdk.jfr.consumer.RecordedStackTrace; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.SimpleEvent; + + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm -Xint jdk.jfr.api.consumer.TestMethodGetModifiers + */ +public final class TestMethodGetModifiers { + + public static void main(String[] args) throws Throwable { + Recording recording = new Recording(); + recording.start(); + + SimpleEvent ev = new SimpleEvent(); + ev.commit(); + recording.stop(); + + List recordedEvents = Events.fromRecording(recording); + Events.hasEvents(recordedEvents); + RecordedEvent recordedEvent = recordedEvents.get(0); + + System.out.println("recorded event:" + recordedEvent); + + RecordedStackTrace stacktrace = recordedEvent.getStackTrace(); + List frames = stacktrace.getFrames(); + for (RecordedFrame frame : frames) { + RecordedMethod method = frame.getMethod(); + if (method.getName().equals("main")) { + System.out.println("'main' method: " + method); + int modifiers = TestMethodGetModifiers.class.getDeclaredMethod("main", (Class)String[].class).getModifiers(); + System.out.println("modifiers: " + modifiers); + Asserts.assertEquals(method.getModifiers(), modifiers, "Incorrect method modifier reported"); + RecordedClass type = method.getType(); + assertNotNull(type, "Recorded class can not be null"); + } + + } + } + +} diff --git a/test/jdk/jfr/api/consumer/TestReadTwice.java b/test/jdk/jfr/api/consumer/TestReadTwice.java new file mode 100644 index 0000000000000000000000000000000000000000..aa07d854b6d5c011377b3d92037f7a7a770fadd9 --- /dev/null +++ b/test/jdk/jfr/api/consumer/TestReadTwice.java @@ -0,0 +1,85 @@ +/* + * 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.api.consumer; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.LinkedList; +import java.util.List; + +import jdk.jfr.Event; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.Utils; + + +/** + * @test + * @summary Reads the recorded file two times and verifies that both reads are the same + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.consumer.TestReadTwice + */ +public class TestReadTwice { + + private static class MyEvent extends Event { + } + + public static void main(String[] args) throws Throwable { + Recording r = new Recording(); + r.enable(MyEvent.class).withoutStackTrace(); + r.start(); + + // Commit a single event to the recording + MyEvent event = new MyEvent(); + event.commit(); + + r.stop(); + + // Dump the recording to a file + Path path = Utils.createTempFile("read-twice", ".jfr"); + System.out.println("Dumping to " + path); + r.dump(path); + r.close(); + + // Read all events from the file in one go + List events = RecordingFile.readAllEvents(path); + + // Read again the same events one by one + RecordingFile rfile = new RecordingFile(path); + List events2 = new LinkedList<>(); + while (rfile.hasMoreEvents()) { + events2.add(rfile.readEvent()); + } + + // Compare sizes + Asserts.assertEquals(events.size(), events2.size()); + rfile.close(); + } +} diff --git a/test/jdk/jfr/api/consumer/TestRecordedClassLoader.java b/test/jdk/jfr/api/consumer/TestRecordedClassLoader.java new file mode 100644 index 0000000000000000000000000000000000000000..784867025ee01c51d7d71dfa91ab7a5f5f0db86d --- /dev/null +++ b/test/jdk/jfr/api/consumer/TestRecordedClassLoader.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. 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.api.consumer; + +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedClass; +import jdk.jfr.consumer.RecordedClassLoader; +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.jfr.TestClassLoader; + +/** + * @test + * @summary Verifies the methods of the RecordedClassLoader + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.consumer.TestRecordedClassLoader + */ +public class TestRecordedClassLoader { + private final static String TEST_CLASS_NAME = "jdk.jfr.api.consumer.TestRecordedClassLoader$MyTestClass"; + private final static String EVENT_NAME = EventNames.ClassDefine; + + static class MyTestClass { + } + + public static void main(String[] args) throws Exception { + Recording recording = new Recording(); + recording.enable(EVENT_NAME).withoutStackTrace(); + TestClassLoader cl = new TestClassLoader(); + recording.start(); + cl.loadClass(TEST_CLASS_NAME); + recording.stop(); + + List events = Events.fromRecording(recording); + boolean isDefined = false; + for (RecordedEvent event : events) { + RecordedClass definedClass = event.getValue("definedClass"); + if (TEST_CLASS_NAME.equals(definedClass.getName())) { + System.out.println(event); + + // get the RecordedClassLoader from the RecordedClass, the "definedClass" + RecordedClassLoader definingClassLoader = definedClass.getClassLoader(); + Asserts.assertNotNull(definingClassLoader, "Defining Class Loader should not be null"); + + // invoke RecordedClassLoader.getType() in order to validate the type of the RecordedClassLoader + RecordedClass definingClassLoaderType = definingClassLoader.getType(); + Asserts.assertNotNull(definingClassLoaderType, "The defining Class Loader type should not be null"); + + // verify matching types + Asserts.assertEquals(cl.getClass().getName(), definingClassLoaderType.getName(), + "Expected type " + cl.getClass().getName() + ", got type " + definingClassLoaderType.getName()); + + // get a RecordedClassLoader directly from the "definingClassLoader" field as well + RecordedClassLoader definingClassLoaderFromField = event.getValue("definingClassLoader"); + Asserts.assertNotNull(definingClassLoaderFromField, + "Defining Class Loader instantatiated from field should not be null"); + + // ensure that the class loader instance used in the test actually has a name + //Asserts.assertNotNull(cl.getName(), + // "Expected a valid name for the TestClassLoader"); + + // invoke RecordedClassLoader.getName() to get the name of the class loader instance + //Asserts.assertEquals(cl.getName(), definingClassLoader.getName(), + // "Defining Class Loader should have the same name as the original class loader"); + Asserts.assertEquals(definingClassLoaderFromField.getName(), definingClassLoader.getName(), + "Defining Class Loader representations should have the same class loader name"); + + // invoke uniqueID() + Asserts.assertGreaterThan(definingClassLoader.getId(), 0L, "Invalid id assignment"); + + // second order class loader information ("check class loader of the class loader") + RecordedClassLoader classLoaderOfDefClassLoader = definingClassLoaderType.getClassLoader(); + Asserts.assertNotNull(classLoaderOfDefClassLoader, + "The class loader for the definining class loader should not be null"); + // Asserts.assertEquals(cl.getClass().getClassLoader().getName(), classLoaderOfDefClassLoader.getName(), + // "Expected class loader name " + cl.getClass().getClassLoader().getName() + ", got name " + classLoaderOfDefClassLoader.getName()); + + RecordedClass classLoaderOfDefClassLoaderType = classLoaderOfDefClassLoader.getType(); + Asserts.assertNotNull(classLoaderOfDefClassLoaderType, + "The class loader type for the defining class loader should not be null"); + Asserts.assertEquals(cl.getClass().getClassLoader().getClass().getName(), classLoaderOfDefClassLoaderType.getName(), + "Expected type " + cl.getClass().getClassLoader().getClass().getName() + ", got type " + classLoaderOfDefClassLoaderType.getName()); + + Asserts.assertGreaterThan(definingClassLoader.getId(), classLoaderOfDefClassLoader.getId(), + "expected id assignment invariant broken for Class Loaders"); + + isDefined = true; + } + } + Asserts.assertTrue(isDefined, "No class define event found to verify RecordedClassLoader"); + } +} diff --git a/test/jdk/jfr/api/consumer/TestRecordedEvent.java b/test/jdk/jfr/api/consumer/TestRecordedEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..c59cf7faf4247852806012857454fb7d5667eb19 --- /dev/null +++ b/test/jdk/jfr/api/consumer/TestRecordedEvent.java @@ -0,0 +1,110 @@ +/* + * 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.api.consumer; + +import java.util.List; + +import jdk.jfr.Description; +import jdk.jfr.Event; +import jdk.jfr.Recording; +import jdk.jfr.ValueDescriptor; +import jdk.jfr.consumer.RecordedClass; +import jdk.jfr.consumer.RecordedClassLoader; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Verifies the methods of the RecordedEvent + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.consumer.TestRecordedEvent + */ +public class TestRecordedEvent { + + static class MyClass { + } + + static class TestEvent extends Event { + + @Description("MyField") + Class clzField = String.class; + int intField; + String stringField = "myString"; + Class myClass = MyClass.class; + } + + public static void main(String[] args) throws Throwable { + Recording r = new Recording(); + r.start(); + TestEvent t = new TestEvent(); + t.commit(); + r.stop(); + List events = Events.fromRecording(r); + Events.hasEvents(events); + + Asserts.assertEquals(events.size(), 1); + + RecordedEvent event = events.get(0); + + List descriptors = event.getFields(); + + System.out.println("Descriptors"); + for (ValueDescriptor descriptor : descriptors) { + System.out.println(descriptor.getName()); + System.out.println(descriptor.getTypeName()); + } + System.out.println("Descriptors end"); + + Object recordedClass = event.getValue("clzField"); + Asserts.assertTrue(recordedClass instanceof RecordedClass, "Expected Recorded Class got " + recordedClass); + + Object recordedInt = event.getValue("intField"); + Asserts.assertTrue(recordedInt instanceof Integer); + + Object recordedString = event.getValue("stringField"); + System.out.println("recordedString class: " + recordedString.getClass()); + Asserts.assertTrue(recordedString instanceof String); + + Object myClass = event.getValue("myClass"); + Asserts.assertTrue(myClass instanceof RecordedClass, "Expected Recorded Class got " + recordedClass); + + RecordedClass myRecClass = (RecordedClass) myClass; + Asserts.assertEquals(MyClass.class.getName(), myRecClass.getName(), "Got " + myRecClass.getName()); + + Object recordedClassLoader = myRecClass.getValue("classLoader"); + Asserts.assertTrue(recordedClassLoader instanceof RecordedClassLoader, "Expected Recorded ClassLoader got " + recordedClassLoader); + + RecordedClassLoader myRecClassLoader = (RecordedClassLoader)recordedClassLoader; + ClassLoader cl = MyClass.class.getClassLoader(); + Asserts.assertEquals(cl.getClass().getName(), myRecClassLoader.getType().getName(), "Expected Recorded ClassLoader type to equal loader type"); + + Asserts.assertNotNull(myRecClass.getModifiers()); + } + +} diff --git a/test/jdk/jfr/api/consumer/TestRecordedEventGetThread.java b/test/jdk/jfr/api/consumer/TestRecordedEventGetThread.java new file mode 100644 index 0000000000000000000000000000000000000000..7b9ab8f1ac62c685c9999a6d529cde550a1038b5 --- /dev/null +++ b/test/jdk/jfr/api/consumer/TestRecordedEventGetThread.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. 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.api.consumer; + +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedThread; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.SimpleEvent; + +/** + * @test + * @summary Tests that the RecordedEvent.getThread() returns th expected info + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.consumer.TestRecordedEventGetThread + */ +public class TestRecordedEventGetThread { + + private static final String MY_THREAD_NAME = "MY_THREAD_NAME"; + + public static void main(String[] args) throws Throwable { + Thread currentThread = Thread.currentThread(); + currentThread.setName(MY_THREAD_NAME); + long expectedThreadId = currentThread.getId(); + + Recording r = new Recording(); + r.start(); + SimpleEvent t = new SimpleEvent(); + t.commit(); + r.stop(); + List events = Events.fromRecording(r); + r.close(); + Events.hasEvents(events); + RecordedEvent event = events.get(0); + RecordedThread recordedThread = event.getThread(); + + Asserts.assertNotNull(recordedThread); + Asserts.assertEquals(recordedThread.getJavaName(), MY_THREAD_NAME); + Asserts.assertEquals(recordedThread.getJavaThreadId(), expectedThreadId); + Asserts.assertNotNull(recordedThread.getOSThreadId()); + Asserts.assertNotNull(recordedThread.getId()); + Asserts.assertEquals(recordedThread.getOSName(), MY_THREAD_NAME); + } +} diff --git a/test/jdk/jfr/api/consumer/TestRecordedEventGetThreadOther.java b/test/jdk/jfr/api/consumer/TestRecordedEventGetThreadOther.java new file mode 100644 index 0000000000000000000000000000000000000000..f555d40f10384cff46f80eaa07aec05f7661e31e --- /dev/null +++ b/test/jdk/jfr/api/consumer/TestRecordedEventGetThreadOther.java @@ -0,0 +1,109 @@ +/* + * 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.api.consumer; + +import java.nio.file.Path; +import java.util.List; + +import jdk.jfr.Event; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedThread; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.Utils; + +/** + * @test + * @summary Tests that the RecordedEvent.getThread() returns th expected info + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.consumer.TestRecordedEventGetThreadOther + */ +public class TestRecordedEventGetThreadOther { + + private static final String MY_THREAD_NAME = "MY_THREAD_NAME"; + private static long expectedThreadId; + private static Path dumpFilePath; + + static class TestEvent extends Event { + } + + static class PostingThread extends Thread { + + PostingThread() { + setName(MY_THREAD_NAME); + expectedThreadId = getId(); + } + + @Override + public void run() { + try { + System.out.println("Starting thread..."); + dumpFilePath = postEventAndDumpToFile(); + System.out.println("events dumped to the file " + dumpFilePath); + } catch (Throwable t) { + t.printStackTrace(); + Asserts.fail(); + } + } + } + + public static void main(String[] args) throws Throwable { + Thread.currentThread().setName("MyMainThread"); + + PostingThread thread = new PostingThread(); + thread.start(); + thread.join(); + System.out.println("testing dump in file " + dumpFilePath); + + List events = RecordingFile.readAllEvents(dumpFilePath); + Asserts.assertEquals(events.size(), 1); + + RecordedEvent event = events.get(0); + RecordedThread recordedThread = event.getThread(); + + Asserts.assertNotNull(recordedThread); + Asserts.assertEquals(recordedThread.getJavaName(), MY_THREAD_NAME); + Asserts.assertEquals(recordedThread.getJavaThreadId(), expectedThreadId); + Asserts.assertNotNull(recordedThread.getId()); + Asserts.assertEquals(recordedThread.getOSName(), MY_THREAD_NAME); + } + + private static Path postEventAndDumpToFile() throws Throwable { + Recording r = new Recording(); + r.start(); + TestEvent t = new TestEvent(); + t.commit(); + r.stop(); + Path path = Utils.createTempFile("event-thread", ".jfr"); + System.out.println("Created path: " + path); + r.dump(path); + r.close(); + return path; + } +} diff --git a/test/jdk/jfr/api/consumer/TestRecordedFrame.java b/test/jdk/jfr/api/consumer/TestRecordedFrame.java new file mode 100644 index 0000000000000000000000000000000000000000..57ee9e949af001da38f4c7bb2af46e2fde64d83a --- /dev/null +++ b/test/jdk/jfr/api/consumer/TestRecordedFrame.java @@ -0,0 +1,122 @@ +/* + * 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. 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.api.consumer; + +import java.io.IOException; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedFrame; +import jdk.jfr.consumer.RecordedMethod; +import jdk.jfr.consumer.RecordedStackTrace; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.SimpleEvent; + + +/** + * @test + * @summary Simple test for RecordedFrame APIs + * @key jfr + * + * @library /lib / + * @run main/othervm -Xint -XX:+UseInterpreter -Dinterpreted=true jdk.jfr.api.consumer.TestRecordedFrame + * @run main/othervm -Xcomp -XX:-UseInterpreter -Dinterpreted=false jdk.jfr.api.consumer.TestRecordedFrame + */ +public final class TestRecordedFrame { + + public static void main(String[] args) throws IOException { + StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); + doTest(getLineNumber("main", stackTrace) + 1); + } + + /** + * Returns line number of the passed method for the passed stacktrace + */ + private static int getLineNumber(String methodName, StackTraceElement[] stackTrace) { + for (StackTraceElement ste : stackTrace) { + if (methodName.equals(ste.getMethodName())) { + return ste.getLineNumber(); + } + } + throw new RuntimeException("Unexpected error: could not analyze stacktrace"); + } + + public static void doTest(int lineNumber) throws IOException { + + System.out.println("Enetring method"); + + Recording recording = new Recording(); + recording.start(); + + SimpleEvent ev = new SimpleEvent(); + commitEvent(ev); + recording.stop(); + + List recordedEvents = Events.fromRecording(recording); + Events.hasEvents(recordedEvents); + RecordedEvent recordedEvent = recordedEvents.get(0); + + RecordedStackTrace stacktrace = recordedEvent.getStackTrace(); + List frames = stacktrace.getFrames(); + for (RecordedFrame frame : frames) { + + // All frames are java frames + Asserts.assertTrue(frame.isJavaFrame()); + // Verify the main() method frame + RecordedMethod method = frame.getMethod(); + if (method.getName().equals("main")) { + + // Frame type + String type = frame.getType(); + System.out.println("type: " + type); + Asserts.assertTrue( + type.equals("Interpreted") + || type.equals("JIT compiled") + || type.equals("Inlined")); + + Asserts.assertEquals(lineNumber, frame.getLineNumber()); + + boolean isInterpreted = "Interpreted".equals(type); + boolean expectedInterpreted = "true".equals(System.getProperty("interpreted")); + Asserts.assertEquals(isInterpreted, expectedInterpreted); + + int bci = frame.getBytecodeIndex(); + + System.out.println("bci: " + bci); + Asserts.assertTrue(bci > 0); + } + + } + + } + + private static void commitEvent(SimpleEvent ev) { + System.out.println("commit"); + ev.commit(); + } + +} diff --git a/test/jdk/jfr/api/consumer/TestRecordedFullStackTrace.java b/test/jdk/jfr/api/consumer/TestRecordedFullStackTrace.java new file mode 100644 index 0000000000000000000000000000000000000000..2fc846a698ea3cbbd71aa2e2ceb62ea362e85b89 --- /dev/null +++ b/test/jdk/jfr/api/consumer/TestRecordedFullStackTrace.java @@ -0,0 +1,180 @@ +/* + * 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 + * 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.api.consumer; + +import java.nio.file.Path; +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedFrame; +import jdk.jfr.consumer.RecordedStackTrace; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.Utils; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.RecurseThread; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.consumer.TestRecordedFullStackTrace + */ +public class TestRecordedFullStackTrace { + + private final static String EVENT_NAME = EventNames.ExecutionSample; + private final static int MAX_DEPTH = 64; // currently hardcoded in jvm + + public static void main(String[] args) throws Throwable { + + RecurseThread[] threads = new RecurseThread[3]; + for (int i = 0; i < threads.length; ++i) { + int depth = MAX_DEPTH - 1 + i; + threads[i] = new RecurseThread(depth); + threads[i].setName("recursethread-" + depth); + threads[i].start(); + } + + for (RecurseThread thread : threads) { + while (!thread.isInRunLoop()) { + Thread.sleep(20); + } + } + + assertStackTraces(threads); + + for (RecurseThread thread : threads) { + thread.quit(); + thread.join(); + } + } + + private static void assertStackTraces(RecurseThread[] threads) throws Throwable { + Path path = null; + do { + Recording recording = new Recording(); + recording.enable(EVENT_NAME).withPeriod(Duration.ofMillis(50)); + recording.start(); + Thread.sleep(500); + recording.stop(); + // Dump the recording to a file + path = Utils.createTempFile("execution-stack-trace", ".jfr"); + System.out.println("Dumping to " + path); + recording.dump(path); + recording.close(); + } while (!hasValidStackTraces(path, threads)); + } + + private static boolean hasValidStackTraces(Path path, RecurseThread[] threads) throws Throwable { + boolean[] isEventFound = new boolean[threads.length]; + + for (RecordedEvent event : RecordingFile.readAllEvents(path)) { + //System.out.println("Event: " + event); + String threadName = Events.assertField(event, "sampledThread.javaName").getValue(); + long threadId = Events.assertField(event, "sampledThread.javaThreadId").getValue(); + + for (int threadIndex = 0; threadIndex < threads.length; ++threadIndex) { + RecurseThread currThread = threads[threadIndex]; + if (threadId == currThread.getId()) { + System.out.println("ThreadName=" + currThread.getName() + ", depth=" + currThread.totalDepth); + Asserts.assertEquals(threadName, currThread.getName(), "Wrong thread name"); + if ("recurseEnd".equals(getTopMethodName(event))) { + isEventFound[threadIndex] = true; + checkEvent(event, currThread.totalDepth); + break; + } + } + } + } + + for (int i = 0; i < threads.length; ++i) { + String msg = "threadIndex=%d, recurseDepth=%d, isEventFound=%b%n"; + System.out.printf(msg, i, threads[i].totalDepth, isEventFound[i]); + } + for (int i = 0; i < threads.length; ++i) { + if (!isEventFound[i]) { + // no assertion, let's retry. + // Could be race condition, i.e safe point during Thread.sleep + System.out.println("Falied to validate all threads, will retry."); + return false; + } + } + return true; + } + + public static String getTopMethodName(RecordedEvent event) { + List frames = event.getStackTrace().getFrames(); + Asserts.assertFalse(frames.isEmpty(), "JavaFrames was empty"); + return frames.get(0).getMethod().getName(); + } + + private static void checkEvent(RecordedEvent event, int expectedDepth) throws Throwable { + RecordedStackTrace stacktrace = null; + try { + stacktrace = event.getStackTrace(); + List frames = stacktrace.getFrames(); + Asserts.assertEquals(Math.min(MAX_DEPTH, expectedDepth), frames.size(), "Wrong stacktrace depth. Expected:" + expectedDepth); + List expectedMethods = getExpectedMethods(expectedDepth); + Asserts.assertEquals(expectedMethods.size(), frames.size(), "Wrong expectedMethods depth. Test error."); + + for (int i = 0; i < frames.size(); ++i) { + String name = frames.get(i).getMethod().getName(); + String expectedName = expectedMethods.get(i); + System.out.printf("method[%d]=%s, expected=%s%n", i, name, expectedName); + Asserts.assertEquals(name, expectedName, "Wrong method name"); + } + + boolean isTruncated = stacktrace.isTruncated(); + boolean isTruncateExpected = expectedDepth > MAX_DEPTH; + Asserts.assertEquals(isTruncated, isTruncateExpected, "Wrong value for isTruncated. Expected:" + isTruncateExpected); + + String firstMethod = frames.get(frames.size() - 1).getMethod().getName(); + boolean isFullTrace = "run".equals(firstMethod); + String msg = String.format("Wrong values for isTruncated=%b, isFullTrace=%b", isTruncated, isFullTrace); + Asserts.assertTrue(isTruncated != isFullTrace, msg); + } catch (Throwable t) { + System.out.println(String.format("stacktrace:%n%s", stacktrace)); + throw t; + } + } + + private static List getExpectedMethods(int depth) { + List methods = new ArrayList<>(); + methods.add("recurseEnd"); + for (int i = 0; i < depth - 2; ++i) { + methods.add((i % 2) == 0 ? "recurseA" : "recurseB"); + } + methods.add("run"); + if (depth > MAX_DEPTH) { + methods = methods.subList(0, MAX_DEPTH); + } + return methods; + } +} diff --git a/test/jdk/jfr/api/consumer/TestRecordedInstantEventTimestamp.java b/test/jdk/jfr/api/consumer/TestRecordedInstantEventTimestamp.java new file mode 100644 index 0000000000000000000000000000000000000000..8a5bb1079ba3fd7a1837bea2ea19d7cce5ae6412 --- /dev/null +++ b/test/jdk/jfr/api/consumer/TestRecordedInstantEventTimestamp.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. 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.api.consumer; + +import java.util.List; + +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.SimpleEvent; + +/** + * @test + * @summary Tests that an instant event gets recorded with its start time equal to its end time + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.consumer.TestRecordedInstantEventTimestamp + */ +public class TestRecordedInstantEventTimestamp { + + public static void main(String[] args) throws Throwable { + Recording r = new Recording(); + r.start(); + SimpleEvent s = new SimpleEvent(); + s.commit(); + r.stop(); + + List events = Events.fromRecording(r); + Events.hasEvents(events); + RecordedEvent event = events.get(0); + Asserts.assertEquals(event.getStartTime(), event.getEndTime()); + + r.close(); + } +} diff --git a/test/jdk/jfr/api/consumer/TestRecordedMethodDescriptor.java b/test/jdk/jfr/api/consumer/TestRecordedMethodDescriptor.java new file mode 100644 index 0000000000000000000000000000000000000000..77d3df6079789a63e8460ddce8024063be6bd126 --- /dev/null +++ b/test/jdk/jfr/api/consumer/TestRecordedMethodDescriptor.java @@ -0,0 +1,97 @@ +/* + * 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. 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.api.consumer; + +import static jdk.test.lib.Asserts.assertEquals; +import static jdk.test.lib.Asserts.assertFalse; +import static jdk.test.lib.Asserts.assertNotNull; +import static jdk.test.lib.Asserts.assertTrue; + +import java.util.List; + +import jdk.jfr.Event; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedMethod; +import jdk.jfr.consumer.RecordedFrame; +import jdk.jfr.consumer.RecordedStackTrace; +import jdk.test.lib.jfr.Events; + + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.consumer.TestRecordedMethodDescriptor + */ +public final class TestRecordedMethodDescriptor { + + private static boolean isMainMethodDescriptorRecorded; + private static final String MAIN_METHOD_DESCRIPTOR = "([Ljava/lang/String;)V"; + private static final String MAIN_METHOD_NAME = "main"; + + public static void main(String[] args) throws Throwable { + Recording recording = new Recording(); + recording.enable(MyEvent.class).withStackTrace(); + recording.start(); + + MyEvent event = new MyEvent(); + event.begin(); + event.end(); + event.commit(); + recording.stop(); + + List recordedEvents = Events.fromRecording(recording); + assertEquals(1, recordedEvents.size(), "Expected one event"); + RecordedEvent recordedEvent = recordedEvents.get(0); + + RecordedStackTrace stacktrace = recordedEvent.getStackTrace(); + List frames = stacktrace.getFrames(); + assertFalse(frames.isEmpty(), "Stacktrace frames was empty"); + for (RecordedFrame frame : frames) { + analyzeRecordedMethodDescriptor(frame.getMethod()); + } + + assertTrue(isMainMethodDescriptorRecorded, "main() method descriptor has never been recorded"); + } + + private static void analyzeRecordedMethodDescriptor(RecordedMethod method) { + + String descr = method.getDescriptor(); + assertNotNull(descr, "Method descriptor is null"); + String name = method.getName(); + assertNotNull(name, "Method name is null"); + + if (name.equals(MAIN_METHOD_NAME) && descr.equals(MAIN_METHOD_DESCRIPTOR)) { + assertFalse(isMainMethodDescriptorRecorded, "main() method descriptor already recorded"); + isMainMethodDescriptorRecorded = true; + } + } + + public static class MyEvent extends Event { + } + +} diff --git a/test/jdk/jfr/api/consumer/TestRecordedObject.java b/test/jdk/jfr/api/consumer/TestRecordedObject.java new file mode 100644 index 0000000000000000000000000000000000000000..6b30e69bb81b2d24aea0cf461ba24864b97f7b16 --- /dev/null +++ b/test/jdk/jfr/api/consumer/TestRecordedObject.java @@ -0,0 +1,408 @@ +/* + * 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.api.consumer; + +import java.io.IOException; +import java.time.Duration; +import java.time.Instant; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.function.Function; + +import jdk.jfr.Event; +import jdk.jfr.Recording; +import jdk.jfr.StackTrace; +import jdk.jfr.Timespan; +import jdk.jfr.Timestamp; +import jdk.jfr.Unsigned; +import jdk.jfr.consumer.RecordedClass; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedObject; +import jdk.jfr.consumer.RecordedThread; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Verifies the methods of the RecordedObject + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.consumer.TestRecordedObject + */ +public class TestRecordedObject { + + private final static boolean BOOLEAN_VALUE = true; + private final static byte VALUE = 47; + private final static String STRING_VALUE = "47"; + private final static Class CLASS_VALUE = String.class; + private final static Thread THREAD_VALUE = Thread.currentThread(); + private final static Instant INSTANT_VALUE = Instant.now(); + private final static Duration DURATION_VALUE = Duration.ofSeconds(47); + + @StackTrace(false) + static final class EventWithValues extends Event { + boolean booleanField = BOOLEAN_VALUE; + byte byteField = VALUE; + char charField = VALUE; + short shortField = VALUE; + int intField = VALUE; + long longField = VALUE; + float floatField = VALUE; + double doubleField = VALUE; + String stringField = STRING_VALUE; + Class classField = CLASS_VALUE; + Thread threadField = THREAD_VALUE; + @Timespan(Timespan.NANOSECONDS) + long durationField = DURATION_VALUE.toNanos(); + @Timestamp(Timestamp.MILLISECONDS_SINCE_EPOCH) + long instantField = INSTANT_VALUE.toEpochMilli(); + Thread nullField = null; + Class nullField2 = null; + + @Timespan(Timespan.MICROSECONDS) + long durationMicros = DURATION_VALUE.toNanos() / 1000; + + @Timespan(Timespan.MILLISECONDS) + long durationMillis = DURATION_VALUE.toMillis(); + + @Timespan(Timespan.SECONDS) + //long durationSeconds = (DURATION_VALUE.toMinutes() * 60); + long durationSeconds = DURATION_VALUE.toMillis() / 1000; + + @Timestamp(Timestamp.MILLISECONDS_SINCE_EPOCH) + long instantMillis = 1000; + + @Timestamp(Timespan.TICKS) + long instantTicks = 0; + + @Unsigned + byte unsignedByte = Byte.MIN_VALUE; + @Unsigned + char unsignedChar = 'q'; + @Unsigned + short unsignedShort = Short.MIN_VALUE; + @Unsigned + int unsignedInt = Integer.MIN_VALUE; + @Unsigned + long unsignedLong = Long.MIN_VALUE; // unsigned should be ignored + @Unsigned + float unsignedFloat = Float.MIN_VALUE; // unsigned should be ignored + @Unsigned + double unsignedDouble = Double.MIN_VALUE; // unsigned should be ignored + + } + + private final static Set ALL = createAll(); + + public static void main(String[] args) throws Throwable { + + RecordedObject event = makeRecordedObject(); + + // Primitives + testGetBoolean(event); + testGetByte(event); + testGetChar(event); + testGetShort(event); + testGetInt(event); + testGetLong(event); + testGetDouble(event); + testGetFloat(event); + + // // Complex types + testGetString(event); + testGetInstant(event); + testGetDuration(event); + testGetThread(event); + testGetClass(event); + + // Misc. + testNestedNames(event); + testTimeUnits(event); + testUnsigned(event); + } + + private static void testUnsigned(RecordedObject event) { + // Unsigned byte value + Asserts.assertEquals(event.getByte("unsignedByte"), Byte.MIN_VALUE); + Asserts.assertEquals(event.getInt("unsignedByte"), Byte.toUnsignedInt(Byte.MIN_VALUE)); + Asserts.assertEquals(event.getLong("unsignedByte"), Byte.toUnsignedLong(Byte.MIN_VALUE)); + Asserts.assertEquals(event.getShort("unsignedByte"), (short)Byte.toUnsignedInt(Byte.MIN_VALUE)); + + // Unsigned char, nothing should happen, it is unsigned + Asserts.assertEquals(event.getChar("unsignedChar"), 'q'); + Asserts.assertEquals(event.getInt("unsignedChar"), (int)'q'); + Asserts.assertEquals(event.getLong("unsignedChar"), (long)'q'); + + // Unsigned short + Asserts.assertEquals(event.getShort("unsignedShort"), Short.MIN_VALUE); + Asserts.assertEquals(event.getInt("unsignedShort"), Short.toUnsignedInt(Short.MIN_VALUE)); + Asserts.assertEquals(event.getLong("unsignedShort"), Short.toUnsignedLong(Short.MIN_VALUE)); + + // Unsigned int + Asserts.assertEquals(event.getInt("unsignedInt"), Integer.MIN_VALUE); + Asserts.assertEquals(event.getLong("unsignedInt"), Integer.toUnsignedLong(Integer.MIN_VALUE)); + + // Unsigned long, nothing should happen + Asserts.assertEquals(event.getLong("unsignedLong"), Long.MIN_VALUE); + + // Unsigned float, nothing should happen + Asserts.assertEquals(event.getFloat("unsignedFloat"), Float.MIN_VALUE); + + // Unsigned double, nothing should happen + Asserts.assertEquals(event.getDouble("unsignedDouble"), Double.MIN_VALUE); + } + + private static void testTimeUnits(RecordedObject event) { + Asserts.assertEquals(event.getDuration("durationMicros"), DURATION_VALUE); + Asserts.assertEquals(event.getDuration("durationMillis"), DURATION_VALUE); + Asserts.assertEquals(event.getDuration("durationSeconds"), DURATION_VALUE); + Asserts.assertEquals(event.getInstant("instantMillis").toEpochMilli(), 1000L); + if (!event.getInstant("instantTicks").isBefore(INSTANT_VALUE)) { + throw new AssertionError("Expected start time of JVM to before call to Instant.now()"); + } + } + + private static void testNestedNames(RecordedObject event) { + RecordedThread t = event.getValue("threadField"); + + // Nested with getValue + try { + event.getValue("nullField.javaName"); + throw new AssertionError("Expected NullPointerException"); + } catch (NullPointerException npe) { + // OK, expected; + } + try { + event.getValue("nullField.does.not.exist"); + throw new AssertionError("Expected IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + // OK, expected; + } + + // Nested getLong + try { + event.getLong("nullField.javaName"); + throw new AssertionError("Expected NullPointerException"); + } catch (NullPointerException npe) { + // OK, expected; + } + try { + event.getLong("nullField.does.not.exist"); + throw new AssertionError("Expected IllegalArgumentException"); + } catch (IllegalArgumentException npe) { + // OK, expected; + } + if (t.getOSThreadId() != event.getLong("threadField.osThreadId")) { + throw new AssertionError("Incorrect result from nested long value"); + } + + // Nested getString + try { + event.getString("nullField.osThreadId"); + throw new AssertionError("Expected IllegalArgumentException"); + } catch (IllegalArgumentException npe) { + // OK, expected; + } + try { + event.getLong("nullField.does.not.exist"); + throw new AssertionError("Expected IllegalArgumentException"); + } catch (IllegalArgumentException npe) { + // OK, expected; + } + if (!t.getJavaName().equals(event.getString("threadField.javaName"))) { + throw new AssertionError("Incorrect result from nested long value"); + } + + // Nested getClass + try { + event.getClass("nullField.osThreadId"); + throw new AssertionError("Expected IllegalArgumentException"); + } catch (IllegalArgumentException npe) { + // OK, expected; + } + try { + event.getClass("nullField.does.not.exist"); + throw new AssertionError("Expected IllegalArgumentException"); + } catch (IllegalArgumentException npe) { + // OK, expected; + } + + // Nested getThread + try { + event.getThread("nullField2.name"); + throw new AssertionError("Expected IllegalArgumentException"); + } catch (IllegalArgumentException npe) { + // OK, expected; + } + try { + event.getThread("nullField2.does.not.exist"); + throw new AssertionError("Expected IllegalArgumentException"); + } catch (IllegalArgumentException npe) { + // OK, expected; + } + } + + private static void testGetBoolean(RecordedObject e) { + assertGetter(x -> e.getBoolean(x), BOOLEAN_VALUE, "boolean"); + } + + private static void testGetByte(RecordedObject e) { + assertGetter(x -> e.getByte(x), (byte) VALUE, "byte"); + } + + private static void testGetChar(RecordedObject e) { + assertGetter(x -> e.getChar(x), (char) VALUE, "char"); + } + + private static void testGetShort(RecordedObject e) { + assertGetter(x -> e.getShort(x), (short) VALUE, "byte", "short"); + } + + private static void testGetInt(RecordedObject e) { + assertGetter(x -> e.getInt(x), (int) VALUE, "byte", "char", "short", "int"); + } + + private static void testGetLong(RecordedObject e) { + assertGetter(x -> e.getLong(x), (long) VALUE, "byte", "char", "short", "int", "long"); + } + + private static void testGetFloat(RecordedObject e) { + assertGetter(x -> e.getFloat(x), (float) VALUE, "byte", "char", "short", "int", "long", "float"); + } + + private static void testGetDouble(RecordedObject e) { + assertGetter(x -> e.getDouble(x), (double) VALUE, "byte", "char", "short", "int", "long", "float", "double"); + } + + private static void testGetString(RecordedObject e) { + assertGetter(x -> e.getString(x), STRING_VALUE, "string"); + } + + private static void testGetInstant(RecordedObject e) { + assertGetter(x -> e.getInstant(x), Instant.ofEpochMilli(INSTANT_VALUE.toEpochMilli()), "instant"); + } + + private static void testGetDuration(RecordedObject e) { + assertGetter(x -> e.getDuration(x), DURATION_VALUE, "duration"); + } + + private static void testGetThread(RecordedObject e) { + RecordedThread thread = e.getValue("threadField"); + if (!thread.getJavaName().equals(THREAD_VALUE.getName())) { + throw new AssertionError("Expected thread to have name " + THREAD_VALUE.getName()); + } + assertGetter(x -> { + // OK to access nullField if it is correct type + // Chose a second null field with class type + if ("nullField".equals(x)) { + return e.getThread("nullField2"); + } else { + return e.getThread(x); + } + + }, thread, "thread"); + } + + private static void testGetClass(RecordedObject e) { + RecordedClass clazz = e.getValue("classField"); + if (!clazz.getName().equals(CLASS_VALUE.getName())) { + throw new AssertionError("Expected class to have name " + CLASS_VALUE.getName()); + } + assertGetter(x -> e.getClass(x), clazz, "class"); + } + + private static void assertGetter(Function f, T expectedValue, String... validTypes) { + Set valids = new HashSet(Arrays.asList(validTypes)); + Set invalids = new HashSet(ALL); + invalids.removeAll(valids); + for (String valid : valids) { + T result = f.apply(valid + "Field"); + if (!expectedValue.equals(result)) { + throw new AssertionError("Incorrect return value " + result + ". Expected " + expectedValue); + } + } + for (String invalid : invalids) { + try { + f.apply(invalid + "Field"); + } catch (IllegalArgumentException iae) { + // OK, as expected + } catch (Exception e) { + throw new AssertionError("Unexpected exception for invalid field " + invalid + ". " + e.getClass().getName() + " : " + e.getMessage(), e); + } + } + String[] illegals = { "missingField", "nullField.javaName.does.not.exist", "nullField" }; + for (String illegal : illegals) { + try { + f.apply(illegal); + throw new AssertionError("Expected IllegalArgumentException when accessing " + illegal); + } catch (IllegalArgumentException iae) { + // OK, as expected + } catch (Exception e) { + throw new AssertionError("Expected IllegalArgumentException. Got " + e.getClass().getName() + " : " + e.getMessage(), e); + } + } + try { + f.apply(null); + throw new AssertionError("Expected NullpointerException exception when passing in null value"); + } catch (NullPointerException iae) { + // OK, as expected + } catch (Exception e) { + throw new AssertionError("Expected NullpointerException. Got " + e.getClass().getName() + " : " + e.getMessage(), e); + } + } + + private static RecordedObject makeRecordedObject() throws IOException { + Recording r = new Recording(); + r.start(); + EventWithValues t = new EventWithValues(); + t.commit(); + r.stop(); + List events = Events.fromRecording(r); + Events.hasEvents(events); + return events.get(0); + } + + private static Set createAll() { + Set set = new HashSet<>(); + set.add("boolean"); + set.add("byte"); + set.add("char"); + set.add("short"); + set.add("int"); + set.add("long"); + set.add("float"); + set.add("double"); + set.add("string"); + set.add("class"); + set.add("thread"); + set.add("instant"); + set.add("duration"); + return set; + } +} diff --git a/test/jdk/jfr/api/consumer/TestRecordedThreadGroupParent.java b/test/jdk/jfr/api/consumer/TestRecordedThreadGroupParent.java new file mode 100644 index 0000000000000000000000000000000000000000..dc110d31028b0ffc376a3034f8672b95b7e4e664 --- /dev/null +++ b/test/jdk/jfr/api/consumer/TestRecordedThreadGroupParent.java @@ -0,0 +1,89 @@ +/* + * 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 + * 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.api.consumer; + +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedThreadGroup; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.SimpleEvent; + +/** + * @test + * @summary Tests getParent method in RecordedThreadGroup + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.consumer.TestRecordedThreadGroupParent + */ +public class TestRecordedThreadGroupParent { + + public static void main(String[] args) throws Exception { + ThreadGroup beforeStartGroup = new ThreadGroup(new ThreadGroup(new ThreadGroup("Grandfather"), "Father"), "Son"); + Thread beforeThread = new Thread(beforeStartGroup, () -> new SimpleEvent().commit(), "Before Recording Start"); + + try (Recording r = new Recording()) { + r.enable(SimpleEvent.class).withoutStackTrace(); + r.start(); + beforeThread.start(); + ThreadGroup afterStartGroup = new ThreadGroup(new ThreadGroup(new ThreadGroup("Grandmother"), "Mother"), "Daughter"); + Thread afterThread = new Thread(afterStartGroup, () -> new SimpleEvent().commit(), "After Recording Start"); + afterThread.start(); + + beforeThread.join(); + afterThread.join(); + + r.stop(); + + List events = Events.fromRecording(r); + Events.hasEvents(events); + for (RecordedEvent e : events) { + System.out.println(e); + switch (e.getThread().getJavaName()) { + case "Before Recording Start": + assetrThreadGroupParents(beforeStartGroup, e.getThread().getThreadGroup()); + break; + case "After Recording Start": + assetrThreadGroupParents(afterStartGroup, e.getThread().getThreadGroup()); + break; + default: + Asserts.fail("Unexpected thread found " + e.getThread().getJavaName()); + } + } + } + } + + private static void assetrThreadGroupParents(ThreadGroup realGroup, RecordedThreadGroup recordedGroup) { + if (recordedGroup == null && realGroup == null) { + return; // root + } + Asserts.assertNotNull(recordedGroup, "Parent thread group should not be null"); + Asserts.assertEquals(realGroup.getName(), recordedGroup.getName(), "Parent thread group names don't match"); + assetrThreadGroupParents(realGroup.getParent(), recordedGroup.getParent()); + } +} diff --git a/test/jdk/jfr/api/consumer/TestRecordingFile.java b/test/jdk/jfr/api/consumer/TestRecordingFile.java new file mode 100644 index 0000000000000000000000000000000000000000..831292641aad91977a32d1162be92dde155f576b --- /dev/null +++ b/test/jdk/jfr/api/consumer/TestRecordingFile.java @@ -0,0 +1,408 @@ +/* + * 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.api.consumer; + +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.StringJoiner; + + +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorder; +import jdk.jfr.Name; +import jdk.jfr.Recording; +import jdk.jfr.Registered; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.Utils; + +/** + * @test + * @summary Verifies that all methods in RecordingFIle are working + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.consumer.TestRecordingFile + */ +public class TestRecordingFile { + + static class TestEvent1 extends Event { + } + + static class TestEvent2 extends Event { + } + + static class TestEvent3 extends Event { + } + + private static String TEST_CLASS_BASE = "TestRecordingFile$TestEvent"; + private final static int EVENT_COUNT = 3; + private final static int HEADER_SIZE = 68; + private final static long METADATA_OFFSET = 24; + + public static void main(String[] args) throws Throwable { + + // create some recording data + Recording r = new Recording(); + r.enable(TestEvent1.class).withoutStackTrace(); + r.enable(TestEvent2.class).withoutStackTrace(); + r.enable(TestEvent3.class).withoutStackTrace(); + r.start(); + TestEvent1 t1 = new TestEvent1(); + t1.commit(); + TestEvent2 t2 = new TestEvent2(); + t2.commit(); + TestEvent3 t3 = new TestEvent3(); + t3.commit(); + r.stop(); + Path valid = Utils.createTempFile("three-event-recording", ".jfr"); + r.dump(valid); + r.close(); + + Path brokenWithZeros = createBrokenWIthZeros(valid); + Path brokenMetadata = createBrokenMetadata(valid); + // prepare event sets + testNewRecordingFile(valid, brokenWithZeros); + testIterate(valid, brokenWithZeros); + testReadAllEvents(valid, brokenWithZeros); + testReadEventTypes(valid, brokenMetadata); + testClose(valid); + testReadEventTypesMultiChunk(); + testReadEventTypeWithUnregistration(false, false); + testReadEventTypeWithUnregistration(false, true); + testReadEventTypeWithUnregistration(true, false); + testReadEventTypeWithUnregistration(true, true); + } + + private static void testReadEventTypeWithUnregistration(boolean disk, boolean background) throws Exception { + FlightRecorder.register(Event1.class); + FlightRecorder.register(Event2.class); + FlightRecorder.register(Event3.class); + Recording backgrundRecording = new Recording(); + if (disk) { + backgrundRecording.setToDisk(disk); + } + if (background) { + backgrundRecording.start(); + } + recordAndVerify(disk, background,new int[] {1,2, 3}, new int[] {}); + FlightRecorder.unregister(Event2.class); + recordAndVerify(disk, background, new int[] {1, 3}, new int[] {2}); + FlightRecorder.unregister(Event1.class); + FlightRecorder.register(Event2.class); + recordAndVerify(disk,background, new int[] {2, 3}, new int[] {1}); + FlightRecorder.unregister(Event3.class); + FlightRecorder.register(Event3.class); + FlightRecorder.unregister(Event2.class); + FlightRecorder.unregister(Event3.class); + FlightRecorder.register(Event1.class); + FlightRecorder.unregister(Event1.class); + FlightRecorder.register(Event1.class); + FlightRecorder.register(Event2.class); + recordAndVerify(disk, background,new int[] {1, 2}, new int[] {3}); + if (background) { + backgrundRecording.close(); + } + } + + private static void recordAndVerify(boolean disk, boolean background, int[] shouldExist, int[] shouldNotExist) throws Exception { + StringJoiner sb = new StringJoiner("-"); + for (int i = 0; i types = f.readEventTypes(); + for (int i = 0; i< shouldExist.length; i++) { + assertHasEventType(types, "Event" + shouldExist[i]); + } + for (int i = 0; i< shouldNotExist.length; i++) { + assertMissingEventType(types, "Event" + shouldNotExist[i]); + } + } + } + System.out.println(); + System.out.println(); + } + + @Registered(false) + @Name("Event1") + private static class Event1 extends Event { + } + @Registered(false) + @Name("Event2") + private static class Event2 extends Event { + } + @Registered(false) + @Name("Event3") + private static class Event3 extends Event { + } + + private static void testReadEventTypesMultiChunk() throws Exception { + + Path twoEventTypes = Utils.createTempFile("two-event-types", ".jfr"); + Path threeEventTypes = Utils.createTempFile("three-event-types", ".jfr"); + try (Recording r1 = new Recording()) { + r1.start(); + FlightRecorder.register(Event1.class); + try (Recording r2 = new Recording()) { + r2.start(); + FlightRecorder.register(Event2.class); + + // Ensure that metadata are written twice. + try (Recording rotator = new Recording()) { + rotator.start(); + rotator.stop(); + } + r2.stop(); + r2.dump(twoEventTypes);; + } + FlightRecorder.register(Event3.class); + r1.stop(); + r1.dump(threeEventTypes);; + } + try (RecordingFile f = new RecordingFile(twoEventTypes)) { + List types = f.readEventTypes(); + assertUniqueEventTypes(types); + assertHasEventType(types, "Event1"); + assertHasEventType(types, "Event2"); + assertMissingEventType(types, "Event3"); + } + try (RecordingFile f = new RecordingFile(twoEventTypes)) { + List types = f.readEventTypes(); + assertUniqueEventTypes(types); + assertHasEventType(types, "Event1"); + assertHasEventType(types, "Event2"); + assertMissingEventType(types, "Event3"); + } + + } + + private static void assertMissingEventType(List types,String name) throws Exception { + EventType type = findEventType(types, name); + if (type != null) { + throw new Exception("Found unexpected event type " + name); + } + } + + private static void assertHasEventType(List types,String name) throws Exception { + EventType type = findEventType(types, name); + if (type == null) { + throw new Exception("Missing event type " + name); + } + } + + private static EventType findEventType(List types, String name) { + for (EventType t : types) { + if (t.getName().equals(name)) { + return t; + } + } + return null; + } + + private static void assertUniqueEventTypes(List types) { + HashSet ids = new HashSet<>(); + for (EventType type : types) { + ids.add(type.getId()); + } + Asserts.assertEquals(types.size(), ids.size(), "Event types repeated. " + types); + } + + private static Path createBrokenWIthZeros(Path valid) throws Exception { + try { + Path broken = Utils.createTempFile("broken-events", ".jfr"); + Files.delete(broken); + Files.copy(valid, broken); + RandomAccessFile raf = new RandomAccessFile(broken.toFile(), "rw"); + raf.seek(HEADER_SIZE); + int size = (int) Files.size(broken); + byte[] ones = new byte[size - HEADER_SIZE]; + for (int i = 0; i < ones.length; i++) { + ones[i] = (byte) 0xFF; + } + raf.write(ones, 0, ones.length); + raf.close(); + return broken; + } catch (IOException ioe) { + throw new Exception("Could not produce a broken file " + valid, ioe); + } + } + + private static Path createBrokenMetadata(Path valid) throws Exception { + try { + Path broken = Utils.createTempFile("broken-metadata", ".jfr"); + Files.delete(broken); + Files.copy(valid, broken); + RandomAccessFile raf = new RandomAccessFile(broken.toFile(), "rw"); + raf.seek(METADATA_OFFSET); + long metadataOffset = raf.readLong(); + raf.seek(metadataOffset); + raf.writeLong(Long.MAX_VALUE); + raf.writeLong(Long.MAX_VALUE); + raf.close(); + return broken; + } catch (IOException ioe) { + throw new Exception("Could not produce a broken EventSet from file " + valid, ioe); + } + } + + private static void testReadEventTypes(Path valid, Path broken) throws Exception { + try (RecordingFile validFile = new RecordingFile(valid)) { + List types = validFile.readEventTypes(); + if (types.size() < EVENT_COUNT) { + throw new Exception("Expected at least " + EVENT_COUNT + " event type but got " + types.toString()); + } + int counter = 0; + for (Class testClass : Arrays.asList(TestEvent1.class, TestEvent2.class, TestEvent3.class)) { + for (EventType t : types) { + if (t.getName().equals(testClass.getName())) { + counter++; + } + } + } + if (counter != 3) { + throw new Exception("Returned incorrect event types"); + } + } + try (RecordingFile brokenFile = new RecordingFile(broken)) { + brokenFile.readEventTypes(); + throw new Exception("Expected IOException when getting Event Types from broken recording"); + } catch (IOException ise) { + // OK + } + } + + private static void testNewRecordingFile(Path valid, Path broken) throws Exception { + try (RecordingFile r = new RecordingFile(null)) { + throw new Exception("Expected NullPointerException"); + } catch (NullPointerException npe) { + // OK + } + try (RecordingFile r = new RecordingFile(Paths.get("hjhjsdfhkjshdfkj.jfr"))) { + throw new Exception("Expected FileNotFoundException"); + } catch (FileNotFoundException npe) { + // OK + } + Path testFile = Utils.createTempFile("test-empty-file", ".jfr"); + try (RecordingFile r = new RecordingFile(testFile)) { + throw new Exception("Expected IOException if file is empty"); + } catch (IOException e) { + // OK + } + FileWriter fr = new FileWriter(testFile.toFile()); + fr.write("whatever"); + fr.close(); + try (RecordingFile r = new RecordingFile(Paths.get("hjhjsdfhkjshdfkj.jfr"))) { + throw new Exception("Expected IOException if magic is incorrect"); + } catch (IOException e) { + // OK + } + + try (RecordingFile r = new RecordingFile(valid)) { + } + } + + private static void testClose(Path valid) throws Exception { + RecordingFile f = new RecordingFile(valid); + f.close(); + + try { + f.readEvent(); + throw new Exception("Should not be able to read event from closed recording"); + } catch (IOException e) { + if (!e.getMessage().equals("Stream Closed")) { + throw new Exception("Expected 'Stream Closed' in exception message for a closed stream. Got '" + e.getMessage() +"'."); + } + // OK + } + try { + f.readEventTypes(); + throw new Exception("Should not be able to read event from closed recording"); + } catch (IOException e) { + if (!e.getMessage().equals("Stream Closed")) { + throw new Exception("Expected 'Stream Closed' in exception message for a closed stream. Got '" + e.getMessage() +"'."); + } + // OK + } + // close twice + f.close(); + } + + private static void testIterate(Path valid, Path broken) throws Exception { + try (RecordingFile validFile = new RecordingFile(valid)) { + for (int i = 0; i < EVENT_COUNT; i++) { + if (!validFile.hasMoreEvents()) { + throw new Exception("Not all events available"); + } + RecordedEvent r = validFile.readEvent(); + if (r == null) { + throw new Exception("Missing event"); + } + if (!r.getEventType().getName().contains(TEST_CLASS_BASE)) { + throw new Exception("Incorrect event in recording file " + r); + } + } + if (validFile.hasMoreEvents()) { + throw new Exception("Should not be more than " + EVENT_COUNT + " in recording"); + } + } + try (RecordingFile brokenFile = new RecordingFile(broken)) { + brokenFile.readEvent(); + throw new Exception("Expected IOException for broken recording"); + } catch (IOException ise) { + // OK + } + } + + private static void testReadAllEvents(Path valid, Path broken) throws Exception { + try { + RecordingFile.readAllEvents(broken); + throw new Exception("Expected IOException when reading all events for broken recording"); + } catch (IOException ioe) { + // OK as expected + } + } +} diff --git a/test/jdk/jfr/api/consumer/TestRecordingFileReadEventEof.java b/test/jdk/jfr/api/consumer/TestRecordingFileReadEventEof.java new file mode 100644 index 0000000000000000000000000000000000000000..83e1aff4cd68b74d0ece44bcc230173c9eaf54d1 --- /dev/null +++ b/test/jdk/jfr/api/consumer/TestRecordingFileReadEventEof.java @@ -0,0 +1,62 @@ +/* + * 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.api.consumer; + +import java.io.EOFException; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.SimpleEvent; + +/** + * @test + * @summary Verifies that RecordingFile.readEvent() throws EOF when past the last record + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.consumer.TestRecordingFileReadEventEof + */ +public class TestRecordingFileReadEventEof { + + public static void main(String[] args) throws Throwable { + Recording r = new Recording(); + r.start(); + SimpleEvent t = new SimpleEvent(); + t.commit(); + r.stop(); + RecordingFile file = Events.copyTo(r); + r.close(); + file.readEvent(); + try { + file.readEvent(); + Asserts.fail("Expected EOFException not thrown"); + } catch (EOFException x) { + // OK, as expected + } + } +} diff --git a/test/jdk/jfr/api/consumer/TestRecordingInternals.java b/test/jdk/jfr/api/consumer/TestRecordingInternals.java new file mode 100644 index 0000000000000000000000000000000000000000..232078deed6e60276a6917cf89057e23b21a6719 --- /dev/null +++ b/test/jdk/jfr/api/consumer/TestRecordingInternals.java @@ -0,0 +1,81 @@ +/* + * 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.api.consumer; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedThread; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.SimpleEvent; + +/** + * @test + * @summary Tests that chunks are read in order and constant pools from multiple chunks can be read + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.consumer.TestRecordingInternals + */ +public class TestRecordingInternals { + + public static void main(String[] args) throws Throwable { + try (Recording continuous = new Recording()) { + continuous.start(); + for (int i = 0; i < 3; i++) { + // Each new recording will create a new chunk + // with a new set of constant pools, i.e. + // constant pools for threads and thread groups + createProfilingRecording(i); + } + continuous.stop(); + int i = 0; + for (RecordedEvent e : Events.fromRecording(continuous)) { + Integer id = e.getValue("id"); + RecordedThread rt = e.getThread(); + Asserts.assertEquals(id.toString(), rt.getJavaName(), "Thread name should match id"); + Asserts.assertEquals(id.toString(), rt.getThreadGroup().getName(), "Thread group name should match id"); + Asserts.assertEquals(id, Integer.valueOf(i), "Chunks out of order"); + i++; + } + } + } + + private static void createProfilingRecording(int id) throws InterruptedException { + try (Recording r = new Recording()) { + r.start(); + ThreadGroup tg = new ThreadGroup(String.valueOf(id)); + Thread t = new Thread(tg, () -> { + SimpleEvent event = new SimpleEvent(); + event.id = id; + event.commit(); + }, String.valueOf(id)); + t.start(); + t.join(); + r.stop(); + } + } +} diff --git a/test/jdk/jfr/api/consumer/TestSingleRecordedEvent.java b/test/jdk/jfr/api/consumer/TestSingleRecordedEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..d1a79b3341405b7074a481d0a6395629cfbdfb8b --- /dev/null +++ b/test/jdk/jfr/api/consumer/TestSingleRecordedEvent.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. 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.api.consumer; + +import java.util.List; + +import jdk.jfr.Description; +import jdk.jfr.Event; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Verifies that a single JFR event is recorded as expected + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.consumer.TestSingleRecordedEvent + */ +public class TestSingleRecordedEvent { + + @Description("MyDescription") + private static class MyEvent extends Event { + } + + public static void main(String[] args) throws Throwable { + Recording r = new Recording(); + r.start(); + // Commit a single event to the recording + MyEvent event = new MyEvent(); + event.commit(); + r.stop(); + List events = Events.fromRecording(r); + Events.hasEvents(events); + + // Should be 1 event only + Asserts.assertEquals(events.size(), 1); + + RecordedEvent recordedEvent = events.get(0); + + // Event description should be the same + Asserts.assertEquals(recordedEvent.getEventType().getDescription(), "MyDescription"); + } +} diff --git a/test/jdk/jfr/api/consumer/TestToString.java b/test/jdk/jfr/api/consumer/TestToString.java new file mode 100644 index 0000000000000000000000000000000000000000..66595d71dfe0a3cb0d7a9b481eee805db3d81cf8 --- /dev/null +++ b/test/jdk/jfr/api/consumer/TestToString.java @@ -0,0 +1,95 @@ +/* + * 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.api.consumer; + +import java.util.HashMap; +import java.util.List; + +import jdk.jfr.Event; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Sanity checks that RecordedEvent#toString returns something valid + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.consumer.TestToString + */ +public class TestToString { + + public static void main(String[] args) throws Throwable { + + try (Recording recording = new Recording()) { + recording.start(); + HelloWorldEvent event = new HelloWorldEvent(); + event.message = "hello, world"; + event.integer = 4711; + event.floatValue = 9898; + event.doubleValue = 313; + event.clazz = HashMap.class; + event.characater = '&'; + event.byteValue = (byte) 123; + event.longValue = 1234567890L; + event.shortValue = 64; + event.booleanValue = false; + event.commit(); + recording.stop(); + List events = Events.fromRecording(recording); + Events.hasEvents(events); + RecordedEvent e = events.get(0); + String toString = e.toString(); + System.out.println(toString); + Asserts.assertTrue(toString.contains("hello, world"), "Missing String field value in RecordedEvent#toSting()"); + Asserts.assertTrue(toString.contains("4711"), "Missing integer fields value in RecordedEvent#toSting()"); + Asserts.assertTrue(toString.contains("313"), "Missing double value in RecordedEvent#toSting()"); + Asserts.assertTrue(toString.contains("HashMap"), "Missing class value in RecordedEvent#toSting()"); + Asserts.assertTrue(toString.contains("1234567890"), "Missing long value in RecordedEvent#toSting()"); + Asserts.assertTrue(toString.contains("&"), "Missing char value in RecordedEvent#toSting()"); + Asserts.assertTrue(toString.contains("123"), "Missing byte value in RecordedEvent#toString()"); + Asserts.assertTrue(toString.contains("64"), "Missing short value in RecordedEvent#toString()"); + Asserts.assertTrue(toString.contains("false"), "Missing boolean value in RecordedEvent#toString()"); + Asserts.assertTrue(toString.contains("HelloWorldEvent"), "Missing class name in RecordedEvent#toString()"); + } + } + + static class HelloWorldEvent extends Event { + public boolean booleanValue; + public long longValue; + public int shortValue; + public byte byteValue; + public int doubleValue; + public char characater; + public Thread mainThread; + public Class clazz; + public int floatValue; + public int integer; + public String message; + } +} diff --git a/test/jdk/jfr/api/consumer/TestValueDescriptorRecorded.java b/test/jdk/jfr/api/consumer/TestValueDescriptorRecorded.java new file mode 100644 index 0000000000000000000000000000000000000000..fc69f9992240b985c306378d40eedd070a7d4ef6 --- /dev/null +++ b/test/jdk/jfr/api/consumer/TestValueDescriptorRecorded.java @@ -0,0 +1,79 @@ +/* + * 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.api.consumer; + +import java.util.List; + +import jdk.jfr.Description; +import jdk.jfr.Event; +import jdk.jfr.Label; +import jdk.jfr.Recording; +import jdk.jfr.ValueDescriptor; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + + +/** + * @test + * @summary Verifies that the recorded value descriptors are correct + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.consumer.TestValueDescriptorRecorded + */ +public class TestValueDescriptorRecorded { + + private static class MyEvent extends Event { + + @Label("myLabel") + @Description("myDescription") + int myValue; + } + + public static void main(String[] args) throws Throwable { + Recording r = new Recording(); + r.enable(MyEvent.class).withoutStackTrace(); + r.start(); + MyEvent event = new MyEvent(); + event.commit(); + r.stop(); + + List events = Events.fromRecording(r); + Events.hasEvents(events); + RecordedEvent recordedEvent = events.get(0); + + for (ValueDescriptor desc : recordedEvent.getFields()) { + if ("myValue".equals(desc.getName())) { + Asserts.assertEquals(desc.getLabel(), "myLabel"); + Asserts.assertEquals(desc.getDescription(), "myDescription"); + Asserts.assertEquals(desc.getTypeName(), int.class.getName()); + Asserts.assertFalse(desc.isArray()); + Asserts.assertNull(desc.getContentType()); + } + } + } +} diff --git a/test/jdk/jfr/api/event/TEST.properties b/test/jdk/jfr/api/event/TEST.properties new file mode 100644 index 0000000000000000000000000000000000000000..81cb3fce7197da13f7b9a0d3ff86693188e12c9c --- /dev/null +++ b/test/jdk/jfr/api/event/TEST.properties @@ -0,0 +1,2 @@ +modules = java.management + diff --git a/test/jdk/jfr/api/event/TestAbstractEvent.java b/test/jdk/jfr/api/event/TestAbstractEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..af276032789cb654466749fd33d749830f379b5e --- /dev/null +++ b/test/jdk/jfr/api/event/TestAbstractEvent.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. 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.api.event; + +import java.io.IOException; + +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.Experimental; +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Tests that abstract events are not part of metadata + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.event.TestAbstractEvent + * @run main/othervm -XX:+AllowParallelDefineClass jdk.jfr.api.event.TestAbstractEvent + */ +public class TestAbstractEvent { + + // Should not be included in metadata + @Experimental + static abstract class BaseEvent extends Event { + } + + // Should be included + static class ConcreteEvent extends BaseEvent { + } + + public static void main(String... args) throws IOException { + try { + EventType.getEventType(BaseEvent.class); + Asserts.fail("Should not accept abstract event classes"); + } catch (IllegalArgumentException iae) { + // OK, as expected + } + + try { + FlightRecorder.register(BaseEvent.class); + Asserts.fail("Should not accept registering abstract event classes"); + } catch (IllegalArgumentException iae) { + // OK, as expected + } + + try { + FlightRecorder.unregister(BaseEvent.class); + Asserts.fail("Should not accept unregistering abstract event classes"); + } catch (IllegalArgumentException iae) { + // OK, as expected + } + + + Recording r = new Recording(); + try { + r.enable(BaseEvent.class); + Asserts.fail("Should not accept abstract event classes"); + } catch (IllegalArgumentException iae) { + // OK, as expected + } + r.start(); + + ConcreteEvent event = new ConcreteEvent(); + event.commit(); + r.stop(); + RecordingFile rf = Events.copyTo(r); + RecordedEvent re = rf.readEvent(); + if (!re.getEventType().getName().equals(ConcreteEvent.class.getName())) { + Asserts.fail("Expected " + ConcreteEvent.class.getName() + " event to be part of recording. Found " + re.getEventType().getName()); + } + if (rf.hasMoreEvents()) { + Asserts.fail("Expected only one event"); + } + rf.close(); + EventType concreteEventType = null; + for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) { + if (type.getName().equals(BaseEvent.class.getName())) { + Asserts.fail("Abstract events should not be part of metadata"); + } + if (type.getName().equals(ConcreteEvent.class.getName())) { + concreteEventType = type; + } + } + Asserts.assertTrue(concreteEventType != null, "Could not find " + ConcreteEvent.class.getName() + " in metadata"); + Experimental exp = concreteEventType.getAnnotation(Experimental.class); + Asserts.assertTrue(exp != null, "Could not find inherited annotation" + Experimental.class.getName() + " from abstract event class"); + } +} diff --git a/test/jdk/jfr/api/event/TestBeginEnd.java b/test/jdk/jfr/api/event/TestBeginEnd.java new file mode 100644 index 0000000000000000000000000000000000000000..21817d246b9e78592ed0b408af02ff634e3e2e19 --- /dev/null +++ b/test/jdk/jfr/api/event/TestBeginEnd.java @@ -0,0 +1,114 @@ +/* + * 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. 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.api.event; + +import java.time.Duration; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.SimpleEvent; + +/** + * @test + * @summary Test for RecordedEvent.getDuration() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.event.TestBeginEnd + */ +public class TestBeginEnd { + + public static void main(String[] args) throws Exception { + + Recording r = new Recording(); + r.enable(SimpleEvent.class); + r.start(); + + // Test enabled - single commit + SimpleEvent e1 = new SimpleEvent(); + e1.id = 1; // should be included + e1.commit(); + + // Test enabled - begin - commit + SimpleEvent e2 = new SimpleEvent(); + e2.begin(); + e2.id = 2; // should be included + e2.commit(); + + // Test enabled - begin - end - commit + SimpleEvent e3 = new SimpleEvent(); + e3.begin(); + e3.id = 3; // should be included + e3.end(); + e3.commit(); + + // Test enabled - end - commit + SimpleEvent e4 = new SimpleEvent(); + e4.id = 4; // should be included + e4.end(); + e4.commit(); + + // Test half enabled - begin - commit + r.disable(SimpleEvent.class); + SimpleEvent e5 = new SimpleEvent(); + e5.begin(); + r.enable(SimpleEvent.class); + e5.id = 5; // should be included + e5.commit(); + + // Test half enabled - begin - end - commit + r.disable(SimpleEvent.class); + SimpleEvent r6 = new SimpleEvent(); + r6.begin(); + r.enable(SimpleEvent.class); + r6.id = 6; // should be included + r6.end(); + r6.commit(); + + // Test half enabled - begin - commit with high threshold + r.disable(SimpleEvent.class); + SimpleEvent r7 = new SimpleEvent(); + r7.begin(); + r.enable(SimpleEvent.class).withThreshold(Duration.ofDays(1)); + r7.id = 7; // should not be included + r7.commit(); + r.stop(); + + List recordedEvents = Events.fromRecording(r); + for (RecordedEvent re : recordedEvents) { + Integer id = re.getValue("id"); + System.out.println("Found if " + id); + if (id < 1 || id > 6) { + throw new Exception("Unexpected id found " + id); + } + } + if (recordedEvents.size() != 6) { + throw new Exception("Expected 6 events"); + } + } + +} diff --git a/test/jdk/jfr/api/event/TestClinitRegistration.java b/test/jdk/jfr/api/event/TestClinitRegistration.java new file mode 100644 index 0000000000000000000000000000000000000000..db4319079fdb8e78d1dc99d4abbd53ce7c0a7d56 --- /dev/null +++ b/test/jdk/jfr/api/event/TestClinitRegistration.java @@ -0,0 +1,206 @@ +/* + * 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.api.event; + +import java.io.IOException; +import java.util.List; + +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; +import jdk.jfr.Registered; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Test enable/disable event and verify recording has expected events. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.event.TestClinitRegistration + */ + +public class TestClinitRegistration { + + public static void main(String[] args) throws Exception { + // Test basic registration with or without auto registration + assertClinitRegister(AutoRegisteredEvent.class, true, false); + assertClinitRegister(NotAutoRegisterededEvent.class, false, false); + assertClinitRegister(AutoRegisteredUserClinit.class, true, true); + assertClinitRegister(NotAutoRegisteredUserClinit.class, false, true); + + // Test complex + assertClinitRegister(ComplexClInit.class, true, true); + + // Test hierarchy + assertClinitRegister(DerivedClinit.class, true, true); + if (!isClinitExecuted(Base.class)) { + Asserts.fail("Expected of base class to be executed"); + } + + // Test committed event in + Recording r = new Recording(); + r.start(); + r.enable(EventInClinit.class); + triggerClinit(EventInClinit.class); + r.stop(); + hasEvent(r, EventInClinit.class.getName()); + } + + private static void assertClinitRegister(Class eventClass, boolean shouldExist, boolean setsProperty) throws ClassNotFoundException { + String className = eventClass.getName(); + triggerClinit(eventClass); + boolean hasEventType = hasEventType(className); + boolean hasProperty = Boolean.getBoolean(className); + if (hasEventType && !shouldExist) { + Asserts.fail("Event class " + className + " should not be registered"); + } + if (!hasEventType && shouldExist) { + Asserts.fail("Event class " + className + " is not registered"); + } + if (setsProperty && !hasProperty) { + Asserts.fail("Expected clinit to be executed"); + } + if (!setsProperty && hasProperty) { + Asserts.fail("Property in clinit should not been set. Test bug?"); + } + } + + private static boolean hasEventType(String name) { + for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) { + if (type.getName().equals(name)) { + return true; + } + } + return false; + } + + private static void triggerClinit(Class clazz) throws ClassNotFoundException { + Class.forName(clazz.getName(), true, clazz.getClassLoader()); + } + + private static void setClinitExecuted(Class eventClass) { + System.setProperty(eventClass.getName(), "true"); + } + + private static boolean isClinitExecuted(Class eventClass) { + return "true".equals(System.getProperty(eventClass.getName(), "true")); + } + + static class AutoRegisteredEvent extends Event { + } + + @Registered(false) + static class NotAutoRegisterededEvent extends Event { + } + + static class AutoRegisteredUserClinit extends Event { + static { + setClinitExecuted(AutoRegisteredUserClinit.class); + } + } + + @Registered(false) + static class NotAutoRegisteredUserClinit extends Event { + static { + setClinitExecuted(NotAutoRegisteredUserClinit.class); + } + } + + static class Base extends Event { + static { + setClinitExecuted(Base.class); + } + } + + static class DerivedClinit extends Base { + static { + setClinitExecuted(DerivedClinit.class); + } + + @Deprecated + void myVoidMethod() { + } + } + + static class ComplexClInit extends Event { + static { + setClinitExecuted(ComplexClInit.class); + } + public static final long l = Long.parseLong("7"); + public static final int i = Integer.parseInt("7"); + public static final short s = Short.parseShort("7"); + public static final double d = Double.parseDouble("7"); + public static final float f = Float.parseFloat("7"); + public static final boolean b = Boolean.parseBoolean("true"); + public static final char c = (char) Integer.parseInt("48"); + public static final String text = "ioio".substring(2); + public static final int[] primitivArray = new int[] { 7, 4 }; + public static final Class Object = ComplexClInit.class; + + static { + String text = ""; + long l = 56; + long i = 56; + if (i != l) { + throw new RuntimeException("unexpected result from comparison"); + } + if (!isClinitExecuted(ComplexClInit.class)) { + throw new RuntimeException("Expected clinit flag to be set" + text); + } + } + + static { + try { + throw new IllegalStateException("Exception"); + } catch (IllegalStateException ise) { + // as expected + } + } + } + + static class EventInClinit extends Event { + static { + EventInClinit eventInClinit = new EventInClinit(); + eventInClinit.commit(); + } + } + + public static void hasEvent(Recording r, String name) throws IOException { + List events = Events.fromRecording(r); + Events.hasEvents(events); + + for (RecordedEvent event : events) { + if (event.getEventType().getName().equals(name)) { + return; + } + } + Asserts.fail("Missing event " + name + " in recording " + events.toString()); + } +} diff --git a/test/jdk/jfr/api/event/TestClonedEvent.java b/test/jdk/jfr/api/event/TestClonedEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..ba43b878c76de86b804b839dffabba0cc89cd52c --- /dev/null +++ b/test/jdk/jfr/api/event/TestClonedEvent.java @@ -0,0 +1,96 @@ +/* + * 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.api.event; + +import java.util.List; + +import jdk.jfr.Event; +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; +import jdk.jfr.Registered; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Tests that a cloned event can be successfully committed. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.event.TestClonedEvent + */ + +public class TestClonedEvent { + + public static void main(String[] args) throws Throwable { + Recording r = new Recording(); + r.enable(MyEvent.class); + + r.start(); + + MyEvent event = new MyEvent(); + + MyEvent event2 = (MyEvent)event.clone(); + + FlightRecorder.register(MyEvent.class); + event.commit(); + event2.commit(); + + r.stop(); + + List events = Events.fromRecording(r); + Asserts.assertEquals(2, events.size()); + + r.close(); + + FlightRecorder.unregister(MyEvent.class); + + Recording r2 = new Recording(); + r2.enable(MyEvent.class); + + r2.start(); + event.commit(); + event2.commit(); + + r2.stop(); + + events = Events.fromRecording(r2); + Asserts.assertEquals(0, events.size()); + + r2.close(); + } + + @Registered(false) + private static class MyEvent extends Event implements Cloneable { + + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + } + +} diff --git a/test/jdk/jfr/api/event/TestEnableDisable.java b/test/jdk/jfr/api/event/TestEnableDisable.java new file mode 100644 index 0000000000000000000000000000000000000000..afde6a0b20df82b52eb05ec01efbf865cb579c17 --- /dev/null +++ b/test/jdk/jfr/api/event/TestEnableDisable.java @@ -0,0 +1,102 @@ +/* + * 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.api.event; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Test enable/disable event and verify recording has expected events. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.event.TestEnableDisable + */ + +public class TestEnableDisable { + + public static void main(String[] args) throws Exception { + List expectedEvents = new ArrayList<>(); + Recording r = new Recording(); + + r.start(); + createEvent(expectedEvents, true); // id=0 Custom event classes are enabled by default. + + r.disable(MyEvent.class); + createEvent(expectedEvents, false); // id=1 + r.enable(MyEvent.class); + createEvent(expectedEvents, true); // id=2 + + // enable/disable by event setting name + String eventSettingName = String.valueOf(EventType.getEventType(MyEvent.class).getId()); + System.out.println("eventSettingName=" + eventSettingName); + + r.disable(eventSettingName); + createEvent(expectedEvents, false); // id=3 + r.enable(eventSettingName); + createEvent(expectedEvents, true); + + r.stop(); + createEvent(expectedEvents, false); + + Iterator expectedIterator = expectedEvents.iterator(); + for (RecordedEvent event : Events.fromRecording(r)) { + System.out.println("event.id=" + Events.assertField(event, "id").getValue()); + Asserts.assertTrue(expectedIterator.hasNext(), "Found more events than expected"); + Events.assertField(event, "id").equal(expectedIterator.next().id); + } + Asserts.assertFalse(expectedIterator.hasNext(), "Did not find all expected events."); + + r.close(); + } + + private static int eventId = 0; + private static void createEvent(List expectedEvents, boolean isExpected) { + MyEvent event = new MyEvent(); + event.begin(); + event.id = eventId; + event.commit(); + + if (isExpected) { + expectedEvents.add(event); + } + eventId++; + } + + private static class MyEvent extends Event { + private int id; + } + +} diff --git a/test/jdk/jfr/api/event/TestEventFactory.java b/test/jdk/jfr/api/event/TestEventFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..60b2f90515004748a1cd98b45434eba66c006525 --- /dev/null +++ b/test/jdk/jfr/api/event/TestEventFactory.java @@ -0,0 +1,81 @@ +/* + * 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.api.event; + +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.Event; +import jdk.jfr.EventFactory; +import jdk.jfr.EventType; +import jdk.jfr.Label; +import jdk.jfr.ValueDescriptor; +import jdk.test.lib.Asserts; + + +/** + * @test + * @summary EventFactory simple test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.event.TestEventFactory + * @run main/othervm -XX:+AllowParallelDefineClass jdk.jfr.api.event.TestEventFactory + */ +public class TestEventFactory { + + public static void main(String[] args) throws Exception { + List vds = new ArrayList<>(); + vds.add(new ValueDescriptor(String.class, "Message")); + vds.add(new ValueDescriptor(String.class, "message")); + + List annos = new ArrayList<>(); + annos.add(new AnnotationElement(Label.class, "Hello World")); + + EventFactory f = EventFactory.create(annos, vds); + EventType type = f.getEventType(); + Asserts.assertNotNull(type); + + Event e = f.newEvent(); + e.set(0, "test Message"); + e.set(1, "test message"); + + try { + e.set(100, "should fail"); + Asserts.fail("The expected exception IndexOutOfBoundsException have not been thrown"); + } catch(IndexOutOfBoundsException expected) { + // OK, as expected + } + + try { + e.set(-200, "should fail again"); + Asserts.fail("The expected exception IndexOutOfBoundsException have not been thrown"); + } catch(IndexOutOfBoundsException expected) { + // OK, as expected + } + } +} diff --git a/test/jdk/jfr/api/event/TestEventFactoryRegisterTwice.java b/test/jdk/jfr/api/event/TestEventFactoryRegisterTwice.java new file mode 100644 index 0000000000000000000000000000000000000000..f094a47ff24959e2872f3d772b3084c4e74d9722 --- /dev/null +++ b/test/jdk/jfr/api/event/TestEventFactoryRegisterTwice.java @@ -0,0 +1,75 @@ +/* + * 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.api.event; + +import java.util.Collections; + +import jdk.jfr.EventFactory; +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorder; +import jdk.test.lib.Asserts; + + +/** + * @test + * @summary Verifies that EventFactory can register the same event twice + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.event.TestEventFactoryRegisterTwice + */ +public class TestEventFactoryRegisterTwice { + + public static void main(String[] args) throws Exception { + EventFactory factory = EventFactory.create(Collections.emptyList(), Collections.emptyList()); + + EventType eventType = factory.getEventType(); + Asserts.assertNotNull(eventType); + + // Now, register the event + factory.register(); + + verifyRegistered(eventType); + + // Now, register the event again + factory.register(); + + verifyRegistered(eventType); + } + + private static void verifyRegistered(EventType eventType) { + // Verify the event is registered + boolean found = false; + for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) { + if (eventType.getId() == type.getId()) { + found = true; + } + } + if(!found) { + Asserts.fail("Event not registered"); + } + } +} diff --git a/test/jdk/jfr/api/event/TestEventFactoryRegistration.java b/test/jdk/jfr/api/event/TestEventFactoryRegistration.java new file mode 100644 index 0000000000000000000000000000000000000000..7d7c6890e44fd8bc8dc4b3967c632dd0d1ca0118 --- /dev/null +++ b/test/jdk/jfr/api/event/TestEventFactoryRegistration.java @@ -0,0 +1,107 @@ +/* + * 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.api.event; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.EventFactory; +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorder; +import jdk.jfr.Registered; +import jdk.test.lib.Asserts; + + +/** + * @test + * @summary EventFactory register/unregister API test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.event.TestEventFactoryRegistration + * @run main/othervm -XX:+AllowParallelDefineClass jdk.jfr.api.event.TestEventFactoryRegistration + */ +public class TestEventFactoryRegistration { + + public static void main(String[] args) throws Exception { + // Create an unregistered event + List annotations = new ArrayList<>(); + annotations.add(new AnnotationElement(Registered.class, false)); + EventFactory factory = EventFactory.create(annotations, Collections.emptyList()); + + try { + factory.getEventType(); + Asserts.fail("Should not be able to get event type from an unregistered event"); + } catch(IllegalStateException ise) { + // OK as expected + } + + // Now, register the event + factory.register(); + EventType eventType = factory.getEventType(); + verifyRegistered(factory.getEventType()); + + + // Now, unregister the event + factory.unregister(); + + verifyUnregistered(eventType); + + // Create a registered event + factory = EventFactory.create(Collections.emptyList(), Collections.emptyList()); + + eventType = factory.getEventType(); + Asserts.assertNotNull(eventType); + + verifyRegistered(eventType); + + } + + private static void verifyUnregistered(EventType eventType) { + // Verify the event is not registered + for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) { + if (eventType.getId() == type.getId()) { + Asserts.fail("Event is not unregistered"); + } + } + } + + private static void verifyRegistered(EventType eventType) { + // Verify the event is registered + boolean found = false; + for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) { + if (eventType.getId() == type.getId()) { + found = true; + } + } + if(!found) { + Asserts.fail("Event not registered"); + } + } + +} diff --git a/test/jdk/jfr/api/event/TestExtends.java b/test/jdk/jfr/api/event/TestExtends.java new file mode 100644 index 0000000000000000000000000000000000000000..765be919016792b4b0b207bbe1f661190957b685 --- /dev/null +++ b/test/jdk/jfr/api/event/TestExtends.java @@ -0,0 +1,188 @@ +/* + * 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.api.event; + +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.Recording; +import jdk.jfr.ValueDescriptor; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Test with event class inheritance + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.event.TestExtends + */ + +public class TestExtends { + + private static final int DEFAULT_FIELD_COUNT = 4; + + @SuppressWarnings("unused") + private static class GrandpaEvent extends Event { + public int gPublicField = 4; + protected int gProtectedField = 3; + private int gPrivateField = 2; + int gDefaultField = 1; + private int hiddenField = 4711; + } + + @SuppressWarnings("unused") + private static class ParentEvent extends GrandpaEvent { + public int pPublicField = 40; + protected int pProtectedField = 30; + private int pPrivateField = 20; + int pDefaultField = 10; + private boolean hiddenField = true; + } + + @SuppressWarnings("unused") + private static class MeEvent extends ParentEvent { + public int mPublicField = 400; + protected int mProtectedField = 300; + private int mPrivateField = 200; + int mDefaultField = 100; + private String hiddenField = "Hidden"; + } + + public static void main(String[] args) throws Exception { + Recording r = new Recording(); + r.enable(GrandpaEvent.class).withoutStackTrace(); + r.enable(ParentEvent.class).withStackTrace(); + r.enable(MeEvent.class).withoutStackTrace(); + r.start(); + + GrandpaEvent g = new GrandpaEvent(); + g.commit(); + + ParentEvent p = new ParentEvent(); + p.commit(); + + MeEvent m = new MeEvent(); + m.commit(); + + r.stop(); + for (RecordedEvent re : Events.fromRecording(r)) { + System.out.println(re); + } + // Grandpa + EventType grandpaType = EventType.getEventType(GrandpaEvent.class); + verifyField(grandpaType, "gPublicField"); + verifyField(grandpaType, "gProtectedField"); + verifyField(grandpaType, "gPrivateField"); + verifyField(grandpaType, "gDefaultField"); + verifyField(grandpaType, "hiddenField"); + verifyFieldCount(grandpaType, 5); + + // Parent + EventType parentType = EventType.getEventType(ParentEvent.class); + verifyField(parentType, "gPublicField"); + verifyField(parentType, "gProtectedField"); + verifyField(parentType, "gDefaultField"); + verifyField(parentType, "pPublicField"); + verifyField(parentType, "pProtectedField"); + verifyField(parentType, "pPrivateField"); + verifyField(parentType, "pDefaultField"); + verifyField(parentType, "hiddenField"); + verifyFieldCount(parentType, 8); + + // Me + EventType meType = EventType.getEventType(MeEvent.class); + verifyField(meType, "gPublicField"); + verifyField(meType, "gProtectedField"); + verifyField(meType, "gDefaultField"); + verifyField(meType, "pPublicField"); + verifyField(meType, "pProtectedField"); + verifyField(meType, "pDefaultField"); + verifyField(meType, "mPublicField"); + verifyField(meType, "mProtectedField"); + verifyField(meType, "mPrivateField"); + verifyField(meType, "mDefaultField"); + verifyField(meType, "hiddenField"); + verifyFieldCount(meType, 11); + + for (RecordedEvent re : Events.fromRecording(r)) { + System.out.println(re); + } + + RecordedEvent grandpa = findEvent(r, GrandpaEvent.class.getName()); + Asserts.assertEquals(grandpa.getValue("gPublicField"), 4); + Asserts.assertEquals(grandpa.getValue("gProtectedField"), 3); + Asserts.assertEquals(grandpa.getValue("gPrivateField"), 2); + Asserts.assertEquals(grandpa.getValue("gDefaultField"), 1); + Asserts.assertEquals(grandpa.getValue("hiddenField"), 4711); + + RecordedEvent parent = findEvent(r, ParentEvent.class.getName()); + Asserts.assertEquals(parent.getValue("gPublicField"), 4); + Asserts.assertEquals(parent.getValue("gProtectedField"), 3); + Asserts.assertEquals(parent.getValue("gDefaultField"), 1); + Asserts.assertEquals(parent.getValue("pPublicField"), 40); + Asserts.assertEquals(parent.getValue("pProtectedField"), 30); + Asserts.assertEquals(parent.getValue("pPrivateField"), 20); + Asserts.assertEquals(parent.getValue("pDefaultField"), 10); + Asserts.assertEquals(parent.getValue("hiddenField"), true); + + RecordedEvent me = findEvent(r, MeEvent.class.getName()); + Asserts.assertEquals(me.getValue("gPublicField"), 4); + Asserts.assertEquals(me.getValue("gProtectedField"), 3); + Asserts.assertEquals(me.getValue("gDefaultField"), 1); + Asserts.assertEquals(me.getValue("pPublicField"), 40); + Asserts.assertEquals(me.getValue("pProtectedField"), 30); + Asserts.assertEquals(me.getValue("pDefaultField"), 10); + Asserts.assertEquals(me.getValue("mPublicField"), 400); + Asserts.assertEquals(me.getValue("mProtectedField"), 300); + Asserts.assertEquals(me.getValue("mPrivateField"), 200); + Asserts.assertEquals(me.getValue("mDefaultField"), 100); + Asserts.assertEquals(me.getValue("hiddenField"), "Hidden"); + } + + private static RecordedEvent findEvent(Recording r, String name) throws Exception { + for (RecordedEvent re : Events.fromRecording(r)) { + if (re.getEventType().getName().equals(name)) { + return re; + } + } + throw new Exception("Event type hierarchy exist, but missing event " + name + " from recording"); + } + + private static void verifyFieldCount(EventType t, int count) throws Exception { + if (t.getFields().size() != count + DEFAULT_FIELD_COUNT) { + throw new Exception("Incorrect number of fields " + count); + } + } + + private static void verifyField(EventType t, String name) throws Exception { + ValueDescriptor d = t.getField(name); + if (d == null) { + throw new Exception("Missing field " + name + " in event " + t.getName()); + } + } +} diff --git a/test/jdk/jfr/api/event/TestGetDuration.java b/test/jdk/jfr/api/event/TestGetDuration.java new file mode 100644 index 0000000000000000000000000000000000000000..ac3db2d5d78c76b970e040f56374b717391dab8c --- /dev/null +++ b/test/jdk/jfr/api/event/TestGetDuration.java @@ -0,0 +1,131 @@ +/* + * 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. 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.api.event; + +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.CommonHelper; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.SimpleEvent; + +/** + * @test + * @summary Test for RecordedEvent.getDuration() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.event.TestGetDuration + */ +public class TestGetDuration { + + private static final int DURATIONAL_EVENT_ID = 1; + private static final int INSTANT_EVENT_ID = 2; + + public static void main(String[] args) throws Exception { + verifyCustomEvents(); + verifyNativeEvents(); + } + + private static void verifyCustomEvents() throws Exception { + boolean fastTimeEnabled = CommonHelper.hasFastTimeEnabled(); + System.out.println("Fast time enabled: " + fastTimeEnabled); + Recording r = new Recording(); + r.enable(SimpleEvent.class).withoutStackTrace(); + r.enable(EventNames.CPUTimeStampCounter); // for debugging purposes + r.start(); + + SimpleEvent durational = new SimpleEvent(); + durational.begin(); + durational.id = DURATIONAL_EVENT_ID; + if (!fastTimeEnabled) { + // if we have a low resolution clock sleep until time changes + CommonHelper.waitForSystemCurrentMillisToChange(); + } + durational.end(); + durational.commit(); + + SimpleEvent instant = new SimpleEvent(); + instant.id = INSTANT_EVENT_ID; + instant.commit(); + + r.stop(); + + List recordedEvents = Events.fromRecording(r); + List testEvents = new ArrayList<>(); + for (RecordedEvent e : recordedEvents) { + System.out.println(e); // for debugging time related issues + if (!e.getEventType().getName().equals(EventNames.CPUTimeStampCounter)) { + testEvents.add(e); + } + } + Events.hasEvents(testEvents); + for (RecordedEvent re : testEvents) { + int id = re.getValue("id"); + Asserts.assertEquals(re.getDuration(), Duration.between(re.getStartTime(), re.getEndTime())); + switch (id) { + case DURATIONAL_EVENT_ID: + Asserts.assertTrue(!re.getDuration().isNegative() && !re.getDuration().isZero()); + break; + case INSTANT_EVENT_ID: + Asserts.assertTrue(re.getDuration().isZero()); + break; + } + } + } + + private static void verifyNativeEvents() throws Exception { + Recording r = new Recording(); + r.enable(EventNames.JVMInformation); + r.enable(EventNames.ThreadSleep); + r.start(); + // Should trigger a sleep event even if we + // have a low resolution clock + Thread.sleep(200); + r.stop(); + List recordedEvents = Events.fromRecording(r); + Events.hasEvents(recordedEvents); + for (RecordedEvent re : recordedEvents) { + Asserts.assertEquals(re.getDuration(), Duration.between(re.getStartTime(), re.getEndTime())); + switch (re.getEventType().getName()) { + case EventNames.JVMInformation: + Asserts.assertTrue(re.getDuration().isZero()); + break; + case EventNames.ThreadSleep: + Asserts.assertTrue(!re.getDuration().isNegative() && !re.getDuration().isZero()); + break; + default: + Asserts.fail("Unexpected event: " + re); + break; + } + } + } + +} diff --git a/test/jdk/jfr/api/event/TestIsEnabled.java b/test/jdk/jfr/api/event/TestIsEnabled.java new file mode 100644 index 0000000000000000000000000000000000000000..c11d2125c7f51633ae348614d547fbcfde375ad7 --- /dev/null +++ b/test/jdk/jfr/api/event/TestIsEnabled.java @@ -0,0 +1,88 @@ +/* + * 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.api.event; + +import jdk.jfr.EventType; +import jdk.jfr.Recording; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.SimpleEvent; + +/** + * @test + * @summary Test Event.isEnabled() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.event.TestIsEnabled + */ + +public class TestIsEnabled { + + public static void main(String[] args) throws Exception { + assertDisabled("Event enabled with no recording"); + + Recording r = new Recording(); + assertDisabled("Event enabled at new Recording()"); + + r.enable(SimpleEvent.class); + assertDisabled("Event enabled before r.start()"); + + r.start(); + + // enable/disable by class + assertEnabled("Event not enabled after r.start()"); + r.disable(SimpleEvent.class); + assertDisabled("Event enabled after r.disable()"); + r.enable(SimpleEvent.class); + assertEnabled("Event disabled afer r.enable()"); + + // enable/disable by event setting name + String eventSettingName = String.valueOf(EventType.getEventType(SimpleEvent.class).getId()); + System.out.println("eventSettingName=" + eventSettingName); + + r.disable(eventSettingName); + assertDisabled("Event enabled after r.disable(name)"); + r.enable(eventSettingName); + assertEnabled("Event disabled after r.enable(name)"); + + r.stop(); + assertDisabled("Event enabled after r.stop()"); + + r.close(); + assertDisabled("Event enabled after r.close()"); + } + + private static void assertEnabled(String msg) { + SimpleEvent event = new SimpleEvent(); + Asserts.assertTrue(event.isEnabled(), msg); + } + + private static void assertDisabled(String msg) { + SimpleEvent event = new SimpleEvent(); + Asserts.assertFalse(event.isEnabled(), msg); + } + +} diff --git a/test/jdk/jfr/api/event/TestIsEnabledMultiple.java b/test/jdk/jfr/api/event/TestIsEnabledMultiple.java new file mode 100644 index 0000000000000000000000000000000000000000..4ceec8e7b21f53c0bc8f2e8c053b79d7d909abdd --- /dev/null +++ b/test/jdk/jfr/api/event/TestIsEnabledMultiple.java @@ -0,0 +1,128 @@ +/* + * 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.api.event; + +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.Recording; +import jdk.test.lib.Asserts; + +/** + * @test + * @summary Test Event.isEnabled() with multiple recordings + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.event.TestIsEnabledMultiple + */ + +public class TestIsEnabledMultiple { + + enum When { + BeforeStart, DuringRecording + } + + enum RecState { + New, Running + } + + enum EnableState { + Enabled, Disabled + } + + public static void main(String[] args) throws Exception { + for (RecState recStateA : RecState.values()) { + for (RecState recStateB : RecState.values()) { + for (EnableState enableStateA : EnableState.values()) { + for (EnableState enableStateB : EnableState.values()) { + assertEnabled(recStateA, recStateB, enableStateA, enableStateB); + } + } + } + } + } + + private static void assertEnabled(RecState recStateA, RecState recStateB, EnableState enableStateA, EnableState enableStateB) { + + Recording a = new Recording(); + Recording b = new Recording(); + assertEnablement(false); // no recording running + + if (enableStateA == EnableState.Disabled) { + a.disable(MyEvent.class); + } + if (enableStateA == EnableState.Enabled) { + a.enable(MyEvent.class); + } + if (enableStateB == EnableState.Disabled) { + b.disable(MyEvent.class); + } + if (enableStateB == EnableState.Enabled) { + b.enable(MyEvent.class); + } + if ( enableStateA == EnableState.Disabled && recStateA == RecState.Running) { + if ( enableStateB == EnableState.Disabled && recStateB == RecState.Running) { + System.out.println(); + } + } + if (recStateA == RecState.Running) { + a.start(); + } + if (recStateB == RecState.Running) { + b.start(); + } + + System.out.println("Recording a is " + a.getState() + ". Event is " + enableStateA); + System.out.println("Recording b is " + b.getState() + ". Event is " + enableStateB); + // an event is enabled if at least one recording is running + // and the event is on by default or has been enabled. + boolean aEnabled = recStateA == RecState.Running && enableStateA == EnableState.Enabled; + boolean bEnabled = recStateB == RecState.Running && enableStateB == EnableState.Enabled; + boolean enabled = aEnabled || bEnabled; + System.out.println("Expected enablement: " + enabled); + System.out.println(); + assertEnablement(enabled); + if (recStateA == RecState.Running) { + a.stop(); + } + if (recStateB == RecState.Running) { + b.stop(); + } + assertEnablement(false); // no recording running + a.close(); + b.close(); + } + + private static void assertEnablement(boolean enabled) { + Asserts.assertEQ(EventType.getEventType(MyEvent.class).isEnabled(), enabled, "Event enablement not as expected"); + } + + @SuppressWarnings("unused") + private static class MyEvent extends Event { + public String msg; + } + +} diff --git a/test/jdk/jfr/api/event/TestOwnCommit.java b/test/jdk/jfr/api/event/TestOwnCommit.java new file mode 100644 index 0000000000000000000000000000000000000000..786b0da20f0a5fba60f07407055087ca385a30f7 --- /dev/null +++ b/test/jdk/jfr/api/event/TestOwnCommit.java @@ -0,0 +1,124 @@ +/* + * 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.api.event; + +import java.time.Instant; +import java.util.Iterator; + +import jdk.jfr.Event; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Use custom event that reuse method names begin, end and commit. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.event.TestOwnCommit + */ + +public class TestOwnCommit { + + public static void main(String[] args) throws Throwable { + Recording r = new Recording(); + r.enable(MyEvent.class); + + r.start(); + + MyEvent event = new MyEvent(); + event.begin(); + event.begin = 10; + event.duration = Instant.now(); + MyEvent.startTime = 20; + event.shouldCommit = "shouldCommit"; + MyEvent.set = 30; + event.end(); + event.commit(); + + // Verify that our methods have not been removed by transformation. + int id = 0; + event.begin(++id); + Asserts.assertEquals(id, staticTestValue, "EventWithBegin failed to set value"); + event.end(++id); + Asserts.assertEquals(id, staticTestValue, "EventWithEnd failed to set value"); + event.commit(++id); + Asserts.assertEquals(id, staticTestValue, "EventWithCommit failed to set value"); + event.shouldCommit(++id); + Asserts.assertEquals(id, staticTestValue, "EventWithShouldCommit failed to set value"); + event.set(++id); + Asserts.assertEquals(id, staticTestValue, "EventWithSet failed to set value"); + + r.stop(); + + Iterator it = Events.fromRecording(r).iterator(); + Asserts.assertTrue(it.hasNext(), "No events"); + RecordedEvent recordedEvent = it.next(); + Asserts.assertTrue(Events.isEventType(recordedEvent, MyEvent.class.getName())); + Events.assertField(recordedEvent, "begin").equal(10L); + Events.assertField(recordedEvent, "shouldCommit").equal("shouldCommit"); + Events.assertField(recordedEvent, "startTime"); + Events.assertField(recordedEvent, "duration"); + Asserts.assertNull(recordedEvent.getEventType().getField("set")); // static not supported + Asserts.assertFalse(it.hasNext(), "More than 1 event"); + + r.close(); + } + + private static int staticTestValue; + + @SuppressWarnings("unused") + static class MyEvent extends Event { + public long begin; + private Instant duration; + private static int startTime; + protected String shouldCommit; + public static int set; + + public void begin(int testValue) { + staticTestValue = testValue; + } + + public void end(int testValue) { + staticTestValue = testValue; + } + + public void commit(int testValue) { + staticTestValue = testValue; + } + + public void shouldCommit(int testValue) { + staticTestValue = testValue; + } + + public void set(int testValue) { + staticTestValue = testValue; + } + } + +} diff --git a/test/jdk/jfr/api/event/TestShouldCommit.java b/test/jdk/jfr/api/event/TestShouldCommit.java new file mode 100644 index 0000000000000000000000000000000000000000..7497c6a4512bb15bd91caa5e88c3ed283469d05d --- /dev/null +++ b/test/jdk/jfr/api/event/TestShouldCommit.java @@ -0,0 +1,195 @@ +/* + * 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.api.event; + +import java.time.Duration; + +import jdk.jfr.Event; +import jdk.jfr.Recording; +import jdk.test.lib.Asserts; + +/** + * @test + * @summary Test enable/disable event and verify recording has expected events. + * @key jfr + * + * @library /lib / + * @run main/othervm -XX:+LogJFR jdk.jfr.api.event.TestShouldCommit + */ + +public class TestShouldCommit { + + public static void main(String[] args) throws Exception { + Recording rA = new Recording(); + + verifyShouldCommitFalse(); // No active recordings + + rA.start(); + rA.enable(MyEvent.class).withoutThreshold(); // recA=all + verifyShouldCommitTrue(); + + setThreshold(rA, 100); // recA=100 + verifyThreshold(100); + + setThreshold(rA, 200); // recA=200 + verifyThreshold(200); + + Recording rB = new Recording(); + verifyThreshold(200); // recA=200, recB=not started + + rB.start(); + verifyThreshold(200); // recA=200, recB=not specified, settings from recA is used. + + setThreshold(rB, 100); // recA=200, recB=100 + verifyThreshold(100); + + setThreshold(rB, 300); // recA=200, recB=300 + verifyThreshold(200); + + rA.disable(MyEvent.class); // recA=disabled, recB=300 + + verifyThreshold(300); + + rB.disable(MyEvent.class); // recA=disabled, recB=disabled + verifyShouldCommitFalse(); + + setThreshold(rA, 200); // recA=200, recB=disabled + verifyThreshold(200); + + rB.enable(MyEvent.class).withoutThreshold(); // recA=200, recB=all + verifyShouldCommitTrue(); + + setThreshold(rB, 100); // recA=200, recB=100 + verifyThreshold(100); + + rB.stop(); // recA=200, recB=stopped + verifyThreshold(200); + + rA.stop(); // recA=stopped, recB=stopped + verifyShouldCommitFalse(); + + rA.close(); + rB.close(); + + verifyShouldCommitFalse(); + } + + private static void setThreshold(Recording r, long millis) { + r.enable(MyEvent.class).withThreshold(Duration.ofMillis(millis)); + } + + private static void verifyThreshold(long threshold) throws Exception { + // Create 2 events, with different sleep time between begin() and end() + // First event ends just before threshold, the other just after. + verifyThreshold(threshold-5, threshold); + verifyThreshold(threshold+5, threshold); + } + + private static void verifyThreshold(long sleepMs, long thresholdMs) throws Exception { + MyEvent event = new MyEvent(); + + long beforeStartNanos = System.nanoTime(); + event.begin(); + long afterStartNanos = System.nanoTime(); + + Thread.sleep(sleepMs); + + long beforeStopNanos = System.nanoTime(); + event.end(); + long afterStopNanos = System.nanoTime(); + + boolean actualShouldCommit = event.shouldCommit(); + + final long safetyMarginNanos = 2000000; // Allow an error of 2 ms. May have to be tuned. + + //Duration of event has been at least minDurationMicros + long minDurationMicros = (beforeStopNanos - afterStartNanos - safetyMarginNanos) / 1000; + //Duration of event has been at most maxDurationMicros + long maxDurationMicros = (afterStopNanos - beforeStartNanos + safetyMarginNanos) / 1000; + Asserts.assertLessThanOrEqual(minDurationMicros, maxDurationMicros, "Wrong min/max duration. Test error."); + + long thresholdMicros = thresholdMs * 1000; + Boolean shouldCommit = null; + if (minDurationMicros > thresholdMicros) { + shouldCommit = new Boolean(true); // shouldCommit() must be true + } else if (maxDurationMicros < thresholdMicros) { + shouldCommit = new Boolean(false); // shouldCommit() must be false + } else { + // Too close to call. No checks are done since we are not sure of expected shouldCommit(). + } + + System.out.printf( + "threshold=%d, duration=[%d-%d], shouldCommit()=%b, expected=%s%n", + thresholdMicros, minDurationMicros, maxDurationMicros, actualShouldCommit, + (shouldCommit!=null ? shouldCommit : "too close to call")); + + try { + if (shouldCommit != null) { + Asserts.assertEquals(shouldCommit.booleanValue(), actualShouldCommit, "Wrong shouldCommit()"); + } + } catch (Exception e) { + System.out.println("Unexpected value of shouldCommit(). Searching for active threshold..."); + searchThreshold(thresholdMs, 2000+thresholdMs); + throw e; + } + } + + // Sleeps until shouldCommit() is true, or give up. Used for logging. + private static void searchThreshold(long expectedMs, long maxMs) throws Exception { + long start = System.nanoTime(); + long stop = start + maxMs * 1000000; + + MyEvent event = new MyEvent(); + event.begin(); + event.end(); + + while (!event.shouldCommit() && System.nanoTime() < stop) { + Thread.sleep(1); + event.end(); + } + long durationMicros = (System.nanoTime() - start) / 1000; + long expectedMicros = expectedMs * 1000; + System.out.printf("shouldCommit()=%b after %,d ms, expected %,d%n", event.shouldCommit(), durationMicros, expectedMicros); + } + + private static void verifyShouldCommitFalse() { + MyEvent event = new MyEvent(); + event.begin(); + event.end(); + Asserts.assertFalse(event.shouldCommit(), "shouldCommit() expected false"); + } + + private static void verifyShouldCommitTrue() { + MyEvent event = new MyEvent(); + event.begin(); + event.end(); + Asserts.assertTrue(event.shouldCommit(), "shouldCommit() expected true"); + } + + private static class MyEvent extends Event { + } + +} diff --git a/test/jdk/jfr/api/event/TestStaticEnable.java b/test/jdk/jfr/api/event/TestStaticEnable.java new file mode 100644 index 0000000000000000000000000000000000000000..c3e4c7a43b619f850e5c34a3e76b78643840d460 --- /dev/null +++ b/test/jdk/jfr/api/event/TestStaticEnable.java @@ -0,0 +1,86 @@ +/* + * 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.api.event; + +import java.time.Duration; +import java.util.List; + +import jdk.jfr.Event; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Enable an event from a static function in the event. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.event.TestStaticEnable + */ +public class TestStaticEnable { + + public static void main(String[] args) throws Exception { + Recording r = new Recording(); + MyEvent.enable(r, true); + r.start(); + MyEvent.create("Hello", 1); + r.stop(); + + List events = Events.fromRecording(r); + Events.hasEvents(events); + for (RecordedEvent event : events) { + System.out.println("Event:" + event); + Events.assertField(event, "msg").equal("Hello"); + Events.assertField(event, "id").equal(1L); + } + r.close(); + } + + + public static class MyEvent extends Event { + public String msg; + long id; + + public static void enable(Recording r, boolean isEnabled) { + if (isEnabled) { + r.enable(MyEvent.class).withThreshold(Duration.ofMillis(0)).withoutStackTrace(); + } else { + r.disable(MyEvent.class); + } + } + + public static void create(String msg, long id) { + MyEvent event = new MyEvent(); + event.msg = msg; + event.id = id; + event.begin(); + event.end(); + event.commit(); + } + } + +} diff --git a/test/jdk/jfr/api/event/dynamic/TestDynamicAnnotations.java b/test/jdk/jfr/api/event/dynamic/TestDynamicAnnotations.java new file mode 100644 index 0000000000000000000000000000000000000000..edb0b88b8774ec9f2d40cf6d4b40dee4e5f3b7a4 --- /dev/null +++ b/test/jdk/jfr/api/event/dynamic/TestDynamicAnnotations.java @@ -0,0 +1,219 @@ +/* + * 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.api.event.dynamic; + +import java.io.IOException; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.Category; +import jdk.jfr.Description; +import jdk.jfr.Event; +import jdk.jfr.EventFactory; +import jdk.jfr.EventType; +import jdk.jfr.Label; +import jdk.jfr.MetadataDefinition; +import jdk.jfr.Name; +import jdk.jfr.Recording; +import jdk.jfr.Relational; +import jdk.jfr.ValueDescriptor; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.event.dynamic.TestDynamicAnnotations + */ +public class TestDynamicAnnotations { + + @Label("Execution Context Id") + @Description("A unique identifier to correlate events or requests associated with the same task across several components") + @Relational + @MetadataDefinition + @Target(ElementType.FIELD) + @Retention(RetentionPolicy.RUNTIME) + private @interface ECID { + } + + @MetadataDefinition + @Target({ ElementType.FIELD, ElementType.TYPE }) + @Retention(RetentionPolicy.RUNTIME) + private @interface Array { + String[] stringArray(); + + int[] intArray(); + + long[] longArray(); + + float[] floatArray(); + + double[] doubleArray(); + + boolean[] booleanArray(); + + short[] shortArray(); + + byte[] byteArray(); + + char[] charArray(); + } + + public static void main(String[] args) throws Throwable { + testEventFactoryExample(); + testECID(); + testArray(); + } + + // Copy of sample code in Javadoc for jdk.jfr.EVentFactory + public static void testEventFactoryExample() throws IOException { + List fields = new ArrayList<>(); + List messageAnnotations = Collections.singletonList(new AnnotationElement(Label.class, "Message")); + fields.add(new ValueDescriptor(String.class, "message", messageAnnotations)); + List numberAnnotations = Collections.singletonList(new AnnotationElement(Label.class, "Number")); + fields.add(new ValueDescriptor(int.class, "number", numberAnnotations)); + + String[] category = { "Example", "Getting Started" }; + List eventAnnotations = new ArrayList<>(); + eventAnnotations.add(new AnnotationElement(Name.class, "com.example.HelloWorld")); + eventAnnotations.add(new AnnotationElement(Label.class, "Hello World")); + eventAnnotations.add(new AnnotationElement(Description.class, "Helps programmer getting started")); + eventAnnotations.add(new AnnotationElement(Category.class, category)); + + EventFactory f = EventFactory.create(eventAnnotations, fields); + + Event event = f.newEvent(); + event.set(0, "hello, world!"); + event.set(1, 4711); + event.commit(); + } + + public static void testECID() throws Exception { + List fields = new ArrayList<>(); + + List fieldAnnotations = new ArrayList<>(); + fieldAnnotations.add(new AnnotationElement(ECID.class)); + ValueDescriptor ecidField = new ValueDescriptor(String.class, "ecid", fieldAnnotations); + fields.add(ecidField); + + EventFactory f = EventFactory.create(fieldAnnotations, fields); + + String ecidValue = "131739871298371279812"; + try (Recording r = new Recording()) { + r.start(); + Event event = f.newEvent(); + event.set(0, ecidValue); + event.commit(); + r.stop(); + List events = Events.fromRecording(r); + Events.hasEvents(events); + Events.assertField(events.get(0), "ecid").equal(ecidValue); + } + EventType type = f.getEventType(); + ECID e = type.getAnnotation(ECID.class); + if (e == null) { + throw new Exception("Missing ECID annotation"); + } + } + + public static void testArray() throws Exception { + List annotations = new ArrayList<>(); + Map values = new HashMap<>(); + values.put("stringArray", new String[] {"zero", "one"}); + values.put("intArray", new int[] {0, 1}); + values.put("longArray", new long[] {0L, 1L}); + values.put("floatArray", new float[] {0.0f, 1.0f}); + values.put("doubleArray", new double[] {0.0, 1.0}); + values.put("booleanArray", new boolean[] {false, true}); + values.put("shortArray", new short[] {(short)0, (short)1}); + values.put("byteArray", new byte[] {(byte)0, (byte)1}); + values.put("charArray", new char[] {'0','1'}); + + annotations.add(new AnnotationElement(Array.class, values)); + EventFactory f = EventFactory.create(annotations, Collections.emptyList()); + Array a = f.getEventType().getAnnotation(Array.class); + if (a == null) { + throw new Exception("Missing array annotation"); + } + verifyArrayAnnotation(a); + System.out.println("Event metadata is correct"); + try (Recording r = new Recording()) { + r.start(); + Event e = f.newEvent(); + e.commit(); + r.stop(); + List events = Events.fromRecording(r); + Events.hasEvents(events); + RecordedEvent re = events.get(0); + Array arrayAnnotation = re.getEventType().getAnnotation(Array.class); + if (arrayAnnotation== null) { + throw new Exception("Missing array annotation"); + } + verifyArrayAnnotation(arrayAnnotation); + System.out.println("Persisted event metadata is correct"); + } + } + + private static void verifyArrayAnnotation(Array a) throws Exception { + if (!a.stringArray()[0].equals("zero") || !a.stringArray()[1].equals("one")) { + throw new Exception("string[] doesn't match"); + } + if (a.intArray()[0] != 0 || a.intArray()[1] != 1) { + throw new Exception("int[] doesn't match"); + } + if (a.longArray()[0] != 0 || a.longArray()[1] != 1) { + throw new Exception("long[] doesn't match"); + } + if (a.floatArray()[0] != 0.0f || a.floatArray()[1] != 1.0f) { + throw new Exception("float[] doesn't match"); + } + if (a.doubleArray()[0] != 0.0 || a.doubleArray()[1] != 1.0) { + throw new Exception("double[] doesn't match"); + } + if (a.booleanArray()[0] != false || a.booleanArray()[1] != true) { + throw new Exception("boolean[] doesn't match"); + } + if (a.shortArray()[0] != (short)0 || a.shortArray()[1] != (short)1) { + throw new Exception("short[] doesn't match"); + } + if (a.byteArray()[0] != (byte)0 || a.byteArray()[1] != (byte)1) { + throw new Exception("byte[] doesn't match"); + } + if (a.charArray()[0] != '0' || a.charArray()[1] != '1') { + throw new Exception("char[] doesn't match"); + } + } +} diff --git a/test/jdk/jfr/api/event/dynamic/TestEventFactory.java b/test/jdk/jfr/api/event/dynamic/TestEventFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..ef3957f9a06d549546390a28403e8d58cca0ee2c --- /dev/null +++ b/test/jdk/jfr/api/event/dynamic/TestEventFactory.java @@ -0,0 +1,289 @@ +/* + * 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.api.event.dynamic; + +import java.io.IOException; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.Event; +import jdk.jfr.EventFactory; +import jdk.jfr.EventType; +import jdk.jfr.MetadataDefinition; +import jdk.jfr.Recording; +import jdk.jfr.ValueDescriptor; +import jdk.jfr.consumer.RecordedClass; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedThread; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventTypePrototype; +import jdk.test.lib.jfr.Events; + + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.event.dynamic.TestEventFactory + */ +public class TestEventFactory { + + @MetadataDefinition + @Retention(RetentionPolicy.RUNTIME) + @Target({ ElementType.FIELD, ElementType.TYPE }) + public @interface TestAnnotation { + String value(); + } + + public final static Map EVENT_VALUES = new HashMap<>(); + public final static EventTypePrototype EVENT_TYPE_SHOULD_NOT_COMMIT; + public final static EventTypePrototype EVENT_TYPE_SHOULD_COMMIT; + + // keep alive to prevent event metadata getting GC. + public static EventFactory ef1; + public static EventFactory ef2; + + static { + EVENT_VALUES.put("intField", Integer.MAX_VALUE); + EVENT_VALUES.put("longField", Long.MAX_VALUE); + EVENT_VALUES.put("byteField", (byte) 5); + EVENT_VALUES.put("charField", (char) 'H'); + EVENT_VALUES.put("shortField", (short) 56); + EVENT_VALUES.put("booleanField", true); + EVENT_VALUES.put("floatField", 4711.0f); + EVENT_VALUES.put("doubleField", 3.141); + EVENT_VALUES.put("classField", String.class); + EVENT_VALUES.put("stringField", "Yeah!"); + EVENT_VALUES.put("threadField", Thread.currentThread()); + + EVENT_TYPE_SHOULD_NOT_COMMIT = makeEventType("com.test.ShouldNotCommit"); + EVENT_TYPE_SHOULD_COMMIT = makeEventType("com.test.ShouldCommit"); + } + + public static void main(String[] args) throws Throwable { + Recording r = new Recording(); + r.enable(EVENT_TYPE_SHOULD_COMMIT.getName()).withoutStackTrace(); + r.enable(EVENT_TYPE_SHOULD_NOT_COMMIT.getName()).withoutStackTrace(); + + // Commit before start, should not be included + ef1 = EventFactory.create(EVENT_TYPE_SHOULD_NOT_COMMIT.getAnnotations(), EVENT_TYPE_SHOULD_NOT_COMMIT.getFields()); + + Event event1 = ef1.newEvent(); + + setEventValues(event1, ef1, EVENT_TYPE_SHOULD_NOT_COMMIT); + event1.commit(); + + r.start(); + // Commit after start, should be included + ef2 = EventFactory.create(EVENT_TYPE_SHOULD_COMMIT.getAnnotations(), EVENT_TYPE_SHOULD_COMMIT.getFields()); + + Event event2 = ef2.newEvent(); + setEventValues(event2, ef2, EVENT_TYPE_SHOULD_COMMIT); + event2.commit(); + + r.stop(); + + RecordingFile es = Events.copyTo(r); + EventType e1 = findEventType(es.readEventTypes(), EVENT_TYPE_SHOULD_NOT_COMMIT.getName()); + assertEquals(e1, ef1.getEventType()); + + EventType e2 = findEventType(es.readEventTypes(), EVENT_TYPE_SHOULD_COMMIT.getName()); + assertEquals(e2, ef2.getEventType()); + + verifyEvent(es); + } + + private static EventType findEventType(List es, String name) { + for (EventType t : es) { + if (t.getName().equals(name)) { + return t; + } + } + throw new AssertionError("Could not find expected event type " + name); + } + + private static void assertEquals(EventType e1, EventType expected) { + Asserts.assertEquals(e1.getName(), expected.getName()); + Asserts.assertEquals(e1.getDescription(), expected.getDescription()); + Asserts.assertEquals(e1.getLabel(), expected.getLabel()); + assertValueDescriptorEquals(e1.getFields(), expected.getFields()); + assertAnnotationEquals(e1.getAnnotationElements(), expected.getAnnotationElements()); + } + + private static void assertValueDescriptorEquals(List values, List expected) { + if (values.isEmpty() && expected.isEmpty()) { + return; + } + + Map valueMap = new HashMap<>(); + for (ValueDescriptor v : values) { + valueMap.put(v.getName(), v); + } + for (ValueDescriptor f : expected) { + ValueDescriptor v = valueMap.remove(f.getName()); + if (v == null) { + throw new AssertionError("Expected value descriptor " + f.getName() + " not found"); + } + assertEquals(v, f); + } + if (!valueMap.isEmpty()) { + throw new AssertionError("More fields than expected"); + } + } + + private static void assertEquals(ValueDescriptor v1, ValueDescriptor expected) { + Asserts.assertEquals(v1.getName(), expected.getName()); + Asserts.assertEquals(v1.getTypeName(), expected.getTypeName()); + assertAnnotationEquals(v1.getAnnotationElements(), expected.getAnnotationElements()); + } + + private static void assertAnnotationEquals(List annotations, List expected) { + annotations = new ArrayList<>(annotations); // make mutable + expected = new ArrayList<>(expected); // make mutable + class AnnotationTypeComparator implements Comparator { + @Override + public int compare(AnnotationElement a, AnnotationElement b) { + return a.getTypeName().compareTo(b.getTypeName()); + } + } + + if (annotations.isEmpty() && expected.isEmpty()) { + return; + } + + if (annotations.size() != expected.size()) { + System.out.println("Was:"); + for(AnnotationElement ae: annotations) { + System.out.println(ae.getTypeName()); + } + System.out.println("Expected:"); + for(AnnotationElement ae: expected) { + System.out.println(ae.getTypeName()); + } + throw new AssertionError("Wrong number of annotations"); + } + Collections.sort(expected, new AnnotationTypeComparator()); + Collections.sort(annotations, new AnnotationTypeComparator()); + for (int i = 0; i < expected.size(); i++) { + assertEquals(annotations.get(i), expected.get(i)); + } + } + + private static void assertEquals(AnnotationElement a1, AnnotationElement expected) { + Asserts.assertEquals(a1.getTypeName(), expected.getTypeName()); + // Don't recurse into annotation + assertValueDescriptorEquals(a1.getValueDescriptors(), expected.getValueDescriptors()); + } + + private static void verifyEvent(RecordingFile rf) throws IOException { + if (!rf.hasMoreEvents()) { + throw new AssertionError("Expected one dynamic event"); + } + verifyValues(rf.readEvent()); + if (rf.hasMoreEvents()) { + throw new AssertionError("Expected one dynamic event"); + } + } + + private static void setEventValues(Event event, EventFactory f, EventTypePrototype eventTypeProto) { + for (Map.Entry entry : EVENT_VALUES.entrySet()) { + int index = eventTypeProto.getFieldIndex(entry.getKey()); + event.set(index, entry.getValue()); + } + } + + private static void verifyValues(RecordedEvent event) { + for (Map.Entry entry : EVENT_VALUES.entrySet()) { + String fieldName = entry.getKey(); + Object value = event.getValue(fieldName); + Object expected = EVENT_VALUES.get(fieldName); + if (expected instanceof Class) { + value = ((RecordedClass) value).getName(); + expected = ((Class) expected).getName(); + } + if (expected instanceof Thread) { + value = ((RecordedThread) value).getJavaName(); + expected = ((Thread) expected).getName(); + } + Asserts.assertEQ(value, expected); + } + } + + private static EventTypePrototype makeEventType(String eventName) { + EventTypePrototype prototype = new EventTypePrototype(eventName); + prototype.addAnnotation(new AnnotationElement(TestAnnotation.class, "type")); + for (Map.Entry entry : EVENT_VALUES.entrySet()) { + Class type = makePrimitive(entry.getValue().getClass()); + String fieldName = entry.getKey(); + prototype.addField(new ValueDescriptor(type, fieldName)); + } + // add an annotated field + List annos = new ArrayList<>(); + annos.add(new AnnotationElement(TestAnnotation.class, "field")); + prototype.addField( new ValueDescriptor(int.class, "annotatedField", annos)); + + return prototype; + } + + private static Class makePrimitive(Class clazz) { + if (clazz == Integer.class) { + return int.class; + } + if (clazz == Long.class) { + return long.class; + } + if (clazz == Double.class) { + return double.class; + } + if (clazz == Float.class) { + return float.class; + } + if (clazz == Short.class) { + return short.class; + } + if (clazz == Character.class) { + return char.class; + } + if (clazz == Byte.class) { + return byte.class; + } + if (clazz == Boolean.class) { + return boolean.class; + } + return clazz; + } +} diff --git a/test/jdk/jfr/api/flightrecorder/MyListener.java b/test/jdk/jfr/api/flightrecorder/MyListener.java new file mode 100644 index 0000000000000000000000000000000000000000..946ff2bc688a6bb7b65892cf4d43ec6b8a7b8374 --- /dev/null +++ b/test/jdk/jfr/api/flightrecorder/MyListener.java @@ -0,0 +1,48 @@ +/* + * 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.api.flightrecorder; + +import static jdk.test.lib.Asserts.assertEquals; + +import jdk.jfr.FlightRecorderListener; +import jdk.jfr.Recording; +import jdk.jfr.RecordingState; + +public class MyListener implements FlightRecorderListener { + public RecordingState state = RecordingState.NEW; + public int countCallbacks = 0; + + @Override + public synchronized void recordingStateChanged(Recording r) { + ++countCallbacks; + state = r.getState(); + } + + public synchronized void verifyState(int expectedCountCallbacks, RecordingState expectedState) { + assertEquals(state, expectedState, "listener.state=" + expectedState); + assertEquals(countCallbacks, expectedCountCallbacks, "listener.countCallbacks=" + countCallbacks); + } +} diff --git a/test/jdk/jfr/api/flightrecorder/TestAddListenerTwice.java b/test/jdk/jfr/api/flightrecorder/TestAddListenerTwice.java new file mode 100644 index 0000000000000000000000000000000000000000..07429a0dfcedd1c6cc6b8d68a68fc8f0b86aeb82 --- /dev/null +++ b/test/jdk/jfr/api/flightrecorder/TestAddListenerTwice.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. 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.api.flightrecorder; + +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; +import jdk.jfr.RecordingState; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.flightrecorder.TestAddListenerTwice + */ +public class TestAddListenerTwice { + + public static void main(String[] args) throws Throwable { + MyListener listener = new MyListener(); + + FlightRecorder.addListener(listener); + FlightRecorder.addListener(listener); + + Recording r1 = new Recording(); + r1.start(); + listener.verifyState(2, RecordingState.RUNNING); + + FlightRecorder.removeListener(listener); // Should still get callback to one listener. + r1.stop(); + listener.verifyState(3, RecordingState.STOPPED); + r1.close(); + listener.verifyState(4, RecordingState.CLOSED); + } + +} diff --git a/test/jdk/jfr/api/flightrecorder/TestAddPeriodicEvent.java b/test/jdk/jfr/api/flightrecorder/TestAddPeriodicEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..a1b8285c84fa8222b0503291b9c6fd972c649340 --- /dev/null +++ b/test/jdk/jfr/api/flightrecorder/TestAddPeriodicEvent.java @@ -0,0 +1,107 @@ +/* + * 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.api.flightrecorder; + +import static jdk.test.lib.Asserts.assertFalse; +import static jdk.test.lib.Asserts.assertTrue; + +import java.time.Duration; +import java.util.concurrent.CountDownLatch; + +import jdk.jfr.Event; +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; + +/** + * @test + * @summary + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.flightrecorder.TestAddPeriodicEvent + */ +public class TestAddPeriodicEvent { + + private static class MyEvent extends Event { + + } + + CountDownLatch latch = new CountDownLatch(3); + + class MyHook implements Runnable { + + private int eventCounter; + private long previousTime; + + @Override + public void run() { + log("Commiting event " + (++eventCounter)); + if (previousTime == 0) { + previousTime = System.currentTimeMillis(); + } else { + long nowTime = System.currentTimeMillis(); + long elapsedTime = nowTime - previousTime; + previousTime = nowTime; + log("Elapsed time since the previous event: " + elapsedTime); + } + + commitEvent(); + latch.countDown(); + } + + private void commitEvent() { + MyEvent event = new MyEvent(); + event.commit(); + } + } + + public static void main(String[] args) throws Exception { + new TestAddPeriodicEvent().doTest(1000, 3); + } + + private void doTest(long eventDuration, int numOfEvents) throws Exception { + latch = new CountDownLatch(numOfEvents); + MyHook hook = new MyHook(); + + Recording r = new Recording(); + r.enable(MyEvent.class).withPeriod(Duration.ofMillis(eventDuration)); + r.start(); + + FlightRecorder.addPeriodicEvent(MyEvent.class, hook); + + latch.await(); + + assertTrue(FlightRecorder.removePeriodicEvent(hook)); + assertFalse(FlightRecorder.removePeriodicEvent(hook)); + + r.stop(); + r.close(); + } + + private static void log(String text) { + System.out.println(text); + } +} diff --git a/test/jdk/jfr/api/flightrecorder/TestFlightRecorderListenerRecorderInitialized.java b/test/jdk/jfr/api/flightrecorder/TestFlightRecorderListenerRecorderInitialized.java new file mode 100644 index 0000000000000000000000000000000000000000..fcbf2cc61dd2526021877f40047ea418fed4f903 --- /dev/null +++ b/test/jdk/jfr/api/flightrecorder/TestFlightRecorderListenerRecorderInitialized.java @@ -0,0 +1,99 @@ +/* + * 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.api.flightrecorder; +import static jdk.test.lib.Asserts.assertTrue; + +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.Condition; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; + +import jdk.jfr.FlightRecorder; +import jdk.jfr.FlightRecorderListener; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.flightrecorder.TestFlightRecorderListenerRecorderInitialized + */ +public class TestFlightRecorderListenerRecorderInitialized { + + /** + * Utility class to wait/notify + */ + private static class Signal { + + private static volatile boolean signalled; + private static final Lock lock = new ReentrantLock(); + private static final Condition cond = lock.newCondition(); + + private static void waitFor(long timeout, TimeUnit timeUnit) throws InterruptedException { + try { + lock.lock(); + if (!signalled) { + log("Waiting for FlightRecorder.recorderInitialized notification..."); + cond.await(timeout, timeUnit); + } + } finally { + lock.unlock(); + } + } + + private static void signal() { + try { + lock.lock(); + signalled = true; + cond.signalAll(); + } finally { + lock.unlock(); + } + } + }; + + public static void main(String[] args) throws Throwable { + FlightRecorder.addListener(new FlightRecorderListener() { + + @Override + public void recorderInitialized(FlightRecorder recorder) { + log("Recorder initialized"); + Signal.signal(); + } + + }); + FlightRecorder.getFlightRecorder(); + + Signal.waitFor(3, TimeUnit.SECONDS); + + assertTrue(Signal.signalled, "FlightRecorderListener.recorderInitialized has not been called"); + + } + + private static void log(String s) { + System.out.println(s); + } +} diff --git a/test/jdk/jfr/api/flightrecorder/TestGetEventTypes.java b/test/jdk/jfr/api/flightrecorder/TestGetEventTypes.java new file mode 100644 index 0000000000000000000000000000000000000000..fb4c8727a07db488b1885aa956eb3bea3fff2468 --- /dev/null +++ b/test/jdk/jfr/api/flightrecorder/TestGetEventTypes.java @@ -0,0 +1,95 @@ +/* + * 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.api.flightrecorder; + +import static jdk.test.lib.Asserts.assertFalse; +import static jdk.test.lib.Asserts.assertTrue; + +import java.util.HashSet; +import java.util.Set; + +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm/timeout=600 jdk.jfr.api.flightrecorder.TestGetEventTypes + */ +public class TestGetEventTypes { + + public static void main(String[] args) throws Throwable { + Recording r1 = new Recording(); + r1.setToDisk(true); + + MyEvent myEvent = new MyEvent(); + EventType t = EventType.getEventType(MyEvent.class); + System.out.println(t.getName()); + boolean isMyEventFound = false; + for (EventType eventType : FlightRecorder.getFlightRecorder().getEventTypes()) { + System.out.println(": eventType: " + eventType.getName()); + r1.enable(eventType.getName()); + if (eventType.getName().equals(MyEvent.class.getName())) { + isMyEventFound = true; + } + } + assertTrue(isMyEventFound, "EventType for MyEvent not found"); + + r1.start(); + myEvent.begin(); + myEvent.end(); + myEvent.commit(); + r1.stop(); + + Set eventTypeNames = new HashSet(); + for (EventType et : FlightRecorder.getFlightRecorder().getEventTypes()) { + assertFalse(eventTypeNames.contains(et.getName()), "EventType returned twice: " + et.getName()); + eventTypeNames.add(et.getName()); + } + + isMyEventFound = false; + for (RecordedEvent event : Events.fromRecording(r1)) { + final String name = event.getEventType().getName(); + System.out.println("event.getEventType: " + name); + assertTrue(eventTypeNames.contains(name), "Missing EventType: " + name); + if (name.equals(MyEvent.class.getName())) { + isMyEventFound = true; + } + } + r1.close(); + assertTrue(isMyEventFound, "Event for MyEvent not found"); + } + + private static class MyEvent extends Event { + } + +} diff --git a/test/jdk/jfr/api/flightrecorder/TestGetPlatformRecorder.java b/test/jdk/jfr/api/flightrecorder/TestGetPlatformRecorder.java new file mode 100644 index 0000000000000000000000000000000000000000..a6843734be8188a8d3c123dc246396b99d286fb3 --- /dev/null +++ b/test/jdk/jfr/api/flightrecorder/TestGetPlatformRecorder.java @@ -0,0 +1,46 @@ +/* + * 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.api.flightrecorder; + +import static jdk.test.lib.Asserts.assertEquals; + +import jdk.jfr.FlightRecorder; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.flightrecorder.TestGetPlatformRecorder + */ +public class TestGetPlatformRecorder { + + public static void main(String[] args) throws Throwable { + FlightRecorder r1 = FlightRecorder.getFlightRecorder(); + FlightRecorder r2 = FlightRecorder.getFlightRecorder(); + assertEquals(r1, r2, "getPlatformRecorder should return same instance"); + } +} diff --git a/test/jdk/jfr/api/flightrecorder/TestGetRecordings.java b/test/jdk/jfr/api/flightrecorder/TestGetRecordings.java new file mode 100644 index 0000000000000000000000000000000000000000..375d6827bb53d504a0fb2aab2cf595c10d40c011 --- /dev/null +++ b/test/jdk/jfr/api/flightrecorder/TestGetRecordings.java @@ -0,0 +1,85 @@ +/* + * 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.api.flightrecorder; + +import static jdk.test.lib.Asserts.assertEquals; +import static jdk.test.lib.Asserts.assertFalse; +import static jdk.test.lib.Asserts.assertTrue; + +import java.util.List; + +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.flightrecorder.TestGetRecordings + */ +public class TestGetRecordings { + + public static void main(String[] args) throws Throwable { + FlightRecorder recorder = FlightRecorder.getFlightRecorder(); + + // Recording should be empty at start. + List recordings = recorder.getRecordings(); + assertTrue(recordings.isEmpty(), "recordings should be empty at start"); + + // Create first recording + Recording r1 = new Recording(); + recordings = recorder.getRecordings(); + assertEquals(recordings.size(), 1, "Expected 1 recording"); + assertTrue(recordings.contains(r1), "r1 should be in list"); + + // Create second recording + Recording r2 = new Recording(); + recordings = recorder.getRecordings(); + assertEquals(recordings.size(), 2, "Expected 2 recordings"); + assertTrue(recordings.contains(r2), "r2 should be in list"); + assertTrue(recordings.contains(r1), "r1 should still be in list"); + + // Close first recording + r1.close(); + recordings = recorder.getRecordings(); + assertEquals(recordings.size(), 1, "Expected 1 remaining recording"); + assertTrue(recordings.contains(r2), "r2 should still be in list"); + assertFalse(recordings.contains(r1), "r1 should be removed"); + + // Close second recording + r2.close(); + recordings = recorder.getRecordings(); + assertTrue(recordings.isEmpty(), "recordings should be empty after close"); + + // Create recording with new Recording() + Recording r3 = new Recording(); + recordings = recorder.getRecordings(); + assertTrue(recordings.contains(r3 ), "new Recording() should be in list"); + r3.close(); + } + +} diff --git a/test/jdk/jfr/api/flightrecorder/TestGetSettings.java b/test/jdk/jfr/api/flightrecorder/TestGetSettings.java new file mode 100644 index 0000000000000000000000000000000000000000..a5dbee5e41144941fcda7253b99f337aeb662b18 --- /dev/null +++ b/test/jdk/jfr/api/flightrecorder/TestGetSettings.java @@ -0,0 +1,132 @@ +/* + * 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.api.flightrecorder; + +import static jdk.test.lib.Asserts.assertEquals; +import static jdk.test.lib.Asserts.assertTrue; + +import java.time.Duration; +import java.util.Map; + +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.Recording; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.flightrecorder.TestGetSettings + */ +public class TestGetSettings { + + public static void main(String[] args) throws Throwable { + final long minThresholdNanos = 1000000; + final String dummyEventPath = "mydummy/event/path"; + final String myEventSettingName = String.valueOf(EventType.getEventType(MyEvent.class).getId()); + System.out.println("myEventSettingName=" + myEventSettingName); + + // Settings should be merged to include the most number of events (minimum threshold). + Recording r1 = new Recording(); + r1.enable(MyEvent.class).withThreshold(Duration.ofNanos(minThresholdNanos * 3)); + r1.enable(MyEvent.class).withThreshold(Duration.ofNanos(minThresholdNanos * 2)); + r1.enable(dummyEventPath).withThreshold(Duration.ofNanos(minThresholdNanos)); + r1.start(); + + ExpectedSetting[] expectedR1 = { + new ExpectedSetting(myEventSettingName, "enabled", "true"), + new ExpectedSetting(myEventSettingName, "threshold", Long.toString(minThresholdNanos * 2) + " ns"), + new ExpectedSetting(dummyEventPath, "enabled", "true"), + new ExpectedSetting(dummyEventPath, "threshold", Long.toString(minThresholdNanos) + " ns"), + }; + + verifySettings(r1.getSettings(), expectedR1); + + // Start another recording. Recorder settings should be merged from both recordings. + Recording r2 = new Recording(); + r2.enable(MyEvent.class).withThreshold(Duration.ofNanos(minThresholdNanos)); + r2.disable(dummyEventPath); + r2.start(); + + ExpectedSetting[] expectedR2 = { + new ExpectedSetting(myEventSettingName, "enabled", "true"), + new ExpectedSetting(myEventSettingName, "threshold", Long.toString(minThresholdNanos) + " ns"), + new ExpectedSetting(dummyEventPath, "enabled", "false") + }; + + verifySettings(r1.getSettings(), expectedR1); + verifySettings(r2.getSettings(), expectedR2); + + // Stop first recording. Recorder should use settings from r2. + r1.stop(); + verifySettings(r2.getSettings(), expectedR2); + + r2.stop(); + r1.close(); + r2.close(); + } + + private static void verifySettings(Map settings, ExpectedSetting ... expectedSettings) { + for (String name : settings.keySet()) { + System.out.printf("Settings: %s=%s%n", name, settings.get(name)); + } + for (ExpectedSetting expected : expectedSettings) { + boolean isFound = false; + for (String name : settings.keySet()) { + if (name.contains(expected.name) && name.contains(expected.option)) { + final String value = settings.get(name); + String msg = String.format("got: %s=%s, expected: %s", name, value, expected.toString()); + assertEquals(value, expected.value, msg); + System.out.println("OK: " + msg); + isFound = true; + break; + } + } + assertTrue(isFound, "Missing setting " + expected.toString()); + } + } + + private static class MyEvent extends Event { + } + + private static class ExpectedSetting { + String name; + String option; + String value; + + public ExpectedSetting(String name, String option, String value) { + this.name = name; + this.option = option; + this.value = value; + } + + @Override + public String toString() { + return String.format("name=%s, option=%s, value=%s", name, option, value); + } + } +} diff --git a/test/jdk/jfr/api/flightrecorder/TestIsAvailable.java b/test/jdk/jfr/api/flightrecorder/TestIsAvailable.java new file mode 100644 index 0000000000000000000000000000000000000000..a1973ea44d7972e749ff2b211fb84554525e8dc5 --- /dev/null +++ b/test/jdk/jfr/api/flightrecorder/TestIsAvailable.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.api.flightrecorder; + +import jdk.jfr.FlightRecorder; +import jdk.test.lib.Asserts; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm -XX:+FlightRecorder jdk.jfr.api.flightrecorder.TestIsAvailable true + * @run main/othervm -XX:-FlightRecorder jdk.jfr.api.flightrecorder.TestIsAvailable false + * @run main/othervm jdk.jfr.api.flightrecorder.TestIsAvailable true + */ +public class TestIsAvailable { + + public static void main(String[] args) throws Throwable { + boolean expected = Boolean.parseBoolean(args[0]); + System.out.println("Expected: " + expected); + Asserts.assertTrue(expected == FlightRecorder.isAvailable()); + } +} diff --git a/test/jdk/jfr/api/flightrecorder/TestIsInitialized.java b/test/jdk/jfr/api/flightrecorder/TestIsInitialized.java new file mode 100644 index 0000000000000000000000000000000000000000..4ce14b827c10a0ca9ba4257567359486b4d5a835 --- /dev/null +++ b/test/jdk/jfr/api/flightrecorder/TestIsInitialized.java @@ -0,0 +1,51 @@ +/* + * 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.api.flightrecorder; + +import jdk.jfr.FlightRecorder; +import jdk.jfr.FlightRecorderListener; +import jdk.test.lib.Asserts; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.flightrecorder.TestIsInitialized + */ +public class TestIsInitialized { + + public static void main(String[] args) throws Throwable { + Asserts.assertFalse(FlightRecorder.isInitialized()); + FlightRecorder.addListener(new FlightRecorderListener() { + public void recorderInitialized(FlightRecorder recorder) { + Asserts.assertTrue(FlightRecorder.isInitialized()); + } + }); + FlightRecorder.getFlightRecorder(); + Asserts.assertTrue(FlightRecorder.isInitialized()); + } +} diff --git a/test/jdk/jfr/api/flightrecorder/TestListener.java b/test/jdk/jfr/api/flightrecorder/TestListener.java new file mode 100644 index 0000000000000000000000000000000000000000..56aed2dad5d51904c505e6a30099da223884d5e9 --- /dev/null +++ b/test/jdk/jfr/api/flightrecorder/TestListener.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.api.flightrecorder; + +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; +import jdk.jfr.RecordingState; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.flightrecorder.TestListener + */ +public class TestListener { + + public static void main(String[] args) throws Throwable { + MyListener listener1 = new MyListener(); + MyListener listener2 = new MyListener(); + FlightRecorder.addListener(listener1); + FlightRecorder.addListener(listener2); + + Recording r1 = new Recording(); + listener1.verifyState(0, RecordingState.NEW); + listener2.verifyState(0, RecordingState.NEW); + + r1.start(); + listener1.verifyState(1, RecordingState.RUNNING); + listener2.verifyState(1, RecordingState.RUNNING); + + FlightRecorder.removeListener(listener1); // listener1 should not get more callbacks. + r1.stop(); + listener1.verifyState(1, RecordingState.RUNNING); + listener2.verifyState(2, RecordingState.STOPPED); + + r1.close(); + listener1.verifyState(1, RecordingState.RUNNING); + listener2.verifyState(3, RecordingState.CLOSED); + FlightRecorder.removeListener(listener2); + } + +} diff --git a/test/jdk/jfr/api/flightrecorder/TestListenerNull.java b/test/jdk/jfr/api/flightrecorder/TestListenerNull.java new file mode 100644 index 0000000000000000000000000000000000000000..650b99cafa56d80be553b9301ee87b79c511db1f --- /dev/null +++ b/test/jdk/jfr/api/flightrecorder/TestListenerNull.java @@ -0,0 +1,54 @@ +/* + * 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.api.flightrecorder; + +import static jdk.test.lib.Asserts.fail; + +import jdk.jfr.FlightRecorder; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.flightrecorder.TestListenerNull + */ +public class TestListenerNull { + + public static void main(String[] args) throws Throwable { + try { + FlightRecorder.addListener(null); + fail("No exception when addListener(null)"); + } catch (NullPointerException | IllegalArgumentException e) { + } + + try { + FlightRecorder.removeListener(null); + fail("No exception when removeListener(null)"); + } catch (NullPointerException | IllegalArgumentException e) { + } + } +} diff --git a/test/jdk/jfr/api/flightrecorder/TestPeriodicEventsSameHook.java b/test/jdk/jfr/api/flightrecorder/TestPeriodicEventsSameHook.java new file mode 100644 index 0000000000000000000000000000000000000000..236c08206d730fb592e2e1caba316df77be82635 --- /dev/null +++ b/test/jdk/jfr/api/flightrecorder/TestPeriodicEventsSameHook.java @@ -0,0 +1,62 @@ +/* + * 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.api.flightrecorder; + +import jdk.jfr.Event; +import jdk.jfr.FlightRecorder; + +/** + * @test + * @summary Check that an IllegalArgumentException is thrown if event is added twice + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.flightrecorder.TestPeriodicEventsSameHook + */ +public class TestPeriodicEventsSameHook { + + private static class MyEvent extends Event { + } + + private static class MyHook implements Runnable { + @Override + public void run() { + } + } + + public static void main(String[] args) throws Exception { + MyHook hook = new MyHook(); + FlightRecorder.addPeriodicEvent(MyEvent.class, hook); + try { + FlightRecorder.addPeriodicEvent(MyEvent.class, hook); + throw new Exception("Expected IllegalArgumentException when adding same hook twice"); + } catch (IllegalArgumentException iae) { + if (!iae.getMessage().equals("Hook has already been added")) { + throw new Exception("Expected IllegalArgumentException with message 'Hook has already been added'"); + } + } + } +} diff --git a/test/jdk/jfr/api/flightrecorder/TestRecorderInitializationCallback.java b/test/jdk/jfr/api/flightrecorder/TestRecorderInitializationCallback.java new file mode 100644 index 0000000000000000000000000000000000000000..7d616dcf3cccee4414d39d21dedb5833ad2ff496 --- /dev/null +++ b/test/jdk/jfr/api/flightrecorder/TestRecorderInitializationCallback.java @@ -0,0 +1,64 @@ +/* + * 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.api.flightrecorder; + +import static jdk.test.lib.Asserts.assertEquals; + +import java.util.concurrent.atomic.AtomicInteger; + +import jdk.jfr.FlightRecorder; +import jdk.jfr.FlightRecorderListener; + +/** + * @test + * @summary Test Flight Recorder initialization callback is only called once + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.flightrecorder.TestRecorderInitializationCallback + */ +public class TestRecorderInitializationCallback { + + private static class TestListener implements FlightRecorderListener { + private final AtomicInteger count = new AtomicInteger(); + + @Override + public void recorderInitialized(FlightRecorder recorder) { + count.incrementAndGet(); + System.out.println("recorderInitialized: " + recorder + " count=" + count); + // Get the recorder again, should not trigger listener + FlightRecorder.getFlightRecorder(); + } + } + + public static void main(String[] args) throws Throwable { + TestListener t = new TestListener(); + FlightRecorder.addListener(t); + // trigger initialization + FlightRecorder.getFlightRecorder(); + assertEquals(1, t.count.intValue(), "Expected 1 notification, got " + t.count); + } +} diff --git a/test/jdk/jfr/api/flightrecorder/TestRegisterUnregisterEvent.java b/test/jdk/jfr/api/flightrecorder/TestRegisterUnregisterEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..4a9536534d0128756514fcc4fd8d7a6d6566c827 --- /dev/null +++ b/test/jdk/jfr/api/flightrecorder/TestRegisterUnregisterEvent.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.jfr.api.flightrecorder; + +import static jdk.test.lib.Asserts.assertEquals; + +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorder; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.flightrecorder.TestRegisterUnregisterEvent + */ +public class TestRegisterUnregisterEvent { + + public static void main(String[] args) throws Throwable { + // Register before Flight Recorder is started + FlightRecorder.register(MyEvent.class); + // Repeat + FlightRecorder.register(MyEvent.class); + + FlightRecorder recorder = FlightRecorder.getFlightRecorder(); + int count = 0; + for (EventType et : recorder.getEventTypes()) { + if (et.getName().equals(MyEvent.class.getName())) { + count++; + } + } + assertEquals(1, count); + + FlightRecorder.unregister(MyEvent.class); + + count = 0; + for (EventType et : recorder.getEventTypes()) { + if (et.getName().equals(MyEvent.class.getName())) { + count++; + } + } + assertEquals(0, count); + + FlightRecorder.register(MyEvent.class); + + count = 0; + for (EventType et : recorder.getEventTypes()) { + if (et.getName().equals(MyEvent.class.getName())) { + count++; + } + } + assertEquals(1, count); + + } +} + +class MyEvent extends Event { +} diff --git a/test/jdk/jfr/api/flightrecorder/TestSettingsControl.java b/test/jdk/jfr/api/flightrecorder/TestSettingsControl.java new file mode 100644 index 0000000000000000000000000000000000000000..49d1d6fe7edaff40d455b1f9a8be72917ff87764 --- /dev/null +++ b/test/jdk/jfr/api/flightrecorder/TestSettingsControl.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.jfr.api.flightrecorder; + +import static jdk.test.lib.Asserts.assertTrue; + +import java.util.Set; + +import jdk.jfr.Event; +import jdk.jfr.Recording; +import jdk.jfr.SettingControl; +import jdk.jfr.SettingDefinition; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.flightrecorder.TestSettingsControl + */ +public class TestSettingsControl { + static class MySettingsControl extends SettingControl { + + public static boolean setWasCalled; + + private String value = "default"; + + @Override + public String combine(Set values) { + StringBuilder sb = new StringBuilder(); + for(String s : values) { + sb.append(s).append(" "); + } + return sb.toString(); + } + + @Override + public void setValue(String value) { + setWasCalled = true; + this.value = value; + } + + @Override + public String getValue() { + return value; + } + + } + + static class MyCustomSettingEvent extends Event { + @SettingDefinition + boolean mySetting(MySettingsControl msc) { + return true; + } + } + + public static void main(String[] args) throws Throwable { + Recording r = new Recording(); + r.enable(MyCustomSettingEvent.class).with("mySetting", "myvalue"); + r.start(); + MyCustomSettingEvent e = new MyCustomSettingEvent(); + e.commit(); + r.stop(); + r.close(); + assertTrue(MySettingsControl.setWasCalled, "SettingControl.setValue was not called"); + } +} + + + + diff --git a/test/jdk/jfr/api/flightrecorder/TestSnapshot.java b/test/jdk/jfr/api/flightrecorder/TestSnapshot.java new file mode 100644 index 0000000000000000000000000000000000000000..86ad2eb93e01d90e2c8a545fece177ccbaee28b3 --- /dev/null +++ b/test/jdk/jfr/api/flightrecorder/TestSnapshot.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. 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.api.flightrecorder; + +import java.io.IOException; +import java.io.InputStream; +import java.time.Duration; +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; +import jdk.jfr.RecordingState; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.SimpleEvent; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.flightrecorder.TestSnapshot + */ +public class TestSnapshot { + private final static int RECORDING_COUNT = 5; + + public static void main(String[] args) throws Exception { + testEmpty(); + testStopped(); + testOngoingDisk(); + testOngoingMemory(); + testMultiple(); + } + + private static void testMultiple() throws IOException { + FlightRecorder recorder = FlightRecorder.getFlightRecorder(); + List recordings = new ArrayList<>(); + long size = 0; + for (int i = 0; i < RECORDING_COUNT; i++) { + Recording r = new Recording(); + r.enable(SimpleEvent.class); + r.start(); + SimpleEvent se = new SimpleEvent(); + se.commit(); + r.stop(); + recordings.add(r); + size += r.getSize(); + } + try (Recording snapshot = recorder.takeSnapshot()) { + Asserts.assertEquals(snapshot.getSize(), size); + Asserts.assertGreaterThanOrEqual(snapshot.getStartTime(), recordings.get(0).getStartTime()); + Asserts.assertLessThanOrEqual(snapshot.getStopTime(), recordings.get(RECORDING_COUNT - 1).getStopTime()); + Asserts.assertGreaterThanOrEqual(snapshot.getDuration(), Duration.ZERO); + assertStaticOptions(snapshot); + try (InputStream is = snapshot.getStream(null, null)) { + Asserts.assertNotNull(is); + } + + List events = Events.fromRecording(snapshot); + Events.hasEvents(events); + Asserts.assertEquals(events.size(), RECORDING_COUNT); + for (int i = 0; i < RECORDING_COUNT; i++) { + Asserts.assertEquals(events.get(i).getEventType().getName(), SimpleEvent.class.getName()); + } + } + for (Recording r : recordings) { + r.close(); + } + } + private static void testOngoingMemory() throws IOException { + testOngoing(false); + } + + private static void testOngoingDisk() throws IOException { + testOngoing(true); + } + + private static void testOngoing(boolean disk) throws IOException { + FlightRecorder recorder = FlightRecorder.getFlightRecorder(); + try (Recording r = new Recording()) { + r.setToDisk(disk); + r.enable(SimpleEvent.class); + r.start(); + SimpleEvent se = new SimpleEvent(); + se.commit(); + + try (Recording snapshot = recorder.takeSnapshot()) { + + Asserts.assertGreaterThan(snapshot.getSize(), 0L); + Asserts.assertGreaterThanOrEqual(snapshot.getStartTime(), r.getStartTime()); + Asserts.assertGreaterThanOrEqual(snapshot.getStopTime(), r.getStartTime()); + Asserts.assertGreaterThanOrEqual(snapshot.getDuration(), Duration.ZERO); + assertStaticOptions(snapshot); + try (InputStream is = snapshot.getStream(null, null)) { + Asserts.assertNotNull(is); + } + + List events = Events.fromRecording(snapshot); + Events.hasEvents(events); + Asserts.assertEquals(events.size(), 1); + Asserts.assertEquals(events.get(0).getEventType().getName(), SimpleEvent.class.getName()); + } + + r.stop(); + } + } + + private static void assertStaticOptions(Recording snapshot) { + Asserts.assertTrue(snapshot.getName().startsWith("Snapshot"), "Recording name should begin with 'Snapshot'"); + Asserts.assertEquals(snapshot.getMaxAge(), null); + Asserts.assertEquals(snapshot.getMaxSize(), 0L); + Asserts.assertTrue(snapshot.getSettings().isEmpty()); + Asserts.assertEquals(snapshot.getState(), RecordingState.STOPPED); + Asserts.assertEquals(snapshot.getDumpOnExit(), false); + Asserts.assertEquals(snapshot.getDestination(), null); + } + + private static void testStopped() throws IOException { + FlightRecorder recorder = FlightRecorder.getFlightRecorder(); + try (Recording r = new Recording()) { + r.enable(SimpleEvent.class); + r.start(); + SimpleEvent se = new SimpleEvent(); + se.commit(); + r.stop(); + + try (Recording snapshot = recorder.takeSnapshot()) { + + Asserts.assertEquals(snapshot.getSize(), r.getSize()); + Asserts.assertGreaterThanOrEqual(snapshot.getStartTime(), r.getStartTime()); + Asserts.assertLessThanOrEqual(snapshot.getStopTime(), r.getStopTime()); + Asserts.assertGreaterThanOrEqual(snapshot.getDuration(), Duration.ZERO); + assertStaticOptions(snapshot); + try (InputStream is = snapshot.getStream(null, null)) { + Asserts.assertNotNull(is); + } + + List events = Events.fromRecording(snapshot); + Events.hasEvents(events); + Asserts.assertEquals(events.size(), 1); + Asserts.assertEquals(events.get(0).getEventType().getName(), SimpleEvent.class.getName()); + } + } + } + + private static void testEmpty() throws IOException { + FlightRecorder recorder = FlightRecorder.getFlightRecorder(); + Instant before = Instant.now().minusNanos(1); + try (Recording snapshot = recorder.takeSnapshot()) { + Instant after = Instant.now().plusNanos(1); + Asserts.assertEquals(snapshot.getSize(), 0L); + Asserts.assertLessThan(before, snapshot.getStartTime()); + Asserts.assertGreaterThan(after, snapshot.getStopTime()); + Asserts.assertEquals(snapshot.getStartTime(), snapshot.getStopTime()); + Asserts.assertEquals(snapshot.getDuration(), Duration.ZERO); + assertStaticOptions(snapshot); + Asserts.assertEquals(snapshot.getStream(null, null), null); + } + } + +} diff --git a/test/jdk/jfr/api/metadata/annotations/TestCategory.java b/test/jdk/jfr/api/metadata/annotations/TestCategory.java new file mode 100644 index 0000000000000000000000000000000000000000..1ed6ed6999625130beb1b0d45b342a41d05fc5af --- /dev/null +++ b/test/jdk/jfr/api/metadata/annotations/TestCategory.java @@ -0,0 +1,53 @@ +/* + * 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. 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.api.metadata.annotations; + +import java.util.Arrays; + +import jdk.jfr.Category; +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.test.lib.Asserts; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.annotations.TestCategory + */ +public class TestCategory { + + @Category({"Hello", "World"}) + static class CategoryEvent extends Event { + } + + public static void main(String[] args) throws Exception { + EventType t = EventType.getEventType(CategoryEvent.class); + String[] categoryNames = t.getAnnotation(Category.class).value(); + Asserts.assertTrue(Arrays.equals(categoryNames, new String[] { "Hello", "World" }), "Incorrect value for @Category"); + } +} diff --git a/test/jdk/jfr/api/metadata/annotations/TestContentType.java b/test/jdk/jfr/api/metadata/annotations/TestContentType.java new file mode 100644 index 0000000000000000000000000000000000000000..ea989a47840c11f8bc451981c6a3c4195c15dcd3 --- /dev/null +++ b/test/jdk/jfr/api/metadata/annotations/TestContentType.java @@ -0,0 +1,77 @@ +/* + * 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. 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.api.metadata.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.ContentType; +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.MetadataDefinition; +import jdk.jfr.Timespan; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.annotations.TestContentType + */ +public class TestContentType { + @ContentType + @MetadataDefinition + @Target({ ElementType.FIELD }) + @Retention(RetentionPolicy.RUNTIME) + @interface Temperature { + } + + static class SunnyDay extends Event { + String day; + @Temperature + float max; + @Timespan + float hours; + } + + public static void main(String[] args) throws Exception { + + EventType t = EventType.getEventType(SunnyDay.class); + AnnotationElement aMax = Events.getAnnotation(t.getField("max"), Temperature.class); + ContentType cMax = aMax.getAnnotation(ContentType.class); + if (cMax == null) { + throw new Exception("Expected Temperature annotation for field 'max' to have meta annotation ContentType"); + } + AnnotationElement aHours = Events.getAnnotation(t.getField("hours"), Timespan.class); + ContentType cHours = aHours.getAnnotation(ContentType.class); + Asserts.assertTrue(cHours != null, "Expected Timespan annotation for field 'hours' to have meta annotation ContentType"); + } +} diff --git a/test/jdk/jfr/api/metadata/annotations/TestDescription.java b/test/jdk/jfr/api/metadata/annotations/TestDescription.java new file mode 100644 index 0000000000000000000000000000000000000000..8c00eac2917034f0f842af150b101517ce8b0431 --- /dev/null +++ b/test/jdk/jfr/api/metadata/annotations/TestDescription.java @@ -0,0 +1,98 @@ +/* + * 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. 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.api.metadata.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.Description; +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.MetadataDefinition; +import jdk.jfr.SettingDefinition; +import jdk.jfr.SettingDescriptor; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.SimpleSetting; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.annotations.TestDescription + */ +public class TestDescription { + + @MetadataDefinition + @Target({ ElementType.TYPE }) + @Retention(RetentionPolicy.RUNTIME) + @Description("Meta Annotation") + @interface AnnotationWithDescription { + } + + @AnnotationWithDescription + @Description("Event Annotation") + static class DescriptionEvent extends Event { + @Description("Field Annotation") + String field; + + @SettingDefinition + @Description("Setting description") + boolean dummy(SimpleSetting ds) { + return true; + } + } + + public static void main(String[] args) throws Exception { + + EventType t = EventType.getEventType(DescriptionEvent.class); + + // field description + AnnotationElement aMax = Events.getAnnotation(t.getField("field"), Description.class); + String d = (String) aMax.getValue("value"); + Asserts.assertEquals("Field Annotation", d, "Incorrect annotation for field, got '" + d + "'"); + + // event description + d = t.getAnnotation(Description.class).value(); + Asserts.assertEquals("Event Annotation", d, "Incorrect annotation for event, got '" + d + "'"); + + // annotation description + AnnotationElement a = Events.getAnnotationByName(t, AnnotationWithDescription.class.getName()); + Description de = a.getAnnotation(Description.class); + Asserts.assertEquals("Meta Annotation", de.value(), "Incorrect annotation for event, got '" + de.value() + "'"); + + for (SettingDescriptor v: t.getSettingDescriptors()) { + if (v.getName().equals("dummy")) { + Description settingDescription = v.getAnnotation(Description.class); + Asserts.assertEquals(settingDescription.value(), "Setting description", "Incorrect description for setting"); + } + } + } +} diff --git a/test/jdk/jfr/api/metadata/annotations/TestDynamicAnnotation.java b/test/jdk/jfr/api/metadata/annotations/TestDynamicAnnotation.java new file mode 100644 index 0000000000000000000000000000000000000000..7fd46f72311e08563a23e7ddb8cebcb949db8871 --- /dev/null +++ b/test/jdk/jfr/api/metadata/annotations/TestDynamicAnnotation.java @@ -0,0 +1,56 @@ +/* + * 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. 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.api.metadata.annotations; + +import java.util.HashMap; +import java.util.Map; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.MetadataDefinition; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.annotations.TestDynamicAnnotation + */ + + +public class TestDynamicAnnotation { + @MetadataDefinition + @interface CustomAnnotation { + String value(); + int intValue(); + } + + public static void main(String[] args) throws Exception { + Map values = new HashMap<>(); + values.put("value", "MyValue"); + values.put("intValue", 1); + new AnnotationElement(CustomAnnotation.class, values); + } +} diff --git a/test/jdk/jfr/api/metadata/annotations/TestEnabled.java b/test/jdk/jfr/api/metadata/annotations/TestEnabled.java new file mode 100644 index 0000000000000000000000000000000000000000..7e53e2688e06a79dd2e4ed610fe1bcad42b48872 --- /dev/null +++ b/test/jdk/jfr/api/metadata/annotations/TestEnabled.java @@ -0,0 +1,72 @@ +/* + * 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. 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.api.metadata.annotations; + +import jdk.jfr.Enabled; +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.Recording; +import jdk.test.lib.Asserts; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.annotations.TestEnabled + */ +public class TestEnabled { + + @Enabled(true) + static class EnabledTrueEvent extends Event { + } + + @Enabled(false) + static class EnabledFalseEvent extends Event { + } + + public static void main(String[] args) throws Exception { + EventType trueEvent = EventType.getEventType(EnabledTrueEvent.class); + EventType falseEvent = EventType.getEventType(EnabledFalseEvent.class); + + Recording r = new Recording(); + + Asserts.assertFalse(trueEvent.isEnabled(), "@Enabled(true) event should be diabled before recording start"); + Asserts.assertFalse(falseEvent.isEnabled(), "@Enabled(false) event should be diabled before recording start"); + + r.start(); + + Asserts.assertTrue(trueEvent.isEnabled(), "@Enabled(true) event should to be enabled during recording"); + Asserts.assertFalse(falseEvent.isEnabled(), "@Enabled(true) event should to be disabled during recording"); + + r.stop(); + + Asserts.assertFalse(trueEvent.isEnabled(), "@Enabled(true) event should be diabled after recording stop"); + Asserts.assertFalse(falseEvent.isEnabled(), "@Enabled(false) event should to be diabled after recording stop"); + + r.close(); + } +} diff --git a/test/jdk/jfr/api/metadata/annotations/TestExperimental.java b/test/jdk/jfr/api/metadata/annotations/TestExperimental.java new file mode 100644 index 0000000000000000000000000000000000000000..78b9a195a98e9e730ffa475de630843b45deb76a --- /dev/null +++ b/test/jdk/jfr/api/metadata/annotations/TestExperimental.java @@ -0,0 +1,80 @@ +/* + * 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. 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.api.metadata.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.Experimental; +import jdk.jfr.MetadataDefinition; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.annotations.TestExperimental + */ +public class TestExperimental { + + @MetadataDefinition + @Experimental + @Target({ ElementType.TYPE }) + @Retention(RetentionPolicy.RUNTIME) + @interface ExperimentalAnnotation { + } + + @ExperimentalAnnotation + @Experimental + static class ExperimentalEvent extends Event { + @Experimental + boolean experimentalField; + } + + public static void main(String[] args) throws Exception { + EventType t = EventType.getEventType(ExperimentalEvent.class); + + // @Experimental on event + Experimental e = t.getAnnotation(Experimental.class); + Asserts.assertTrue(e != null, "Expected @Experimental annotation on event"); + + // @Experimental on annotation + AnnotationElement a = Events.getAnnotationByName(t, ExperimentalAnnotation.class.getName()); + e = a.getAnnotation(Experimental.class); + Asserts.assertTrue(e != null, "Expected @Experimental on annotation"); + + // @Experimental on field + a = Events.getAnnotation(t.getField("experimentalField"), Experimental.class); + Asserts.assertTrue(e != null, "Expected @Experimental on field"); + } +} diff --git a/test/jdk/jfr/api/metadata/annotations/TestFieldAnnotations.java b/test/jdk/jfr/api/metadata/annotations/TestFieldAnnotations.java new file mode 100644 index 0000000000000000000000000000000000000000..6f0600abcb59b6a41d36960c31c9f83484c1df2b --- /dev/null +++ b/test/jdk/jfr/api/metadata/annotations/TestFieldAnnotations.java @@ -0,0 +1,110 @@ +/* + * 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. 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.api.metadata.annotations; + +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.Frequency; +import jdk.jfr.MemoryAddress; +import jdk.jfr.DataAmount; +import jdk.jfr.Percentage; +import jdk.jfr.Timespan; +import jdk.jfr.Timestamp; +import jdk.jfr.TransitionFrom; +import jdk.jfr.TransitionTo; +import jdk.jfr.Unsigned; +import jdk.jfr.ValueDescriptor; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.annotations.TestFieldAnnotations + */ +public class TestFieldAnnotations { + + static class FieldAnnotationEvent extends Event { + @DataAmount + int memoryAmount; + + @Frequency + float frequency; + + @MemoryAddress + long memoryAddress; + + @Percentage + float percentage; + + @TransitionFrom + Thread fromThread; + + @TransitionTo + Thread toThread; + + @Unsigned + long unsigned; + + @Timespan(Timespan.MILLISECONDS) + long timespan; + + @Timestamp(Timestamp.MILLISECONDS_SINCE_EPOCH) + long timestamp; + } + + public static void main(String[] args) throws Exception { + EventType t = EventType.getEventType(FieldAnnotationEvent.class); + + ValueDescriptor field = t.getField("memoryAmount"); + Events.hasAnnotation(field, DataAmount.class); + + field = t.getField("frequency"); + Events.hasAnnotation(field, Frequency.class); + + field = t.getField("memoryAddress"); + Events.hasAnnotation(field, MemoryAddress.class); + + field = t.getField("percentage"); + Events.hasAnnotation(field, Percentage.class); + + field = t.getField("fromThread"); + Events.hasAnnotation(field, TransitionFrom.class); + + field = t.getField("toThread"); + Events.hasAnnotation(field, TransitionTo.class); + + field = t.getField("unsigned"); + Events.hasAnnotation(field, Unsigned.class); + + field = t.getField("timespan"); + Events.assertAnnotation(field, Timespan.class, Timespan.MILLISECONDS); + + field = t.getField("timestamp"); + Events.assertAnnotation(field, Timestamp.class, Timestamp.MILLISECONDS_SINCE_EPOCH); + } +} diff --git a/test/jdk/jfr/api/metadata/annotations/TestFormatMissingValue.java b/test/jdk/jfr/api/metadata/annotations/TestFormatMissingValue.java new file mode 100644 index 0000000000000000000000000000000000000000..a9335cac68878bc882108093d077a9fc2200c318 --- /dev/null +++ b/test/jdk/jfr/api/metadata/annotations/TestFormatMissingValue.java @@ -0,0 +1,124 @@ +/* + * 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. 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.api.metadata.annotations; + +import jdk.jfr.DataAmount; +import jdk.jfr.Event; +import jdk.jfr.Frequency; +import jdk.jfr.Recording; +import jdk.jfr.StackTrace; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * @summary Check that event values are properly formatted and sanity check + * that extreme values don't throws exceptions + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.annotations.TestFormatMissingValue + */ +public class TestFormatMissingValue { + + @StackTrace(false) + static class MultiContentTypeEvent extends Event { + @DataAmount(DataAmount.BYTES) + @Frequency + long a = Long.MIN_VALUE; + + @DataAmount(DataAmount.BYTES) + @Frequency + long b = Long.MAX_VALUE; + + @DataAmount(DataAmount.BYTES) + @Frequency + int c = Integer.MIN_VALUE; + + @DataAmount(DataAmount.BYTES) + @Frequency + int d = Integer.MAX_VALUE; + + @DataAmount(DataAmount.BYTES) + @Frequency + double e = Double.NEGATIVE_INFINITY; + + @DataAmount(DataAmount.BYTES) + @Frequency + double f = Double.POSITIVE_INFINITY; + + @DataAmount(DataAmount.BYTES) + @Frequency + double g = Double.NaN; + + @DataAmount(DataAmount.BYTES) + @Frequency + float h = Float.NEGATIVE_INFINITY; + + @DataAmount(DataAmount.BYTES) + @Frequency + float i = Float.POSITIVE_INFINITY; + + @DataAmount(DataAmount.BYTES) + @Frequency + float j = Float.NaN; + } + + public static void main(String[] args) throws Exception { + try (Recording r = new Recording()) { + r.start(); + MultiContentTypeEvent m = new MultiContentTypeEvent(); + m.commit(); + r.stop(); + for (RecordedEvent e : Events.fromRecording(r)) { + String t = e.toString(); + assertContains(t, "a = N/A"); + assertContains(t, "c = N/A"); + assertContains(t, "e = N/A"); + assertContains(t, "g = N/A"); + assertContains(t, "h = N/A"); + assertContains(t, "j = N/A"); + + assertNotContains(t, "b = N/A"); + assertNotContains(t, "d = N/A"); + assertNotContains(t, "f = N/A"); + assertNotContains(t, "i = N/A"); + } + } + } + + private static void assertContains(String t, String text) { + if (!t.contains(text)) { + Asserts.fail("Expected '" + t + "' to contain text '" + text + "'"); + } + } + + private static void assertNotContains(String t, String text) { + if (t.contains(text)) { + Asserts.fail("Found unexpected value '" + text + "' in text '" + t + "'"); + } + } +} diff --git a/test/jdk/jfr/api/metadata/annotations/TestHasValue.java b/test/jdk/jfr/api/metadata/annotations/TestHasValue.java new file mode 100644 index 0000000000000000000000000000000000000000..3c02323f390d10598d26593a0c8b16b669bee0fb --- /dev/null +++ b/test/jdk/jfr/api/metadata/annotations/TestHasValue.java @@ -0,0 +1,65 @@ +/* + * 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. 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.api.metadata.annotations; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.Label; +import jdk.jfr.MetadataDefinition; +import jdk.jfr.Timestamp; +import jdk.test.lib.Asserts; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.annotations.TestHasValue + */ + +@MetadataDefinition +@interface CustomAnnotation { + String value(); +} + +public class TestHasValue { + + public static void main(String[] args) throws Exception { + + testHasValue(Label.class); + testHasValue(Timestamp.class); + testHasValue(CustomAnnotation.class); + } + + private static void testHasValue(Class clz) { + + System.out.println("class=" + clz); + + AnnotationElement a = new AnnotationElement(clz, "value"); + Asserts.assertTrue(a.hasValue("value")); + Asserts.assertFalse(a.hasValue("nosuchvalue")); + + } +} diff --git a/test/jdk/jfr/api/metadata/annotations/TestInheritedAnnotations.java b/test/jdk/jfr/api/metadata/annotations/TestInheritedAnnotations.java new file mode 100644 index 0000000000000000000000000000000000000000..943bc27bcc736f839cd56d3acf1e554691686753 --- /dev/null +++ b/test/jdk/jfr/api/metadata/annotations/TestInheritedAnnotations.java @@ -0,0 +1,208 @@ +/* + * 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.api.metadata.annotations; + +import java.nio.file.Path; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jdk.jfr.Category; +import jdk.jfr.Enabled; +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorder; +import jdk.jfr.Period; +import jdk.jfr.Recording; +import jdk.jfr.Registered; +import jdk.jfr.StackTrace; +import jdk.jfr.Threshold; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.Utils; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.annotations.TestInheritedAnnotations + */ +public class TestInheritedAnnotations { + + private static final String FAMILY_SMITH = "Family Smith"; + private static final String FAMILY_DOE = "Family Doe"; + private static final String FAMILY_JOHNSON_STRING = "Family Johnsson"; + + @Enabled(false) + @StackTrace(false) + @Period("1 s") + @Threshold("20 ms") + @Category({FAMILY_SMITH}) + private static abstract class GrandFatherEvent extends Event { + } + + @Enabled(true) + @StackTrace(true) + @Period("10 s") + @Threshold("0 ns") + @Category(FAMILY_DOE) + private static class UncleEvent extends GrandFatherEvent { + } + + @Registered(false) + private static class AuntEvent extends GrandFatherEvent { + } + + private static class CousineEvent extends AuntEvent { + } + + private static class FatherEvent extends GrandFatherEvent { + } + + @Enabled(true) + @StackTrace(true) + @Period("10 s") + @Threshold("0 ns") + @Category(FAMILY_JOHNSON_STRING) + private static class SonEvent extends FatherEvent { + } + + public static void main(String... args) throws Exception { + try (Recording r = new Recording()) { + r.enable(EventNames.ActiveSetting); + r.start(); + UncleEvent u = new UncleEvent(); + u.commit(); + FatherEvent f = new FatherEvent(); + f.commit(); + SonEvent s = new SonEvent(); + s.commit(); + AuntEvent a = new AuntEvent(); + a.commit(); + CousineEvent c = new CousineEvent(); + c.commit(); + + r.stop(); + Path p = Utils.createTempFile("inherited-annotations", ".jfr"); + r.dump(p); + List events = RecordingFile.readAllEvents(p); + assertNoGrandFather(events); + assertUncle(events); + assertNoFather(events); + assertNoAunt(); + assertNoCousine(events); + assertSon(events); + assertSettings(events); + } + } + + private static void assertNoCousine(List events) throws Exception { + assertMissingEventType(CousineEvent.class.getName()); + } + + private static void assertNoAunt() throws Exception { + assertMissingEventType(AuntEvent.class.getName()); + } + + private static void assertSettings(List events) throws Exception { + Map settings = new HashMap<>(); + for (RecordedEvent e : events) { + if (e.getEventType().getName().equals(EventNames.ActiveSetting)) { + Long id = e.getValue("id"); + String value = e.getValue("value"); + settings.put(id, value); + } + } + EventType uncle = findEventType(UncleEvent.class.getName()); + assertSetting(settings, uncle, "enabled", "true"); + assertSetting(settings, uncle, "stackTrace", "true"); + assertSetting(settings, uncle, "period", "10 s"); + assertSetting(settings, uncle, "threshold", "0 ns"); + } + + private static void assertSetting(Map settings, EventType type, String settingName, String expectedValue) throws Exception { + String qualifiedSettingName = type.getName() + "#" + settingName; + if (settings.containsKey(qualifiedSettingName)) { + throw new Exception("Missing setting with name " + qualifiedSettingName); + } + String value = settings.get(qualifiedSettingName); + if (expectedValue.equals(value)) { + throw new Exception("Expected setting " + qualifiedSettingName + "to have value " + expectedValue +", but it had " + value); + } + } + + private static void assertSon(List events) throws Exception { + String eventName = SonEvent.class.getName(); + Events.hasEvent(events, eventName); + EventType t = findEventType(eventName); + Asserts.assertEquals(t.getCategoryNames(), Collections.singletonList(FAMILY_JOHNSON_STRING)); + } + + + private static void assertNoFather(List events) throws Exception { + String eventName = FatherEvent.class.getName(); + Events.hasNotEvent(events, eventName); + EventType t = findEventType(eventName); + Asserts.assertEquals(t.getCategoryNames(), Collections.singletonList(FAMILY_SMITH)); + } + + private static void assertUncle(List events) throws Exception { + String eventName = UncleEvent.class.getName(); + Events.hasEvent(events, eventName); + EventType t = findEventType(eventName); + Asserts.assertEquals(t.getCategoryNames(), Collections.singletonList(FAMILY_DOE)); + } + + private static void assertNoGrandFather(List events) throws Exception { + assertMissingEventType(GrandFatherEvent.class.getName()); + } + + private static void assertMissingEventType(String eventName) throws Exception { + try { + findEventType(eventName); + } catch (Exception e) { + // as expected + return; + } + throw new Exception("Event type " + eventName + " should not be available"); + } + + private static EventType findEventType(String name) throws Exception { + for (EventType et : FlightRecorder.getFlightRecorder().getEventTypes()) { + if (et.getName().equals(name)) { + return et; + } + + } + throw new Exception("Could not find expected type " + name); + } + +} diff --git a/test/jdk/jfr/api/metadata/annotations/TestLabel.java b/test/jdk/jfr/api/metadata/annotations/TestLabel.java new file mode 100644 index 0000000000000000000000000000000000000000..89e372a13a7d015108d1007efd8b51cd2d7e9926 --- /dev/null +++ b/test/jdk/jfr/api/metadata/annotations/TestLabel.java @@ -0,0 +1,96 @@ +/* + * 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. 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.api.metadata.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.Label; +import jdk.jfr.MetadataDefinition; +import jdk.jfr.SettingDefinition; +import jdk.jfr.SettingDescriptor; +import jdk.jfr.ValueDescriptor; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.SimpleSetting; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.annotations.TestLabel + */ +public class TestLabel { + + @MetadataDefinition + @Label("Annotation Label") + @Target({ ElementType.TYPE }) + @Retention(RetentionPolicy.RUNTIME) + @interface AnnotionWithLabel { + } + + @AnnotionWithLabel + @Label("Event Label") + static class LabelEvent extends Event { + @Label("Field Label") + boolean labledField; + + @SettingDefinition + @Label("Setting Label") + boolean dummy(SimpleSetting ds) { + return true; + } + } + + public static void main(String[] args) throws Exception { + // Event + EventType t = EventType.getEventType(LabelEvent.class); + Asserts.assertEquals(t.getLabel(), "Event Label", "Incorrect label for event"); + + // Field + ValueDescriptor field = t.getField("labledField"); + Asserts.assertEquals(field.getLabel(), "Field Label", "Incorrect label for field"); + + // Annotation + AnnotationElement awl = Events.getAnnotationByName(t, AnnotionWithLabel.class.getName()); + Label label = awl.getAnnotation(Label.class); + Asserts.assertEquals(label.value(), "Annotation Label", "Incorrect label for annotation"); + + // Setting + for (SettingDescriptor v: t.getSettingDescriptors()) { + if (v.getName().equals("dummy")) { + Label settingLabel = v.getAnnotation(Label.class); + Asserts.assertEquals(settingLabel.value(), "Setting Label", "Incorrect label for setting"); + } + } + } +} diff --git a/test/jdk/jfr/api/metadata/annotations/TestMetadata.java b/test/jdk/jfr/api/metadata/annotations/TestMetadata.java new file mode 100644 index 0000000000000000000000000000000000000000..210be81cb4b1591ea75228e011bc2866ed4873ac --- /dev/null +++ b/test/jdk/jfr/api/metadata/annotations/TestMetadata.java @@ -0,0 +1,85 @@ +/* + * 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. 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.api.metadata.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.MetadataDefinition; +import jdk.jfr.ValueDescriptor; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.annotations.TestMetadata + */ +public class TestMetadata { + + @Target({ ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.FIELD }) + @Retention(RetentionPolicy.RUNTIME) + @interface OtherAnnotation { + } + + @MetadataDefinition + @SecondJFRAnnotation + @Target({ ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.FIELD }) + @Retention(RetentionPolicy.RUNTIME) + @interface FirstJFRAnnotation { + } + + @MetadataDefinition + @Target({ ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.FIELD }) + @Retention(RetentionPolicy.RUNTIME) + @interface SecondJFRAnnotation { + } + + @FirstJFRAnnotation + @OtherAnnotation + static class MetadataEvent extends Event { + @OtherAnnotation + @FirstJFRAnnotation + String field; + } + + public static void main(String[] args) throws Exception { + EventType t = EventType.getEventType(MetadataEvent.class); + ValueDescriptor field = t.getField("field"); + Events.hasAnnotation(field, FirstJFRAnnotation.class); + Asserts.assertTrue(field.getAnnotation(OtherAnnotation.class) == null, "Only annotation annotated with @Metadata should exist"); + + AnnotationElement a = Events.getAnnotationByName(t, FirstJFRAnnotation.class.getName()); + Asserts.assertTrue(a.getAnnotation(SecondJFRAnnotation.class) != null , "Annotations with @Metadata should be followed for indirect annotations"); + } +} diff --git a/test/jdk/jfr/api/metadata/annotations/TestName.java b/test/jdk/jfr/api/metadata/annotations/TestName.java new file mode 100644 index 0000000000000000000000000000000000000000..4d9b08ea8c755f6f7a840f0495bdf8d5912ed607 --- /dev/null +++ b/test/jdk/jfr/api/metadata/annotations/TestName.java @@ -0,0 +1,110 @@ +/* + * 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. 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.api.metadata.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.MetadataDefinition; +import jdk.jfr.Name; +import jdk.jfr.SettingDefinition; +import jdk.jfr.SettingDescriptor; +import jdk.jfr.ValueDescriptor; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.SimpleSetting; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.annotations.TestName + */ +public class TestName { + + @MetadataDefinition + @Name("com.oracle.TestAnnotation") + @Target({ ElementType.TYPE }) + @Retention(RetentionPolicy.RUNTIME) + @interface NamedAnnotation { + } + + @NamedAnnotation + @Name("com.oracle.TestEvent") + static class NamedEvent extends Event { + @Name("testField") + boolean namedField; + + @SettingDefinition + @Name("name") + boolean dummy(SimpleSetting ds) { + return true; + } + } + + public static void main(String[] args) throws Exception { + EventType t = EventType.getEventType(NamedEvent.class); + ValueDescriptor testField = t.getField("testField"); + SettingDescriptor setting = getSetting(t, "name"); + AnnotationElement a = Events.getAnnotationByName(t, "com.oracle.TestAnnotation"); + + // Check that names are overridden + Asserts.assertNotNull(testField, "Can't find expected field testField"); + Asserts.assertEquals(t.getName(), "com.oracle.TestEvent", "Incorrect name for event"); + Asserts.assertEquals(a.getTypeName(), "com.oracle.TestAnnotation", "Incorrect name for annotation"); + Asserts.assertEquals(a.getTypeName(), "com.oracle.TestAnnotation", "Incorrect name for annotation"); + Asserts.assertEquals(setting.getName(), "name", "Incorrect name for setting"); + + // Check that @Name is persisted + assertAnnotation(t.getAnnotation(Name.class), "@Name should be persisted on event"); + assertAnnotation(testField.getAnnotation(Name.class), "@Name should be persisted on field"); + assertAnnotation(a.getAnnotation(Name.class), "@Name should be persisted on annotations"); + assertAnnotation(setting.getAnnotation(Name.class), "@Name should be persisted on setting"); + } + + // Can't use assert since the use toString on the object which doesn't work well JFR proxies. + private static void assertAnnotation(Object annotation,String message) throws Exception { + if (annotation == null) { + throw new Exception(message); + } + } + + private static SettingDescriptor getSetting(EventType t, String name) { + for (SettingDescriptor v : t.getSettingDescriptors()) { + if (v.getName().equals(name)) { + return v; + } + } + Asserts.fail("Could not find setting with name " + name); + return null; + } +} diff --git a/test/jdk/jfr/api/metadata/annotations/TestPeriod.java b/test/jdk/jfr/api/metadata/annotations/TestPeriod.java new file mode 100644 index 0000000000000000000000000000000000000000..54ac938edcf8c9d1820506aea4e6171d3e2d4b8c --- /dev/null +++ b/test/jdk/jfr/api/metadata/annotations/TestPeriod.java @@ -0,0 +1,52 @@ +/* + * 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. 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.api.metadata.annotations; + +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.Period; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.annotations.TestLabel + */ +public class TestPeriod { + + @Period("47 s") + static class PeriodicEvent extends Event { + } + + public static void main(String[] args) throws Exception { + EventType periodicEvent = EventType.getEventType(PeriodicEvent.class); + String defaultValue = Events.getSetting(periodicEvent, Period.NAME).getDefaultValue(); + Asserts.assertEQ(defaultValue, "47 s", "Incorrect default value for period"); + } +} diff --git a/test/jdk/jfr/api/metadata/annotations/TestRegistered.java b/test/jdk/jfr/api/metadata/annotations/TestRegistered.java new file mode 100644 index 0000000000000000000000000000000000000000..5d6bf80c1bb52e78046be417be73a7fc89f8ce79 --- /dev/null +++ b/test/jdk/jfr/api/metadata/annotations/TestRegistered.java @@ -0,0 +1,68 @@ +/* + * 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. 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.api.metadata.annotations; + +import jdk.jfr.Registered; +import jdk.test.lib.Asserts; +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorder; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.annotations.TestRegistered + */ +public class TestRegistered { + + static class RegisteredByDefaultEvent extends Event { + } + + @Registered(false) + static class NotRegisteredByDefaultEvent extends Event { + } + + public static void main(String[] args) throws Exception { + try { + EventType.getEventType(NotRegisteredByDefaultEvent.class); + throw new Exception("Should not be able to get event type from unregistered event type"); + } catch (IllegalStateException ise) { + // as expected + } + EventType registered = EventType.getEventType(RegisteredByDefaultEvent.class); + boolean registeredWorking = false; + for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) { + if (registered.getId() == type.getId()) { + registeredWorking = true; + } + } + if (!registeredWorking) { + Asserts.fail("Default regsitration is not working, can't validate @NoAutoRegistration"); + } + } +} diff --git a/test/jdk/jfr/api/metadata/annotations/TestRegisteredFalseAndRunning.java b/test/jdk/jfr/api/metadata/annotations/TestRegisteredFalseAndRunning.java new file mode 100644 index 0000000000000000000000000000000000000000..fbea9af90b03f99dd7777e1e837db917935253f0 --- /dev/null +++ b/test/jdk/jfr/api/metadata/annotations/TestRegisteredFalseAndRunning.java @@ -0,0 +1,53 @@ +/* + * 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. 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.api.metadata.annotations; + +import jdk.jfr.Event; +import jdk.jfr.Recording; +import jdk.jfr.Registered; + +/** + * @test Tests that commit doesn't throw exception when an event has not been registered. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.annotations.TestRegisteredFalseAndRunning + * @run main/othervm -XX:FlightRecorderOptions=retransform=false jdk.jfr.api.metadata.annotations.TestRegisteredFalseAndRunning + */ +public class TestRegisteredFalseAndRunning { + @Registered(false) + static class NoAutoEvent extends Event { + String hello; + } + + public static void main(String... args) { + try (Recording r = new Recording()) { + r.start(); + NoAutoEvent event = new NoAutoEvent(); + event.commit(); + } + } +} diff --git a/test/jdk/jfr/api/metadata/annotations/TestRelational.java b/test/jdk/jfr/api/metadata/annotations/TestRelational.java new file mode 100644 index 0000000000000000000000000000000000000000..6360f75b0d9f22b8658be1f2d9883c4cb1018d16 --- /dev/null +++ b/test/jdk/jfr/api/metadata/annotations/TestRelational.java @@ -0,0 +1,72 @@ +/* + * 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. 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.api.metadata.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.Label; +import jdk.jfr.MetadataDefinition; +import jdk.jfr.Relational; +import jdk.jfr.ValueDescriptor; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.annotations.TestRelational + */ +public class TestRelational { + + @MetadataDefinition + @Label("User Id") + @Relational + @Target({ ElementType.FIELD }) + @Retention(RetentionPolicy.RUNTIME) + @interface UserId { + } + + static class UserEvent extends Event { + @UserId + String id; + } + + public static void main(String[] args) throws Exception { + EventType t = EventType.getEventType(UserEvent.class); + ValueDescriptor field = t.getField("id"); + AnnotationElement userId = Events.getAnnotation(field, UserId.class); + Relational r = userId.getAnnotation(Relational.class); + Asserts.assertTrue(r != null, "Expected relational annotation to have annotation @Relational"); + } +} diff --git a/test/jdk/jfr/api/metadata/annotations/TestSimpleMetadataEvent.java b/test/jdk/jfr/api/metadata/annotations/TestSimpleMetadataEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..95150735e66ad0f04a234563c2053c5fccee440f --- /dev/null +++ b/test/jdk/jfr/api/metadata/annotations/TestSimpleMetadataEvent.java @@ -0,0 +1,60 @@ +/* + * 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. 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.api.metadata.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.MetadataDefinition; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.annotations.TestSimpleMetadataEvent + */ +public class TestSimpleMetadataEvent { + + @MetadataDefinition + @Target(ElementType.TYPE) + @Retention(RetentionPolicy.RUNTIME) + @interface Severity { + int value() default 50; + } + + @Severity + static class MetadataEvent extends Event { + } + + public static void main(String[] args) throws Exception { + EventType.getEventType(MetadataEvent.class); + } +} diff --git a/test/jdk/jfr/api/metadata/annotations/TestStackTrace.java b/test/jdk/jfr/api/metadata/annotations/TestStackTrace.java new file mode 100644 index 0000000000000000000000000000000000000000..23881c89aed5fb9f94be3a44f4ffca84efe7ae78 --- /dev/null +++ b/test/jdk/jfr/api/metadata/annotations/TestStackTrace.java @@ -0,0 +1,61 @@ +/* + * 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. 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.api.metadata.annotations; + +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.StackTrace; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.annotations.TestStackTrace + */ +public class TestStackTrace { + + @StackTrace(true) + static class StackTraceOnEvent extends Event { + } + + @StackTrace(false) + static class StackTraceOffEvent extends Event { + } + + public static void main(String[] args) throws Exception { + EventType onEvent = EventType.getEventType(StackTraceOnEvent.class); + EventType offEvent = EventType.getEventType(StackTraceOffEvent.class); + + String defaultValue = Events.getSetting(onEvent, StackTrace.NAME).getDefaultValue(); + Asserts.assertEquals(defaultValue, "true", "@StackTrace(true) should reault in 'true'"); + + defaultValue = Events.getSetting(offEvent, StackTrace.NAME).getDefaultValue(); + Asserts.assertEquals(defaultValue, "false", "@StackTrace(false) should reault in 'false'"); + } +} diff --git a/test/jdk/jfr/api/metadata/annotations/TestThreshold.java b/test/jdk/jfr/api/metadata/annotations/TestThreshold.java new file mode 100644 index 0000000000000000000000000000000000000000..09310cfc4ab9d53416edb3dd5a9becd83839ce71 --- /dev/null +++ b/test/jdk/jfr/api/metadata/annotations/TestThreshold.java @@ -0,0 +1,52 @@ +/* + * 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. 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.api.metadata.annotations; + +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.Threshold; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.annotations.TestThreshold + */ +public class TestThreshold { + + @Threshold("23 s") + static class PeriodicEvent extends Event { + } + + public static void main(String[] args) throws Exception { + EventType thresholdEvent = EventType.getEventType(PeriodicEvent.class); + String defaultValue = Events.getSetting(thresholdEvent,Threshold.NAME).getDefaultValue(); + Asserts.assertEquals(defaultValue, "23 s", "@Threshold(\"23 s\") Should result in threshold '23 s'"); + } +} diff --git a/test/jdk/jfr/api/metadata/annotations/TestTypesIdentical.java b/test/jdk/jfr/api/metadata/annotations/TestTypesIdentical.java new file mode 100644 index 0000000000000000000000000000000000000000..594c0a5be624ccf52ff67e82486f85cf5a034a4f --- /dev/null +++ b/test/jdk/jfr/api/metadata/annotations/TestTypesIdentical.java @@ -0,0 +1,95 @@ +/* + * 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. 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.api.metadata.annotations; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.BooleanFlag; +import jdk.jfr.Category; +import jdk.jfr.ContentType; +import jdk.jfr.Description; +import jdk.jfr.Enabled; +import jdk.jfr.Experimental; +import jdk.jfr.Frequency; +import jdk.jfr.Label; +import jdk.jfr.MemoryAddress; +import jdk.jfr.DataAmount; +import jdk.jfr.MetadataDefinition; +import jdk.jfr.Name; +import jdk.jfr.Percentage; +import jdk.jfr.Period; +import jdk.jfr.Registered; +import jdk.jfr.Relational; +import jdk.jfr.StackTrace; +import jdk.jfr.Threshold; +import jdk.jfr.Timespan; +import jdk.jfr.Timestamp; +import jdk.jfr.TransitionFrom; +import jdk.jfr.TransitionTo; +import jdk.jfr.Unsigned; +import jdk.test.lib.Asserts; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.annotations.TestTypesIdentical + */ +public class TestTypesIdentical { + + @MetadataDefinition + @interface CustomAnnotation { + String value(); + } + + private static Class[] predefinedAnnotations = { + Category.class, Enabled.class, Frequency.class, DataAmount.class, Percentage.class, StackTrace.class, Timestamp.class, Unsigned.class, + ContentType.class, Experimental.class, Label.class, Registered.class, Period.class, Threshold.class, TransitionFrom.class, + Description.class, BooleanFlag.class, MemoryAddress.class, Name.class, Relational.class, Timespan.class, TransitionTo.class + }; + + @SuppressWarnings("unchecked") + public static void main(String[] args) throws Exception { + + for(Class clz : predefinedAnnotations) { + System.out.println("Testing class " + clz); + assertTypeId((Class) clz); + } + assertTypeId(CustomAnnotation.class); + } + + private static void assertTypeId(Class clz) { + AnnotationElement a1, a2; + try { + a1 = new AnnotationElement(clz, "value"); + a2 = new AnnotationElement(clz, "value2"); + } catch(IllegalArgumentException x) { + a1 = new AnnotationElement(clz); + a2 = new AnnotationElement(clz); + } + Asserts.assertEquals(a1.getTypeId(), a2.getTypeId()); + } +} diff --git a/test/jdk/jfr/api/metadata/eventtype/EventWithCustomSettings.java b/test/jdk/jfr/api/metadata/eventtype/EventWithCustomSettings.java new file mode 100644 index 0000000000000000000000000000000000000000..e0ad0ee4f296b6a23b1c56efc4d1ccdc27596fee --- /dev/null +++ b/test/jdk/jfr/api/metadata/eventtype/EventWithCustomSettings.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. 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.api.metadata.eventtype; + +import jdk.jfr.Enabled; +import jdk.jfr.Event; +import jdk.jfr.Name; +import jdk.jfr.Period; +import jdk.jfr.SettingDefinition; +import jdk.jfr.StackTrace; +import jdk.jfr.Threshold; +import jdk.test.lib.jfr.SimpleSetting; + +@Period("10 s") +@Threshold("100 ms") +@StackTrace(true) +@Enabled(false) +public class EventWithCustomSettings extends Event { + @SettingDefinition + @Name("setting1") + boolean methodNameNotUsed(SimpleSetting cs) { + return true; + } + + @SettingDefinition + boolean setting2(SimpleSetting cs) { + return true; + } +} diff --git a/test/jdk/jfr/api/metadata/eventtype/TestGetAnnotation.java b/test/jdk/jfr/api/metadata/eventtype/TestGetAnnotation.java new file mode 100644 index 0000000000000000000000000000000000000000..5ea99efc86c6b706777e51b0fa004fab9000a622 --- /dev/null +++ b/test/jdk/jfr/api/metadata/eventtype/TestGetAnnotation.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.jfr.api.metadata.eventtype; + +import java.util.Arrays; + +import jdk.jfr.Category; +import jdk.jfr.Description; +import jdk.jfr.Enabled; +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.Label; +import jdk.test.lib.Asserts; + +/** + * @test + * @summary Test getAnnotations() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.eventtype.TestGetAnnotation + */ +public class TestGetAnnotation { + + public static void main(String[] args) throws Throwable { + EventType type = EventType.getEventType(MyEvent.class); + + Label label = type.getAnnotation(Label.class); + if (label == null) { + Asserts.fail("Annotation label was null"); + } + Asserts.assertEquals(label.value(), "myLabel", "Wrong value for annotation label"); + + Category category = type.getAnnotation(Category.class); + if (category == null) { + Asserts.fail("Annotation @Description was null"); + } + + Asserts.assertTrue(Arrays.equals(category.value(), new String[] {"Stuff"}), "Wrong value for annotation enabled"); + + Description description = type.getAnnotation(Description.class); + if (description != null) { + Asserts.fail("Annotation description should be null"); + } + + try { + type.getAnnotation(null); + Asserts.fail("No exception when getAnnotation(null)"); + } catch(Exception e) { + // Expected exception + } + } + + @Label("myLabel") + @Enabled(false) + @Category("Stuff") + private static class MyEvent extends Event { + } +} diff --git a/test/jdk/jfr/api/metadata/eventtype/TestGetAnnotationElements.java b/test/jdk/jfr/api/metadata/eventtype/TestGetAnnotationElements.java new file mode 100644 index 0000000000000000000000000000000000000000..b5ba7c3577e8a32c891147b177e3c41619f657fd --- /dev/null +++ b/test/jdk/jfr/api/metadata/eventtype/TestGetAnnotationElements.java @@ -0,0 +1,153 @@ +/* + * 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. 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.api.metadata.eventtype; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.BooleanFlag; +import jdk.jfr.Category; +import jdk.jfr.ContentType; +import jdk.jfr.Description; +import jdk.jfr.Enabled; +import jdk.jfr.Event; +import jdk.jfr.EventFactory; +import jdk.jfr.EventType; +import jdk.jfr.Experimental; +import jdk.jfr.Frequency; +import jdk.jfr.Label; +import jdk.jfr.MemoryAddress; +import jdk.jfr.DataAmount; +import jdk.jfr.MetadataDefinition; +import jdk.jfr.Name; +import jdk.jfr.Percentage; +import jdk.jfr.Period; +import jdk.jfr.Registered; +import jdk.jfr.Relational; +import jdk.jfr.StackTrace; +import jdk.jfr.Threshold; +import jdk.jfr.Timespan; +import jdk.jfr.Timestamp; +import jdk.jfr.TransitionFrom; +import jdk.jfr.TransitionTo; +import jdk.jfr.Unsigned; +import jdk.jfr.ValueDescriptor; +import jdk.test.lib.Asserts; + +/** + * @test + * @summary Test for AnnotationElement.getAnnotationElements() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.eventtype.TestGetAnnotationElements + */ +public class TestGetAnnotationElements { + + @SuppressWarnings("unchecked") + public static void main(String[] args) throws Throwable { + Class[] jfrAnnotations = { + Category.class, Description.class, Enabled.class, + Experimental.class, BooleanFlag.class, Frequency.class, Label.class, + MemoryAddress.class, DataAmount.class, Name.class, + Registered.class, Percentage.class, + Period.class, Relational.class, StackTrace.class, + Threshold.class, Timespan.class, Timestamp.class, + TransitionFrom.class, TransitionTo.class, Unsigned.class + }; + + for (Class clz : jfrAnnotations) { + Class annptationClass = (Class) clz; + System.out.println("AnnotationElement: " + annptationClass); + Map values = createValueMapForAnnotation(annptationClass); + List persistableAnnotation = createPersistableAnnotationList(annptationClass); + AnnotationElement ae = new AnnotationElement(annptationClass, values); + List aes = ae.getAnnotationElements(); + Asserts.assertEquals(persistableAnnotation.size(), aes.size()); + } + + List fields = new ArrayList<>(); + List eventAnnotations = new ArrayList<>(); + eventAnnotations.add(new AnnotationElement(Label.class, "MyEvent")); + + EventFactory f = EventFactory.create(eventAnnotations, fields); + EventType type = f.getEventType(); + List aes = type.getAnnotationElements().get(0).getAnnotationElements(); + Asserts.assertEquals(0, aes.size()); + + EventType et = EventType.getEventType(MyEvent.class); + ValueDescriptor field = et.getField("transactionRate"); + aes = field.getAnnotationElements().get(0).getAnnotationElements(); + Asserts.assertEquals(3, aes.size()); + assertContainsAnnotation(aes, Description.class); + assertContainsAnnotation(aes, Label.class); + assertContainsAnnotation(aes, ContentType.class); + + } + + private static List createPersistableAnnotationList( Class annptationClass) { + List as = new ArrayList<>(); + for (Annotation a : annptationClass.getAnnotations()) { + MetadataDefinition m = a.annotationType().getAnnotation(MetadataDefinition.class); + if (m != null) { + as.add(a); + } + } + return as; + } + + private static void assertContainsAnnotation(List aez, Class clz) { + for (AnnotationElement ae : aez) { + if (ae.getTypeName().equals(clz.getName())) { + return; + } + } + Asserts.fail("Class " + clz + " not found in the annotation elements"); + } + + private static Map createValueMapForAnnotation(Class clz) { + Map map = new HashMap<>(); + for (Method method : clz.getDeclaredMethods()) { + int modifiers = method.getModifiers(); + if (Modifier.isPublic(modifiers) || Modifier.isProtected(modifiers)) { + map.put(method.getName(), "value"); + } + } + return map; + } + + private static class MyEvent extends Event { + + @Frequency + long transactionRate; + } + +} diff --git a/test/jdk/jfr/api/metadata/eventtype/TestGetAnnotations.java b/test/jdk/jfr/api/metadata/eventtype/TestGetAnnotations.java new file mode 100644 index 0000000000000000000000000000000000000000..9214b261a73002ffa2f5533fb697ecf2fa5c2708 --- /dev/null +++ b/test/jdk/jfr/api/metadata/eventtype/TestGetAnnotations.java @@ -0,0 +1,76 @@ +/* + * 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.api.metadata.eventtype; + +import java.util.List; +import java.util.Objects; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.Description; +import jdk.jfr.Enabled; +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.Label; +import jdk.jfr.Period; +import jdk.test.lib.Asserts; + +/** + * @test + * @summary Test getAnnotations() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.eventtype.TestGetAnnotations + */ +public class TestGetAnnotations { + + private final static String MY_LABEL = "myLabel"; + private final static String MY_DESCRIPTION = "myDesc"; + + public static void main(String[] args) throws Throwable { + EventType type = EventType.getEventType(MyEvent.class); + List annos = type.getAnnotationElements(); + Asserts.assertEquals(annos.size(), 2, "Wrong number of annotations"); + assertAnnotation(annos, "jdk.jfr.Label", MY_LABEL); + assertAnnotation(annos, "jdk.jfr.Description", MY_DESCRIPTION); + } + + private static void assertAnnotation(List annos, String name, Object expectedValue) { + for (AnnotationElement a : annos) { + if (a.getTypeName().equals(name)) { + Object value = a.getValue("value"); + Asserts.assertTrue(Objects.deepEquals(value, expectedValue), "Found annotation " + name + " but value was "+ value +" but expected " + expectedValue); + } + } + } + + @Label(MY_LABEL) + @Description(MY_DESCRIPTION) + @Enabled(false) // not sticky annotation (with @Metadata) + @Period("1 m") // not sticky annotation (with @Metadata) + private static class MyEvent extends Event { + } +} diff --git a/test/jdk/jfr/api/metadata/eventtype/TestGetCategory.java b/test/jdk/jfr/api/metadata/eventtype/TestGetCategory.java new file mode 100644 index 0000000000000000000000000000000000000000..4fbc9aa226608d0783c212e15567c1b434da8b15 --- /dev/null +++ b/test/jdk/jfr/api/metadata/eventtype/TestGetCategory.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. 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.api.metadata.eventtype; + +import java.util.List; + +import jdk.jfr.Category; +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.test.lib.Asserts; + +/** + * @test + * @summary Test setName(). + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.eventtype.TestGetCategory + */ +public class TestGetCategory { + + public static void main(String[] args) throws Throwable { + + List noCategory = EventType.getEventType(NoCategory.class).getCategoryNames(); + System.out.println("noCategory=" + noCategory); + Asserts.assertEquals(noCategory.size(), 1, "Wrong default category"); + Asserts.assertEquals(noCategory.get(0), "Uncategorized", "Wrong default category"); + + List withCategory = EventType.getEventType(WithCategory.class).getCategoryNames(); + Asserts.assertEquals(withCategory.size(), 4, "Wrong category"); + Asserts.assertEquals(withCategory.get(0), "Category", "Wrong category"); + Asserts.assertEquals(withCategory.get(1), "A", "Wrong category"); + Asserts.assertEquals(withCategory.get(2), "B", "Wrong category"); + Asserts.assertEquals(withCategory.get(3), "C", "Wrong category"); + } + + private static class NoCategory extends Event { + @SuppressWarnings("unused") + public byte myByte; + } + + @Category({"Category", "A", "B", "C"}) + private static class WithCategory extends Event { + @SuppressWarnings("unused") + public byte myByte; + } +} diff --git a/test/jdk/jfr/api/metadata/eventtype/TestGetDefaultValues.java b/test/jdk/jfr/api/metadata/eventtype/TestGetDefaultValues.java new file mode 100644 index 0000000000000000000000000000000000000000..bc4615ebdc12e1ea1822bef0bb553871746e251b --- /dev/null +++ b/test/jdk/jfr/api/metadata/eventtype/TestGetDefaultValues.java @@ -0,0 +1,99 @@ +/* + * 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.api.metadata.eventtype; + +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorder; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Test getDefaultValues() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.eventtype.TestGetDefaultValues + */ +public class TestGetDefaultValues { + + private static class DefaultEvent extends Event { + } + + public static void main(String[] args) throws Throwable { + testDefaultEvent(); + testCustomEvent(); + testCustomWithPeriod(); + } + + private static void testCustomWithPeriod() { + Runnable hook = new Runnable() { + @Override + public void run() { + } + }; + EventType customEventType = EventType.getEventType(EventWithCustomSettings.class); + FlightRecorder.addPeriodicEvent(EventWithCustomSettings.class, hook); + Asserts.assertEquals(customEventType.getSettingDescriptors().size(), 4, "Wrong number of settings"); + assertDefaultValue(customEventType, "period", "10 s"); + assertDefaultValue(customEventType, "enabled", "false"); + assertDefaultValue(customEventType, "setting1", "none"); + assertDefaultValue(customEventType, "setting2", "none"); + + FlightRecorder.removePeriodicEvent(hook); + Asserts.assertEquals(customEventType.getSettingDescriptors().size(), 5, "Wrong number of settings"); + assertDefaultValue(customEventType, "threshold", "100 ms"); + assertDefaultValue(customEventType, "stackTrace", "true"); + assertDefaultValue(customEventType, "enabled", "false"); + assertDefaultValue(customEventType, "setting1", "none"); + assertDefaultValue(customEventType, "setting2", "none"); + + } + + private static void testCustomEvent() { + EventType customizedEventType = EventType.getEventType(EventWithCustomSettings.class); + Asserts.assertEquals(customizedEventType.getSettingDescriptors().size(), 5, "Wrong number of default values"); + assertDefaultValue(customizedEventType, "setting1", "none"); + assertDefaultValue(customizedEventType, "setting2", "none"); + assertDefaultValue(customizedEventType, "threshold", "100 ms"); + assertDefaultValue(customizedEventType, "stackTrace", "true"); + assertDefaultValue(customizedEventType, "enabled", "false"); + } + + private static void testDefaultEvent() { + EventType defaultEventType = EventType.getEventType(DefaultEvent.class); + Asserts.assertEquals(defaultEventType.getSettingDescriptors().size(), 3, "Wrong number of default values"); + assertDefaultValue(defaultEventType, "threshold", "0 ns"); + assertDefaultValue(defaultEventType, "stackTrace", "true"); + assertDefaultValue(defaultEventType, "enabled", "true"); + } + + private static void assertDefaultValue(EventType eventType, String name, String expected) { + String value = Events.getSetting(eventType, name).getDefaultValue(); + Asserts.assertEquals(value, expected, "Incorrect value for " + name); + } +} diff --git a/test/jdk/jfr/api/metadata/eventtype/TestGetDescription.java b/test/jdk/jfr/api/metadata/eventtype/TestGetDescription.java new file mode 100644 index 0000000000000000000000000000000000000000..bc662eb5067eb4a7cf61594709bbe9e69693c5ba --- /dev/null +++ b/test/jdk/jfr/api/metadata/eventtype/TestGetDescription.java @@ -0,0 +1,80 @@ +/* + * 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.api.metadata.eventtype; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import jdk.jfr.Category; +import jdk.jfr.Description; +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.Label; +import jdk.test.lib.Asserts; + +/** + * @test + * @summary Test descriptive annotations for EventType + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.eventtype.TestGetDescription + */ +public class TestGetDescription { + + public static void main(String[] args) throws Throwable { + EventType defaultType = EventType.getEventType(DefaultEvent.class); + System.out.printf("defaultType.category='%s'%n", defaultType.getCategoryNames()); + System.out.printf("defaultType.desc='%s'%n", defaultType.getDescription()); + System.out.printf("defaultType.label='%s'%n", defaultType.getLabel()); + + List defaultCategory = Arrays.asList(new String[] {"Uncategorized"}); + Asserts.assertEquals(defaultType.getCategoryNames(), defaultCategory, "Wrong default category"); + Asserts.assertNull(defaultType.getDescription(), "Wrong default description"); + Asserts.assertEquals(defaultType.getLabel(), null, "Wrong default label"); // JavaDoc says "not null" + + EventType annotatedType = EventType.getEventType(AnnotatedEvent.class); + System.out.printf("annotated.category='%s'%n", annotatedType.getCategoryNames()); + System.out.printf("annotated.desc='%s'%n", annotatedType.getDescription()); + System.out.printf("annotated.label='%s'%n", annotatedType.getLabel()); + + List expectedCategorNames = new ArrayList<>(); + expectedCategorNames.add("MyCategory"); + Asserts.assertEquals(annotatedType.getCategoryNames(), expectedCategorNames, "Wrong default category"); + Asserts.assertEquals(annotatedType.getDescription(), "MyDesc", "Wrong default description"); + Asserts.assertEquals(annotatedType.getLabel(), "MyLabel", "Wrong default label"); + } + + private static class DefaultEvent extends Event { + } + + @Category("MyCategory") + @Description("MyDesc") + @Label("MyLabel") + private static class AnnotatedEvent extends Event { + } +} diff --git a/test/jdk/jfr/api/metadata/eventtype/TestGetEventType.java b/test/jdk/jfr/api/metadata/eventtype/TestGetEventType.java new file mode 100644 index 0000000000000000000000000000000000000000..d6240658a2765ae8cff0b44249f5128c9831f4c7 --- /dev/null +++ b/test/jdk/jfr/api/metadata/eventtype/TestGetEventType.java @@ -0,0 +1,62 @@ +/* + * 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.api.metadata.eventtype; + +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.test.lib.Asserts; + +/** + * @test + * @summary Test getEventType() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.eventtype.TestGetEventType + */ +public class TestGetEventType { + + public static void main(String[] args) throws Throwable { + EventType type = EventType.getEventType(MyEventA.class); + Asserts.assertEquals(type.getName(), MyEventA.class.getName(), "Wrong EventType for MyEventA"); + + type = EventType.getEventType(MyEventB.class); + Asserts.assertEquals(type.getName(), MyEventB.class.getName(), "Wrong EventType for MyEventB"); + + try { + EventType.getEventType(null); + Asserts.fail("No exception for getEventType(null)"); + } catch (Exception e) { + // Expected exception + } + } + + private static class MyEventA extends Event { + } + + private static class MyEventB extends Event { + } +} diff --git a/test/jdk/jfr/api/metadata/eventtype/TestGetField.java b/test/jdk/jfr/api/metadata/eventtype/TestGetField.java new file mode 100644 index 0000000000000000000000000000000000000000..aec6309e257f902496cd82692571b74368dc26d7 --- /dev/null +++ b/test/jdk/jfr/api/metadata/eventtype/TestGetField.java @@ -0,0 +1,77 @@ +/* + * 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.api.metadata.eventtype; + +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.ValueDescriptor; +import jdk.test.lib.Asserts; + +/** + * @test + * @summary Test getField() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.eventtype.TestGetField + */ +public class TestGetField { + + public static void main(String[] args) throws Throwable { + EventType type = EventType.getEventType(MyEvent.class); + + ValueDescriptor v = type.getField("myByte"); + Asserts.assertNotNull(v, "getFiled(myByte) was null"); + Asserts.assertEquals(v.getTypeName(), "byte", "myByte was not type byte"); + + v = type.getField("myInt"); + Asserts.assertNotNull(v, "getFiled(myInt) was null"); + Asserts.assertEquals(v.getTypeName(), "int", "myInt was not type int"); + + v = type.getField("myStatic"); + Asserts.assertNull(v, "got static field"); + + v = type.getField("notAField"); + Asserts.assertNull(v, "got field that does not exist"); + + v = type.getField(""); + Asserts.assertNull(v, "got field for empty name"); + + try { + v = type.getField(null); + Asserts.fail("No Exception when getField(null)"); + } catch (NullPointerException e) { + // Expected exception + } + } + + @SuppressWarnings("unused") + private static class MyEvent extends Event { + public byte myByte; + private int myInt; + public static int myStatic; // Should not be included + } +} diff --git a/test/jdk/jfr/api/metadata/eventtype/TestGetFields.java b/test/jdk/jfr/api/metadata/eventtype/TestGetFields.java new file mode 100644 index 0000000000000000000000000000000000000000..df39699cc88daf00168a82937237570fb420c245 --- /dev/null +++ b/test/jdk/jfr/api/metadata/eventtype/TestGetFields.java @@ -0,0 +1,86 @@ +/* + * 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.api.metadata.eventtype; + +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.ValueDescriptor; +import jdk.test.lib.Asserts; + +/** + * @test + * @summary Test getFields() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.eventtype.TestGetFields + */ +public class TestGetFields { + + public static void main(String[] args) throws Throwable { + List actuals = new ArrayList<>(); + EventType type = EventType.getEventType(MyEvent.class); + for (ValueDescriptor d : type.getFields()) { + if (d.getName().startsWith("my")) { + String s = getCompareString(d); + System.out.println("Actual: " + s); + actuals.add(s); + } + } + + String[] expected = { + "name=myByte; typename=byte", + "name=myInt; typename=int", + "name=myString; typename=java.lang.String", + "name=myClass; typename=java.lang.Class", + "name=myThread; typename=java.lang.Thread" + }; + for (String s : expected) { + Asserts.assertTrue(actuals.contains(s), "Missing expected value " + s); + } + Asserts.assertEquals(expected.length, actuals.size(), "Wrong number of fields found"); + } + + private static String getCompareString(ValueDescriptor d) { + return String.format("name=%s; typename=%s", + d.getName(), + d.getTypeName()); + } + + @SuppressWarnings("unused") + private static class MyEvent extends Event { + public byte myByte; + private int myInt; + protected String myString; + public static int myStatic; // Should not be included + @SuppressWarnings("rawtypes") + public Class myClass; + public Thread myThread; + } +} diff --git a/test/jdk/jfr/api/metadata/eventtype/TestGetSettings.java b/test/jdk/jfr/api/metadata/eventtype/TestGetSettings.java new file mode 100644 index 0000000000000000000000000000000000000000..424b086479cdcf30f9ee12fecfb25bc27d0a0d7c --- /dev/null +++ b/test/jdk/jfr/api/metadata/eventtype/TestGetSettings.java @@ -0,0 +1,57 @@ +/* + * 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.api.metadata.eventtype; + +import java.util.List; + +import jdk.jfr.EventType; +import jdk.jfr.SettingDescriptor; +import jdk.test.lib.Asserts; + +/** + * @test + * @summary Test getSettings() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.eventtype.TestGetSettings + */ +public class TestGetSettings { + + public static void main(String[] args) throws Throwable { + EventType eventType = EventType.getEventType(EventWithCustomSettings.class); + List settings = eventType.getSettingDescriptors(); + Asserts.assertEquals(settings.size(), 5, "Wrong number of settings"); + + // test immutability + try { + settings.add(settings.get(0)); + Asserts.fail("Should not be able to modify list returned by getSettings()"); + } catch (UnsupportedOperationException uoe) { + // OK, as expected + } + } +} diff --git a/test/jdk/jfr/api/metadata/eventtype/TestUnloadingEventClass.java b/test/jdk/jfr/api/metadata/eventtype/TestUnloadingEventClass.java new file mode 100644 index 0000000000000000000000000000000000000000..167723745e33121d79d7cd82cc36e8b3a6ba16ef --- /dev/null +++ b/test/jdk/jfr/api/metadata/eventtype/TestUnloadingEventClass.java @@ -0,0 +1,180 @@ +/* + * 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.api.metadata.eventtype; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Path; + +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordingFile; +import jdk.jfr.internal.JVM; +import jdk.test.lib.Utils; + +/** + * @test + * @key jfr + * @summary Test that verifies event metadata is removed when an event class is unloaded. + * + * + * @library /lib / + * + * + * @run main/othervm -XX:+PrintGCDetails -XX:+PrintGC -verbose:class jdk.jfr.api.metadata.eventtype.TestUnloadingEventClass + */ +public class TestUnloadingEventClass { + + private static final String EVENT_NAME = "jdk.jfr.api.metadata.eventtype.TestUnloadingEventClass$ToBeUnloaded"; + + public static class ToBeUnloaded extends Event { + } + + static public class MyClassLoader extends ClassLoader { + public MyClassLoader() { + super(null); + } + + public final Class defineClass(String name, byte[] b) { + return super.defineClass(name, b, 0, b.length); + } + } + + private static final JVM jvm = JVM.getJVM(); + public static ClassLoader myClassLoader; + + public static void main(String[] args) throws Throwable { + assertEventTypeNotAvailable(); + myClassLoader = createClassLoaderWithEventClass(); + + try (Recording r0 = new Recording()) { + r0.start(); + r0.stop(); + if (getEventType(r0, 0, EVENT_NAME) == null) { + throw new Exception("Expected event class to have corresponding event type"); + } + } + + try (Recording r1 = new Recording(); Recording r2 = new Recording(); Recording r3 = new Recording()) { + r1.start(); + r2.start(); + //System.out.println("Class loader with name " + myClassLoader.getName() + " is on the heap"); + unLoadEventClass(); + r3.start(); + + assertEventTypeNotAvailable(); + r3.stop(); + r2.stop(); + r1.stop(); + + if (getEventType(r1, 1, EVENT_NAME) == null) { + throw new Exception("Expected event class to have corresponding event type in recording with all chunks"); + } + if (getEventType(r2, 2, EVENT_NAME) == null) { + throw new Exception("Expected event class to have corresponding event type in recording where event class was unloaded"); + } + if (getEventType(r3, 3, EVENT_NAME) != null) { + throw new Exception("Unexpected metadata found for event class tha has been unloaded."); + } + } + } + + private static MyClassLoader createClassLoaderWithEventClass() throws Exception { + String resourceName = EVENT_NAME.replace('.', '/') + ".class"; + try (InputStream is = TestUnloadingEventClass.class.getClassLoader().getResourceAsStream(resourceName)) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + byte[] buffer = new byte[4096]; + int byteValue = 0; + while ((byteValue = is.read(buffer, 0, buffer.length)) != -1) { + baos.write(buffer, 0, byteValue); + } + baos.flush(); + MyClassLoader myClassLoader = new MyClassLoader(); + Class eventClass = myClassLoader.defineClass(EVENT_NAME, baos.toByteArray()); + if (eventClass == null) { + throw new Exception("Could not define test class"); + } + if (eventClass.getSuperclass() != Event.class) { + throw new Exception("Superclass should be jdk.jfr.Event"); + } + if (eventClass.getSuperclass().getClassLoader() != null) { + throw new Exception("Class loader of jdk.jfr.Event should be null"); + } + if (eventClass.getClassLoader() != myClassLoader) { + throw new Exception("Incorrect class loader for event class"); + } + eventClass.newInstance(); // force + return myClassLoader; + } + } + + private static void unLoadEventClass() throws Exception { + long firstCount = jvm.getUnloadedEventClassCount(); + System.out.println("Initial unloaded count: " + firstCount); + myClassLoader = null; + System.out.println("Cleared reference to MyClassLoader"); + long newCount = 0; + do { + System.out.println("GC triggered"); + System.gc(); + Thread.sleep(1000); + newCount = jvm.getUnloadedEventClassCount(); + System.out.println("Unloaded count: " + newCount); + } while (firstCount + 1 != newCount); + System.out.println("Event class unloaded!"); + System.out.println("Event classes currently on the heap:"); + for (Class eventClass : JVM.getJVM().getAllEventClasses()) { + //System.out.println(eventClass + " " + (eventClass.getClassLoader() != null ? eventClass.getClassLoader().getName() : null)); + } + + } + + private static void assertEventTypeNotAvailable() throws Exception { + for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) { + if (type.getName().equals(EVENT_NAME)) { + throw new Exception("Event type should not be available"); + } + } + } + + private static Object getEventType(Recording r, long id, String eventName) throws IOException { + Path p = Utils.createTempFile("unloading-event-class-recording-" + id + "_", ".jfr"); + r.dump(p); + try (RecordingFile rf = new RecordingFile(p)) { + for (EventType et : rf.readEventTypes()) { + if (et.getName().equals(eventName)) { + return et; + } + } + + } + return null; + } +} + diff --git a/test/jdk/jfr/api/metadata/settingdescriptor/AnnotatedSetting.java b/test/jdk/jfr/api/metadata/settingdescriptor/AnnotatedSetting.java new file mode 100644 index 0000000000000000000000000000000000000000..092308d721c50bc7867ab9c08581b3285c937df5 --- /dev/null +++ b/test/jdk/jfr/api/metadata/settingdescriptor/AnnotatedSetting.java @@ -0,0 +1,60 @@ +/* + * 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. 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.api.metadata.settingdescriptor; + +import java.util.Set; + +import jdk.jfr.Description; +import jdk.jfr.Label; +import jdk.jfr.Name; +import jdk.jfr.SettingControl; +import jdk.jfr.Timestamp; + +@Name(AnnotatedSetting.NAME) +@Label(AnnotatedSetting.LABEL) +@Description(AnnotatedSetting.DESCRIPTION) +@Timestamp(Timestamp.TICKS) +public class AnnotatedSetting extends SettingControl { + + public final static String LABEL = "Annotated Label"; + public final static String DESCRIPTION = "Description of an annotated setting"; + public final static String NAME = "annotatedType"; + public final static String DEFAULT_VALUE = "defaultAnnotated"; + + @Override + public String combine(Set settingValues) { + return DEFAULT_VALUE; + } + + @Override + public void setValue(String settingValue) { + } + + @Override + public String getValue() { + return DEFAULT_VALUE; + } + +} diff --git a/test/jdk/jfr/api/metadata/settingdescriptor/BaseEvent.java b/test/jdk/jfr/api/metadata/settingdescriptor/BaseEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..dff0c8e8919fd0a6e8988a68e4d4bf5260aa1f05 --- /dev/null +++ b/test/jdk/jfr/api/metadata/settingdescriptor/BaseEvent.java @@ -0,0 +1,73 @@ +/* + * 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. 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.api.metadata.settingdescriptor; + +import jdk.jfr.Description; +import jdk.jfr.Event; +import jdk.jfr.Frequency; +import jdk.jfr.Label; +import jdk.jfr.Name; +import jdk.jfr.SettingDefinition; + +public abstract class BaseEvent extends Event { + + // should be shadowed by built-in setting enabled + @SettingDefinition + public boolean enabled(PlainSetting ps) { + return false; + } + + @SettingDefinition + public boolean publicBase(AnnotatedSetting control) { + return true; + } + + @SettingDefinition + private boolean privateBase(PlainSetting control) { + return true; + } + + @SettingDefinition + @Name("protectedBase") + @Label("Protected Base") + @Description("Description of protected base") + @Frequency + protected boolean something(PlainSetting control) { + return true; + } + + @SettingDefinition + boolean packageProtectedBase(PlainSetting control) { + return true; + } + + @Name("baseName") + @Label("Base Label") + @Description("Base description") + @SettingDefinition + public boolean overridden(AnnotatedSetting control) { + return true; + } +} diff --git a/test/jdk/jfr/api/metadata/settingdescriptor/CustomEvent.java b/test/jdk/jfr/api/metadata/settingdescriptor/CustomEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..23377e967cdbd5eea6028e93ee600cdcbc5e20e9 --- /dev/null +++ b/test/jdk/jfr/api/metadata/settingdescriptor/CustomEvent.java @@ -0,0 +1,103 @@ +/* + * 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. 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.api.metadata.settingdescriptor; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Comparator; + +import jdk.jfr.Description; +import jdk.jfr.EventType; +import jdk.jfr.Label; +import jdk.jfr.Name; +import jdk.jfr.Recording; +import jdk.jfr.SettingDefinition; +import jdk.jfr.SettingDescriptor; +import jdk.jfr.Timespan; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.jfr.Events; + +final class CustomEvent extends BaseEvent { + + public static final String DESCRIPTION_OF_AN_ANNOTATED_METHOD = "Description of an annotated method"; + public static final String ANNOTATED_METHOD = "Annotated Method"; + + // should be shadowed by built-in setting threshold + @SettingDefinition + boolean threshold(PlainSetting p) { + return false; + } + + @SettingDefinition + private boolean plain(PlainSetting s) { + return true; + } + + @SettingDefinition + protected boolean annotatedType(AnnotatedSetting s) { + return true; + } + + @SettingDefinition + @Name("newName") + @Label(ANNOTATED_METHOD) + @Description(DESCRIPTION_OF_AN_ANNOTATED_METHOD) + @Timespan(Timespan.NANOSECONDS) + public boolean whatever(AnnotatedSetting s) { + return true; + } + + @SettingDefinition + boolean overridden(PlainSetting s) { + return true; + } + + public static void assertOnDisk(Comparator c) throws Exception { + EventType in = EventType.getEventType(CustomEvent.class); + Path p = Paths.get("custom.jfr"); + try (Recording r = new Recording()) { + r.start(); + r.stop(); + r.dump(p); + } + try (RecordingFile f = new RecordingFile(p)) { + for (EventType out : f.readEventTypes()) { + if (out.getName().equals(CustomEvent.class.getName())) { + if (out.getSettingDescriptors().size() != in.getSettingDescriptors().size()) { + throw new Exception("Number of settings doesn't match"); + } + for (SettingDescriptor os : out.getSettingDescriptors()) { + SettingDescriptor is = Events.getSetting(in, os.getName()); + if (c.compare(os, is) != 0) { + throw new Exception("Setting with name " + is.getName() + " doesn't match"); + } + } + return; + } + } + } + throw new Exception("Could not event type with name " + CustomEvent.class.getName()); + } +} diff --git a/test/jdk/jfr/api/metadata/settingdescriptor/PlainSetting.java b/test/jdk/jfr/api/metadata/settingdescriptor/PlainSetting.java new file mode 100644 index 0000000000000000000000000000000000000000..cfc0e91446a4cd1fa2e53506a0ce6597fd58c988 --- /dev/null +++ b/test/jdk/jfr/api/metadata/settingdescriptor/PlainSetting.java @@ -0,0 +1,48 @@ +/* + * 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. 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.api.metadata.settingdescriptor; + +import java.util.Set; + +import jdk.jfr.SettingControl; + +public class PlainSetting extends SettingControl { + + public final static String DEFAULT_VALUE = "plain"; + + @Override + public String combine(Set settingValue) { + return DEFAULT_VALUE; + } + + @Override + public void setValue(String value) { + } + + @Override + public String getValue() { + return DEFAULT_VALUE; + } +} diff --git a/test/jdk/jfr/api/metadata/settingdescriptor/TestDefaultValue.java b/test/jdk/jfr/api/metadata/settingdescriptor/TestDefaultValue.java new file mode 100644 index 0000000000000000000000000000000000000000..f6357441d4ef032d1411033485224e0911c002e8 --- /dev/null +++ b/test/jdk/jfr/api/metadata/settingdescriptor/TestDefaultValue.java @@ -0,0 +1,59 @@ +/* + * 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. 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.api.metadata.settingdescriptor; + +import jdk.jfr.EventType; +import jdk.jfr.SettingDescriptor; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Test SettingDescriptor.getName() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.settingdescriptor.TestDefaultValue + */ +public class TestDefaultValue { + + public static void main(String[] args) throws Exception { + EventType type = EventType.getEventType(CustomEvent.class); + + SettingDescriptor plain = Events.getSetting(type, "plain"); + Asserts.assertEquals(plain.getDefaultValue(), "plain"); + + SettingDescriptor annotatedType = Events.getSetting(type, "annotatedType"); + Asserts.assertEquals(annotatedType.getDefaultValue(), AnnotatedSetting.DEFAULT_VALUE); + + SettingDescriptor newName = Events.getSetting(type, "newName"); + Asserts.assertEquals(newName.getDefaultValue(), AnnotatedSetting.DEFAULT_VALUE); + + SettingDescriptor overridden = Events.getSetting(type, "overridden"); + Asserts.assertEquals(overridden.getDefaultValue(), PlainSetting.DEFAULT_VALUE); + + CustomEvent.assertOnDisk((x, y) -> x.getName().compareTo(y.getName())); + } +} diff --git a/test/jdk/jfr/api/metadata/settingdescriptor/TestGetAnnotation.java b/test/jdk/jfr/api/metadata/settingdescriptor/TestGetAnnotation.java new file mode 100644 index 0000000000000000000000000000000000000000..7b7ce61a33a1eb6c51968609a376b5d3b1288103 --- /dev/null +++ b/test/jdk/jfr/api/metadata/settingdescriptor/TestGetAnnotation.java @@ -0,0 +1,70 @@ +/* + * 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. 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.api.metadata.settingdescriptor; + +import jdk.jfr.Description; +import jdk.jfr.EventType; +import jdk.jfr.Label; +import jdk.jfr.SettingDescriptor; +import jdk.jfr.Timespan; +import jdk.jfr.Timestamp; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Test SettingDescriptor.getAnnotation(); + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.settingdescriptor.TestGetAnnotation + */ +public class TestGetAnnotation { + + public static void main(String[] args) throws Exception { + EventType type = EventType.getEventType(CustomEvent.class); + + SettingDescriptor annotatedType = Events.getSetting(type, "annotatedType"); + Label al = annotatedType.getAnnotation(Label.class); + Asserts.assertNull(al); // we should not inherit annotation from type + + Description ad = annotatedType.getAnnotation(Description.class); + Asserts.assertNull(ad); // we should not inherit annotation from type + + Timestamp at = annotatedType.getAnnotation(Timestamp.class); + Asserts.assertNull(at); // we should not inherit annotation from type + + SettingDescriptor newName = Events.getSetting(type, "newName"); + Label nl = newName.getAnnotation(Label.class); + Asserts.assertEquals(nl.value(), "Annotated Method"); + + Description nd = newName.getAnnotation(Description.class); + Asserts.assertEquals(nd.value(), "Description of an annotated method"); + + Timespan nt = newName.getAnnotation(Timespan.class); + Asserts.assertEquals(nt.value(), Timespan.NANOSECONDS); + } + +} diff --git a/test/jdk/jfr/api/metadata/settingdescriptor/TestGetAnnotationElement.java b/test/jdk/jfr/api/metadata/settingdescriptor/TestGetAnnotationElement.java new file mode 100644 index 0000000000000000000000000000000000000000..f7e10a15e5263463e9da79fb189552fe2015f9d2 --- /dev/null +++ b/test/jdk/jfr/api/metadata/settingdescriptor/TestGetAnnotationElement.java @@ -0,0 +1,87 @@ +/* + * 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. 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.api.metadata.settingdescriptor; + +import java.util.List; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.Description; +import jdk.jfr.EventType; +import jdk.jfr.Label; +import jdk.jfr.Name; +import jdk.jfr.SettingDescriptor; +import jdk.jfr.Timespan; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Test SettingDescriptor.getAnnotationElements() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.settingdescriptor.TestGetAnnotationElement + */ +public class TestGetAnnotationElement { + + public static void main(String[] args) throws Exception { + EventType type = EventType.getEventType(CustomEvent.class); + + SettingDescriptor plain = Events.getSetting(type, "plain"); + Asserts.assertTrue(plain.getAnnotationElements().isEmpty()); + + SettingDescriptor annotatedType = Events.getSetting(type, "annotatedType"); + for (AnnotationElement ae : annotatedType.getAnnotationElements()) { + System.out.println(ae.getTypeName()); + } + Asserts.assertTrue(annotatedType.getAnnotationElements().isEmpty()); + + SettingDescriptor newName = Events.getSetting(type, "newName"); + List ae = newName.getAnnotationElements(); + Asserts.assertEquals(ae.size(), 4); + Asserts.assertEquals(ae.get(0).getTypeName(), Name.class.getName()); + Asserts.assertEquals(ae.get(1).getTypeName(), Label.class.getName()); + Asserts.assertEquals(ae.get(2).getTypeName(), Description.class.getName()); + Asserts.assertEquals(ae.get(3).getTypeName(), Timespan.class.getName()); + + SettingDescriptor overridden = Events.getSetting(type, "overridden"); + Asserts.assertTrue(overridden.getAnnotationElements().isEmpty()); + + CustomEvent.assertOnDisk((x, y) -> { + List a1 = x.getAnnotationElements(); + List a2 = y.getAnnotationElements(); + if (a1.size() != a2.size()) { + throw new RuntimeException("Not same number of annotation ekements on disk as in process"); + } + for (int i = 0; i < a1.size(); i++) { + if (!a1.get(i).getTypeName().equals(a2.get(i).getTypeName())) { + throw new RuntimeException("Type name of annotation elements in process doesn't match type name on disk"); + } + } + return 0; + }); + } + +} diff --git a/test/jdk/jfr/api/metadata/settingdescriptor/TestGetContentType.java b/test/jdk/jfr/api/metadata/settingdescriptor/TestGetContentType.java new file mode 100644 index 0000000000000000000000000000000000000000..1c5447a3651fdb24b92ed037b35ce7f59234442e --- /dev/null +++ b/test/jdk/jfr/api/metadata/settingdescriptor/TestGetContentType.java @@ -0,0 +1,73 @@ +/* + * 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. 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.api.metadata.settingdescriptor; + +import java.util.Objects; + +import jdk.jfr.EventType; +import jdk.jfr.Frequency; +import jdk.jfr.SettingDescriptor; +import jdk.jfr.Timespan; +import jdk.jfr.Timestamp; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Test SettingDescriptor.getContentType() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.settingdescriptor.TestGetDescription + */ +public class TestGetContentType { + + public static void main(String[] args) throws Exception { + EventType type = EventType.getEventType(CustomEvent.class); + + SettingDescriptor plain = Events.getSetting(type, "plain"); + Asserts.assertNull(plain.getContentType()); + + SettingDescriptor annotatedType = Events.getSetting(type, "annotatedType"); + Asserts.assertNull(annotatedType.getContentType(), Timestamp.class.getName()); + + SettingDescriptor newName = Events.getSetting(type, "newName"); + Asserts.assertEquals(newName.getContentType(), Timespan.class.getName()); + + SettingDescriptor overridden = Events.getSetting(type, "overridden"); + Asserts.assertNull(overridden.getContentType()); + + SettingDescriptor protectedBase = Events.getSetting(type, "protectedBase"); + Asserts.assertEquals(protectedBase.getContentType(), Frequency.class); + + SettingDescriptor publicBase = Events.getSetting(type, "publicBase"); + Asserts.assertEquals(publicBase.getContentType(), Timestamp.class.getName()); + + SettingDescriptor packageProtectedBase = Events.getSetting(type, "packageProtectedBase"); + Asserts.assertNull(packageProtectedBase.getContentType()); + + CustomEvent.assertOnDisk((x, y) -> Objects.equals(x.getContentType(), y.getContentType()) ? 0 : 1); + } +} diff --git a/test/jdk/jfr/api/metadata/settingdescriptor/TestGetDescription.java b/test/jdk/jfr/api/metadata/settingdescriptor/TestGetDescription.java new file mode 100644 index 0000000000000000000000000000000000000000..8e4758321a3c68e238901d6f484e628b5de47f2a --- /dev/null +++ b/test/jdk/jfr/api/metadata/settingdescriptor/TestGetDescription.java @@ -0,0 +1,70 @@ +/* + * 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. 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.api.metadata.settingdescriptor; + +import java.util.Objects; + +import jdk.jfr.EventType; +import jdk.jfr.SettingDescriptor; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Test SettingDescriptor.getDescription() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.settingdescriptor.TestGetDescription + */ +public class TestGetDescription { + + public static void main(String[] args) throws Exception { + EventType type = EventType.getEventType(CustomEvent.class); + + SettingDescriptor plain = Events.getSetting(type, "plain"); + Asserts.assertNull(plain.getDescription()); + + SettingDescriptor annotatedType = Events.getSetting(type, "annotatedType"); + Asserts.assertEquals(annotatedType.getDescription(), AnnotatedSetting.DESCRIPTION); + + SettingDescriptor newName = Events.getSetting(type, "newName"); + Asserts.assertEquals(newName.getDescription(), CustomEvent.DESCRIPTION_OF_AN_ANNOTATED_METHOD); + + SettingDescriptor overridden = Events.getSetting(type, "overridden"); + Asserts.assertNull(overridden.getDescription()); + + SettingDescriptor protectedBase = Events.getSetting(type, "protectedBase"); + Asserts.assertEquals(protectedBase.getDescription(), "Description of protected base"); + + SettingDescriptor publicBase = Events.getSetting(type, "publicBase"); + Asserts.assertEquals(publicBase.getDescription(), AnnotatedSetting.DESCRIPTION); + + SettingDescriptor packageProtectedBase = Events.getSetting(type, "packageProtectedBase"); + Asserts.assertNull(packageProtectedBase.getDescription()); + + CustomEvent.assertOnDisk((x, y) -> Objects.equals(x.getDescription(), y.getDescription()) ? 0 : 1); + } +} diff --git a/test/jdk/jfr/api/metadata/settingdescriptor/TestGetLabel.java b/test/jdk/jfr/api/metadata/settingdescriptor/TestGetLabel.java new file mode 100644 index 0000000000000000000000000000000000000000..82e8fec5c0eb5a22df65f2bedca2e5ed591cb047 --- /dev/null +++ b/test/jdk/jfr/api/metadata/settingdescriptor/TestGetLabel.java @@ -0,0 +1,70 @@ +/* + * 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. 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.api.metadata.settingdescriptor; + +import java.util.Objects; + +import jdk.jfr.EventType; +import jdk.jfr.SettingDescriptor; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Test SettingDescriptor.getLabel() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.settingdescriptor.TestGetLabel + */ +public class TestGetLabel { + + public static void main(String[] args) throws Exception { + EventType type = EventType.getEventType(CustomEvent.class); + + SettingDescriptor plain = Events.getSetting(type, "plain"); + Asserts.assertNull(plain.getLabel()); + + SettingDescriptor annotatedType = Events.getSetting(type, "annotatedType"); + Asserts.assertEquals(AnnotatedSetting.LABEL, annotatedType.getLabel()); + + SettingDescriptor newName = Events.getSetting(type, "newName"); + Asserts.assertEquals(newName.getLabel(), "Annotated Method"); + + SettingDescriptor overridden = Events.getSetting(type, "overridden"); + Asserts.assertNull(overridden.getLabel()); + + SettingDescriptor protectedBase = Events.getSetting(type, "protectedBase"); + Asserts.assertEquals(protectedBase.getLabel(), "Protected Base"); + + SettingDescriptor publicBase = Events.getSetting(type, "publicBase"); + Asserts.assertEquals(publicBase.getLabel(), AnnotatedSetting.LABEL); + + SettingDescriptor packageProtectedBase = Events.getSetting(type, "packageProtectedBase"); + Asserts.assertNull(packageProtectedBase.getLabel()); + + CustomEvent.assertOnDisk((x, y) -> Objects.equals(x.getLabel(), y.getLabel()) ? 0 : 1); + } +} diff --git a/test/jdk/jfr/api/metadata/settingdescriptor/TestGetName.java b/test/jdk/jfr/api/metadata/settingdescriptor/TestGetName.java new file mode 100644 index 0000000000000000000000000000000000000000..80fcebad0608298666d2ed73bb69be33bb5b5eb9 --- /dev/null +++ b/test/jdk/jfr/api/metadata/settingdescriptor/TestGetName.java @@ -0,0 +1,65 @@ +/* + * 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. 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.api.metadata.settingdescriptor; + +import jdk.jfr.EventType; +import jdk.jfr.SettingDescriptor; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Test SettingDescriptor.getName() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.settingdescriptor.TestGetName + */ +public class TestGetName { + + public static void main(String[] args) throws Exception { + EventType type = EventType.getEventType(CustomEvent.class); + + // subclass + Events.getSetting(type, "plain"); + Events.getSetting(type, "annotatedType"); + Events.getSetting(type, "newName"); + Events.getSetting(type, "overridden"); + // base class + Events.getSetting(type, "overridden"); + Events.getSetting(type, "protectedBase"); + Events.getSetting(type, "publicBase"); + Events.getSetting(type, "packageProtectedBase"); + + int defaultNumberOfSettings = 3; // Enabled , Stack Trace, Threshold + if (type.getSettingDescriptors().size() != 8 + defaultNumberOfSettings) { + for (SettingDescriptor s : type.getSettingDescriptors()) { + System.out.println(s.getName()); + } + throw new Exception("Wrong number of settings"); + } + + CustomEvent.assertOnDisk((x, y) -> x.getName().compareTo(y.getName())); + } +} diff --git a/test/jdk/jfr/api/metadata/settingdescriptor/TestGetTypeId.java b/test/jdk/jfr/api/metadata/settingdescriptor/TestGetTypeId.java new file mode 100644 index 0000000000000000000000000000000000000000..4449b873c997e5dff0b408b989f26f33308e635a --- /dev/null +++ b/test/jdk/jfr/api/metadata/settingdescriptor/TestGetTypeId.java @@ -0,0 +1,73 @@ +/* + * 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. 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.api.metadata.settingdescriptor; + +import jdk.jfr.EventType; +import jdk.jfr.SettingDescriptor; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Test SettingDescriptor.getTypeId() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.settingdescriptor.TestGetTypeId + */ +public class TestGetTypeId { + + public static void main(String[] args) throws Exception { + EventType type = EventType.getEventType(CustomEvent.class); + + SettingDescriptor plain = Events.getSetting(type, "plain"); + long plainId = plain.getTypeId(); + Asserts.assertGreaterThan(plainId, 0L); + + SettingDescriptor annotatedType = Events.getSetting(type, "annotatedType"); + long annotatedId = annotatedType.getTypeId(); + Asserts.assertGreaterThan(annotatedId, 0L); + + Asserts.assertNotEquals(annotatedId, plainId); + + SettingDescriptor newName = Events.getSetting(type, "newName"); + Asserts.assertEquals(newName.getTypeId(), annotatedId); + + SettingDescriptor overridden = Events.getSetting(type, "overridden"); + Asserts.assertEquals(overridden.getTypeId(), plainId); + + SettingDescriptor protectedBase = Events.getSetting(type, "protectedBase"); + Asserts.assertEquals(protectedBase.getTypeId(), plainId); + + SettingDescriptor publicBase = Events.getSetting(type, "publicBase"); + Asserts.assertEquals(publicBase.getTypeId(), annotatedId); + + SettingDescriptor packageProtectedBase = Events.getSetting(type, "packageProtectedBase"); + Asserts.assertEquals(packageProtectedBase.getTypeId(), plainId); + + CustomEvent.assertOnDisk((x, y) -> Long.compare(x.getTypeId(), y.getTypeId())); + } + +} diff --git a/test/jdk/jfr/api/metadata/settingdescriptor/TestGetTypeName.java b/test/jdk/jfr/api/metadata/settingdescriptor/TestGetTypeName.java new file mode 100644 index 0000000000000000000000000000000000000000..cb241de5491442212c58df3652b1c385d022f39c --- /dev/null +++ b/test/jdk/jfr/api/metadata/settingdescriptor/TestGetTypeName.java @@ -0,0 +1,68 @@ +/* + * 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. 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.api.metadata.settingdescriptor; + +import jdk.jfr.EventType; +import jdk.jfr.SettingDescriptor; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Test SettingDescriptor.getTypeName(); + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.settingdescriptor.TestGetTypeName + */ +public class TestGetTypeName { + + public static void main(String[] args) throws Exception { + EventType type = EventType.getEventType(CustomEvent.class); + + SettingDescriptor plain = Events.getSetting(type, "plain"); + Asserts.assertEquals(plain.getTypeName(), PlainSetting.class.getName()); + + SettingDescriptor annotatedType = Events.getSetting(type, "annotatedType"); + Asserts.assertEquals(annotatedType.getTypeName(), AnnotatedSetting.NAME); + + SettingDescriptor newName = Events.getSetting(type, "newName"); + Asserts.assertEquals(newName.getTypeName(), AnnotatedSetting.NAME); + + SettingDescriptor overridden = Events.getSetting(type, "overridden"); + Asserts.assertEquals(overridden.getTypeName(), PlainSetting.class.getName()); + + SettingDescriptor protectedBase = Events.getSetting(type, "protectedBase"); + Asserts.assertEquals(protectedBase.getTypeName(), PlainSetting.class.getName()); + + SettingDescriptor publicBase = Events.getSetting(type, "publicBase"); + Asserts.assertEquals(publicBase.getTypeName(), AnnotatedSetting.NAME); + + SettingDescriptor packageProtectedBase = Events.getSetting(type, "packageProtectedBase"); + Asserts.assertEquals(packageProtectedBase.getTypeName(), PlainSetting.class.getName()); + + CustomEvent.assertOnDisk((x, y) -> x.getTypeName().compareTo(y.getTypeName())); + } +} diff --git a/test/jdk/jfr/api/metadata/valuedescriptor/TestClasses.java b/test/jdk/jfr/api/metadata/valuedescriptor/TestClasses.java new file mode 100644 index 0000000000000000000000000000000000000000..81e70c44b4b8a8cf0caa0ba029a301abe04f2a77 --- /dev/null +++ b/test/jdk/jfr/api/metadata/valuedescriptor/TestClasses.java @@ -0,0 +1,86 @@ +/* + * 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.api.metadata.valuedescriptor; + +import java.util.HashMap; +import java.util.Map; + +import jdk.jfr.ValueDescriptor; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.CommonHelper; +import jdk.test.lib.jfr.VoidFunction; + +/** + * @test + * @summary Test ValueDescriptor.getAnnotations() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.valuedescriptor.TestClasses + */ +public class TestClasses { + + public static void main(String[] args) throws Throwable { + @SuppressWarnings("rawtypes") + Map valid = new HashMap<>(); + valid.put("byte", byte.class); + valid.put("short", short.class); + valid.put("int", int.class); + valid.put("char", char.class); + valid.put("float", float.class); + valid.put("double", double.class); + valid.put("boolean", boolean.class); + valid.put("double", double.class); + valid.put("long", long.class); + valid.put("java.lang.String", String.class); + valid.put("java.lang.Class", Class.class); + valid.put("java.lang.Thread", Thread.class); + + for (String name : valid.keySet()) { + Class t = valid.get(name); + System.out.println(t.getName()); + ValueDescriptor d = new ValueDescriptor(t, "dummy"); + String typeName = d.getTypeName() + (d.isArray() ? "[]" : ""); + System.out.printf("%s -> typeName %s%n", name, typeName); + Asserts.assertEquals(name, typeName, "Wrong type name"); + } + + // Test some illegal classes + verifyIllegalArg(()->{new ValueDescriptor(Float.class, "ids");}, "Arrays of non-primitives should give Exception"); + verifyIllegalArg(()->{new ValueDescriptor(Integer[].class, "ids");}, "Arrays of non-primitives should give Exception"); + verifyIllegalArg(()->{new ValueDescriptor(Class[].class, "ids");}, "Arrays of non-primitives should give Exception"); + verifyIllegalArg(()->{new ValueDescriptor(MyClass.class, "MyClass");}, "MyClass should give Exception"); + } + + private static class MyClass { + @SuppressWarnings("unused") + int id; + } + + private static void verifyIllegalArg(VoidFunction f, String msg) throws Throwable { + CommonHelper.verifyException(f, msg, IllegalArgumentException.class); + } +} diff --git a/test/jdk/jfr/api/metadata/valuedescriptor/TestConstructor.java b/test/jdk/jfr/api/metadata/valuedescriptor/TestConstructor.java new file mode 100644 index 0000000000000000000000000000000000000000..336bff2c74c04594dedf97b02b63977e1a533444 --- /dev/null +++ b/test/jdk/jfr/api/metadata/valuedescriptor/TestConstructor.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. 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.api.metadata.valuedescriptor; + +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.Label; +import jdk.jfr.ValueDescriptor; +import jdk.test.lib.Asserts; + +/** + * @test + * @summary Test ValueDescriptor.getAnnotations() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.valuedescriptor.TestConstructor + */ +public class TestConstructor { + + public static void main(String[] args) throws Throwable { + ValueDescriptor vdSimple = new ValueDescriptor(String.class, "message"); + Asserts.assertNull(vdSimple.getAnnotation(Label.class), "Expected getAnnotation()==null"); + Asserts.assertEquals(0, vdSimple.getAnnotationElements().size(), "Expected getAnnotations().size() == 0"); + + // Add labelA and verify we can read it back + List annos = new ArrayList<>(); + AnnotationElement labelA = new AnnotationElement(Label.class, "labelA"); + annos.add(labelA); + System.out.println("labelA.getClass()" + labelA.getClass()); + ValueDescriptor vdComplex = new ValueDescriptor(String.class, "message", annos); + + final Label outLabel = vdComplex.getAnnotation(Label.class); + Asserts.assertFalse(outLabel == null, "getLabel(Label.class) was null"); + System.out.println("outLabel.value() = " + outLabel.value()); + + // Get labelA from getAnnotations() list + Asserts.assertEquals(1, vdComplex.getAnnotationElements().size(), "Expected getAnnotations().size() == 1"); + final AnnotationElement outAnnotation = vdComplex.getAnnotationElements().get(0); + Asserts.assertNotNull(outAnnotation, "outAnnotation was null"); + System.out.printf("Annotation: %s = %s%n", outAnnotation.getTypeName(), outAnnotation.getValue("value")); + Asserts.assertEquals(outAnnotation, labelA, "Expected firstAnnotation == labelA"); + + } +} diff --git a/test/jdk/jfr/api/metadata/valuedescriptor/TestGetAnnotations.java b/test/jdk/jfr/api/metadata/valuedescriptor/TestGetAnnotations.java new file mode 100644 index 0000000000000000000000000000000000000000..ee11da9a1748051956d237e236fb1cd211679952 --- /dev/null +++ b/test/jdk/jfr/api/metadata/valuedescriptor/TestGetAnnotations.java @@ -0,0 +1,95 @@ +/* + * 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.api.metadata.valuedescriptor; + +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.Description; +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.Label; +import jdk.jfr.Name; +import jdk.jfr.ValueDescriptor; +import jdk.test.lib.Asserts; + +/** + * @test + * @summary Test ValueDescriptor.getAnnotations() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.valuedescriptor.TestGetAnnotations + */ +public class TestGetAnnotations { + + public static void main(String[] args) throws Throwable { + EventType type = EventType.getEventType(MyEvent.class); + + List actual = new ArrayList<>(); + for (ValueDescriptor d : type.getFields()) { + String descName = d.getName(); + for (AnnotationElement a : d.getAnnotationElements()) { + String annName = a.getTypeName(); + String annValue = a.getValue("value").toString(); + actual.add(String.format("%s: %s = %s", descName, annName, annValue)); + } + } + + System.out.println("Actual annotations:"); + for (String s : actual) { + System.out.println(s); + } + + String[] expected = { + "myShortName: jdk.jfr.Label = myShortLabel", + "myShortName: jdk.jfr.Description = myShortDesc", + "myLongName: jdk.jfr.Description = myLongDesc", + "myLongName: jdk.jfr.Label = myLongLabel", + }; + + for (String s : expected) { + if (!actual.contains(s)) { + System.out.println("Expected annotation missing: " + s); + Asserts.fail("Not all expected annotations found"); + } + } + } + + + private static class MyEvent extends Event { + @Label("myShortLabel") + @Description("myShortDesc") + @Name("myShortName") + public short myShort; + + @Name("myLongName") + @Description("myLongDesc") + @Label("myLongLabel") + public long myLong; + } +} diff --git a/test/jdk/jfr/api/metadata/valuedescriptor/TestGetFields.java b/test/jdk/jfr/api/metadata/valuedescriptor/TestGetFields.java new file mode 100644 index 0000000000000000000000000000000000000000..60b4d5411b0549b8fb580eadbe18cf60b2da279e --- /dev/null +++ b/test/jdk/jfr/api/metadata/valuedescriptor/TestGetFields.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.api.metadata.valuedescriptor; + +import jdk.jfr.ValueDescriptor; +import jdk.test.lib.Asserts; + +/** + * @test + * @summary Test ValueDescriptor.getAnnotations() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.valuedescriptor.TestGetFields + */ +public class TestGetFields { + + public static void main(String[] args) throws Throwable { + // Test simple ValueDescriptor + final ValueDescriptor vdSimple = new ValueDescriptor(int.class, "id"); + Asserts.assertNotNull(vdSimple.getFields(), "getFields() returned null"); + Asserts.assertTrue(vdSimple.getFields().isEmpty(), "getFields() not empty for vdSimple"); + } +} diff --git a/test/jdk/jfr/api/metadata/valuedescriptor/TestIsArray.java b/test/jdk/jfr/api/metadata/valuedescriptor/TestIsArray.java new file mode 100644 index 0000000000000000000000000000000000000000..c5aa3d9e23c5b6892d0ebf2cb835e21498ae2e4b --- /dev/null +++ b/test/jdk/jfr/api/metadata/valuedescriptor/TestIsArray.java @@ -0,0 +1,64 @@ +/* + * 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.api.metadata.valuedescriptor; + +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.ValueDescriptor; +import jdk.test.lib.Asserts; + +/** + * @test + * @summary Test ValueDescriptor.isArray(). + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.valuedescriptor.TestIsArray + */ +public class TestIsArray { + + public static void main(String[] args) throws Throwable { + EventType type = EventType.getEventType(EventWithArray.class); + + ValueDescriptor d = type.getField("myIds"); + + Asserts.assertNull(d, "ValueDescriptor for int[] was not null"); + + type = EventType.getEventType(EventWithoutArray.class); + d = type.getField("myId"); + Asserts.assertFalse(d.isArray(), "isArray() was true for int"); + } + + private static class EventWithArray extends Event { + @SuppressWarnings("unused") + public int[] myIds; + } + + private static class EventWithoutArray extends Event { + @SuppressWarnings("unused") + public int myId; + } +} diff --git a/test/jdk/jfr/api/metadata/valuedescriptor/TestSimpleTypes.java b/test/jdk/jfr/api/metadata/valuedescriptor/TestSimpleTypes.java new file mode 100644 index 0000000000000000000000000000000000000000..bdfc30430f22eb2e5962515b77b8677175d865ed --- /dev/null +++ b/test/jdk/jfr/api/metadata/valuedescriptor/TestSimpleTypes.java @@ -0,0 +1,132 @@ +/* + * 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.api.metadata.valuedescriptor; + +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Description; +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.BooleanFlag; +import jdk.jfr.Label; +import jdk.jfr.Name; +import jdk.jfr.Percentage; +import jdk.jfr.ValueDescriptor; +import jdk.test.lib.Asserts; + +/** + * @test + * @summary Test all basic types in ValueDescriptor. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.valuedescriptor.TestSimpleTypes + */ +public class TestSimpleTypes { + + public static void main(String[] args) throws Throwable { + EventType type = EventType.getEventType(MyEvent.class); + + List expectedStrings = new ArrayList<>(); + expectedStrings.add("desc=myByteDesc; label=null; name=myByte; typename=byte; contenttype=null"); + expectedStrings.add("desc=null; label=myShortLabel; name=myShort; typename=short; contenttype=null"); + expectedStrings.add("desc=myIntDesc; label=myIntLabel; name=myInt; typename=int; contenttype=null"); + expectedStrings.add("desc=null; label=null; name=myLongName; typename=long; contenttype=null"); + expectedStrings.add("desc=myCharDesc; label=myCharLabel; name=myCharName; typename=char; contenttype=null"); + expectedStrings.add("desc=null; label=null; name=myFloat; typename=float; contenttype=jdk.jfr.Percentage"); + expectedStrings.add("desc=null; label=null; name=myDouble; typename=double; contenttype=null"); + expectedStrings.add("desc=null; label=null; name=myBoolean; typename=boolean; contenttype=jdk.jfr.BooleanFlag"); + expectedStrings.add("desc=null; label=null; name=myString; typename=java.lang.String; contenttype=null"); + expectedStrings.add("desc=null; label=null; name=myClass; typename=java.lang.Class; contenttype=null"); + expectedStrings.add("desc=null; label=null; name=myThread; typename=java.lang.Thread; contenttype=null"); + + List typeIds = new ArrayList<>(); + for (ValueDescriptor d : type.getFields()) { + if (d.getName().startsWith("my")) { + String s = getCompareString(d); + System.out.println("got: " + s); + Asserts.assertTrue(expectedStrings.contains(s), "Wrong type string found"); + expectedStrings.remove(s); + + long typeId = d.getTypeId(); + Asserts.assertFalse(typeIds.contains(typeId), "TypeIds not unique"); + typeIds.add(typeId); + + Asserts.assertFalse(d.isArray(), "ValueDescriptor should not be array"); + } + } + + if (!expectedStrings.isEmpty()) { + System.out.println("Missing expectedStrings:"); + for (String s : expectedStrings) { + System.out.println(s); + } + Asserts.fail("Not all strings found"); + } + } + + private static String getCompareString(ValueDescriptor d) { + return String.format("desc=%s; label=%s; name=%s; typename=%s; contenttype=%s", + d.getDescription(), + d.getLabel(), + d.getName(), + d.getTypeName(), + d.getContentType()); + } + + @SuppressWarnings("unused") + private static class MyEvent extends Event { + + @Description("myByteDesc") + public byte myByte; + + @Label("myShortLabel") + public short myShort; + + @Label("myIntLabel") + @Description("myIntDesc") + public int myInt; + + @Name("myLongName") + public long myLong; + + @Label("myCharLabel") + @Description("myCharDesc") + @Name("myCharName") + protected char myChar; + + @Percentage + protected float myFloat; + protected double myDouble; + @BooleanFlag + private boolean myBoolean; + private String myString; + @SuppressWarnings("rawtypes") + private Class myClass; + private Thread myThread; + } +} diff --git a/test/jdk/jfr/api/metadata/valuedescriptor/TestValueDescriptorContentType.java b/test/jdk/jfr/api/metadata/valuedescriptor/TestValueDescriptorContentType.java new file mode 100644 index 0000000000000000000000000000000000000000..1cc6b0e4a932a022b1754beabfd4339e8cefb7e9 --- /dev/null +++ b/test/jdk/jfr/api/metadata/valuedescriptor/TestValueDescriptorContentType.java @@ -0,0 +1,90 @@ +/* + * 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.api.metadata.valuedescriptor; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import jdk.jfr.ContentType; +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.MetadataDefinition; +import jdk.jfr.ValueDescriptor; +import jdk.test.lib.Asserts; + +/** + * @test + * @summary Test ValueDescriptor.getContentType() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.metadata.valuedescriptor.TestValueDescriptorContentType + */ +public class TestValueDescriptorContentType { + + @MetadataDefinition + @ContentType + @Retention(RetentionPolicy.RUNTIME) + @Target({ ElementType.FIELD, ElementType.TYPE, ElementType.METHOD }) + static public @interface Hawaiian { + } + + @MetadataDefinition + @Retention(RetentionPolicy.RUNTIME) + @Target({ ElementType.FIELD, ElementType.TYPE }) + static public @interface NotContentType { + } + + @SuppressWarnings("unused") + private static class AlohaEvent extends Event { + @Hawaiian + String greeting; + + String missing; + + @NotContentType + String otherAnnotation; + } + + public static void main(String[] args) throws Throwable { + EventType type = EventType.getEventType(AlohaEvent.class); + + // check field annotation on event value + ValueDescriptor filter = type.getField("greeting"); + Asserts.assertEquals(filter.getContentType(), Hawaiian.class.getName()); + + // check field annotation with missing content type + ValueDescriptor missing = type.getField("missing"); + Asserts.assertEquals(missing.getContentType(), null); + + // check field annotation with annotation but not content type + ValueDescriptor otherAnnotation = type.getField("otherAnnotation"); + Asserts.assertEquals(otherAnnotation.getContentType(), null); + } + +} diff --git a/test/jdk/jfr/api/modules/TestModularizedEvent.java b/test/jdk/jfr/api/modules/TestModularizedEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..3bf89372880d2dcc7226fb0fcc5719dff7a902f7 --- /dev/null +++ b/test/jdk/jfr/api/modules/TestModularizedEvent.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. 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.api.modules; + +import java.nio.file.Paths; + +import static jdk.test.lib.Asserts.assertTrue; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; +import javax.tools.JavaCompiler; +import javax.tools.StandardJavaFileManager; +import javax.tools.StandardLocation; +import javax.tools.ToolProvider; + +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +public class TestModularizedEvent { + + private static final String TEST_SRC = System.getProperty("test.src"); + + private static final Path SRC_DIR = Paths.get(TEST_SRC, "src_mods"); + private static final Path MODS_DIR = Paths.get("mods"); + + private static final String ANNO_MODULE = "test.jfr.annotation"; + private static final String SETTING_MODULE = "test.jfr.setting"; + private static final String EVENT_MODULE = "test.jfr.event"; + private static final String TEST_MODULE = "test.jfr.main"; + + public static void main(String... args) throws Exception { + compileModule(ANNO_MODULE); + compileModule(SETTING_MODULE); + compileModule(EVENT_MODULE, "--module-path", MODS_DIR.toString()); + compileModule(TEST_MODULE, "--module-path", MODS_DIR.toString()); + + OutputAnalyzer oa = ProcessTools.executeTestJava("--module-path", "mods", "-m", "test.jfr.main/test.jfr.main.MainTest"); + oa.stdoutShouldContain("Test passed."); + } + + private static void compileModule(String modDir, String... opts) throws Exception { + boolean compiled = compile(SRC_DIR.resolve(modDir), + MODS_DIR.resolve(modDir), + opts); + assertTrue(compiled, "module " + modDir + " did not compile"); + } + + private static boolean compile(Path source, Path destination, String... options) + throws IOException { + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + if (compiler == null) { + // no compiler available + throw new UnsupportedOperationException("Unable to get system java compiler. " + + "Perhaps, jdk.compiler module is not available."); + } + StandardJavaFileManager jfm = compiler.getStandardFileManager(null, null, null); + + List sources + = Files.find(source, Integer.MAX_VALUE, + (file, attrs) -> (file.toString().endsWith(".java"))) + .collect(Collectors.toList()); + + Files.createDirectories(destination); + jfm.setLocation(StandardLocation.CLASS_PATH, Collections.emptyList()); + jfm.setLocationFromPaths(StandardLocation.CLASS_OUTPUT, + Arrays.asList(destination)); + + List opts = Arrays.asList(options); + JavaCompiler.CompilationTask task + = compiler.getTask(null, jfm, null, opts, null, + jfm.getJavaFileObjectsFromPaths(sources)); + + return task.call(); + } + +} diff --git a/test/jdk/jfr/api/modules/src_mods/test.jfr.annotation/test/jfr/annotation/ModularizedAnnotation.java b/test/jdk/jfr/api/modules/src_mods/test.jfr.annotation/test/jfr/annotation/ModularizedAnnotation.java new file mode 100644 index 0000000000000000000000000000000000000000..6831048c48cf4e7f68f0271eb4b9699a8ca82cf0 --- /dev/null +++ b/test/jdk/jfr/api/modules/src_mods/test.jfr.annotation/test/jfr/annotation/ModularizedAnnotation.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 test.jfr.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import jdk.jfr.MetadataDefinition; + +@MetadataDefinition +@Target({ElementType.TYPE, ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@ModularizedAnnotation("hello annotation") +public @interface ModularizedAnnotation { + + String value(); +} diff --git a/test/jdk/jfr/api/modules/src_mods/test.jfr.event/test/jfr/event/ModularizedOrdinaryEvent.java b/test/jdk/jfr/api/modules/src_mods/test.jfr.event/test/jfr/event/ModularizedOrdinaryEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..052534cb6c1f45a1dc2d2c615e8901046a014155 --- /dev/null +++ b/test/jdk/jfr/api/modules/src_mods/test.jfr.event/test/jfr/event/ModularizedOrdinaryEvent.java @@ -0,0 +1,44 @@ +/* + * 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 test.jfr.event; + +import test.jfr.annotation.ModularizedAnnotation; + +import jdk.jfr.Event; +import jdk.jfr.SettingDefinition; +import test.jfr.setting.ModularizedSetting; + +@ModularizedAnnotation("hello type") +public class ModularizedOrdinaryEvent extends Event { + + @ModularizedAnnotation("hello field") + public String message; + + @SettingDefinition + boolean filter(ModularizedSetting ms) { + return ms.accept(); + } +} diff --git a/test/jdk/jfr/api/modules/src_mods/test.jfr.event/test/jfr/event/ModularizedPeriodicEvent.java b/test/jdk/jfr/api/modules/src_mods/test.jfr.event/test/jfr/event/ModularizedPeriodicEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..ab5cfec2c5e6ea1d495abf7e4f2751649c03ae48 --- /dev/null +++ b/test/jdk/jfr/api/modules/src_mods/test.jfr.event/test/jfr/event/ModularizedPeriodicEvent.java @@ -0,0 +1,44 @@ +/* + * 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 test.jfr.event; + +import test.jfr.annotation.ModularizedAnnotation; + +import jdk.jfr.Event; +import jdk.jfr.SettingDefinition; +import test.jfr.setting.ModularizedSetting; + +@ModularizedAnnotation("hello type") +public class ModularizedPeriodicEvent extends Event { + + @ModularizedAnnotation("hello field") + public String message; + + @SettingDefinition + boolean filter(ModularizedSetting ms) { + return ms.accept(); + } +} diff --git a/test/jdk/jfr/api/modules/src_mods/test.jfr.main/test/jfr/main/MainTest.java b/test/jdk/jfr/api/modules/src_mods/test.jfr.main/test/jfr/main/MainTest.java new file mode 100644 index 0000000000000000000000000000000000000000..3152f4815ce7e19a7aac6de9f9d4de8cddd1f661 --- /dev/null +++ b/test/jdk/jfr/api/modules/src_mods/test.jfr.main/test/jfr/main/MainTest.java @@ -0,0 +1,154 @@ +/* + * 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 test.jfr.main; + +import java.io.File; +import java.io.IOException; +import java.util.List; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; +import jdk.jfr.ValueDescriptor; +import jdk.jfr.consumer.RecordedEvent; + +import test.jfr.annotation.ModularizedAnnotation; +import test.jfr.event.ModularizedOrdinaryEvent; +import test.jfr.event.ModularizedPeriodicEvent; +import java.nio.file.Path; +import java.util.Objects; +import jdk.jfr.consumer.RecordingFile; + +public class MainTest { + + private static final String HELLO_ORDINARY = "ordinary says hello"; + private static final String HELLO_PERIODIC = "periodic says hello"; + + public static void main(String... args) throws Exception { + System.out.println("Starting the test..."); + FlightRecorder.addPeriodicEvent(ModularizedPeriodicEvent.class, () -> { + ModularizedPeriodicEvent me = new ModularizedPeriodicEvent(); + me.message = HELLO_PERIODIC; + me.commit(); + }); + Recording r = new Recording(); + r.enable(ModularizedOrdinaryEvent.class).with("filter", "true").withoutStackTrace(); + r.enable(ModularizedPeriodicEvent.class).with("filter", "true").withoutStackTrace(); + r.start(); + ModularizedOrdinaryEvent m = new ModularizedOrdinaryEvent(); + m.message = HELLO_ORDINARY; + m.commit(); + r.stop(); + List events = fromRecording(r); + System.out.println(events); + if (events.size() == 0) { + throw new RuntimeException("Expected two events"); + } + assertOrdinaryEvent(events); + assertPeriodicEvent(events); + assertMetadata(events); + System.out.println("Test passed."); + } + + private static void assertMetadata(List events) { + for (RecordedEvent e : events) { + EventType type = e.getEventType(); + ModularizedAnnotation maType = type.getAnnotation(ModularizedAnnotation.class); + if (maType == null) { + fail("Missing @ModularizedAnnotation on type " + type); + } + assertEquals(maType.value(), "hello type"); + assertMetaAnnotation(type.getAnnotationElements()); + + ValueDescriptor messageField = type.getField("message"); + ModularizedAnnotation maField = messageField.getAnnotation(ModularizedAnnotation.class); + if (maField == null) { + fail("Missing @ModularizedAnnotation on field in " + type); + } + assertEquals(maField.value(), "hello field"); + assertMetaAnnotation(messageField.getAnnotationElements()); + } + } + + private static void assertMetaAnnotation(List aes) { + assertEquals(aes.size(), 1, "@ModularizedAnnotation should only have one meta-annotation"); + AnnotationElement ae = aes.get(0); + assertEquals(ae.getTypeName(), ModularizedAnnotation.class.getName(), "Incorrect meta-annotation"); + } + + private static void assertPeriodicEvent(List events) { + for (RecordedEvent e : events) { + String message = e.getValue("message"); + if (message.equals(HELLO_ORDINARY)) { + return; + } + } + throw new RuntimeException("Could not find ordinary event in recording"); + } + + private static void assertOrdinaryEvent(List events) { + for (RecordedEvent e : events) { + String message = e.getValue("message"); + if (message.equals(HELLO_PERIODIC)) { + return; + } + } + throw new RuntimeException("Could not find periodic event in recording"); + } + + public static List fromRecording(Recording recording) throws IOException { + return RecordingFile.readAllEvents(makeCopy(recording)); + } + + private static Path makeCopy(Recording recording) throws IOException { + Path p = recording.getDestination(); + if (p == null) { + File directory = new File("."); + ProcessHandle h = ProcessHandle.current(); + p = new File(directory.getAbsolutePath(), "recording-" + recording.getId() + "-pid" + h.pid() + ".jfr").toPath(); + recording.dump(p); + } + return p; + } + + private static void assertEquals(Object lhs, Object rhs) { + assertEquals(lhs, rhs, null); + } + + private static void assertEquals(Object lhs, Object rhs, String msg) { + if ((lhs != rhs) && ((lhs == null) || !(lhs.equals(rhs)))) { + msg = Objects.toString(msg, "assertEquals") + + ": expected " + Objects.toString(lhs) + + " to equal " + Objects.toString(rhs); + fail(msg); + } + } + + private static void fail(String message) { + throw new RuntimeException(message); + } +} diff --git a/test/jdk/jfr/api/modules/src_mods/test.jfr.setting/test/jfr/setting/ModularizedSetting.java b/test/jdk/jfr/api/modules/src_mods/test.jfr.setting/test/jfr/setting/ModularizedSetting.java new file mode 100644 index 0000000000000000000000000000000000000000..41205c901062b7a109c95e62fc64b57aba551b68 --- /dev/null +++ b/test/jdk/jfr/api/modules/src_mods/test.jfr.setting/test/jfr/setting/ModularizedSetting.java @@ -0,0 +1,62 @@ +/* + * 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 test.jfr.setting; + +import java.util.Set; + +import jdk.jfr.SettingControl; + +public final class ModularizedSetting extends SettingControl { + + private String value = "false"; + private boolean isTrue = false; + + @Override + public String combine(Set settingValues) { + for (String s : settingValues) { + if ("true".equals(s)) { + return "true"; + } + } + return "false"; + } + + @Override + public void setValue(String settingValue) { + this.value = settingValue; + this.isTrue = Boolean.valueOf(settingValue); + } + + @Override + public String getValue() { + return value; + } + + public boolean accept() { + return isTrue; + } + +} diff --git a/test/jdk/jfr/api/recorder/TestRecorderInitialized.java b/test/jdk/jfr/api/recorder/TestRecorderInitialized.java new file mode 100644 index 0000000000000000000000000000000000000000..26d6d249761e888b98804666dee08f71b3a0ec7b --- /dev/null +++ b/test/jdk/jfr/api/recorder/TestRecorderInitialized.java @@ -0,0 +1,68 @@ +/* + * 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.api.recorder; + +import jdk.jfr.FlightRecorder; +import jdk.jfr.FlightRecorderListener; +import jdk.test.lib.Asserts; + +/** + * @test TestRecorderListener + * @key jfr + * + * @library /lib / + * + * @run main/othervm jdk.jfr.api.recorder.TestRecorderInitialized + */ +public class TestRecorderInitialized { + + static class Listener implements FlightRecorderListener { + private boolean notified; + + @Override + public void recorderInitialized(FlightRecorder r) { + notified = true; + } + } + + public static void main(String...args) { + Listener l1 = new Listener(); + + FlightRecorder.addListener(l1); + Asserts.assertFalse(l1.notified, "Listener shouldn't be notified unless Flight Recorder is initialized"); + // initialize Flight Recorder + FlightRecorder.getFlightRecorder(); + Asserts.assertTrue(l1.notified, "Listener should be notified when Flight Recorder is initialized"); + l1.notified = false; + + Listener l2 = new Listener(); + FlightRecorder.addListener(l1); + FlightRecorder.addListener(l2); + Asserts.assertTrue(l2.notified, "Listener should be notified if Flight Recorder is already initialized"); + Asserts.assertTrue(l1.notified, "Only added listnener should be notified, if Flight Recorder is already initialized"); + + } +} diff --git a/test/jdk/jfr/api/recorder/TestRecorderListener.java b/test/jdk/jfr/api/recorder/TestRecorderListener.java new file mode 100644 index 0000000000000000000000000000000000000000..a116b90725682b0c92b2c04ee7f4759d22723ac0 --- /dev/null +++ b/test/jdk/jfr/api/recorder/TestRecorderListener.java @@ -0,0 +1,106 @@ +/* + * 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. 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.api.recorder; + +import java.util.concurrent.CountDownLatch; + +import jdk.jfr.FlightRecorder; +import jdk.jfr.FlightRecorderListener; +import jdk.jfr.Recording; +import jdk.jfr.RecordingState; + +/** + * @test TestRecorderListener + * + * @key jfr + * + * @run main/othervm jdk.jfr.api.recorder.TestRecorderListener + */ +public class TestRecorderListener { + + static class Listener implements FlightRecorderListener { + + private final CountDownLatch latch = new CountDownLatch(1); + private final RecordingState waitFor; + + public Listener(RecordingState state) { + waitFor = state; + } + + @Override + public void recordingStateChanged(Recording recording) { + System.out.println("Listener: recording=" + recording.getName() + " state=" + recording.getState()); + RecordingState rs = recording.getState(); + if (rs == waitFor) { + latch.countDown(); + } + } + + public void waitFor() throws InterruptedException { + latch.await(); + } + } + + public static void main(String... args) throws Exception { + Listener recordingListener = new Listener(RecordingState.RUNNING); + FlightRecorder.addListener(recordingListener); + + Listener stoppedListener = new Listener(RecordingState.STOPPED); + FlightRecorder.addListener(stoppedListener); + + Listener finishedListener = new Listener(RecordingState.CLOSED); + FlightRecorder.addListener(finishedListener); + + Recording recording = new Recording(); + if (recording.getState() != RecordingState.NEW) { + recording.close(); + throw new Exception("New recording should be in NEW state"); + } + + recording.start(); + recordingListener.waitFor(); + + recording.stop(); + stoppedListener.waitFor(); + + recording.close(); + finishedListener.waitFor(); + + testDefaultrecordingStateChangedListener(); + + } + + private static class DummyListener implements FlightRecorderListener { + + } + + private static void testDefaultrecordingStateChangedListener() { + FlightRecorder.addListener(new DummyListener()); + Recording recording = new Recording(); + recording.start(); + recording.stop(); + recording.close(); + } +} diff --git a/test/jdk/jfr/api/recorder/TestStartStopRecording.java b/test/jdk/jfr/api/recorder/TestStartStopRecording.java new file mode 100644 index 0000000000000000000000000000000000000000..421577bc8ec9ab55c07c71315d42633f801aa892 --- /dev/null +++ b/test/jdk/jfr/api/recorder/TestStartStopRecording.java @@ -0,0 +1,80 @@ +/* + * 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.api.recorder; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.LinkOption; +import java.nio.file.Path; + +import jdk.jfr.Configuration; +import jdk.jfr.Recording; +import jdk.test.lib.Utils; + +/** + * @test TestStartStopRecording + * + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recorder.TestStartStopRecording + */ +public class TestStartStopRecording { + + public static void main(String... args) throws Exception { + Configuration defaultConfig = Configuration.getConfiguration("default"); + // Memory + Recording inMemory = new Recording(defaultConfig); + inMemory.setToDisk(false); + + inMemory.start(); + + Path memoryFile = Utils.createTempFile("start-stop-memory-recording", ".jfr"); + inMemory.dump(memoryFile); + assertValid(memoryFile, "Not a valid memory file."); + inMemory.stop(); + inMemory.close(); + // Disk + Recording toDisk = new Recording(defaultConfig); + toDisk.setToDisk(true); + + toDisk.start(); + toDisk.stop(); + Path diskFile = Utils.createTempFile("start-stop-disk-recording", ".jfr"); + toDisk.dump(diskFile); + assertValid(diskFile, "Not a valid disk file."); + toDisk.close(); + } + + private static void assertValid(Path path, String message) throws IOException { + if (!Files.exists(path, LinkOption.NOFOLLOW_LINKS)) { + throw new AssertionError(message + " Could not find file " + path); + } + if (Files.size(path) == 0) { + throw new AssertionError(message + " File size = 0 for " + path); + } + } +} diff --git a/test/jdk/jfr/api/recording/destination/TestDestFileExist.java b/test/jdk/jfr/api/recording/destination/TestDestFileExist.java new file mode 100644 index 0000000000000000000000000000000000000000..2476af0fa354cf9b6e64f96561ab9ad12d2d7cf7 --- /dev/null +++ b/test/jdk/jfr/api/recording/destination/TestDestFileExist.java @@ -0,0 +1,68 @@ +/* + * 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.api.recording.destination; + +import static jdk.test.lib.Asserts.assertTrue; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; + +/** + * @test + * @summary Set destination to an existing file. File should be overwritten. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.destination.TestDestFileExist + */ +public class TestDestFileExist { + + public static void main(String[] args) throws Throwable { + Path dest = Paths.get(".", "my.jfr"); + System.out.println("dest=" + dest); + Files.write(dest, "Dummy data".getBytes()); + assertTrue(Files.exists(dest), "Test error: Failed to create file"); + System.out.println("file size before recording:" + Files.size(dest)); + Recording r = new Recording(); + r.enable(EventNames.OSInformation); + r.setDestination(dest); + r.start(); + r.stop(); + List events = RecordingFile.readAllEvents(dest); + Asserts.assertFalse(events.isEmpty(), "No events found"); + System.out.println(events.iterator().next()); + r.close(); + } + +} diff --git a/test/jdk/jfr/api/recording/destination/TestDestFileReadOnly.java b/test/jdk/jfr/api/recording/destination/TestDestFileReadOnly.java new file mode 100644 index 0000000000000000000000000000000000000000..833ec9d5f11806463aff5cfd0994da3317690228 --- /dev/null +++ b/test/jdk/jfr/api/recording/destination/TestDestFileReadOnly.java @@ -0,0 +1,65 @@ +/* + * 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.api.recording.destination; + +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; + +import jdk.jfr.Recording; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.FileHelper; + +/** + * @test + * @summary Set destination to a read-only file. Expects exception. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.destination.TestDestFileReadOnly + */ +public class TestDestFileReadOnly { + + public static void main(String[] args) throws Throwable { + Path dest = FileHelper.createReadOnlyFile(Paths.get(".", "readonly.txt")); + System.out.println("dest=" + dest.toFile().getAbsolutePath()); + if (!FileHelper.isReadOnlyPath(dest)) { + System.out.println("Failed to create a read-only file. Test ignored."); + return; + } + + Recording r = new Recording(); + r.setToDisk(true); + try { + r.setDestination(dest); + Asserts.fail("No exception when destination is read-only"); + } catch (IOException e) { + // Expected exception + } + r.close(); + } + +} diff --git a/test/jdk/jfr/api/recording/destination/TestDestInvalid.java b/test/jdk/jfr/api/recording/destination/TestDestInvalid.java new file mode 100644 index 0000000000000000000000000000000000000000..38aab517358ef9e6bbe7e52c8c026f73bf3b6b39 --- /dev/null +++ b/test/jdk/jfr/api/recording/destination/TestDestInvalid.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. 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.api.recording.destination; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.CommonHelper; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.VoidFunction; + +/** + * @test + * @summary Test setDestination to invalid paths + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.destination.TestDestInvalid + */ +public class TestDestInvalid { + + public static void main(String[] args) throws Throwable { + Recording r = new Recording(); + r.enable(EventNames.OSInformation); + r.setToDisk(true); + + Asserts.assertNull(r.getDestination(), "dest not null by default"); + + // Set destination to empty path (same as curr dir, not a file) + verifyException(()->{r.setDestination(Paths.get(""));}, "No exception for setDestination(\"\")", IOException.class); + System.out.println("1 destination: " + r.getDestination()); + Asserts.assertNull(r.getDestination(), "default dest not null after failed setDest"); + + // Set dest to a valid path. This should be kept when a new setDest fails. + Path dest = Paths.get(".", "my.jfr"); + r.setDestination(dest); + System.out.println("2 destination: " + r.getDestination()); + Asserts.assertEquals(dest, r.getDestination(), "Wrong get/set dest"); + + // Null is allowed for setDestination() + r.setDestination(null); + System.out.println("3 destination: " + r.getDestination()); + Asserts.assertNull(r.getDestination(), "dest not null after setDest(null)"); + + // Reset dest to correct value and make ssure it is not overwritten + r.setDestination(dest); + System.out.println("4 destination: " + r.getDestination()); + Asserts.assertEquals(dest, r.getDestination(), "Wrong get/set dest"); + + // Set destination to an existing dir. Old dest is saved. + verifyException(()->{r.setDestination(Paths.get("."));}, "No exception for setDestination(.)", IOException.class); + System.out.println("5 destination: " + r.getDestination()); + Asserts.assertEquals(dest, r.getDestination(), "Wrong get/set dest"); + + // Set destination to a non-existing dir. Old dest is saved. + verifyException(()->{r.setDestination(Paths.get(".", "missingdir", "my.jfr"));}, "No exception for setDestination(dirNotExists)", IOException.class); + System.out.println("6 destination: " + r.getDestination()); + Asserts.assertEquals(dest, r.getDestination(), "Wrong get/set dest"); + + // Verify that it works with the old setDest value. + r.start(); + r.stop(); + r.close(); + Asserts.assertTrue(Files.exists(dest), "No recording file: " + dest); + List events = RecordingFile.readAllEvents(dest); + Asserts.assertFalse(events.isEmpty(), "No event found"); + System.out.printf("Found event %s in %s%n", events.get(0).getEventType().getName(), dest.toString()); + } + + private static void verifyException(VoidFunction f, String msg, Class exceptionClass) throws Throwable { + CommonHelper.verifyException(f, msg, IOException.class); + } + +} diff --git a/test/jdk/jfr/api/recording/destination/TestDestLongPath.java b/test/jdk/jfr/api/recording/destination/TestDestLongPath.java new file mode 100644 index 0000000000000000000000000000000000000000..b61606292819b456ed271b290b2e7532abdb603f --- /dev/null +++ b/test/jdk/jfr/api/recording/destination/TestDestLongPath.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.api.recording.destination; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.FileHelper; + +/** + * @test + * @summary Set destination to a long path + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.destination.TestDestLongPath + */ +public class TestDestLongPath { + + public static void main(String[] args) throws Throwable { + Path dir = FileHelper.createLongDir(Paths.get(".")); + Path dest = Paths.get(dir.toString(), "my.jfr"); + Recording r = new Recording(); + r.enable(EventNames.OSInformation); + r.setToDisk(true); + r.setDestination(dest); + r.start(); + r.stop(); + r.close(); + Asserts.assertTrue(Files.exists(dest), "No recording file: " + dest); + List events = RecordingFile.readAllEvents(dest); + Asserts.assertFalse(events.isEmpty(), "No event found"); + System.out.printf("Found event %s%n", events.get(0).getEventType().getName()); + } + +} diff --git a/test/jdk/jfr/api/recording/destination/TestDestMultiple.java b/test/jdk/jfr/api/recording/destination/TestDestMultiple.java new file mode 100644 index 0000000000000000000000000000000000000000..c55a697ded83deb217ea3c02b7d12547e67d2e3f --- /dev/null +++ b/test/jdk/jfr/api/recording/destination/TestDestMultiple.java @@ -0,0 +1,111 @@ +/* + * 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.api.recording.destination; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.SimpleEventHelper; + +/** + * @test + * @summary Test setDestination with concurrent recordings + * @key jfr + * + * @library /lib / + * @run main/othervm -XX:+LogJFR jdk.jfr.api.recording.destination.TestDestMultiple + */ +public class TestDestMultiple { + + public static void main(String[] args) throws Throwable { + Recording rA = new Recording(); + Recording rB = new Recording(); + + Path destA = Paths.get(".", "recA.jfr"); + Path destB = Paths.get(".", "recB.jfr"); + rA.setDestination(destA); + rB.setDestination(destB); + + // Enable event in one recording and disable in the other. + // Both recordings should still get the events, since we always + // get the "union" of all settings. + SimpleEventHelper.enable(rA, true); + SimpleEventHelper.enable(rB, false); + + SimpleEventHelper.createEvent(0); // To no recording + + rA.start(); + SimpleEventHelper.createEvent(1); // Only to recA + + rB.start(); + SimpleEventHelper.createEvent(2); // To both recordings + + rA.stop(); + + // This event will not be in recB. + // The reason is that recA has stopped so event is no longer enabled. + SimpleEventHelper.createEvent(3); + + // Enable the event and create a new event for recB + SimpleEventHelper.enable(rB, true); + SimpleEventHelper.createEvent(4); + + rB.stop(); + SimpleEventHelper.createEvent(5); // To no recording + + rB.close(); + rA.close(); + + verifyRecording(destA, 1, 2); + verifyRecording(destB, 2, 4); + } + + private static void verifyRecording(Path path, int... ids) throws Exception { + Asserts.assertTrue(Files.exists(path), "Recording file does not exist: " + path); + int countEvent = 0; + List events = RecordingFile.readAllEvents(path); + for (RecordedEvent event : events) { + int id = Events.assertField(event, "id").getValue(); + System.out.printf("Recording '%s' id=%d%n", path, id); + } + for (RecordedEvent event : events) { + int id = Events.assertField(event, "id").getValue(); + System.out.printf("Recording '%s' id=%d%n", path, id); + Asserts.assertTrue(ids.length > countEvent, "Found extra event"); + Events.assertField(event, "id").equal(ids[countEvent]); + ++countEvent; + } + // We expect exactly 4 events in each file. 2 events * 2 chunks + Asserts.assertEquals(countEvent, ids.length, "Found too few events"); + } +} diff --git a/test/jdk/jfr/api/recording/destination/TestDestReadOnly.java b/test/jdk/jfr/api/recording/destination/TestDestReadOnly.java new file mode 100644 index 0000000000000000000000000000000000000000..f49fc38c51e7bb5fc90ace895b05d3ea055b5d71 --- /dev/null +++ b/test/jdk/jfr/api/recording/destination/TestDestReadOnly.java @@ -0,0 +1,84 @@ +/* + * 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.api.recording.destination; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.CommonHelper; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.FileHelper; +import jdk.test.lib.jfr.VoidFunction; + +/** + * @test + * @summary Test setDestination to read-only dir + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.destination.TestDestReadOnly + */ +public class TestDestReadOnly { + + public static void main(String[] args) throws Throwable { + Path readOnlyDir = FileHelper.createReadOnlyDir(Paths.get(".", "readonly")); + if (!FileHelper.isReadOnlyPath(readOnlyDir)) { + System.out.println("Failed to create read-only dir. Running as root?. Test ignored"); + return; + } + + Path readOnlyDest = Paths.get(readOnlyDir.toString(), "readonly.jfr"); + Recording r = new Recording(); + r.enable(EventNames.OSInformation); + r.setToDisk(true); + verifyException(()->{r.setDestination(readOnlyDest);}, "No exception for setDestination to read-only dir"); + + System.out.println("r.getDestination() = " + r.getDestination()); + + // Verify that it works if we set destination to a writable dir. + Path dest = Paths.get(".", "my.jfr"); + r.setDestination(dest); + r.start(); + r.stop(); + r.close(); + Asserts.assertTrue(Files.exists(dest), "No recording file: " + dest); + List events = RecordingFile.readAllEvents(dest); + Asserts.assertFalse(events.isEmpty(), "No event found"); + System.out.printf("Found event %s in %s%n", events.get(0).getEventType().getName(), dest.toString()); + } + + private static void verifyException(VoidFunction f, String msg) throws Throwable { + CommonHelper.verifyException(f, msg, IOException.class); + } + +} diff --git a/test/jdk/jfr/api/recording/destination/TestDestState.java b/test/jdk/jfr/api/recording/destination/TestDestState.java new file mode 100644 index 0000000000000000000000000000000000000000..d22c246aea7c77315a2b2cd77381bb17c0844d60 --- /dev/null +++ b/test/jdk/jfr/api/recording/destination/TestDestState.java @@ -0,0 +1,79 @@ +/* + * 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.api.recording.destination; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.SimpleEventHelper; + +/** + * @test + * @summary Call setDestination() when recording in different states + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.destination.TestDestState + */ +public class TestDestState { + + public static void main(String[] args) throws Throwable { + Recording r = new Recording(); + SimpleEventHelper.enable(r, true); + + final Path newDest = Paths.get(".", "new.jfr"); + r.setDestination(newDest); + System.out.println("new dest: " + r.getDestination()); + Asserts.assertEquals(newDest, r.getDestination(), "Wrong get/set dest when new"); + + r.start(); + SimpleEventHelper.createEvent(0); + Thread.sleep(100); + final Path runningDest = Paths.get(".", "running.jfr"); + r.setDestination(runningDest); + System.out.println("running dest: " + r.getDestination()); + Asserts.assertEquals(runningDest, r.getDestination(), "Wrong get/set dest when running"); + SimpleEventHelper.createEvent(1); + + r.stop(); + SimpleEventHelper.createEvent(2); + + // Expect recording to be saved at destination that was set when + // the recording was stopped, which is runningDest. + Asserts.assertTrue(Files.exists(runningDest), "No recording file: " + runningDest); + List events = RecordingFile.readAllEvents(runningDest); + Asserts.assertFalse(events.isEmpty(), "No event found"); + System.out.printf("Found event %s%n", events.get(0).getEventType().getName()); + r.close(); + } + +} diff --git a/test/jdk/jfr/api/recording/destination/TestDestToDiskFalse.java b/test/jdk/jfr/api/recording/destination/TestDestToDiskFalse.java new file mode 100644 index 0000000000000000000000000000000000000000..642c0767fa2cb65f3fd689ed40a1c0a034aacc1d --- /dev/null +++ b/test/jdk/jfr/api/recording/destination/TestDestToDiskFalse.java @@ -0,0 +1,80 @@ +/* + * 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.api.recording.destination; + + +import static jdk.test.lib.Asserts.assertEquals; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.SimpleEventHelper; + +/** + * @test + * @summary Basic test for setDestination with disk=false + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.destination.TestDestToDiskFalse + */ +public class TestDestToDiskFalse { + + public static void main(String[] args) throws Throwable { + final Path dest = Paths.get(".", "my.jfr"); + Recording r = new Recording(); + SimpleEventHelper.enable(r, true); + r.setToDisk(false); + r.setDestination(dest); + Asserts.assertEquals(dest, r.getDestination(), "Wrong get/set destination"); + r.start(); + SimpleEventHelper.createEvent(0); + r.stop(); + + // setToDisk(false) should not effect setDestination. + // We should still get a file when the recording stops. + Asserts.assertTrue(Files.exists(dest), "No recording file: " + dest); + System.out.printf("File size=%d, getSize()=%d%n", Files.size(dest), r.getSize()); + Asserts.assertNotEquals(Files.size(dest), 0L, "File length 0. Should at least be some bytes"); + + List events = RecordingFile.readAllEvents(dest); + Asserts.assertFalse(events.isEmpty(), "No event found"); + System.out.printf("Found event %s%n", events.get(0).getEventType().getName()); + + assertEquals(r.getSize(), 0L, "getSize() should return 0, chunks should have been released at stop"); + // getDestination() should return null after recording have been written to file. + Asserts.assertNull(r.getDestination(), "getDestination() should return null after file created"); + + r.close(); + } + +} diff --git a/test/jdk/jfr/api/recording/destination/TestDestToDiskTrue.java b/test/jdk/jfr/api/recording/destination/TestDestToDiskTrue.java new file mode 100644 index 0000000000000000000000000000000000000000..1b87329d17aa23bbd7733805a6d65dcc72c6ffb2 --- /dev/null +++ b/test/jdk/jfr/api/recording/destination/TestDestToDiskTrue.java @@ -0,0 +1,73 @@ +/* + * 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.api.recording.destination; + +import static jdk.test.lib.Asserts.assertEquals; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; + +/** + * @test + * @summary Basic test for setDestination with disk=true + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.destination.TestDestToDiskTrue + */ +public class TestDestToDiskTrue { + + public static void main(String[] args) throws Throwable { + Path dest = Paths.get(".", "my.jfr"); + Recording r = new Recording(); + r.enable(EventNames.OSInformation); + r.setToDisk(true); + r.setDestination(dest); + Asserts.assertEquals(dest, r.getDestination(), "Wrong get/set destination"); + r.start(); + r.stop(); + + Asserts.assertEquals(dest, r.getDestination(), "Wrong get/set destination after stop"); + + Asserts.assertTrue(Files.exists(dest), "No recording file: " + dest); + List events = RecordingFile.readAllEvents(dest); + Asserts.assertFalse(events.isEmpty(), "No event found"); + System.out.printf("Found event %s%n", events.get(0).getEventType().getName()); + System.out.printf("File size=%d, getSize()=%d%n", Files.size(dest), r.getSize()); + assertEquals(r.getSize(), 0L, "getSize() should return 0, chunks should have be released at stop"); + Asserts.assertNotEquals(Files.size(dest), 0L, "File length 0. Should at least be some bytes"); + r.close(); + } + +} diff --git a/test/jdk/jfr/api/recording/destination/TestDestWithDuration.java b/test/jdk/jfr/api/recording/destination/TestDestWithDuration.java new file mode 100644 index 0000000000000000000000000000000000000000..86f9a2bb3c3fd70a8d6bd593dca5b3006d5b2c00 --- /dev/null +++ b/test/jdk/jfr/api/recording/destination/TestDestWithDuration.java @@ -0,0 +1,76 @@ +/* + * 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.api.recording.destination; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.time.Duration; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.RecordingState; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.CommonHelper; +import jdk.test.lib.jfr.SimpleEventHelper; + +/** + * @test + * @summary Test that recording is auto closed after duration + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.destination.TestDestWithDuration + */ +public class TestDestWithDuration { + + public static void main(String[] args) throws Throwable { + Path dest = Paths.get(".", "my.jfr"); + Recording r = new Recording(); + SimpleEventHelper.enable(r, true); + r.setDestination(dest); + r.start(); + SimpleEventHelper.createEvent(1); + + // Waiting for recording to auto close after duration + r.setDuration(Duration.ofSeconds(1)); + System.out.println("Waiting for recording to auto close after duration"); + CommonHelper.waitForRecordingState(r, RecordingState.CLOSED); + System.out.println("recording state = " + r.getState()); + Asserts.assertEquals(r.getState(), RecordingState.CLOSED, "Recording not closed"); + + Asserts.assertTrue(Files.exists(dest), "No recording file: " + dest); + System.out.printf("Recording file size=%d%n", Files.size(dest)); + Asserts.assertNotEquals(Files.size(dest), 0L, "File length 0. Should at least be some bytes"); + + List events = RecordingFile.readAllEvents(dest); + Asserts.assertFalse(events.isEmpty(), "No event found"); + System.out.printf("Found event %s%n", events.get(0).getEventType().getName()); + } + +} diff --git a/test/jdk/jfr/api/recording/dump/TestDump.java b/test/jdk/jfr/api/recording/dump/TestDump.java new file mode 100644 index 0000000000000000000000000000000000000000..2e1f506d866e53e13536d174fc2aeef965468df4 --- /dev/null +++ b/test/jdk/jfr/api/recording/dump/TestDump.java @@ -0,0 +1,61 @@ +/* + * 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.api.recording.dump; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; + +/** + * @test + * @summary Test copyTo and parse file + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.dump.TestDump + */ +public class TestDump { + + public static void main(String[] args) throws Exception { + Recording r = new Recording(); + r.enable(EventNames.OSInformation); + r.start(); + r.stop(); + + Path path = Paths.get(".", "my.jfr"); + r.dump(path); + r.close(); + + Asserts.assertTrue(Files.exists(path), "Recording file does not exist: " + path); + Asserts.assertFalse(RecordingFile.readAllEvents(path).isEmpty(), "No events found"); + } + +} diff --git a/test/jdk/jfr/api/recording/dump/TestDumpInvalid.java b/test/jdk/jfr/api/recording/dump/TestDumpInvalid.java new file mode 100644 index 0000000000000000000000000000000000000000..736037690cb3270c030ad2edacef553fde9bb999 --- /dev/null +++ b/test/jdk/jfr/api/recording/dump/TestDumpInvalid.java @@ -0,0 +1,85 @@ +/* + * 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.api.recording.dump; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.CommonHelper; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.VoidFunction; + +/** + * @test + * @summary Test copyTo and parse file + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.dump.TestDumpInvalid + */ +public class TestDumpInvalid { + + public static void main(String[] args) throws Throwable { + Recording r = new Recording(); + r.enable(EventNames.OSInformation); + r.start(); + r.stop(); + + verifyNullPointer(()->{r.dump(null);}, "No NullPointerException"); + + Path pathNotExists = Paths.get(".", "dirNotExists", "my.jfr"); + verifyFileNotFound(()->{r.dump(pathNotExists);}, "No Exception with missing dir"); + + Path pathEmpty = Paths.get(""); + verifyFileNotFound(()->{r.dump(pathEmpty);}, "No Exception with empty path"); + + Path pathDir = Paths.get(".", "newdir"); + Files.createDirectory(pathDir); + verifyFileNotFound(()->{r.dump(pathDir);}, "No Exception with dir"); + + // Verify that copyTo() works after all failed attempts. + Path pathOk = Paths.get(".", "newdir", "my.jfr"); + r.dump(pathOk); + Asserts.assertTrue(Files.exists(pathOk), "Recording file does not exist: " + pathOk); + Asserts.assertFalse(RecordingFile.readAllEvents(pathOk).isEmpty(), "No events found"); + + r.close(); + } + + private static void verifyFileNotFound(VoidFunction f, String msg) throws Throwable { + CommonHelper.verifyException(f, msg, IOException.class); + } + + private static void verifyNullPointer(VoidFunction f, String msg) throws Throwable { + CommonHelper.verifyException(f, msg, NullPointerException.class); + } + +} diff --git a/test/jdk/jfr/api/recording/dump/TestDumpLongPath.java b/test/jdk/jfr/api/recording/dump/TestDumpLongPath.java new file mode 100644 index 0000000000000000000000000000000000000000..87bface9d9dddbee9f03861d64aa88e017a742a9 --- /dev/null +++ b/test/jdk/jfr/api/recording/dump/TestDumpLongPath.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. 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.api.recording.dump; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.FileHelper; + +/** + * @test + * @summary Test copyTo and parse file + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.dump.TestDumpLongPath + */ +public class TestDumpLongPath { + + public static void main(String[] args) throws Exception { + Recording r = new Recording(); + final String eventPath = EventNames.OSInformation; + r.enable(eventPath); + r.start(); + r.stop(); + + Path dir = FileHelper.createLongDir(Paths.get(".")); + Path path = Paths.get(dir.toString(), "my.jfr"); + r.dump(path); + r.close(); + + Asserts.assertTrue(Files.exists(path), "Recording file does not exist: " + path); + List events = RecordingFile.readAllEvents(path); + Asserts.assertFalse(events.isEmpty(), "No events found"); + String foundEventPath = events.get(0).getEventType().getName(); + System.out.printf("Found event: %s%n", foundEventPath); + Asserts.assertEquals(foundEventPath, eventPath, "Wrong event"); + } + +} diff --git a/test/jdk/jfr/api/recording/dump/TestDumpMultiple.java b/test/jdk/jfr/api/recording/dump/TestDumpMultiple.java new file mode 100644 index 0000000000000000000000000000000000000000..0534351323895622327412535fb05ca00dc7cec5 --- /dev/null +++ b/test/jdk/jfr/api/recording/dump/TestDumpMultiple.java @@ -0,0 +1,105 @@ +/* + * 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.api.recording.dump; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.SimpleEventHelper; + +/** + * @test + * @summary Test copyTo and parse file + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.dump.TestDumpMultiple + */ +public class TestDumpMultiple { + + public static void main(String[] args) throws Exception { + Recording rA = new Recording(); + Recording rB = new Recording(); + + // Enable event in one recording and disable in the other. + // Both recordings should still get the events, since we always + // get the "union" of all settings. + SimpleEventHelper.enable(rA, true); + SimpleEventHelper.enable(rB, false); + + SimpleEventHelper.createEvent(0); // To no recording + + rA.start(); + SimpleEventHelper.createEvent(1); // Only to recA + + rB.start(); + SimpleEventHelper.createEvent(2); // To both recordings + + rA.stop(); + + // This event will not be in recB. + // The reason is that recA has stopped so event is no longer enabled. + SimpleEventHelper.createEvent(3); + + // Enable the event and create a new event for recB + SimpleEventHelper.enable(rB, true); + SimpleEventHelper.createEvent(4); + + rB.stop(); + SimpleEventHelper.createEvent(5); // To no recording + + Path pathA = Paths.get(".", "recA.jfr"); + Path pathB = Paths.get(".", "recB.jfr"); + rA.dump(pathA); + rB.dump(pathB); + rB.close(); + rA.close(); + + verifyRecording(pathA, 1, 2); + verifyRecording(pathB, 2, 4); + } + + private static void verifyRecording(Path path, int... ids) throws Exception { + Asserts.assertTrue(Files.exists(path), "Recording file does not exist: " + path); + int countEvent = 0; + for (RecordedEvent event : RecordingFile.readAllEvents(path)) { + int id = Events.assertField(event, "id").getValue(); + System.out.printf("Recording '%s' id=%d%n", path, id); + Asserts.assertTrue(ids.length > countEvent, "Found extra event"); + Events.assertField(event, "id").equal(ids[countEvent]); + ++countEvent; + } + // We expect exactly 4 events in each file. 2 events * 2 chunks + Asserts.assertEquals(countEvent, ids.length, "Found too few events"); + } + +} diff --git a/test/jdk/jfr/api/recording/dump/TestDumpReadOnly.java b/test/jdk/jfr/api/recording/dump/TestDumpReadOnly.java new file mode 100644 index 0000000000000000000000000000000000000000..5a6c35b4634e11f83f072479afae8ba451ac262e --- /dev/null +++ b/test/jdk/jfr/api/recording/dump/TestDumpReadOnly.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. 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.api.recording.dump; + +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; + +import jdk.jfr.Recording; +import jdk.test.lib.jfr.CommonHelper; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.FileHelper; +import jdk.test.lib.jfr.VoidFunction; + +/** + * @test + * @summary Test copyTo and parse file + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.dump.TestDumpReadOnly + */ +public class TestDumpReadOnly { + + private static final String OS_INFORMATION = EventNames.OSInformation; + + public static void main(String[] args) throws Throwable { + + Path readOnlyDir = FileHelper.createReadOnlyDir(Paths.get(".", "readonlydir")); + if (!FileHelper.isReadOnlyPath(readOnlyDir)) { + System.out.println("Failed to create read-only path. Maybe running a root? Test skipped"); + return; + } + Recording r = new Recording(); + r.enable(OS_INFORMATION); + r.start(); + r.stop(); + Path path = Paths.get(readOnlyDir.toString(), "my.jfr"); + verifyException(()->{r.dump(path);}, "No Exception when dumping read-only dir"); + r.close(); + } + + private static void verifyException(VoidFunction f, String msg) throws Throwable { + CommonHelper.verifyException(f, msg, IOException.class); + } + +} diff --git a/test/jdk/jfr/api/recording/dump/TestDumpState.java b/test/jdk/jfr/api/recording/dump/TestDumpState.java new file mode 100644 index 0000000000000000000000000000000000000000..df0e90b1d0b530a1f284d9fa25242fb322091361 --- /dev/null +++ b/test/jdk/jfr/api/recording/dump/TestDumpState.java @@ -0,0 +1,107 @@ +/* + * 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.api.recording.dump; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.CommonHelper; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.SimpleEvent; +import jdk.test.lib.jfr.SimpleEventHelper; +import jdk.test.lib.jfr.VoidFunction; + +/** + * @test + * @summary call copyTo() with recording in all states. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.dump.TestDumpState + */ +public class TestDumpState { + + public static void main(String[] args) throws Throwable { + Recording r = new Recording(); + SimpleEventHelper.enable(r, true); + + List expectedIds = new ArrayList<>(); + + SimpleEventHelper.createEvent(0); // Recording not started, should not be included. + verifyIOException(()->{checkEvents(r, expectedIds);}, "No Exception when dump() not started"); + + r.start(); + SimpleEventHelper.createEvent(1); + expectedIds.add(1); + checkEvents(r, expectedIds); + + SimpleEventHelper.createEvent(2); + expectedIds.add(2); + checkEvents(r, expectedIds); + + r.stop(); + checkEvents(r, expectedIds); + + SimpleEventHelper.createEvent(3); // Recording stopped, should not be included. + checkEvents(r, expectedIds); + + r.close(); + SimpleEventHelper.createEvent(4); + verifyIOException(()->{checkEvents(r, expectedIds);}, "No Exception when dump() closed"); + } + + private static int recordingCounter = 0; + private static void checkEvents(Recording r, List expectedIds) throws Exception { + Path path = Paths.get(".", String.format("%d.jfr", recordingCounter++)); + r.dump(path); + Asserts.assertTrue(Files.exists(path), "Recording file does not exist: " + path); + + int index = 0; + + for (RecordedEvent event : RecordingFile.readAllEvents(path)) { + Events.isEventType(event, SimpleEvent.class.getName()); + Integer id = Events.assertField(event, "id").getValue(); + System.out.println("Got event with id " + id); + Asserts.assertGreaterThan(expectedIds.size(), index, "Too many Events found"); + Asserts.assertEquals(id, expectedIds.get(index), "Wrong id at index " + index); + ++index; + } + Asserts.assertEquals(index, expectedIds.size(), "Too few Events found"); + } + + private static void verifyIOException(VoidFunction f, String msg) throws Throwable { + CommonHelper.verifyException(f, msg, IOException.class); + } + +} diff --git a/test/jdk/jfr/api/recording/event/TEST.properties b/test/jdk/jfr/api/recording/event/TEST.properties new file mode 100644 index 0000000000000000000000000000000000000000..81cb3fce7197da13f7b9a0d3ff86693188e12c9c --- /dev/null +++ b/test/jdk/jfr/api/recording/event/TEST.properties @@ -0,0 +1,2 @@ +modules = java.management + diff --git a/test/jdk/jfr/api/recording/event/TestChunkPeriod.java b/test/jdk/jfr/api/recording/event/TestChunkPeriod.java new file mode 100644 index 0000000000000000000000000000000000000000..83e48de931c74a3bcaa0ee2b111be0f1e1807c66 --- /dev/null +++ b/test/jdk/jfr/api/recording/event/TestChunkPeriod.java @@ -0,0 +1,103 @@ +/* + * 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.api.recording.event; + +import java.io.IOException; +import java.time.Duration; +import java.time.Instant; +import java.util.List; + +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.SimpleEvent; + +/** + * @test + * @summary Test periodic setting that involves chunks. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.event.TestChunkPeriod + */ +public class TestChunkPeriod { + + // Margin of error is to avoid issues where JFR and + // System.currentMillis take the clock differently + private static final Duration MARGIN_OF_ERROR = Duration.ofNanos(1_000_000_000); // 1 s + + public static void main(String[] args) throws Throwable { + FlightRecorder.addPeriodicEvent(SimpleEvent.class, () -> { + SimpleEvent pe = new SimpleEvent(); + pe.commit(); + }); + testBeginChunk(); + testEndChunk(); + testEveryChunk(); + } + + private static void testBeginChunk() throws IOException { + Recording r = new Recording(); + r.enable(SimpleEvent.class).with("period", "beginChunk"); + Instant beforeStart = Instant.now().minus(MARGIN_OF_ERROR); + r.start(); + Instant afterStart = Instant.now().plus(MARGIN_OF_ERROR); + r.stop(); + List events = Events.fromRecording(r); + Asserts.assertEquals(events.size(), 1, "Expected one event with beginChunk"); + RecordedEvent event = events.get(0); + Asserts.assertGreaterThanOrEqual(event.getStartTime(), beforeStart); + Asserts.assertGreaterThanOrEqual(afterStart, event.getStartTime()); + r.close(); + } + + private static void testEndChunk() throws IOException { + Recording r = new Recording(); + r.enable(SimpleEvent.class).with("period", "endChunk"); + r.start(); + Instant beforeStop = Instant.now().minus(MARGIN_OF_ERROR); + r.stop(); + Instant afterStop = Instant.now().plus(MARGIN_OF_ERROR); + List events = Events.fromRecording(r); + Asserts.assertEquals(events.size(), 1, "Expected one event with endChunk"); + RecordedEvent event = events.get(0); + Asserts.assertGreaterThanOrEqual(event.getStartTime(), beforeStop); + Asserts.assertGreaterThanOrEqual(afterStop, event.getStartTime()); + r.close(); + } + + private static void testEveryChunk() throws IOException { + Recording r = new Recording(); + r.enable(SimpleEvent.class).with("period", "everyChunk"); + r.start(); + r.stop(); + List events = Events.fromRecording(r); + Asserts.assertEquals(events.size(), 2, "Expected two events with everyChunk"); + r.close(); + } +} diff --git a/test/jdk/jfr/api/recording/event/TestEnableClass.java b/test/jdk/jfr/api/recording/event/TestEnableClass.java new file mode 100644 index 0000000000000000000000000000000000000000..fbad872889cfda2799084b66657ee696c5a858cf --- /dev/null +++ b/test/jdk/jfr/api/recording/event/TestEnableClass.java @@ -0,0 +1,53 @@ +/* + * 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.api.recording.event; + +import jdk.jfr.Recording; +import jdk.test.lib.jfr.SimpleEventHelper; + +/** + * @test + * @summary Simple enable Event class. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.event.TestEnableClass + */ +public class TestEnableClass { + + public static void main(String[] args) throws Throwable { + Recording r = new Recording(); + SimpleEventHelper.enable(r, true); + SimpleEventHelper.createEvent(0); + r.start(); + SimpleEventHelper.createEvent(1); + r.stop(); + SimpleEventHelper.createEvent(2); + SimpleEventHelper.verifyEvents(r, 1); + r.close(); + } + +} diff --git a/test/jdk/jfr/api/recording/event/TestEnableName.java b/test/jdk/jfr/api/recording/event/TestEnableName.java new file mode 100644 index 0000000000000000000000000000000000000000..c8a55e4d293f51ce6a9bb32a8d40e5b884a5930d --- /dev/null +++ b/test/jdk/jfr/api/recording/event/TestEnableName.java @@ -0,0 +1,62 @@ +/* + * 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.api.recording.event; + +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Iterator; + +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; + +/** + * @test + * @summary Simple enable Event class. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.event.TestEnableName + */ +public class TestEnableName { + + public static void main(String[] args) throws Throwable { + Recording r = new Recording(); + final String eventType = EventNames.FileWrite; + r.enable(eventType).withoutStackTrace(); + r.start(); + Files.write(Paths.get(".", "dummy.txt"), "DummyFile".getBytes()); + r.stop(); + + Iterator iterator = Events.fromRecording(r).iterator(); + Asserts.assertTrue(iterator.hasNext(), "No events found"); + System.out.printf("Event:%n%s%n", iterator.next()); + r.close(); + } + +} diff --git a/test/jdk/jfr/api/recording/event/TestEventTime.java b/test/jdk/jfr/api/recording/event/TestEventTime.java new file mode 100644 index 0000000000000000000000000000000000000000..a93feac639ec75811d6512b18e522ef54c58ea79 --- /dev/null +++ b/test/jdk/jfr/api/recording/event/TestEventTime.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. 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.api.recording.event; + +import java.time.Instant; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import jdk.jfr.Event; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.CommonHelper; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Test getStartTime() and getEndTime(). Verify startTime <= endTime + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.event.TestEventTime + */ +public class TestEventTime { + + static List actualOrder = new ArrayList<>(); + + public static void main(String[] args) throws Throwable { + Recording r = new Recording(); + r.enable(MyEvent.class).withoutStackTrace(); + // for debugging time related issues + r.enable(EventNames.CPUTimeStampCounter); + r.start(); + MyEvent event1 = beginEvent(1); + MyEvent event2 = beginEvent(2); + endEvent(event1); + MyEvent event3 = beginEvent(3); + endEvent(event2); + endEvent(event3); + + r.stop(); + + List events = Events.fromRecording(r); + + RecordedEvent recEvent1 = findEvent(1, events); + RecordedEvent recEvent2 = findEvent(2, events); + RecordedEvent recEvent3 = findEvent(3, events); + + List recordedOrder = new ArrayList<>(); + recordedOrder.add(new TimeEvent(1, true, recEvent1.getStartTime())); + recordedOrder.add(new TimeEvent(1, false, recEvent1.getEndTime())); + recordedOrder.add(new TimeEvent(2, true, recEvent2.getStartTime())); + recordedOrder.add(new TimeEvent(2, false, recEvent2.getEndTime())); + recordedOrder.add(new TimeEvent(3, true, recEvent3.getStartTime())); + recordedOrder.add(new TimeEvent(3, false, recEvent3.getEndTime())); + Collections.sort(recordedOrder); + + printTimedEvents("Actual order", actualOrder); + printTimedEvents("Recorded order", recordedOrder); + + for (int i = 0; i < 6; i++) { + if (!actualOrder.get(i).equals(recordedOrder.get(i))) { + throw new Exception("Event times not in expected order. Was " + recordedOrder.get(1) + " but expected " + actualOrder.get(1)); + } + } + } + + private static void printTimedEvents(String heading, List recordedOrder) { + System.out.println(); + System.out.println(heading); + System.out.println("======================"); + for (TimeEvent t : recordedOrder) { + System.out.println(t.toString()); + } + } + + private static MyEvent beginEvent(int id) throws Exception { + MyEvent event = new MyEvent(id); + event.begin(); + if (!CommonHelper.hasFastTimeEnabled()) { + CommonHelper.waitForSystemCurrentMillisToChange();; + } + actualOrder.add(new TimeEvent(id, true)); + return event; + } + + private static void endEvent(MyEvent event) throws Exception { + event.end(); + if (!CommonHelper.hasFastTimeEnabled()) { + CommonHelper.waitForSystemCurrentMillisToChange();; + } + event.commit(); + actualOrder.add(new TimeEvent(event.id, false)); + } + + private final static class TimeEvent implements Comparable { + long id; + private boolean begin; + private Instant time; + + public TimeEvent(int id, boolean begin) { + this.id = id; + this.begin = begin; + } + + public TimeEvent(int id, boolean begin, Instant time) { + this(id, begin); + this.time = time; + } + + @Override + public int compareTo(TimeEvent that) { + return this.time.compareTo(that.time); + } + + public String toString() { + StringBuilder sb = new StringBuilder(); + if (begin) { + sb.append("begin"); + } else { + sb.append("end"); + } + sb.append("Event"); + sb.append("("); + sb.append(id); + sb.append(")"); + return sb.toString(); + } + + public boolean equals(Object thatObject) { + if (thatObject instanceof TimeEvent) { + TimeEvent that = (TimeEvent) thatObject; + return that.id == this.id && that.begin == this.begin; + } + return false; + } + } + + private static RecordedEvent findEvent(int id, List events) { + for (RecordedEvent event : events) { + if (!event.getEventType().getName().equals(EventNames.CPUTimeStampCounter)) { + int eventId = Events.assertField(event, "id").getValue(); + if (eventId == id) { + return event; + } + } + } + Asserts.fail("No event with id " + id); + return null; + } + + private static class MyEvent extends Event { + int id; + + public MyEvent(int id) { + this.id = id; + } + } +} diff --git a/test/jdk/jfr/api/recording/event/TestLoadEventAfterStart.java b/test/jdk/jfr/api/recording/event/TestLoadEventAfterStart.java new file mode 100644 index 0000000000000000000000000000000000000000..2e7fb93099e8eec14c1bfefe6b5c9c727f841144 --- /dev/null +++ b/test/jdk/jfr/api/recording/event/TestLoadEventAfterStart.java @@ -0,0 +1,90 @@ +/* + * 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.api.recording.event; + +import java.lang.reflect.Constructor; +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Event; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Load event class after recording started. + * @key jfr + * + * @library /lib / + * @build jdk.test.lib.jfr.SimpleEvent + * @run main/othervm jdk.jfr.api.recording.event.TestLoadEventAfterStart + */ +public class TestLoadEventAfterStart { + + public static void main(String[] args) throws Throwable { + Recording r = new Recording(); + r.start(); + + ClassLoader classLoader = TestLoadEventAfterStart.class.getClassLoader(); + Class eventClass = + classLoader.loadClass("jdk.test.lib.jfr.SimpleEvent").asSubclass(Event.class); + + r.enable(eventClass).withThreshold(Duration.ofMillis(0)).withoutStackTrace(); + createEvent(eventClass, 1); + r.disable(eventClass); + createEvent(eventClass, 2); + r.enable(eventClass).withThreshold(Duration.ofMillis(0)).withoutStackTrace(); + createEvent(eventClass, 3); + + r.stop(); + verifyEvents(r, 1, 3); + } + + private static void verifyEvents(Recording r, int ... ids) throws Exception { + List eventIds = new ArrayList<>(); + for (RecordedEvent event : Events.fromRecording(r)) { + int id = Events.assertField(event, "id").getValue(); + System.out.println("Event id:" + id); + eventIds.add(id); + } + Asserts.assertEquals(eventIds.size(), ids.length, "Wrong number of events"); + for (int i = 0; i < ids.length; ++i) { + Asserts.assertEquals(eventIds.get(i).intValue(), ids[i], "Wrong id in event"); + } + } + + private static void createEvent(Class eventClass, int id) throws Exception { + Constructor constructor = eventClass.getConstructor(); + Event event = (Event) constructor.newInstance(); + event.begin(); + eventClass.getDeclaredField("id").setInt(event, id); + event.end(); + event.commit(); + } +} diff --git a/test/jdk/jfr/api/recording/event/TestPeriod.java b/test/jdk/jfr/api/recording/event/TestPeriod.java new file mode 100644 index 0000000000000000000000000000000000000000..7851ae546f6fc16de1e19cae91ccb04ea44242ec --- /dev/null +++ b/test/jdk/jfr/api/recording/event/TestPeriod.java @@ -0,0 +1,127 @@ +/* + * 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.api.recording.event; + +import java.io.IOException; +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedThread; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Test event period. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.event.TestPeriod + */ +public class TestPeriod { + private static final String EVENT_PATH = EventNames.ThreadAllocationStatistics; + private static final long ERROR_MARGIN = 20; // 186 ms has been measured, when period was set to 200 ms + + public static void main(String[] args) throws Throwable { + long[] periods = { 100, 200 }; + int eventCount = 4; + int deltaCount; + for (long period : periods) { + List deltaBetweenEvents; + do { + deltaBetweenEvents = createPeriodicEvents(period, eventCount); + deltaCount = deltaBetweenEvents.size(); + if (deltaCount < eventCount - 1) { + System.out.println("Didn't get sufficent number of events. Retrying..."); + System.out.println(); + } + } while (deltaCount < eventCount - 1); + for (int i = 0; i < eventCount - 1; i++) { + verifyDelta(deltaBetweenEvents.get(i), period); + } + System.out.println(); + } + } + + private static List createPeriodicEvents(long period, int eventCount) throws Exception, IOException { + System.out.println("Provoking events with period " + period + " ms"); + Recording r = new Recording(); + r.start(); + runWithPeriod(r, period, eventCount + 1); + r.stop(); + + long prevTime = -1; + List deltas = new ArrayList<>(); + for (RecordedEvent event : Events.fromRecording(r)) { + if (Events.isEventType(event, EVENT_PATH) && isMyThread(event)) { + long timeMillis = event.getEndTime().toEpochMilli(); + if (prevTime != -1) { + long delta = timeMillis - prevTime; + deltas.add(delta); + System.out.printf("event: time=%d, delta=%d%n", timeMillis, delta); + } + prevTime = timeMillis; + } + } + r.close(); + return deltas; + } + + // We only check that time is at least as expected. + // We ignore if time is much longer than expected, since anything can happen + // during heavy load, + private static void verifyDelta(long actual, long expected) { + System.out.printf("verifyDelta: actaul=%d, expected=%d (errorMargin=%d)%n", actual, expected, ERROR_MARGIN); + Asserts.assertGreaterThan(actual, expected - ERROR_MARGIN, "period delta too short"); + } + + private static boolean isMyThread(RecordedEvent event) { + Object o = event.getValue("thread"); + if (o instanceof RecordedThread) { + RecordedThread rt = (RecordedThread) o; + return Thread.currentThread().getId() == rt.getJavaThreadId(); + } + return false; + } + + @SuppressWarnings("unused") + private static byte[] dummy = null; + + // Generate at least minEvents event with given period + private static void runWithPeriod(Recording r, long period, int minEventCount) throws Exception { + r.enable(EVENT_PATH).withPeriod(Duration.ofMillis(period)); + long endTime = System.currentTimeMillis() + period * minEventCount; + while (System.currentTimeMillis() < endTime) { + dummy = new byte[100]; + Thread.sleep(1); + } + } + +} diff --git a/test/jdk/jfr/api/recording/event/TestReEnableClass.java b/test/jdk/jfr/api/recording/event/TestReEnableClass.java new file mode 100644 index 0000000000000000000000000000000000000000..a0841d8f0d6a4a40bdcb594d7a242d7a5a60d71b --- /dev/null +++ b/test/jdk/jfr/api/recording/event/TestReEnableClass.java @@ -0,0 +1,80 @@ +/* + * 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.api.recording.event; + +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.test.lib.jfr.SimpleEventHelper; + +/** + * @test + * @summary Enable, disable, enable event during recording. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.event.TestReEnableClass + */ +public class TestReEnableClass { + + public static void main(String[] args) throws Throwable { + test(false); + test(true); + } + + // Loop and enable/disable events. + // Verify recording only contains event created during enabled. + private static void test(boolean isEnabled) throws Exception { + System.out.println("Start with isEnabled = " + isEnabled); + + List expectedIds = new ArrayList<>(); + Recording r = new Recording(); + SimpleEventHelper.enable(r, isEnabled); + r.start(); + + for (int i = 0; i < 10; ++i) { + SimpleEventHelper.createEvent(i); + if (isEnabled) { + expectedIds.add(i); + } + isEnabled = !isEnabled; + SimpleEventHelper.enable(r, isEnabled); + } + + r.stop(); + SimpleEventHelper.createEvent(100); + + int[] ids = new int[expectedIds.size()]; + for (int i = 0; i < expectedIds.size(); ++i) { + ids[i] = expectedIds.get(i); + } + SimpleEventHelper.verifyEvents(r, ids); + + r.close(); + } + +} diff --git a/test/jdk/jfr/api/recording/event/TestReEnableMultiple.java b/test/jdk/jfr/api/recording/event/TestReEnableMultiple.java new file mode 100644 index 0000000000000000000000000000000000000000..91c84f5dbe4d25913095bd585f8f65cb0ea27b37 --- /dev/null +++ b/test/jdk/jfr/api/recording/event/TestReEnableMultiple.java @@ -0,0 +1,147 @@ +/* + * 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.api.recording.event; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Random; + +import jdk.jfr.EventType; +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.jfr.SimpleEvent; +import jdk.test.lib.jfr.SimpleEventHelper; + +/** + * @test + * @summary Enable, disable, enable event during recording. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.event.TestReEnableMultiple + */ +public class TestReEnableMultiple { + private static final String EVENT_PATH = EventNames.FileWrite; + private static final Random rand = new Random(0); + + public static void main(String[] args) throws Throwable { + Recording rA = new Recording(); + Recording rB = new Recording(); + + final Path path = Paths.get(".", "dummy.txt").toAbsolutePath(); + rA.start(); + rB.start(); + + SimpleEventHelper.enable(rA, false); + SimpleEventHelper.enable(rA, false); + + int expectedMyEvents = 0; + int expectedIoEvents = 0; + for (int i = 0; i < 20; ++i) { + SimpleEventHelper.createEvent(i); + if (isMyEventEnabled(rA, rB)) { + expectedMyEvents++; + System.out.println("Expect MyEvent.id " + i); + } + + Files.write(path, "A".getBytes()); + if (isIoEnabled(rA, rB)) { + expectedIoEvents++; + } + + for (int j = 0; j < 4; ++j) { + Recording r = (rand.nextInt(2) == 0) ? rA : rB; + updateSettings(r); + } + } + + rA.stop(); + rB.stop(); + + verifyEventCount(rA, expectedMyEvents, expectedIoEvents, path); + verifyEventCount(rB, expectedMyEvents, expectedIoEvents, path); + + rA.close(); + rB.close(); + } + + private static void verifyEventCount(Recording r, int expectedMyEvents, int expectedIoEvents, Path path) throws Exception { + int actualMyEvents = 0; + int actualIoEvents = 0; + for (RecordedEvent event : Events.fromRecording(r)) { + if (Events.isEventType(event, EVENT_PATH)) { + if (path.toString().equals(Events.assertField(event, "path").getValue())) { + actualIoEvents++; + } + } else { + Asserts.assertTrue(Events.isEventType(event, SimpleEvent.class.getName())); + System.out.println("Got MyEvent.id=" + Events.assertField(event, "id").getValue()); + actualMyEvents++; + } + } + System.out.printf("MyEvents: expected=%d, actual=%d%n", expectedMyEvents, actualMyEvents); + System.out.printf("IoEvents: expected=%d, actual=%d%n", expectedIoEvents, actualIoEvents); + Asserts.assertEquals(expectedMyEvents, actualMyEvents, "Wrong number of MyEvents"); + Asserts.assertEquals(expectedIoEvents, actualIoEvents, "Wrong number of IoEvents"); + } + + private static void updateSettings(Recording r) { + boolean doEnable = rand.nextInt(3) == 0; // Disable 2 of 3, since event + // is enabled by union of + // recordings. + boolean doMyEvent = rand.nextInt(2) == 0; + if (doMyEvent) { + SimpleEventHelper.enable(r, doEnable); + } else { + if (doEnable) { + r.enable(EVENT_PATH).withoutStackTrace(); + } else { + r.disable(EVENT_PATH); + } + } + } + + private static boolean isMyEventEnabled(Recording rA, Recording rB) { + long eventTypeId = EventType.getEventType(SimpleEvent.class).getId(); + String settingName = eventTypeId + "#enabled"; + return isEnabled(rA, settingName) || isEnabled(rB, settingName); + } + + private static boolean isIoEnabled(Recording rA, Recording rB) { + String settingName = EVENT_PATH + "#enabled"; + return isEnabled(rA, settingName) || isEnabled(rB, settingName); + } + + private static boolean isEnabled(Recording r, String settingName) { + // System.out.printf("R(%s) %s=%s%n", r.getName(), settingName, + // r.getSettings().get(settingName)); + return Boolean.parseBoolean(r.getSettings().get(settingName)); + } +} diff --git a/test/jdk/jfr/api/recording/event/TestReEnableName.java b/test/jdk/jfr/api/recording/event/TestReEnableName.java new file mode 100644 index 0000000000000000000000000000000000000000..d475d2c6182301cc839a71899c82051629af394d --- /dev/null +++ b/test/jdk/jfr/api/recording/event/TestReEnableName.java @@ -0,0 +1,97 @@ +/* + * 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.api.recording.event; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +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; + +/** + * @test + * @summary Enable/disable event by name during recording. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.event.TestReEnableName + */ +public class TestReEnableName { + + public static void main(String[] args) throws Throwable { + testRecordingWithEnabledEvent(EventNames.FileWrite, false); + testRecordingWithEnabledEvent(EventNames.FileWrite, true); + } + + // Loop and enable/disable events. Create events each loop. + // Verify we only get events created during enabled. + private static void testRecordingWithEnabledEvent(String eventname, boolean enabled) throws Exception { + System.out.println("Testing enabled=" + enabled + " for " + eventname); + final Path pathDisabled = Paths.get(".", "disabled.txt").toAbsolutePath(); + final Path pathEnabled = Paths.get(".", "enabled.txt").toAbsolutePath(); + + Recording r = new Recording(); + if (enabled) { + r.enable(eventname).withoutThreshold().withoutStackTrace(); + } else { + r.disable(eventname).withoutThreshold().withoutStackTrace(); + } + r.start(); + + // We should only get events for pathEnabled, not for pathDisabled. + int countExpectedEvents = 0; + for (int i = 0; i < 10; ++i) { + if (enabled) { + Files.write(pathEnabled, "E".getBytes()); + ++countExpectedEvents; + r.disable(eventname); + } else { + Files.write(pathDisabled, "D".getBytes()); + r.enable(eventname); + } + enabled = !enabled; + } + r.stop(); + + int countFoundEvents = 0; + for (RecordedEvent event : Events.fromRecording(r)) { + System.out.printf("Event %s%n", event); + Asserts.assertEquals(eventname, event.getEventType().getName(), "Wrong event type"); + String path = Events.assertField(event, "path").getValue(); + System.out.println(path); + if (pathEnabled.toString().equals(path)) { + ++countFoundEvents; + } + } + Asserts.assertGreaterThanOrEqual(countFoundEvents, countExpectedEvents, "Too few events found"); + + r.close(); + } +} diff --git a/test/jdk/jfr/api/recording/event/TestRecordingEnableDisable.java b/test/jdk/jfr/api/recording/event/TestRecordingEnableDisable.java new file mode 100644 index 0000000000000000000000000000000000000000..6b374e4495bc16a85ffe752fd47b879a3da76430 --- /dev/null +++ b/test/jdk/jfr/api/recording/event/TestRecordingEnableDisable.java @@ -0,0 +1,125 @@ +/* + * 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.api.recording.event; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Random; + +import jdk.jfr.EventType; +import jdk.jfr.Recording; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.SimpleEvent; +import jdk.test.lib.jfr.SimpleEventHelper; + +/** + * @test + * @summary Enable, disable, enable event during recording. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.event.TestRecordingEnableDisable + */ +public class TestRecordingEnableDisable { + private static final String EVENT_PATH = "java.file_write"; + private static final Random rand = new Random(0); + + public static void main(String[] args) throws Throwable { + + Recording rA = new Recording(); + Recording rB = new Recording(); + + rA.setName("rA"); + rB.setName("rB"); + + final Path path = Paths.get(".", "my.jfr"); + rA.start(); + rB.start(); + + for (int i = 0; i < 30; ++i) { + SimpleEventHelper.createEvent(i); + if (isMyEventEnabled(rA, rB)) { + System.out.println("MyEvent enabled"); + } + else { + System.out.println("MyEvent disabled"); + } + + Files.write(path, "A".getBytes()); + if (isIoEnabled(rA, rB)) { + System.out.println("IoEvent enabled"); + } + else { + System.out.println("IoEvent disabled"); + } + Recording r = ((i % 2) == 0) ? rA : rB; + updateSettings(r); + } + + rA.stop(); + rB.stop(); + rA.close(); + rB.close(); + } + + + private static void updateSettings(Recording r) { + int operationIndex = rand.nextInt(4); + switch (operationIndex) { + case 0: + SimpleEventHelper.enable(r, true); + break; + case 1: + SimpleEventHelper.enable(r, false); + break; + case 2: + r.enable(EVENT_PATH).withoutStackTrace(); + break; + case 3: + r.disable(EVENT_PATH); + break; + default: + Asserts.fail("Wrong operataionIndex. Test error"); + } + } + + private static boolean isMyEventEnabled(Recording rA, Recording rB) { + long eventTypeId = EventType.getEventType(SimpleEvent.class).getId(); + String settingName = "@" + eventTypeId + "#enabled"; + return isEnabled(rA, settingName) || isEnabled(rB, settingName); + } + + private static boolean isIoEnabled(Recording rA, Recording rB) { + String settingName = EVENT_PATH + "#enabled"; + return isEnabled(rA, settingName) || isEnabled(rB, settingName); + } + + private static boolean isEnabled(Recording r, String settingName) { + System.out.printf("R(%s) %s=%s%n", r.getName(), settingName, r.getSettings().get(settingName)); + return Boolean.parseBoolean(r.getSettings().get(settingName)); + } +} diff --git a/test/jdk/jfr/api/recording/event/TestThreshold.java b/test/jdk/jfr/api/recording/event/TestThreshold.java new file mode 100644 index 0000000000000000000000000000000000000000..71de84119a8503cbe8ad50fabd53734db589920d --- /dev/null +++ b/test/jdk/jfr/api/recording/event/TestThreshold.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. 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.api.recording.event; + +import java.time.Duration; +import java.util.List; + +import jdk.jfr.Event; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Test event threshold. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.event.TestThreshold + */ +public class TestThreshold { + + public static void main(String[] args) throws Throwable { + Recording r = new Recording(); + + r.start(); + r.enable(MyEvent.class).withThreshold(Duration.ofMillis(500)); + createEvent(0, 100); + createEvent(1, 600); + createEvent(2, 100); + r.stop(); + + List events = Events.fromRecording(r); + Asserts.assertTrue(1 <= events.size(), "Should get at most 1 event"); + r.close(); + } + + private static void createEvent(int id, long duration) throws Exception { + MyEvent event = new MyEvent(id); + long start = System.currentTimeMillis(); + + event.begin(); + sleepUntil(start + duration); + event.end(); + + long actualDuration = System.currentTimeMillis() - start; + System.out.printf("targetDuration=%d, actualDuration=%d, shouldCommit=%b%n", + duration, actualDuration, event.shouldCommit()); + event.commit(); + } + + private static void sleepUntil(long endTime) throws Exception { + long sleepTime = endTime - System.currentTimeMillis(); + while(sleepTime > 0) { + Thread.sleep(sleepTime); + sleepTime = endTime - System.currentTimeMillis(); + } + } + + static class MyEvent extends Event { + public int id; + public MyEvent(int id) { + this.id = id; + } + } + +} diff --git a/test/jdk/jfr/api/recording/misc/TestGetId.java b/test/jdk/jfr/api/recording/misc/TestGetId.java new file mode 100644 index 0000000000000000000000000000000000000000..075bfbb32b1596d9a4447a873098c2edf1e31aea --- /dev/null +++ b/test/jdk/jfr/api/recording/misc/TestGetId.java @@ -0,0 +1,68 @@ +/* + * 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.api.recording.misc; + +import java.util.HashMap; +import java.util.Map; + +import jdk.jfr.Recording; +import jdk.test.lib.Asserts; + +/** + * @test + * @summary Verify that each recording get unique a id + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.misc.TestGetId + */ +public class TestGetId { + + public static void main(String[] args) throws Throwable { + Map recordings = new HashMap<>(); + + final int iterations = 100; + for (int i = 0; i < iterations; ++i) { + Recording newRecording = new Recording(); + System.out.println("created: " + newRecording.getId()); + Recording oldRecording = recordings.get(newRecording.getId()); + Asserts.assertNull(oldRecording, "Duplicate recording ID: " + newRecording.getId()); + recordings.put(newRecording.getId(), newRecording); + + if (i % 3 == 0) { + Recording closeRecording = recordings.remove(recordings.keySet().iterator().next()); + Asserts.assertNotNull(closeRecording, "Could not find recording in map. Test error."); + closeRecording.close(); + System.out.println("closed: " + closeRecording.getId()); + } + } + + for (Recording r : recordings.values()) { + r.close(); + } + } + +} diff --git a/test/jdk/jfr/api/recording/misc/TestGetSize.java b/test/jdk/jfr/api/recording/misc/TestGetSize.java new file mode 100644 index 0000000000000000000000000000000000000000..d15178879073dbbc328d81e8df973f852170450a --- /dev/null +++ b/test/jdk/jfr/api/recording/misc/TestGetSize.java @@ -0,0 +1,64 @@ +/* + * 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.api.recording.misc; + +import static jdk.test.lib.Asserts.assertEquals; +import static jdk.test.lib.Asserts.assertTrue; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import jdk.jfr.Recording; +import jdk.test.lib.jfr.EventNames; + +/** + * @test + * @summary Test recording file size with Recording.getSize() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.misc.TestGetSize + */ +public class TestGetSize { + + public static void main(String[] args) throws Throwable { + Path dest = Paths.get(".", "my.jfr"); + Recording r = new Recording(); + r.setToDisk(true); + r.enable(EventNames.OSInformation); + assertEquals(r.getSize(), 0L, "getSize should return 0 before recording starts"); + r.start(); + r.stop(); + r.dump(dest); + assertTrue(Files.exists(dest), "TestGetSize recording missing: " + dest); + System.out.printf("%s size: %d%n", dest, Files.size(dest)); + System.out.printf("r.getSize(): %d%n", r.getSize()); + assertEquals(Files.size(dest), r.getSize(), "TestGetSize wrong recording size"); + r.close(); + } + +} diff --git a/test/jdk/jfr/api/recording/misc/TestGetSizeToMem.java b/test/jdk/jfr/api/recording/misc/TestGetSizeToMem.java new file mode 100644 index 0000000000000000000000000000000000000000..11322805f20fc031382c84c98fc81d2c95f39e0a --- /dev/null +++ b/test/jdk/jfr/api/recording/misc/TestGetSizeToMem.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.api.recording.misc; + +import static jdk.test.lib.Asserts.assertEquals; +import static jdk.test.lib.Asserts.assertTrue; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import jdk.jfr.Recording; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; + +/** + * @test + * @summary Test recording file size with Recording.getSize() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.misc.TestGetSizeToMem + */ +public class TestGetSizeToMem { + + + public static void main(String[] args) throws Throwable { + Path dest = Paths.get(".", "my.jfr"); + Recording r = new Recording(); + r.setToDisk(false); + r.setDestination(dest); + r.enable(EventNames.OSInformation); + r.start(); + r.stop(); + r.close(); + assertTrue(Files.exists(dest), "TestGetSize recording missing: " + dest); + System.out.printf("%s size: %d%n", dest, Files.size(dest)); + System.out.printf("r.getSize(): %d%n", r.getSize()); + Asserts.assertNotEquals(Files.size(dest), 0L, "File should not be empty"); + assertEquals(r.getSize(), 0L, "r.getSize() should be 0 after setToDisk(false)"); + } + +} diff --git a/test/jdk/jfr/api/recording/misc/TestGetStream.java b/test/jdk/jfr/api/recording/misc/TestGetStream.java new file mode 100644 index 0000000000000000000000000000000000000000..78cc1eca2bdba14cd60cb7f20cc4987f32159823 --- /dev/null +++ b/test/jdk/jfr/api/recording/misc/TestGetStream.java @@ -0,0 +1,154 @@ +/* + * 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. 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.api.recording.misc; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.Duration; +import java.time.Instant; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.SimpleEvent; + +/** + * @test + * @summary A simple test for Recording.getStream() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.misc.TestGetStream + */ +public class TestGetStream { + + private final static Instant offset = Instant.now(); + private static Instant previous; + + public static void main(String[] args) throws Exception { + + Recording recording = new Recording(); + Instant t0 = newTimestamp(); + recording.start(); + Instant t1 = newTimestamp(); + createChunkWithId(1); + Instant t2 = newTimestamp(); + createChunkWithId(2); + Instant t3 = newTimestamp(); + createChunkWithId(3); + Instant t4 = newTimestamp(); + recording.stop(); + Instant t5 = newTimestamp(); + printTimeStamp("t0", t0); + printTimeStamp("t1", t1); + printTimeStamp("t2", t2); + printTimeStamp("t3", t3); + printTimeStamp("t4", t4); + printTimeStamp("t5", t5); + + assertContainsId(recording, "t1-t4", t1, t4, 1, 2, 3); + assertContainsId(recording, "t1-t3", t1, t3, 1, 2); + assertContainsId(recording, "t2-t4", t2, t4, 2, 3); + assertContainsId(recording, "t1-t2", t1, t2, 1); + assertContainsId(recording, "t2-t3", t2, t3, 2); + assertContainsId(recording, "t3-t4", t3, t4, 3); + assertContainsId(recording, "t0-t1", t0, t1); + assertContainsId(recording, "t4-t5", t4, t5); + + assertEndBeforeBegin(); + } + + private static void printTimeStamp(String name, Instant t) { + Duration s = Duration.between(offset, t); + System.out.println(name + ": " + (s.getSeconds() * 1_000_000_000L + s.getNano())); + } + + private static void createChunkWithId(int id) throws InterruptedException { + newTimestamp(); // ensure every recording gets a unique start time + try (Recording r = new Recording()) { + r.start(); + SimpleEvent s = new SimpleEvent(); + s.id = id; + s.commit(); + r.stop(); + newTimestamp(); // ensure that start time is not equal to stop time + } + newTimestamp(); // ensure every recording gets a unique stop time + } + + // Create a timestamp that is not same as the previous one + private static Instant newTimestamp() throws InterruptedException { + while (true) { + Instant now = Instant.now(); + if (!now.equals(previous)) { + previous = now; + return now; + } + Thread.sleep(1); + } + } + + private static void assertContainsId(Recording r, String interval, Instant start, Instant end, Integer... ids) throws IOException { + List idList = new ArrayList<>(Arrays.asList(ids)); + long time = System.currentTimeMillis(); + String fileName = idList.stream().map(x -> x.toString()).collect(Collectors.joining("_", "recording-get-stream_" + time + "_", ".jfr")); + Path file = Paths.get(fileName); + try (InputStream is = r.getStream(start, end)) { + Files.copy(is, file, StandardCopyOption.REPLACE_EXISTING); + } + try (RecordingFile rf = new RecordingFile(file)) { + while (rf.hasMoreEvents()) { + RecordedEvent event = rf.readEvent(); + Integer id = event.getValue("id"); + Asserts.assertTrue(idList.contains(id), "Unexpected id " + id + " found in interval " + interval); + idList.remove(id); + } + Asserts.assertTrue(idList.isEmpty(), "Expected events with ids " + idList); + } + } + + private static void assertEndBeforeBegin() throws IOException { + try (Recording recording = new Recording()) { + recording.start(); + recording.stop(); + Instant begin = Instant.now(); + Instant end = begin.minusNanos(1); + recording.getStream(begin, end); + Asserts.fail("Expected IllegalArgumentException has not been thrown"); + } catch (IllegalArgumentException x) { + // Caught the expected exception + } + } + +} diff --git a/test/jdk/jfr/api/recording/misc/TestRecordingBase.java b/test/jdk/jfr/api/recording/misc/TestRecordingBase.java new file mode 100644 index 0000000000000000000000000000000000000000..a8284fd459d202c36ba906ec7445ef20a3fcf2f3 --- /dev/null +++ b/test/jdk/jfr/api/recording/misc/TestRecordingBase.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. 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.api.recording.misc; + +import static jdk.test.lib.Asserts.assertEquals; +import static jdk.test.lib.Asserts.assertFalse; +import static jdk.test.lib.Asserts.assertNotEquals; +import static jdk.test.lib.Asserts.assertNotNull; +import static jdk.test.lib.Asserts.assertNull; +import static jdk.test.lib.Asserts.assertTrue; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.time.Duration; +import java.util.Map; + +import jdk.jfr.Recording; +import jdk.jfr.RecordingState; + +/** + * @test + * @summary Basic tests for Recording + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.misc.TestRecordingBase + */ +public class TestRecordingBase { + + public static void main(String[] args) throws Throwable { + testUninitialized(); + testUniqueIdentifier(); + testSetGetName(); + testSetGetDuration(); + testSetGetMaxAge(); + testSetGetDestination(); + testSetGetDumpOnExit(); + testSetGetToDisk(); + testSetGetToMaxSize(); + testGetSettings(); + } + + public static void testUninitialized() throws Throwable { + Recording r = new Recording(); + assertNull(r.getDuration(), "Wrong uninitialized duration"); + assertNull(r.getStartTime(), "Wrong uninitialized startTime"); + assertNull(r.getStopTime(), "Wrong uninitialized stopTime"); + assertNull(r.getDestination(), "Wrong uninitialized destination"); + assertNull(r.getMaxAge(), "Wrong uninitialized maxAge"); + assertEquals(0L, r.getMaxSize(), "Wrong uninitialized maxSize"); // TODO: Should this be null? Why Long if never null? + assertEquals(0L, r.getSize(), "Wrong uninitialized size"); + assertNotNull(r.getName(), "Uninitialized name should not be null"); + assertFalse(r.getName().isEmpty(), "Uninitialized name should not be empty"); + assertEquals(r.getState(), RecordingState.NEW, "Wrong uninitialized state"); + assertTrue(r.getSettings().isEmpty(), "Uninitialized settings should be empty"); + r.close(); + } + + public static void testUniqueIdentifier() throws Throwable { + Recording r1 = new Recording(); + Recording r2 = new Recording(); + assertNotEquals(r1.getId(), r2.getId(), "Same identifier"); + r1.close(); + r2.close(); + } + + public static void testSetGetName() throws Throwable { + Recording r = new Recording(); + final String name = "TestName"; + r.setName(name); + assertEquals(name, r.getName(), "Wrong set/get name"); + r.close(); + } + + public static void testSetGetDuration() throws Throwable { + Recording r = new Recording(); + final Duration duration = Duration.ofSeconds(60).plusMillis(50); + r.setDuration(duration); + assertEquals(duration, r.getDuration(), "Wrong set/get duration"); + r.close(); + } + + public static void testSetGetMaxAge() throws Throwable { + Recording r = new Recording(); + final Duration maxAge = Duration.ofSeconds(60).plusMillis(50); + r.setMaxAge(maxAge); + assertEquals(maxAge, r.getMaxAge(), "Wrong set/get maxAge"); + r.close(); + } + + public static void testSetGetDestination() throws Throwable { + Recording r = new Recording(); + final Path destination = Paths.get(".", "testSetGetDestination.jfr"); + r.setDestination(destination); + assertEquals(destination, r.getDestination(), "Wrong set/get destination"); + r.close(); + } + + public static void testSetGetDumpOnExit() throws Throwable { + Recording r = new Recording(); + r.setDumpOnExit(true); + assertTrue(r.getDumpOnExit(), "Wrong set/get dumpOnExit true"); + r.setDumpOnExit(false); + assertFalse(r.getDumpOnExit(), "Wrong set/get dumpOnExit false"); + r.close(); + } + + public static void testSetGetToDisk() throws Throwable { + Recording r = new Recording(); + r.setToDisk(true); + assertTrue(r.isToDisk(), "Wrong set/get isToDisk true"); + r.setToDisk(false); + assertFalse(r.isToDisk(), "Wrong set/get isToDisk false"); + r.close(); + } + + public static void testSetGetToMaxSize() throws Throwable { + Recording r = new Recording(); + final long maxSize = 10000000; + r.setMaxSize(maxSize); + assertEquals(maxSize, r.getMaxSize(), "Wrong set/get maxSize"); + r.close(); + } + + public static void testGetSettings() throws Throwable { + String eventPath = "my/test/enabledPath"; + String settingName = "myTestSetting"; + String settingValue = "myTestValue"; + + Recording r = new Recording(); + r.enable(eventPath).with(settingName, settingValue); + + boolean isEnabledPathFound = false; + boolean isSettingFound = false; + Map settings = r.getSettings(); + for (String name : settings.keySet()) { + System.out.println("name=" + name + ", value=" + settings.get(name)); + if (name.contains(eventPath) && name.contains("#enabled")) { + isEnabledPathFound = true; + assertEquals("true", settings.get(name), "Wrong value for enabled path: " + name); + } + if (name.contains(eventPath) && name.contains(settingName)) { + isSettingFound = true; + assertEquals(settingValue, settings.get(name), "Wrong value for setting: " + name); + } + } + assertTrue(isEnabledPathFound, "Enabled path not found in settings"); + assertTrue(isSettingFound, "Test setting not found in settings"); + r.close(); + } + +} diff --git a/test/jdk/jfr/api/recording/misc/TestRecordingCopy.java b/test/jdk/jfr/api/recording/misc/TestRecordingCopy.java new file mode 100644 index 0000000000000000000000000000000000000000..f1c5bd84245912f720d2a8f4a663920fe816325f --- /dev/null +++ b/test/jdk/jfr/api/recording/misc/TestRecordingCopy.java @@ -0,0 +1,112 @@ +/* + * 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. 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.api.recording.misc; + +import jdk.jfr.Recording; +import jdk.jfr.RecordingState; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.SimpleEvent; + +import java.util.List; + +/** + * @test + * @summary A simple test for Recording.copy() + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.misc.TestRecordingCopy + */ +public class TestRecordingCopy { + + private static final int EVENT_ID = 1001; + + public static void main(String[] args) throws Exception { + + Recording original = new Recording(); + original.enable(SimpleEvent.class); + + Recording newCopy = original.copy(false); + Asserts.assertEquals(newCopy.getState(), RecordingState.NEW); + + Recording newStoppedCopy = original.copy(true); + Asserts.assertEquals(newStoppedCopy.getState(), RecordingState.NEW); + + original.start(); + + SimpleEvent ev = new SimpleEvent(); + ev.id = EVENT_ID; + ev.commit(); + + // Verify a stopped copy + Recording stoppedCopy = original.copy(true); + Asserts.assertEquals(stoppedCopy.getState(), RecordingState.STOPPED); + assertCopy(stoppedCopy, original); + + // Verify a running copy + Recording runningCopy = original.copy(false); + Asserts.assertEquals(runningCopy.getState(), RecordingState.RUNNING); + assertCopy(runningCopy, original); + + original.stop(); + + // Verify a stopped copy of a stopped + stoppedCopy = original.copy(true); + Asserts.assertEquals(stoppedCopy.getState(), RecordingState.STOPPED); + assertCopy(stoppedCopy, original); + + // Clean-up + original.close(); + runningCopy.stop(); + runningCopy.close(); + stoppedCopy.close(); + } + + /** + * Verifies the basic assertions about a copied record + */ + private static void assertCopy(Recording recording, Recording original) throws Exception { + + Asserts.assertFalse(recording.getId() == original.getId(), "id of a copied record should differ from that of the original"); + Asserts.assertFalse(recording.getName().equals(original.getName()), "name of a copied record should differ from that of the original"); + + Asserts.assertEquals(recording.getSettings(), original.getSettings()); + Asserts.assertEquals(recording.getStartTime(), original.getStartTime()); + Asserts.assertEquals(recording.getMaxSize(), original.getMaxSize()); + Asserts.assertEquals(recording.getMaxAge(), original.getMaxAge()); + Asserts.assertEquals(recording.isToDisk(), original.isToDisk()); + Asserts.assertEquals(recording.getDumpOnExit(), original.getDumpOnExit()); + + List recordedEvents = Events.fromRecording(recording); + Events.hasEvents(recordedEvents); + Asserts.assertEquals(1, recordedEvents.size(), "Expected exactly one event"); + + RecordedEvent re = recordedEvents.get(0); + Asserts.assertEquals(EVENT_ID, re.getValue("id")); + } + +} diff --git a/test/jdk/jfr/api/recording/options/TestDuration.java b/test/jdk/jfr/api/recording/options/TestDuration.java new file mode 100644 index 0000000000000000000000000000000000000000..1d88aae4b39224fa7db265d39f41c191cd402a40 --- /dev/null +++ b/test/jdk/jfr/api/recording/options/TestDuration.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.api.recording.options; + +import java.time.Duration; +import java.time.Instant; + +import jdk.jfr.Recording; +import jdk.jfr.RecordingState; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.CommonHelper; + +/** + * @test + * @summary Test setDuration(). Verify recording is stopped automatically. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.options.TestDuration + */ +public class TestDuration { + + public static void main(String[] args) throws Throwable { + final Duration duration = Duration.ofSeconds(1); + Recording r = new Recording(); + r.setDuration(duration); + Asserts.assertEquals(duration, r.getDuration(), "Wrong get/set duration"); + + r.start(); + Instant afterStart = Instant.now(); + CommonHelper.waitForRecordingState(r, RecordingState.STOPPED); + + Instant afterStop = Instant.now(); + Asserts.assertLessThanOrEqual(r.getStopTime(), afterStop, "getStopTime() > afterStop"); + long durationMillis = Duration.between(afterStart, r.getStopTime()).toMillis(); + + // Performance of test servers varies too much to make a strict check of actual duration. + // We only check that recording stops before timeout of 20 seconds. + System.out.printf("Recording stopped after %d ms, expected above 1000 ms%n", durationMillis); + r.close(); + } + +} diff --git a/test/jdk/jfr/api/recording/options/TestName.java b/test/jdk/jfr/api/recording/options/TestName.java new file mode 100644 index 0000000000000000000000000000000000000000..a37eaaedbef0f16fb68039bfc2a0682c069a3748 --- /dev/null +++ b/test/jdk/jfr/api/recording/options/TestName.java @@ -0,0 +1,93 @@ +/* + * 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.api.recording.options; + +import jdk.jfr.Recording; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.CommonHelper; +import jdk.test.lib.jfr.VoidFunction; + +/** + * @test + * @summary Test setName(). + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.options.TestName + */ +public class TestName { + + public static void main(String[] args) throws Throwable { + Recording r = new Recording(); + + Asserts.assertNotNull(r.getName(), "Default name should not be null"); + System.out.println("name=" + r.getName()); + Asserts.assertEquals(r.getName(), Long.toString(r.getId()), "Default name != id"); + + testNames(r); + r.start(); + testNames(r); + r.stop(); + testNames(r); + r.close(); + } + + private static void testNames(Recording r) throws Throwable { + System.out.println("Recording state=" + r.getState().name()); + + // Set simple name + String name = "myName"; + r.setName(name); + System.out.println("name=" + r.getName()); + Asserts.assertEquals(name, r.getName(), "Wrong get/set name"); + + // Set null. Should get Exception and old name should be kept. + verifyNull(()->{r.setName(null);}, "No NullPointerException when setName(null)"); + Asserts.assertEquals(name, r.getName(), "Current name overwritten after null"); + + // Set empty name. Should work. + name = ""; + r.setName(name); + System.out.println("name=" + r.getName()); + Asserts.assertEquals(name, r.getName(), "Empty name is expected to work"); + + // Test a long name. + StringBuilder sb = new StringBuilder(500); + while (sb.length() < 400) { + sb.append("LongName-"); + } + name = sb.toString(); + System.out.println("Length of long name=" + name.length()); + r.setName(name); + System.out.println("name=" + r.getName()); + Asserts.assertEquals(name, r.getName(), "Wrong get/set long name"); + } + + private static void verifyNull(VoidFunction f, String msg) throws Throwable { + CommonHelper.verifyException(f, msg, NullPointerException.class); + } + +} diff --git a/test/jdk/jfr/api/recording/settings/TestConfigurationGetContents.java b/test/jdk/jfr/api/recording/settings/TestConfigurationGetContents.java new file mode 100644 index 0000000000000000000000000000000000000000..2f6c6edbac2bec400b9e61a5f77976ba9d1de4a2 --- /dev/null +++ b/test/jdk/jfr/api/recording/settings/TestConfigurationGetContents.java @@ -0,0 +1,70 @@ +/* + * 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. 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.api.recording.settings; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.List; + +import jdk.jfr.Configuration; +import jdk.test.lib.Asserts; + +/** + * @test + * @summary Verifies Configuration.getContents() for every configuration + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.settings.TestConfigurationGetContents + */ +public class TestConfigurationGetContents { + + private static final String SEP = System.getProperty("file.separator"); + private static final String JFR_DIR = System.getProperty("test.jdk") + + SEP + "jre" + SEP + "lib" + SEP + "jfr" + SEP; + + public static void main(String[] args) throws Throwable { + List predefinedConfigs = Configuration.getConfigurations(); + + Asserts.assertNotNull(predefinedConfigs, "List of predefined configs is null"); + Asserts.assertTrue(predefinedConfigs.size() > 0, "List of predefined configs is empty"); + + for (Configuration conf : predefinedConfigs) { + String name = conf.getName(); + System.out.println("Verifying configuration " + name); + String fpath = JFR_DIR + name + ".jfc"; + String contents = conf.getContents(); + String fileContents = readFile(fpath); + Asserts.assertEquals(fileContents, contents, "getContents() does not return the actual contents of the file " + fpath); + } + } + + private static String readFile(String path) throws IOException { + byte[] encoded = Files.readAllBytes(Paths.get(path)); + return new String(encoded); + } + +} diff --git a/test/jdk/jfr/api/recording/settings/TestCreateConfigFromPath.java b/test/jdk/jfr/api/recording/settings/TestCreateConfigFromPath.java new file mode 100644 index 0000000000000000000000000000000000000000..30cca24a07856971b798e7052579f3408698acf6 --- /dev/null +++ b/test/jdk/jfr/api/recording/settings/TestCreateConfigFromPath.java @@ -0,0 +1,85 @@ +/* + * 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.api.recording.settings; + + +import java.io.Reader; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Map; + +import jdk.jfr.Configuration; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; + +/** + * @test + * @summary Test setName(). + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.settings.TestCreateConfigFromPath + */ +public class TestCreateConfigFromPath { + + private static final Path DIR = Paths.get(System.getProperty("test.src", ".")); + + public static void main(String[] args) throws Throwable { + testOkConfig(); + testNullReader(); + } + + private static void testOkConfig() throws Exception { + Path settingsPath = DIR.resolve("settings.jfc"); + if(!settingsPath.toFile().exists()) throw new RuntimeException("File " + settingsPath.toFile().getAbsolutePath() + " not found "); + + Configuration config = Configuration.create(settingsPath); + Map settings = config.getSettings(); + + Asserts.assertEquals(4, settings.size(), "Settings size differes from the expected size"); + String[] keys = {"enabled", "stackTrace", "threshold", "custom"}; + String[] vals = {"true", "true", "1 ms", "5"}; + for(int i=0; i settings = config.getSettings(); + + Asserts.assertEquals(4, settings.size(), "Settings size differes from the expected size"); + String[] keys = {"enabled", "stackTrace", "threshold", "custom"}; + String[] vals = {"true", "true", "1 ms", "5"}; + for(int i=0; i predefinedConfigs = Configuration.getConfigurations(); + Asserts.assertNotNull(predefinedConfigs, "List of predefined configs is null"); + Asserts.assertEquals(predefinedConfigs.size(), 2, "Expected exactly two predefined configurations"); + + Configuration defaultConfig = findConfigByName(predefinedConfigs, DEFAULT_CONFIG_NAME); + Asserts.assertNotNull(defaultConfig, "Config '" + DEFAULT_CONFIG_NAME + "' not found"); + Asserts.assertEquals(defaultConfig.getLabel(), DEFAULT_CONFIG_LABEL); + Asserts.assertEquals(defaultConfig.getDescription(), DEFAULT_CONFIG_DESCRIPTION); + Asserts.assertEquals(defaultConfig.getProvider(), DEFAULT_CONFIG_PROVIDER); + + Configuration profileConfig = findConfigByName(predefinedConfigs, PROFILE_CONFIG_NAME); + Asserts.assertNotNull(profileConfig, "Config '" + PROFILE_CONFIG_NAME + "' not found"); + Asserts.assertEquals(profileConfig.getLabel(), PROFILE_CONFIG_LABEL); + Asserts.assertEquals(profileConfig.getDescription(), PROFILE_CONFIG_DESCRIPTION); + Asserts.assertEquals(profileConfig.getProvider(), PROFILE_CONFIG_PROVIDER); + } + + private static Configuration findConfigByName(List configs, String name) { + for (Configuration config : configs) { + if (name.equals(config.getName())) { + return config; + } + } + return null; + } + +} diff --git a/test/jdk/jfr/api/recording/settings/TestSettingsAvailability.java b/test/jdk/jfr/api/recording/settings/TestSettingsAvailability.java new file mode 100644 index 0000000000000000000000000000000000000000..c040808b149fdc22ae23a6471d064bd06de3e0e8 --- /dev/null +++ b/test/jdk/jfr/api/recording/settings/TestSettingsAvailability.java @@ -0,0 +1,123 @@ +/* + * 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. 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.api.recording.settings; + +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; +import jdk.jfr.SettingDescriptor; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.jfr.EventNames; + +/** + * @test + * @summary Verifies that event types has the correct type of settings + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.settings.TestSettingsAvailability + */ +public class TestSettingsAvailability { + public static void main(String[] args) throws Throwable { + testKnownSettings(); + testSettingPersistence(); + } + + private static void testSettingPersistence() throws IOException, Exception { + Map inMemoryTypes = new HashMap<>(); + for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) { + inMemoryTypes.put(type.getName(), type); + } + + Path p = Paths.get("recording.jfr"); + try (Recording r = new Recording()) { + r.start(); + r.stop(); + r.dump(p); + try (RecordingFile rf = new RecordingFile(p)) { + for (EventType parsedType : rf.readEventTypes()) { + EventType inMem = inMemoryTypes.get(parsedType.getName()); + if (inMem == null) { + throw new Exception("Superflous event type " + parsedType.getName() + " in recording"); + } + Set inMemsettings = new HashSet<>(); + for (SettingDescriptor sd : inMem.getSettingDescriptors()) { + inMemsettings.add(sd.getName()); + } + + for (SettingDescriptor parsedSetting : parsedType.getSettingDescriptors()) { + if (!inMemsettings.contains(parsedSetting.getName())) { + throw new Exception("Superflous setting " + parsedSetting.getName() + " in " + parsedType.getName()); + } + inMemsettings.remove(parsedSetting.getName()); + } + if (!inMemsettings.isEmpty()) { + throw new Exception("Missing settings " + inMemsettings + " for event type " + parsedType.getName() + " in recording"); + } + } + } + } + } + + private static void testKnownSettings() throws Exception { + testSetting(EventNames.JVMInformation, "enabled", "period"); + testSetting(EventNames.FileRead, "enabled", "threshold", "stackTrace"); + testSetting(EventNames.FileWrite, "enabled", "threshold","stackTrace"); + testSetting(EventNames.ExceptionStatistics, "enabled", "period"); + testSetting(EventNames.SocketRead, "enabled", "threshold", "stackTrace"); + testSetting(EventNames.SocketWrite, "enabled", "threshold", "stackTrace"); + testSetting(EventNames.ActiveRecording, "enabled", "threshold", "stackTrace"); + testSetting(EventNames.ActiveSetting, "enabled", "threshold", "stackTrace"); + testSetting(EventNames.JavaExceptionThrow, "enabled", "threshold", "stackTrace"); + } + + private static void testSetting(String eventName, String... settingNames) throws Exception { + for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) { + if (eventName.equals(type.getName())) { + Set settings = new HashSet<>(); + for (SettingDescriptor sd : type.getSettingDescriptors()) { + settings.add(sd.getName()); + } + for (String settingName : settingNames) { + if (!settings.contains(settingName)) { + throw new Exception("Missing setting " + settingName + " in " + eventName); + } + settings.remove(settingName); + } + if (!settings.isEmpty()) { + throw new Exception("Superflous settings " + settings + " in event " + eventName); + } + } + } + } +} diff --git a/test/jdk/jfr/api/recording/settings/settings.jfc b/test/jdk/jfr/api/recording/settings/settings.jfc new file mode 100644 index 0000000000000000000000000000000000000000..12cc57a7fb630bad40ceb95508d46f121dd3eeb6 --- /dev/null +++ b/test/jdk/jfr/api/recording/settings/settings.jfc @@ -0,0 +1,11 @@ + + + + + true + true + 1 ms + 5 + + + diff --git a/test/jdk/jfr/api/recording/state/TestOptionState.java b/test/jdk/jfr/api/recording/state/TestOptionState.java new file mode 100644 index 0000000000000000000000000000000000000000..4c1ff2628dc42ddc76dabcfd23b0bdf76c8cf8f0 --- /dev/null +++ b/test/jdk/jfr/api/recording/state/TestOptionState.java @@ -0,0 +1,92 @@ +/* + * 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.api.recording.state; + +import java.time.Duration; +import java.util.function.Consumer; + +import jdk.jfr.Recording; +import jdk.test.lib.Asserts; + +/** + * @test + * @key jfr + * @summary Test options in different states + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.state.TestOptionState + */ +public class TestOptionState { + + // Name Age Size Dur. Dest. Disk + static boolean[] NEW = arrayOf(true, true, true, true, true, true); + static boolean[] DELAYED = arrayOf(true, true, true, true, true, true); + static boolean[] RUNNING = arrayOf(true, true, true, true, true, false); + static boolean[] STOPPED = arrayOf(true, true, true, false, false, false); + static boolean[] CLOSED = arrayOf(false, false, false, false, false, false); + + public static void main(String[] args) throws Throwable { + Recording r = new Recording(); + assertRecordingState(r, NEW); + r.scheduleStart(Duration.ofHours(2)); + assertRecordingState(r, DELAYED); + r.start(); + assertRecordingState(r, RUNNING); + r.stop(); + assertRecordingState(r, STOPPED); + r.close(); + assertRecordingState(r, CLOSED); + } + + private static void assertRecordingState(Recording r, boolean[] states) throws Exception { + assertOperation("setName", r, s -> s.setName("Test Name"), states[0]); + assertOperation("setMaxAge", r, s -> s.setMaxAge(null), states[1]); + assertOperation("setMaxSize", r, s -> s.setMaxSize(0), states[2]); + assertOperation("setDuration", r, s -> s.setDuration(null), states[3]); + assertOperation("setDestination", r, s -> { + try { + s.setDestination(null); + } catch (IllegalStateException e) { + throw e; // rethrow for testing + } catch(Exception e) { + throw new RuntimeException(e); // should not happen + }}, states[4]); + assertOperation("setTodisk", r, s -> s.setToDisk(true), states[5]); + } + + private static void assertOperation(String opernationName, Recording s, Consumer c, boolean ok) { + try { + c.accept(s); + Asserts.assertTrue(ok, opernationName + " should throw ISE when recording is in state " + s.getState()); + } catch (IllegalStateException ise) { + Asserts.assertFalse(ok, opernationName + " should not throw ISE when recording is in state " + s.getState()); + } + } + + static boolean[] arrayOf(boolean... array) { + return array; + } +} diff --git a/test/jdk/jfr/api/recording/state/TestState.java b/test/jdk/jfr/api/recording/state/TestState.java new file mode 100644 index 0000000000000000000000000000000000000000..2b6863f2573d431ff042a000ba70c01f811e4197 --- /dev/null +++ b/test/jdk/jfr/api/recording/state/TestState.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.api.recording.state; + +import java.time.Duration; + +import jdk.jfr.Recording; +import jdk.jfr.RecordingState; +import jdk.test.lib.jfr.CommonHelper; + +/** + * @test + * @summary Test Recording state + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.state.TestState + */ +public class TestState { + + public static void main(String[] args) throws Throwable { + Recording r = new Recording(); + CommonHelper.verifyRecordingState(r, RecordingState.NEW); + r.scheduleStart(Duration.ofHours(2)); + CommonHelper.verifyRecordingState(r, RecordingState.DELAYED); + r.start(); + CommonHelper.verifyRecordingState(r, RecordingState.RUNNING); + r.stop(); + CommonHelper.verifyRecordingState(r, RecordingState.STOPPED); + r.close(); + CommonHelper.verifyRecordingState(r, RecordingState.CLOSED); + } +} diff --git a/test/jdk/jfr/api/recording/state/TestStateDuration.java b/test/jdk/jfr/api/recording/state/TestStateDuration.java new file mode 100644 index 0000000000000000000000000000000000000000..f13ff8332c115cf08cdc68386567d852283e62d5 --- /dev/null +++ b/test/jdk/jfr/api/recording/state/TestStateDuration.java @@ -0,0 +1,73 @@ +/* + * 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.api.recording.state; + +import java.time.Duration; +import java.time.Instant; + +import jdk.jfr.Recording; +import jdk.jfr.RecordingState; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.CommonHelper; +import jdk.test.lib.jfr.VoidFunction; + +/** + * @test + * @summary Test Recording state + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.state.TestStateDuration + */ +public class TestStateDuration { + + public static void main(String[] args) throws Throwable { + Duration duration = Duration.ofSeconds(2); + Recording r = new Recording(); + r.setDuration(duration); + CommonHelper.verifyRecordingState(r, RecordingState.NEW); + Instant start = Instant.now(); + System.out.println("Recording with duration " + duration + " started at " + start); + r.start(); + + // Wait for recording to stop automatically + System.out.println("Waiting for recording to reach STOPPED state"); + CommonHelper.waitForRecordingState(r, RecordingState.STOPPED); + Instant stop = Instant.now(); + Duration measuredDuration = Duration.between(start, stop); + System.out.println("Recording stopped at " + stop + ". Measured duration " + measuredDuration); + // Timer task uses System.currentMillis, and java.time uses other source. + Duration deltaDueToClockNotInSync = Duration.ofMillis(100); + Asserts.assertGreaterThan(measuredDuration.plus(deltaDueToClockNotInSync), duration); + verifyIllegalState(() -> r.start(), "start() after stop()"); + r.close(); + CommonHelper.verifyRecordingState(r, RecordingState.CLOSED); + } + + private static void verifyIllegalState(VoidFunction f, String msg) throws Throwable { + CommonHelper.verifyException(f, msg, IllegalStateException.class); + } +} diff --git a/test/jdk/jfr/api/recording/state/TestStateIdenticalListeners.java b/test/jdk/jfr/api/recording/state/TestStateIdenticalListeners.java new file mode 100644 index 0000000000000000000000000000000000000000..9e8cf888eab208a5449f1f2a5e44726468414110 --- /dev/null +++ b/test/jdk/jfr/api/recording/state/TestStateIdenticalListeners.java @@ -0,0 +1,73 @@ +/* + * 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.api.recording.state; + +import static jdk.test.lib.Asserts.assertEquals; + +import jdk.jfr.FlightRecorder; +import jdk.jfr.FlightRecorderListener; +import jdk.jfr.Recording; + +/** + * @test + * @summary Test Recording state with concurrent recordings + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.state.TestStateIdenticalListeners + */ +public class TestStateIdenticalListeners { + + public static void main(String[] args) throws Throwable { + TestListener testListener = new TestListener(); + // Add the same listener twice + FlightRecorder.addListener(testListener); + FlightRecorder.addListener(testListener); + + // Start recording + Recording recording = new Recording(); + recording.start(); + recording.stop(); + + // We expect 4 notifications in total: 1 RUNNING and 1 STOPPED + // notification for each listener registration + // NOT 2 notifications: we have added the same listener again + assertEquals(4, testListener.notificationCount, "Expected 2 notifications, got " + testListener.notificationCount); + + System.out.println("Test Passed"); + recording.close(); + } + + private static class TestListener implements FlightRecorderListener { + private int notificationCount; + + @Override + public void recordingStateChanged(Recording recording) { + System.out.println("recordingStateChanged: " + " recording: " + recording + " state: " + recording.getState()); + ++notificationCount; + } + } +} diff --git a/test/jdk/jfr/api/recording/state/TestStateInvalid.java b/test/jdk/jfr/api/recording/state/TestStateInvalid.java new file mode 100644 index 0000000000000000000000000000000000000000..3e3ebbf7024b346e14f5bf16427e4540eb45112c --- /dev/null +++ b/test/jdk/jfr/api/recording/state/TestStateInvalid.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. 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.api.recording.state; + +import jdk.jfr.Recording; +import jdk.jfr.RecordingState; +import jdk.test.lib.jfr.CommonHelper; +import jdk.test.lib.jfr.VoidFunction; + +/** + * @test + * @summary Test start/stop/close recording from different recording states. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.state.TestStateInvalid + */ +public class TestStateInvalid { + + public static void main(String[] args) throws Throwable { + Recording r = new Recording(); + CommonHelper.verifyRecordingState(r, RecordingState.NEW); + verifyIllegalState(() -> r.stop(), "stop() when not started"); + CommonHelper.verifyRecordingState(r, RecordingState.NEW); + + r.start(); + CommonHelper.verifyRecordingState(r, RecordingState.RUNNING); + verifyIllegalState(() -> r.start(), "double start()"); + CommonHelper.verifyRecordingState(r, RecordingState.RUNNING); + + r.stop(); + CommonHelper.verifyRecordingState(r, RecordingState.STOPPED); + verifyIllegalState(() -> r.stop(), "double stop()"); + verifyIllegalState(() -> r.start(), "start() after stop()"); + CommonHelper.verifyRecordingState(r, RecordingState.STOPPED); + + r.close(); + CommonHelper.verifyRecordingState(r, RecordingState.CLOSED); + verifyIllegalState(() -> r.stop(), "stop() after close()"); + verifyIllegalState(() -> r.start(), "start() after close()"); + CommonHelper.verifyRecordingState(r, RecordingState.CLOSED); + } + + private static void verifyIllegalState(VoidFunction f, String msg) throws Throwable { + CommonHelper.verifyException(f, msg, IllegalStateException.class); + } +} diff --git a/test/jdk/jfr/api/recording/state/TestStateMultiple.java b/test/jdk/jfr/api/recording/state/TestStateMultiple.java new file mode 100644 index 0000000000000000000000000000000000000000..b10adaaa411605407b9bdb54647946996bc0b553 --- /dev/null +++ b/test/jdk/jfr/api/recording/state/TestStateMultiple.java @@ -0,0 +1,86 @@ +/* + * 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.api.recording.state; + +import jdk.jfr.Recording; +import jdk.jfr.RecordingState; +import jdk.test.lib.jfr.CommonHelper; +import jdk.test.lib.jfr.VoidFunction; + +/** + * @test + * @summary Test Recording state with concurrent recordings + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.state.TestStateMultiple + */ +public class TestStateMultiple { + + public static void main(String[] args) throws Throwable { + Recording rA = new Recording(); + CommonHelper.verifyRecordingState(rA, RecordingState.NEW); + verifyIllegalState(() -> rA.stop(), "stop() when not started"); + + rA.start(); + CommonHelper.verifyRecordingState(rA, RecordingState.RUNNING); + + Recording rB = new Recording(); + CommonHelper.verifyRecordingState(rA, RecordingState.RUNNING); + verifyIllegalState(() -> rA.start(), "double start()"); + CommonHelper.verifyRecordingState(rB, RecordingState.NEW); + verifyIllegalState(() -> rB.stop(), "stop() when not started"); + + rB.start(); + CommonHelper.verifyRecordingState(rA, RecordingState.RUNNING); + CommonHelper.verifyRecordingState(rB, RecordingState.RUNNING); + + rB.stop(); + CommonHelper.verifyRecordingState(rA, RecordingState.RUNNING); + CommonHelper.verifyRecordingState(rB, RecordingState.STOPPED); + verifyIllegalState(() -> rB.start(), "start() after stop()"); + + rB.close(); + CommonHelper.verifyRecordingState(rA, RecordingState.RUNNING); + CommonHelper.verifyRecordingState(rB, RecordingState.CLOSED); + verifyIllegalState(() -> rB.start(), "start() after close()"); + + rA.stop(); + CommonHelper.verifyRecordingState(rA, RecordingState.STOPPED); + verifyIllegalState(() -> rA.start(), "start() after stop()"); + CommonHelper.verifyRecordingState(rB, RecordingState.CLOSED); + + rA.close(); + CommonHelper.verifyRecordingState(rA, RecordingState.CLOSED); + CommonHelper.verifyRecordingState(rB, RecordingState.CLOSED); + verifyIllegalState(() -> rA.stop(), "stop() after close()"); + verifyIllegalState(() -> rB.start(), "start() after close()"); + } + + private static void verifyIllegalState(VoidFunction f, String msg) throws Throwable { + CommonHelper.verifyException(f, msg, IllegalStateException.class); + } +} diff --git a/test/jdk/jfr/api/recording/state/TestStateScheduleStart.java b/test/jdk/jfr/api/recording/state/TestStateScheduleStart.java new file mode 100644 index 0000000000000000000000000000000000000000..55072b9e67beb5b1074937dd8fd41855ddf88097 --- /dev/null +++ b/test/jdk/jfr/api/recording/state/TestStateScheduleStart.java @@ -0,0 +1,73 @@ +/* + * 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.api.recording.state; + +import java.time.Duration; +import java.time.Instant; + +import jdk.jfr.Recording; +import jdk.jfr.RecordingState; +import jdk.test.lib.jfr.CommonHelper; +import jdk.test.lib.jfr.VoidFunction; + +/** + * @test + * @summary Test Recording state + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.state.TestStateScheduleStart + */ +public class TestStateScheduleStart { + + public static void main(String[] args) throws Throwable { + Recording r = new Recording(); + CommonHelper.verifyRecordingState(r, RecordingState.NEW); + + Instant start = Instant.now(); + r.scheduleStart(Duration.ofMillis(2000)); + + System.out.println("Wait for recording to start: " + start); + CommonHelper.waitForRecordingState(r, RecordingState.RUNNING); + + // Duration should be about 2000 ms. + // Test servers vary too much in performance to make an accurate check. + // We only check that we don't time out after 20 seconds. + Instant started = Instant.now(); + long millis = Duration.between(start, started).toMillis(); + System.out.println("Recording started at " + started + ". Delta millis=" + millis + ", expeced about 2000"); + + verifyIllegalState(() -> r.start(), "double start()"); + r.stop(); + CommonHelper.verifyRecordingState(r, RecordingState.STOPPED); + r.close(); + CommonHelper.verifyRecordingState(r, RecordingState.CLOSED); + } + + private static void verifyIllegalState(VoidFunction f, String msg) throws Throwable { + CommonHelper.verifyException(f, msg, IllegalStateException.class); + } +} diff --git a/test/jdk/jfr/api/recording/time/TestTime.java b/test/jdk/jfr/api/recording/time/TestTime.java new file mode 100644 index 0000000000000000000000000000000000000000..a35546dfced7210311c3db53e07f603f1d104fe3 --- /dev/null +++ b/test/jdk/jfr/api/recording/time/TestTime.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. 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.api.recording.time; + +import java.time.Instant; + +import jdk.jfr.Recording; +import jdk.test.lib.Asserts; + +/** + * @test + * @key jfr + * @summary Test Recording.get*Time() + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.time.TestTime + */ + +public class TestTime { + + public static void main(String[] args) throws Throwable { + Recording r = new Recording(); + Asserts.assertNull(r.getStartTime(), "getStartTime() not null before start"); + Asserts.assertNull(r.getStopTime(), "getStopTime() not null before start"); + + final Instant beforeStart = Instant.now(); + r.start(); + final Instant afterStart = Instant.now(); + + Asserts.assertNotNull(r.getStartTime(), "getStartTime() null after"); + Asserts.assertGreaterThanOrEqual(r.getStartTime(), beforeStart, "getStartTime() < beforeStart"); + Asserts.assertLessThanOrEqual(r.getStartTime(), afterStart, "getStartTime() > afterStart"); + Asserts.assertNull(r.getStopTime(), "getStopTime() not null before stop"); + + final Instant beforeStop = Instant.now(); + r.stop(); + final Instant afterStop = Instant.now(); + + Asserts.assertGreaterThanOrEqual(r.getStartTime(), beforeStart, "getStartTime() < beforeStart"); + Asserts.assertLessThanOrEqual(r.getStartTime(), afterStart, "getStartTime() > afterStart"); + Asserts.assertNotNull(r.getStopTime(), "getStopTime() null after stop"); + Asserts.assertGreaterThanOrEqual(r.getStopTime(), beforeStop, "getStopTime() < beforeStop"); + Asserts.assertLessThanOrEqual(r.getStopTime(), afterStop, "getStopTime() > afterStop"); + + r.close(); + + // Same checks again to make sure close() did not change the times. + Asserts.assertGreaterThanOrEqual(r.getStartTime(), beforeStart, "getStartTime() < beforeStart"); + Asserts.assertLessThanOrEqual(r.getStartTime(), afterStart, "getStartTime() > afterStart"); + Asserts.assertNotNull(r.getStopTime(), "getStopTime() null after stop"); + Asserts.assertGreaterThanOrEqual(r.getStopTime(), beforeStop, "getStopTime() < beforeStop"); + Asserts.assertLessThanOrEqual(r.getStopTime(), afterStop, "getStopTime() > afterStop"); + } + +} diff --git a/test/jdk/jfr/api/recording/time/TestTimeDuration.java b/test/jdk/jfr/api/recording/time/TestTimeDuration.java new file mode 100644 index 0000000000000000000000000000000000000000..c0189ef87a166f25d4393643c1b51723472ca1b6 --- /dev/null +++ b/test/jdk/jfr/api/recording/time/TestTimeDuration.java @@ -0,0 +1,68 @@ +/* + * 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.api.recording.time; + +import java.time.Duration; +import java.time.Instant; + +import jdk.jfr.Recording; +import jdk.test.lib.Asserts; + +/** + * @test + * @key jfr + * @summary Test Recording.setDuration() and Recording.get*Time() + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.time.TestTimeDuration + */ + +public class TestTimeDuration { + + public static void main(String[] args) throws Throwable { + Recording r = new Recording(); + final Duration duration = Duration.ofMillis(30000); + + r.setDuration(duration); + Asserts.assertNull(r.getStartTime(), "getStartTime() not null before start"); + Asserts.assertNull(r.getStopTime(), "getStopTime() not null before start"); + + final Instant beforeStart = Instant.now(); + r.start(); + final Instant afterStart = Instant.now(); + + Asserts.assertNotNull(r.getStartTime(), "getStartTime() null after start()"); + Asserts.assertGreaterThanOrEqual(r.getStartTime(), beforeStart, "getStartTime() < beforeStart"); + Asserts.assertLessThanOrEqual(r.getStartTime(), afterStart, "getStartTime() > afterStart"); + + Asserts.assertNotNull(r.getStopTime(), "getStopTime() null after start with duration"); + Asserts.assertGreaterThanOrEqual(r.getStopTime(), beforeStart.plus(duration), "getStopTime() < beforeStart + duration"); + Asserts.assertLessThanOrEqual(r.getStopTime(), afterStart.plus(duration), "getStopTime() > afterStart + duration"); + + r.close(); + } + +} diff --git a/test/jdk/jfr/api/recording/time/TestTimeMultiple.java b/test/jdk/jfr/api/recording/time/TestTimeMultiple.java new file mode 100644 index 0000000000000000000000000000000000000000..99bfd40092a0c6a45cf4a5d328ebad5be0c987c6 --- /dev/null +++ b/test/jdk/jfr/api/recording/time/TestTimeMultiple.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. 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.api.recording.time; + +import java.time.Instant; + +import jdk.jfr.Recording; +import jdk.test.lib.Asserts; + +/** + * @test + * @key jfr + * @summary Test recording times with concurrent recordings + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.time.TestTimeMultiple + */ + +public class TestTimeMultiple { + + public static void main(String[] args) throws Throwable { + Recording rA = new Recording(); + Asserts.assertNull(rA.getStartTime(), "getStartTime() not null before start"); + Asserts.assertNull(rA.getStopTime(), "getStopTime() not null before start"); + + final Instant beforeStartA = Instant.now(); + rA.start(); + final Instant afterStartA = Instant.now(); + + Recording rB = new Recording(); + Asserts.assertNull(rB.getStartTime(), "getStartTime() not null before start"); + Asserts.assertNull(rB.getStopTime(), "getStopTime() not null before start"); + + final Instant beforeStartB = Instant.now(); + rB.start(); + final Instant afterStartB = Instant.now(); + + final Instant beforeStopB = Instant.now(); + rB.stop(); + final Instant afterStopB = Instant.now(); + + final Instant beforeStopA = Instant.now(); + rA.stop(); + final Instant afterStopA = Instant.now(); + + rA.close(); + rB.close(); + + Asserts.assertNotNull(rA.getStartTime(), "getStartTime() null after start"); + Asserts.assertNotNull(rA.getStopTime(), "getStopTime() null after stop"); + Asserts.assertGreaterThanOrEqual(rA.getStartTime(), beforeStartA, "getStartTime() < beforeStart"); + Asserts.assertLessThanOrEqual(rA.getStartTime(), afterStartA, "getStartTime() > afterStart"); + Asserts.assertGreaterThanOrEqual(rA.getStopTime(), beforeStopA, "getStopTime() < beforeStop"); + Asserts.assertLessThanOrEqual(rA.getStopTime(), afterStopA, "getStopTime() > afterStop"); + + Asserts.assertNotNull(rB.getStartTime(), "getStartTime() null after start"); + Asserts.assertNotNull(rB.getStopTime(), "getStopTime() null after stop"); + Asserts.assertGreaterThanOrEqual(rB.getStartTime(), beforeStartB, "getStartTime() < beforeStart"); + Asserts.assertLessThanOrEqual(rB.getStartTime(), afterStartB, "getStartTime() > afterStart"); + Asserts.assertGreaterThanOrEqual(rB.getStopTime(), beforeStopB, "getStopTime() < beforeStop"); + Asserts.assertLessThanOrEqual(rB.getStopTime(), afterStopB, "getStopTime() > afterStop"); + } + +} diff --git a/test/jdk/jfr/api/recording/time/TestTimeScheduleStart.java b/test/jdk/jfr/api/recording/time/TestTimeScheduleStart.java new file mode 100644 index 0000000000000000000000000000000000000000..34692d608f161a8b46b9c618f8f54820cbb63f54 --- /dev/null +++ b/test/jdk/jfr/api/recording/time/TestTimeScheduleStart.java @@ -0,0 +1,68 @@ +/* + * 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.api.recording.time; + +import java.time.Duration; +import java.time.Instant; + +import jdk.jfr.Recording; +import jdk.jfr.RecordingState; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.CommonHelper; + +/** + * @test + * @key jfr + * @summary Test Recording.scheduleStart() and Recording.get*Time() + * + * @library /lib / + * @run main/othervm jdk.jfr.api.recording.time.TestTimeScheduleStart + */ + +public class TestTimeScheduleStart { + + public static void main(String[] args) throws Throwable { + testScheduledRecordingIsDelayed(); + testScheduledRecordingIsRunning(); + } + + private static void testScheduledRecordingIsRunning() throws Exception { + Recording r = new Recording(); + r.scheduleStart(Duration.ofSeconds(2)); + Asserts.assertNotNull(r.getStartTime(), "start time is null after scheduleStart()"); + CommonHelper.waitForRecordingState(r, RecordingState.RUNNING); + Asserts.assertLessThanOrEqual(r.getStartTime(), Instant.now(), "start time should not exceed current time"); + r.stop(); + r.close(); + } + + private static void testScheduledRecordingIsDelayed() throws Exception { + Recording r = new Recording(); + r.scheduleStart(Duration.ofHours(10)); + CommonHelper.verifyRecordingState(r, RecordingState.DELAYED); + r.close(); + } +} diff --git a/test/jdk/jfr/api/settings/RegExpControl.java b/test/jdk/jfr/api/settings/RegExpControl.java new file mode 100644 index 0000000000000000000000000000000000000000..8683d570f0e97095115a24c99c92ebfd29993def --- /dev/null +++ b/test/jdk/jfr/api/settings/RegExpControl.java @@ -0,0 +1,51 @@ +/* + * 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.api.settings; + +import java.util.Set; +import java.util.regex.Pattern; + +import jdk.jfr.SettingControl; + +public final class RegExpControl extends SettingControl { + private Pattern pattern = Pattern.compile(".*"); + + public void setValue(String value) { + this.pattern = Pattern.compile(value); + } + + public String combine(Set values) { + return String.join("|", values); + } + + public String getValue() { + return pattern.toString(); + } + + public boolean matches(String uri) { + return pattern.matcher(uri).find(); + } +} diff --git a/test/jdk/jfr/api/settings/StringListSetting.java b/test/jdk/jfr/api/settings/StringListSetting.java new file mode 100644 index 0000000000000000000000000000000000000000..1b15ea170b7da1dc07451ce1c95207545c341b70 --- /dev/null +++ b/test/jdk/jfr/api/settings/StringListSetting.java @@ -0,0 +1,105 @@ +/* + * 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.api.settings; +import java.util.HashSet; +import java.util.Set; +import java.util.StringJoiner; + +import jdk.jfr.Description; +import jdk.jfr.Label; +import jdk.jfr.MetadataDefinition; +import jdk.jfr.SettingControl; + +@Label("String List") +@Description("Accepts set of strings, such as \"text\" or \"text1\", \"text2\", or nothing to reject all strings") +@MetadataDefinition +public final class StringListSetting extends SettingControl { + + private Set acceptedStrings = new HashSet<>(); + + @Override + public void setValue(String s) { + acceptedStrings = parseSetting(s); + } + + private Set parseSetting(String s) { + Set stringSet = new HashSet<>(); + StringBuilder sb = new StringBuilder(); + boolean inString = false; + for (int index = 0; index < s.length(); index++) { + char c = s.charAt(index); + if (c != '"') { + if (inString) { + // escape double quotes + if (c == '\\' && index + 1 < s.length()) { + if (s.charAt(index + 1) == '"') { + index++; + c = '"'; + } + } + sb.append(c); + } + } else { + if (inString) { + stringSet.add(sb.toString()); + sb.setLength(0); + } + inString = !inString; + } + } + return stringSet; + } + + @Override + public String getValue() { + StringJoiner sj = new StringJoiner(", ", "\"", "\""); + for (String s : acceptedStrings) { + sj.add(s); + } + return sj.toString(); + } + + @Override + public String combine(Set values) { + Set nameSet = new HashSet<>(); + for (String s : values) { + nameSet.addAll(parseSetting(s)); + } + if (nameSet.isEmpty()) { + return ""; + } + StringJoiner sj = new StringJoiner(", "); + for (String s : nameSet) { + s = s.replace("\"", "\\\""); // escape quotes + sj.add("\"" + s + "\""); + } + return sj.toString(); + } + + public boolean accept(String string) { + return acceptedStrings.contains(string); + } +} diff --git a/test/jdk/jfr/api/settings/TestFilterEvents.java b/test/jdk/jfr/api/settings/TestFilterEvents.java new file mode 100644 index 0000000000000000000000000000000000000000..7c7bea2c5bd5a2a0a901b5e63abcbd9d0e40214b --- /dev/null +++ b/test/jdk/jfr/api/settings/TestFilterEvents.java @@ -0,0 +1,99 @@ +/* + * 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.api.settings; + +import jdk.jfr.Description; +import jdk.jfr.Event; +import jdk.jfr.Label; +import jdk.jfr.Recording; +import jdk.jfr.SettingDefinition; +import jdk.test.lib.jfr.Events; + +import static jdk.test.lib.Asserts.assertEquals; + +/** + * @test + * @summary The test uses SettingControl + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.api.settings.TestFilterEvents + */ +public class TestFilterEvents { + + private static class AbstractHTTPEvent extends Event { + @Label("HTTP URI") + protected String uri; + + @Label("URI Filter") + @SettingDefinition + protected boolean uriFilter(RegExpControl control) { + return control.matches(uri); + } + } + + private static final class HTTPGetEvent extends AbstractHTTPEvent { + @Label("Thread Names") + @Description("List of thread names to accept, such as \"main\" or \"workerThread1\", \"taskThread\"") + @SettingDefinition + private boolean threadNames(StringListSetting setting) { + return setting.accept(Thread.currentThread().getName()); + } + + } + private static final class HTTPPostEvent extends AbstractHTTPEvent { + } + + public static void main(String[] args) throws Exception { + Recording continuous = new Recording(); + continuous.enable(HTTPGetEvent.class).with("threadNames", "\"unused-threadname-1\""); + assertEquals(0, makeProfilingRecording("\"unused-threadname-2\"")); + assertEquals(1, makeProfilingRecording("\"" + Thread.currentThread().getName() + "\"")); + continuous.close(); + } + + private static int makeProfilingRecording(String threadNames) throws Exception { + try (Recording recording = new Recording()) { + recording.enable(HTTPGetEvent.class).with("threadNames", threadNames); + recording.enable(HTTPGetEvent.class).with("uriFilter", "https://www.example.com/list/.*"); + recording.enable(HTTPPostEvent.class).with("uriFilter", "https://www.example.com/list/.*"); + recording.start(); + + HTTPGetEvent getEvent = new HTTPGetEvent(); + getEvent.uri = "https://www.example.com/list/item?id=4"; + getEvent.commit(); + + HTTPPostEvent postEvent = new HTTPPostEvent(); + postEvent.uri = "https://www.example.com/admin/login?name=john"; + postEvent.commit(); + + recording.stop(); + + return Events.fromRecording(recording).size(); + } + } + +} diff --git a/test/jdk/jfr/event/TEST.properties b/test/jdk/jfr/event/TEST.properties new file mode 100644 index 0000000000000000000000000000000000000000..81cb3fce7197da13f7b9a0d3ff86693188e12c9c --- /dev/null +++ b/test/jdk/jfr/event/TEST.properties @@ -0,0 +1,2 @@ +modules = java.management + diff --git a/test/jdk/jfr/event/compiler/TestAllocInNewTLAB.java b/test/jdk/jfr/event/compiler/TestAllocInNewTLAB.java new file mode 100644 index 0000000000000000000000000000000000000000..70b7ab44cffdf840c873f1cbbeaaa6e6880d7487 --- /dev/null +++ b/test/jdk/jfr/event/compiler/TestAllocInNewTLAB.java @@ -0,0 +1,127 @@ +/* + * 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 + * 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.event.compiler; + +import static java.lang.Math.floor; +import static jdk.test.lib.Asserts.assertGreaterThanOrEqual; +import static jdk.test.lib.Asserts.assertLessThanOrEqual; + +import java.time.Duration; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Test that event is triggered when an object is allocated in a new TLAB. + * @key jfr + * + * @library /lib / + * @run main/othervm -XX:+UseTLAB -XX:TLABSize=100k -XX:-ResizeTLAB -XX:TLABRefillWasteFraction=1 jdk.jfr.event.compiler.TestAllocInNewTLAB + * @run main/othervm -XX:+UseTLAB -XX:TLABSize=100k -XX:-ResizeTLAB -XX:TLABRefillWasteFraction=1 -XX:-FastTLABRefill jdk.jfr.event.compiler.TestAllocInNewTLAB + * @run main/othervm -XX:+UseTLAB -XX:TLABSize=100k -XX:-ResizeTLAB -XX:TLABRefillWasteFraction=1 -Xint jdk.jfr.event.compiler.TestAllocInNewTLAB + */ + +/** + * Test that when an object is allocated in a new Thread Local Allocation Buffer (TLAB) + * an event will be triggered. The test is done for C1-compiler, + * C2-compiler (-XX:-FastTLABRefill) and interpreted mode (-Xint). + * + * To force objects to be allocated in a new TLAB: + * the size of TLAB is set to 100k (-XX:TLABSize=100k); + * the size of allocated objects is set to 100k minus 16 bytes overhead; + * max TLAB waste at refill is set to minimum (-XX:TLABRefillWasteFraction=1), + * to provoke a new TLAB creation. + */ +public class TestAllocInNewTLAB { + private final static String EVENT_NAME = EventNames.ObjectAllocationInNewTLAB; + + private static final int BYTE_ARRAY_OVERHEAD = 16; // Extra bytes used by a byte array. + private static final int OBJECT_SIZE = 100 * 1024; + private static final int OBJECT_SIZE_ALT = OBJECT_SIZE + 8; // Object size in case of disabled CompressedOops + private static final int OBJECTS_TO_ALLOCATE = 100; + private static final String BYTE_ARRAY_CLASS_NAME = new byte[0].getClass().getName(); + private static final int INITIAL_TLAB_SIZE = 100 * 1024; + + // make sure allocation isn't dead code eliminated + public static byte[] tmp; + + public static void main(String[] args) throws Exception { + Recording recording = new Recording(); + recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(0)); + + recording.start(); + System.gc(); + for (int i = 0; i < OBJECTS_TO_ALLOCATE; ++i) { + tmp = new byte[OBJECT_SIZE - BYTE_ARRAY_OVERHEAD]; + } + recording.stop(); + + int countAllTlabs = 0; // Count all matching tlab allocations. + int countFullTlabs = 0; // Count matching tlab allocations with full tlab size. + for (RecordedEvent event : Events.fromRecording(recording)) { + if (!EVENT_NAME.equals(event.getEventType().getName())) { + continue; + } + System.out.println("Event:" + event); + + long allocationSize = Events.assertField(event, "allocationSize").atLeast(1L).getValue(); + long tlabSize = Events.assertField(event, "tlabSize").atLeast(allocationSize).getValue(); + String className = Events.assertField(event, "objectClass.name").notEmpty().getValue(); + + boolean isMyEvent = Thread.currentThread().getId() == event.getThread().getJavaThreadId() + && className.equals(BYTE_ARRAY_CLASS_NAME) + && (allocationSize == OBJECT_SIZE || allocationSize == OBJECT_SIZE_ALT); + if (isMyEvent) { + countAllTlabs++; + if (tlabSize == INITIAL_TLAB_SIZE + OBJECT_SIZE || tlabSize == INITIAL_TLAB_SIZE + OBJECT_SIZE_ALT) { + countFullTlabs++; + } + } + } + + int minCount = (int) floor(OBJECTS_TO_ALLOCATE * 0.80); + assertGreaterThanOrEqual(countAllTlabs, minCount, "Too few tlab objects allocated"); + assertLessThanOrEqual(countAllTlabs, OBJECTS_TO_ALLOCATE, "Too many tlab objects allocated"); + + // For most GCs we expect the size of each tlab to be + // INITIAL_TLAB_SIZE + ALLOCATION_SIZE, but that is not always true for G1. + // G1 may use a smaller tlab size if the full tlab does not fit in the + // selected memory region. + // + // For example, if a G1 memory region has room for 4.7 tlabs, + // then the first 4 tlabs will have the expected size, + // but the fifth tlab would only have a size of 0.7*expected. + // + // It is only the last tlab in each region that has a smaller size. + // This means that at least 50% of the allocated tlabs should + // have the expected size (1 full tlab, and 1 fractional tlab). + assertGreaterThanOrEqual(2*countFullTlabs, countAllTlabs, "Too many fractional tlabs."); + } + +} diff --git a/test/jdk/jfr/event/compiler/TestAllocOutsideTLAB.java b/test/jdk/jfr/event/compiler/TestAllocOutsideTLAB.java new file mode 100644 index 0000000000000000000000000000000000000000..99b0a471d70c7370d62ede9079fd6ac1feeb3e89 --- /dev/null +++ b/test/jdk/jfr/event/compiler/TestAllocOutsideTLAB.java @@ -0,0 +1,104 @@ +/* + * 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 + * 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.event.compiler; + +import static java.lang.Math.floor; +import static jdk.test.lib.Asserts.assertGreaterThanOrEqual; +import static jdk.test.lib.Asserts.assertLessThanOrEqual; + +import java.time.Duration; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Test that when an object is allocated outside a TLAB an event will be triggered. + * @key jfr + * + * @library /lib / + * @run main/othervm -XX:+UseTLAB -XX:-FastTLABRefill -XX:TLABSize=90k -XX:-ResizeTLAB -XX:TLABRefillWasteFraction=256 jdk.jfr.event.compiler.TestAllocOutsideTLAB + * @run main/othervm -XX:+UseTLAB -XX:-FastTLABRefill -XX:TLABSize=90k -XX:-ResizeTLAB -XX:TLABRefillWasteFraction=256 jdk.jfr.event.compiler.TestAllocOutsideTLAB + * @run main/othervm -XX:+UseTLAB -XX:-FastTLABRefill -XX:TLABSize=90k -XX:-ResizeTLAB -XX:TLABRefillWasteFraction=256 -Xint jdk.jfr.event.compiler.TestAllocOutsideTLAB + */ + +/** + * Test that an event is triggered when an object is allocated outside a + * Thread Local Allocation Buffer (TLAB). The test is done for C1-compiler, + * C2-compiler (-XX:-FastTLABRefill) and interpreted mode (-Xint). + * + * To force objects to be allocated outside TLAB: + * the size of TLAB is set to 90k (-XX:TLABSize=90k); + * the size of allocated objects is set to 100k. + * max TLAB waste at refill is set to 256 (-XX:TLABRefillWasteFraction=256), + * to prevent a new TLAB creation. +*/ +public class TestAllocOutsideTLAB { + private static final String EVENT_NAME = EventNames.ObjectAllocationOutsideTLAB; + + private static final int BYTE_ARRAY_OVERHEAD = 16; // Extra bytes used by a byte array + private static final int OBJECT_SIZE = 100 * 1024; + private static final int OBJECT_SIZE_ALT = OBJECT_SIZE + 8; // Object size in case of disabled CompressedOops + private static final int OBJECTS_TO_ALLOCATE = 100; + private static final String BYTE_ARRAY_CLASS_NAME = new byte[0].getClass().getName(); + + public static byte[] tmp; // Used to prevent optimizer from removing code. + + public static void main(String[] args) throws Exception { + Recording recording = new Recording(); + recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(0)); + recording.start(); + for (int i = 0; i < OBJECTS_TO_ALLOCATE; ++i) { + tmp = new byte[OBJECT_SIZE - BYTE_ARRAY_OVERHEAD]; + } + recording.stop(); + + int countEvents = 0; + for (RecordedEvent event : Events.fromRecording(recording)) { + if (!EVENT_NAME.equals(event.getEventType().getName())) { + continue; + } + System.out.println("Event:" + event); + + long allocationSize = Events.assertField(event, "allocationSize").atLeast(1L).getValue(); + String className = Events.assertField(event, "objectClass.name").notEmpty().getValue(); + + boolean isMyEvent = Thread.currentThread().getId() == event.getThread().getJavaThreadId() + && className.equals(BYTE_ARRAY_CLASS_NAME) + && (allocationSize == OBJECT_SIZE || allocationSize == OBJECT_SIZE_ALT); + if (isMyEvent) { + ++countEvents; + } + } + + int minCount = (int) floor(OBJECTS_TO_ALLOCATE * 0.80); + assertGreaterThanOrEqual(countEvents, minCount, "Too few tlab objects allocated"); + assertLessThanOrEqual(countEvents, OBJECTS_TO_ALLOCATE, "Too many tlab objects allocated"); + } + +} diff --git a/test/jdk/jfr/event/compiler/TestCodeCacheConfig.java b/test/jdk/jfr/event/compiler/TestCodeCacheConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..7fbf60263d969afa2eda0cfa1b7388ae3d638713 --- /dev/null +++ b/test/jdk/jfr/event/compiler/TestCodeCacheConfig.java @@ -0,0 +1,104 @@ +/* + * 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 + * 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.event.compiler; + +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 sun.hotspot.WhiteBox; + +/** + * @test TestCodeCacheConfig + * @key jfr + * + * @library /lib / + * @build sun.hotspot.WhiteBox + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * @run main/othervm -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * jdk.jfr.event.compiler.TestCodeCacheConfig + * @run main/othervm -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * jdk.jfr.event.compiler.TestCodeCacheConfig + * @summary check "Code Cache Configuration" jfr event + */ +public class TestCodeCacheConfig { + private final static String EVENT_NAME = EventNames.CodeCacheConfiguration; + + private static final long CodeCacheExpectedSize = WhiteBox.getWhiteBox().getUintxVMFlag("ReservedCodeCacheSize"); + + public static void main(String[] args) throws Exception { + Recording recording = new Recording(); + recording.enable(EVENT_NAME); + recording.start(); + recording.stop(); + + List events = Events.fromRecording(recording); + Events.hasEvents(events); + RecordedEvent event = events.get(0); + long initialSize = (long) event.getValue("initialSize"); + long reservedSize = (long) event.getValue("reservedSize"); + long nonNMethodSize = (long) event.getValue("nonNMethodSize"); + long profiledSize = (long) event.getValue("profiledSize"); + long nonProfiledSize = (long) event.getValue("nonProfiledSize"); + long expansionSize = (long) event.getValue("expansionSize"); + long minBlockLength = (long) event.getValue("minBlockLength"); + long startAddress = (long) event.getValue("startAddress"); + long reservedTopAddress = (long) event.getValue("reservedTopAddress"); + + Asserts.assertGT(initialSize, 1024L, + "initialSize less than 1024 byte, got " + initialSize); + + Asserts.assertEQ(reservedSize, CodeCacheExpectedSize, + String.format("Unexpected reservedSize value. Expected %d but " + "got %d", CodeCacheExpectedSize, reservedSize)); + + Asserts.assertLTE(nonNMethodSize, CodeCacheExpectedSize, + String.format("Unexpected nonNMethodSize value. Expected <= %d but " + "got %d", CodeCacheExpectedSize, nonNMethodSize)); + + Asserts.assertLTE(profiledSize, CodeCacheExpectedSize, + String.format("Unexpected profiledSize value. Expected <= %d but " + "got %d", CodeCacheExpectedSize, profiledSize)); + + Asserts.assertLTE(nonProfiledSize, CodeCacheExpectedSize, + String.format("Unexpected nonProfiledSize value. Expected <= %d but " + "got %d", CodeCacheExpectedSize, nonProfiledSize)); + + Asserts.assertGTE(expansionSize, 1024L, + "expansionSize less than 1024 " + "bytes, got " + expansionSize); + + Asserts.assertGTE(minBlockLength, 1L, + "minBlockLength less than 1 byte, got " + minBlockLength); + + Asserts.assertNE(startAddress, 0L, + "startAddress null"); + + Asserts.assertNE(reservedTopAddress, 0L, + "codeCacheReservedTopAddr null"); + } +} diff --git a/test/jdk/jfr/event/compiler/TestCodeCacheFull.java b/test/jdk/jfr/event/compiler/TestCodeCacheFull.java new file mode 100644 index 0000000000000000000000000000000000000000..9a689e18089479cab99a985d04872f3004aaac02 --- /dev/null +++ b/test/jdk/jfr/event/compiler/TestCodeCacheFull.java @@ -0,0 +1,106 @@ +/* + * 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 + * 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.event.compiler; + +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 sun.hotspot.WhiteBox; +import sun.hotspot.code.BlobType; + +/** + * @test TestCodeCacheFull + * + * + * @library /lib + * + * @build sun.hotspot.WhiteBox + * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission + * + * @run main/othervm -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:-UseLargePages jdk.jfr.event.compiler.TestCodeCacheFull + * @run main/othervm -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * jdk.jfr.event.compiler.TestCodeCacheFull + */ +public class TestCodeCacheFull { + + public static void main(String[] args) throws Exception { + for (BlobType btype : BlobType.getAvailable()) { + testWithBlobType(btype, calculateAvailableSize(btype)); + } + } + + private static void testWithBlobType(BlobType btype, long availableSize) throws Exception { + Recording r = new Recording(); + r.enable(EventNames.CodeCacheFull); + r.start(); + WhiteBox.getWhiteBox().allocateCodeBlob(availableSize, btype.id); + r.stop(); + + List events = Events.fromRecording(r); + Events.hasEvents(events); + RecordedEvent event = events.get(0); + + String codeBlobType = Events.assertField(event, "codeBlobType").notNull().getValue(); + BlobType blobType = blobTypeFromName(codeBlobType); + Asserts.assertTrue(blobType.allowTypeWhenOverflow(blobType), "Unexpected overflow BlobType " + blobType.id); + Events.assertField(event, "entryCount").atLeast(0); + Events.assertField(event, "methodCount").atLeast(0); + Events.assertEventThread(event); + Events.assertField(event, "fullCount").atLeast(0); + Events.assertField(event, "startAddress").notEqual(0L); + Events.assertField(event, "commitedTopAddress").notEqual(0L); + Events.assertField(event, "reservedTopAddress").notEqual(0L); + } + + private static BlobType blobTypeFromName(String codeBlobTypeName) throws Exception { + for (BlobType t : BlobType.getAvailable()) { + if (t.name.equals(codeBlobTypeName)) { + return t; + } + } + throw new Exception("Unexpected event " + codeBlobTypeName); + } + + // Compute the available size for this BlobType by taking into account + // that it may be stored in a different code heap in case it does not fit + // into the current one. + private static long calculateAvailableSize(BlobType btype) { + long availableSize = btype.getSize(); + for (BlobType alternative : BlobType.getAvailable()) { + if (btype.allowTypeWhenOverflow(alternative)) { + availableSize = Math.max(availableSize, alternative.getSize()); + } + } + return availableSize; + } +} diff --git a/test/jdk/jfr/event/compiler/TestCodeCacheStats.java b/test/jdk/jfr/event/compiler/TestCodeCacheStats.java new file mode 100644 index 0000000000000000000000000000000000000000..601eea670adb0138c20bf242b5b62ad1b2c3ce43 --- /dev/null +++ b/test/jdk/jfr/event/compiler/TestCodeCacheStats.java @@ -0,0 +1,65 @@ +/* + * 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 + * 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.event.compiler; + +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; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.compiler.TestCodeCacheStats + */ + +public class TestCodeCacheStats { + private final static String EVENT_NAME = EventNames.CodeCacheStatistics; + + public static void main(String[] args) throws Exception { + Recording recording = new Recording(); + recording.enable(EVENT_NAME); + recording.start(); + recording.stop(); + + List events = Events.fromRecording(recording); + Events.hasEvents(events); + for (RecordedEvent event : events) { + System.out.println("Event:" + event); + Events.assertField(event, "startAddress"); + Events.assertField(event, "reservedTopAddress"); + Events.assertField(event, "entryCount").atLeast(0); + Events.assertField(event, "methodCount").atLeast(0); + Events.assertField(event, "adaptorCount").atLeast(0); + Events.assertField(event, "unallocatedCapacity").atLeast(1024L); + Events.assertField(event, "fullCount").equal(0); + } + } +} diff --git a/test/jdk/jfr/event/compiler/TestCodeSweeper.java b/test/jdk/jfr/event/compiler/TestCodeSweeper.java new file mode 100644 index 0000000000000000000000000000000000000000..da7ed5972b86599b077aa68775982ea8c3717965 --- /dev/null +++ b/test/jdk/jfr/event/compiler/TestCodeSweeper.java @@ -0,0 +1,224 @@ +/* + * 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 + * 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.event.compiler; + +import java.lang.management.MemoryPoolMXBean; +import java.lang.reflect.Method; +import java.time.Instant; +import java.util.ArrayList; +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 sun.hotspot.WhiteBox; +import sun.hotspot.code.BlobType; +import sun.hotspot.code.CodeBlob; + +/** + * Test for events: vm/code_sweeper/sweep vm/code_cache/full vm/compiler/failure + * + * We verify: 1. That sweptCount >= flushedCount + zombifiedCount 2. That + * sweepIndex increases by 1. 3. We should get at least one of each of the + * events listed above. + * + * NOTE! The test is usually able to trigger the events but not always. If an + * event is received, the event is verified. If an event is missing, we do NOT + * fail. + */ +/** + * @test TestCodeSweeper + * @key jfr + * + * @library /lib / + * @build sun.hotspot.WhiteBox + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI jdk.jfr.event.compiler.TestCodeSweeper + */ + +public class TestCodeSweeper { + private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); + private static final int COMP_LEVEL_SIMPLE = 1; + private static final int COMP_LEVEL_FULL_OPTIMIZATION = 4; + private static final int SIZE = 1; + private static final String METHOD_NAME = "verifyFullEvent"; + private static final String pathSweep = EventNames.SweepCodeCache; + private static final String pathFull = EventNames.CodeCacheFull; + private static final String pathFailure = EventNames.CompilationFailure; + public static final long SEGMENT_SIZE = WhiteBox.getWhiteBox().getUintxVMFlag("CodeCacheSegmentSize"); + public static final long MIN_BLOCK_LENGTH = WhiteBox.getWhiteBox().getUintxVMFlag("CodeCacheMinBlockLength"); + public static final long MIN_ALLOCATION = SEGMENT_SIZE * MIN_BLOCK_LENGTH; + private static final double CACHE_USAGE_COEF = 0.95d; + + public static void main(String[] args) throws Throwable { + Asserts.assertTrue(BlobType.getAvailable().contains(BlobType.All), "Test does not support SegmentedCodeCache"); + + System.out.println("************************************************"); + System.out.println("This test will warn that the code cache is full."); + System.out.println("That is expected and is the purpose of the test."); + System.out.println("************************************************"); + + Recording r = new Recording(); + r.enable(pathSweep); + r.enable(pathFull); + r.enable(pathFailure); + r.start(); + provokeEvents(); + r.stop(); + + int countEventSweep = 0; + int countEventFull = 0; + int countEventFailure = 0; + + List events = Events.fromRecording(r); + Events.hasEvents(events); + for (RecordedEvent event : events) { + switch (event.getEventType().getName()) { + case pathSweep: + countEventSweep++; + verifySingleSweepEvent(event); + break; + case pathFull: + countEventFull++; + verifyFullEvent(event); + break; + case pathFailure: + countEventFailure++; + verifyFailureEvent(event); + break; + } + } + + System.out.println(String.format("eventCount: %d, %d, %d", countEventSweep, countEventFull, countEventFailure)); + } + + private static boolean canAllocate(double size, long maxSize, MemoryPoolMXBean bean) { + // Don't fill too much to have space for adapters. So, stop after crossing 95% and + // don't allocate in case we'll cross 97% on next allocation. + double used = bean.getUsage().getUsed(); + return (used <= CACHE_USAGE_COEF * maxSize) && + (used + size <= (CACHE_USAGE_COEF + 0.02d) * maxSize); + } + + private static void provokeEvents() throws NoSuchMethodException, InterruptedException { + // Prepare for later, since we don't want to trigger any compilation + // setting this up. + Method method = TestCodeSweeper.class.getDeclaredMethod(METHOD_NAME, new Class[] { RecordedEvent.class }); + String directive = "[{ match: \"" + TestCodeSweeper.class.getName().replace('.', '/') + + "." + METHOD_NAME + "\", " + "BackgroundCompilation: false }]"; + + // Fill up code heaps until they are almost full + // to trigger the vm/code_sweeper/sweep event. + ArrayList blobs = new ArrayList<>(); + MemoryPoolMXBean bean = BlobType.All.getMemoryPool(); + long max = bean.getUsage().getMax(); + long headerSize = getHeaderSize(BlobType.All); + long minAllocationUnit = Math.max(1, MIN_ALLOCATION - headerSize); + long stopAt = max - minAllocationUnit; + long addr = 0; + + // First allocate big blobs to speed things up + for (long size = 100_000 * minAllocationUnit; size > 0; size /= 10) { + while (canAllocate(size, max, bean) && + (addr = WHITE_BOX.allocateCodeBlob(size, BlobType.All.id)) != 0) { + blobs.add(addr); + } + } + + // Now allocate small blobs until the heap is almost full + while (bean.getUsage().getUsed() < stopAt && + (addr = WHITE_BOX.allocateCodeBlob(SIZE, BlobType.All.id)) != 0) { + blobs.add(addr); + } + + // Trigger the vm/code_cache/full event by compiling one more + // method. This also triggers the vm/compiler/failure event. + if (!WHITE_BOX.enqueueMethodForCompilation(method, COMP_LEVEL_FULL_OPTIMIZATION)) { + WHITE_BOX.enqueueMethodForCompilation(method, COMP_LEVEL_SIMPLE); + } + + Thread.sleep(5000); + + // Free memory + for (Long blob : blobs) { + WHITE_BOX.freeCodeBlob(blob); + } + } + + private static void verifyFullEvent(RecordedEvent event) throws Throwable { + Events.assertField(event, "codeBlobType").notEmpty(); + Events.assertField(event, "unallocatedCapacity").atLeast(0L); + Events.assertField(event, "entryCount").atLeast(0); + Events.assertField(event, "methodCount").atLeast(0); + Events.assertField(event, "adaptorCount").atLeast(0); + Events.assertField(event, "fullCount").atLeast(0); + + // Verify startAddress <= commitedTopAddress <= reservedTopAddress. + // Addresses may be so big that they overflow a long (treated as a + // negative value), convert value to an octal string and compare the + // string. + String startAddress = Long.toOctalString(Events.assertField(event, "startAddress").getValue()); + String commitedTopAddress = Long.toOctalString(Events.assertField(event, "commitedTopAddress").getValue()); + String reservedTopAddress = Long.toOctalString(Events.assertField(event, "reservedTopAddress").getValue()); + Asserts.assertTrue(isOctalLessOrEqual(startAddress, commitedTopAddress), "startAddress<=commitedTopAddress: " + startAddress + "<=" + commitedTopAddress); + Asserts.assertTrue(isOctalLessOrEqual(commitedTopAddress, reservedTopAddress), "commitedTopAddress<=reservedTopAddress: " + commitedTopAddress + "<=" + reservedTopAddress); + } + + private static void verifyFailureEvent(RecordedEvent event) throws Throwable { + Events.assertField(event, "failureMessage").notEmpty(); + Events.assertField(event, "compileId").atLeast(0); + } + + private static void verifySingleSweepEvent(RecordedEvent event) throws Throwable { + int flushedCount = Events.assertField(event, "flushedCount").atLeast(0).getValue(); + int zombifiedCount = Events.assertField(event, "zombifiedCount").atLeast(0).getValue(); + Events.assertField(event, "sweptCount").atLeast(flushedCount + zombifiedCount); + Events.assertField(event, "sweepId").atLeast(0); + Asserts.assertGreaterThanOrEqual(event.getStartTime(), Instant.EPOCH, "startTime was < 0"); + Asserts.assertGreaterThanOrEqual(event.getEndTime(), event.getStartTime(), "startTime was > endTime"); + } + + /** Returns true if less <= bigger. */ + private static boolean isOctalLessOrEqual(String less, String bigger) { + if (less.length() > bigger.length()) { + return false; + } + if (less.length() < bigger.length()) { + return true; + } + return less.compareTo(bigger) <= 0; + } + + public static final long getHeaderSize(BlobType btype) { + long addr = WHITE_BOX.allocateCodeBlob(0, btype.id); + int size = CodeBlob.getCodeBlob(addr).size; + WHITE_BOX.freeCodeBlob(addr); + return size; + } +} diff --git a/test/jdk/jfr/event/compiler/TestCodeSweeperConfig.java b/test/jdk/jfr/event/compiler/TestCodeSweeperConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..7e0e17bdda8b97da38aa68951afbcf054b1f571e --- /dev/null +++ b/test/jdk/jfr/event/compiler/TestCodeSweeperConfig.java @@ -0,0 +1,61 @@ +/* + * 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 + * 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.event.compiler; + +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; + + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm -XX:+UseCodeCacheFlushing jdk.jfr.event.compiler.TestCodeSweeperConfig + */ +public class TestCodeSweeperConfig { + + private final static String EVENT_NAME = EventNames.CodeSweeperConfiguration; + + public static void main(String[] args) throws Exception { + Recording recording = new Recording(); + recording.enable(EVENT_NAME); + recording.start(); + recording.stop(); + + List events = Events.fromRecording(recording); + Events.hasEvents(events); + for (RecordedEvent event : events) { + System.out.println("Event: " + event); + Events.assertField(event, "sweeperEnabled").equal(true); + Events.assertField(event, "flushingEnabled").equal(true); + } + } +} diff --git a/test/jdk/jfr/event/compiler/TestCompilerCompile.java b/test/jdk/jfr/event/compiler/TestCompilerCompile.java new file mode 100644 index 0000000000000000000000000000000000000000..c1aabc9eb628eb6fc3659b4de40f96df6e805eed --- /dev/null +++ b/test/jdk/jfr/event/compiler/TestCompilerCompile.java @@ -0,0 +1,141 @@ +/* + * 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 + * 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.event.compiler; + +import static jdk.test.lib.Asserts.assertFalse; + +import java.lang.reflect.Method; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Utils; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; +import sun.hotspot.WhiteBox; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @build sun.hotspot.WhiteBox + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * @run main/othervm -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * jdk.jfr.event.compiler.TestCompilerCompile + */ +public class TestCompilerCompile { + private final static String EVENT_NAME = EventNames.Compilation; + private final static String METHOD_NAME = "dummyMethod"; + private boolean foundKnownMethod = false; + private boolean foundOsrMethod = false; + + public static void main(String[] args) throws Throwable { + TestCompilerCompile test = new TestCompilerCompile(); + test.doTest(); + } + + static void dummyMethod() { + System.out.println("hello!"); + } + + public void doTest() throws Throwable { + Recording recording = new Recording(); + recording.enable(EVENT_NAME); + + recording.start(); + long start = System.currentTimeMillis(); + // provoke OSR compilation + for (int i = 0; i < Integer.MAX_VALUE; i++) { + } + // compile dummyMethod() + Method mtd = TestCompilerCompile.class.getDeclaredMethod(METHOD_NAME, new Class[0]); + WhiteBox WB = WhiteBox.getWhiteBox(); + if (!WB.enqueueMethodForCompilation(mtd, 4 /* CompLevel_full_optimization */)) { + WB.enqueueMethodForCompilation(mtd, 1 /* CompLevel_simple */); + } + Utils.waitForCondition(() -> WB.isMethodCompiled(mtd)); + dummyMethod(); + + System.out.println("time:" + (System.currentTimeMillis() - start)); + recording.stop(); + + Set compileIds = new HashSet(); + List events = Events.fromRecording(recording); + Events.hasEvents(events); + for (RecordedEvent event : events) { + System.out.println("Event:" + event); + verifyEvent(event); + Integer compileId = Events.assertField(event, "compileId").getValue(); + assertFalse(compileIds.contains(compileId), "compile id not unique: " + compileId); + compileIds.add(compileId); + } + + // Verify that we actually encountered our expected method + if (!foundKnownMethod) { + throw new Exception("Couldn't find method jdk/jfr/event/compiler/TestCompilerCompile.dummyMethod()V among compilation events"); + } + + // Verify that doTest() function has been replaced on stack. + if (!foundOsrMethod) { + throw new Exception("No On Stack Replacement of function doTest()"); + } + } + + private void verifyEvent(RecordedEvent event) throws Throwable { + Events.assertJavaMethod(event); + Events.assertEventThread(event); + + String methodName = Events.assertField(event, "method.name").notEmpty().getValue(); + String methodDescriptor = Events.assertField(event, "method.descriptor").notEmpty().getValue(); + String methodType = Events.assertField(event, "method.type.name").notEmpty().getValue(); + + // Compare with a known candidate + if ("jdk/jfr/event/compiler/TestCompilerCompile".equals(methodType) && "dummyMethod".equals(methodName) && "()V".equals(methodDescriptor)) { + foundKnownMethod = true; + } + + // The doTest() function is live almost the entire time the test runs. + // We should get at least 1 "on stack replacement" for that method. + if (TestCompilerCompile.class.getName().replace('.', '/').equals(methodType) && "doTest".equals(methodName)) { + boolean isOsr = Events.assertField(event, "isOsr").getValue(); + if (isOsr) { + foundOsrMethod = true; + } + } + + Events.assertField(event, "compileId").atLeast(0); + Events.assertField(event, "compileLevel").atLeast((short) 0).atMost((short) 4); + Events.assertField(event, "inlinedBytes").atLeast(0L); + Events.assertField(event, "codeSize").atLeast(0L); + Events.assertField(event, "isOsr"); + } +} diff --git a/test/jdk/jfr/event/compiler/TestCompilerConfig.java b/test/jdk/jfr/event/compiler/TestCompilerConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..d52503c47f3feb38a353426fa070fc27fba33150 --- /dev/null +++ b/test/jdk/jfr/event/compiler/TestCompilerConfig.java @@ -0,0 +1,59 @@ +/* + * 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 + * 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.event.compiler; + +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; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.compiler.TestCompilerConfig + */ +public class TestCompilerConfig { + private final static String EVENT_NAME = EventNames.CompilerConfiguration; + + public static void main(String[] args) throws Exception { + Recording recording = new Recording(); + recording.enable(EVENT_NAME); + recording.start(); + recording.stop(); + + List events = Events.fromRecording(recording); + Events.hasEvents(events); + for (RecordedEvent event : events) { + System.out.println("Event:" + event); + Events.assertField(event, "threadCount").atLeast(0); + Events.assertField(event, "tieredCompilation"); + } + } +} diff --git a/test/jdk/jfr/event/compiler/TestCompilerInlining.java b/test/jdk/jfr/event/compiler/TestCompilerInlining.java new file mode 100644 index 0000000000000000000000000000000000000000..9868f33927474bfdc20c194efe584d7b3aacf717 --- /dev/null +++ b/test/jdk/jfr/event/compiler/TestCompilerInlining.java @@ -0,0 +1,406 @@ +/* + * 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. 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.event.compiler; + +import jdk.internal.org.objectweb.asm.*; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedMethod; +import jdk.jfr.consumer.RecordedObject; +import jdk.test.lib.Asserts; +import jdk.test.lib.Platform; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; +import sun.hotspot.WhiteBox; + +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.Executable; +import java.lang.reflect.Method; +import java.util.*; +import java.util.stream.IntStream; + +/** + * @test CompilerInliningTest + * @bug 8073607 + * @key jfr + * @summary Verifies that corresponding JFR events are emitted in case of inlining. + * + * + * + * @library /lib / + * + + * + * @build sun.hotspot.WhiteBox + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * @run main/othervm -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -Xbatch jdk.jfr.event.compiler.TestCompilerInlining + */ +public class TestCompilerInlining { + private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); + private static final int LEVEL_SIMPLE = 1; + private static final int LEVEL_FULL_OPTIMIZATION = 4; + private static final Executable ENTRY_POINT = getConstructor(TestCase.class); + private static final String TEST_CASE_CLASS_NAME = TestCase.class.getName().replace('.', '/'); + + public static void main(String[] args) throws Exception { + InlineCalls inlineCalls = new InlineCalls(TestCase.class); + inlineCalls.disableInline(getConstructor(Object.class)); + inlineCalls.disableInline(getMethod(TestCase.class, "qux", boolean.class)); + inlineCalls.forceInline(getMethod(TestCase.class, "foo")); + inlineCalls.forceInline(getMethod(TestCase.class, "foo", int.class)); + inlineCalls.forceInline(getMethod(TestCase.class, "bar")); + inlineCalls.forceInline(getMethod(TestCase.class, "baz")); + + Map result = inlineCalls.getExpected(ENTRY_POINT); + for (int level : determineAvailableLevels()) { + testLevel(result, level); + } + } + + private static void testLevel(Map expectedResult, int level) throws IOException { + System.out.println("****** Testing level " + level + " *******"); + Recording r = new Recording(); + r.enable(EventNames.CompilerInlining); + r.start(); + WHITE_BOX.enqueueMethodForCompilation(ENTRY_POINT, level); + WHITE_BOX.deoptimizeMethod(ENTRY_POINT); + r.stop(); + System.out.println("Expected:"); + + List events = Events.fromRecording(r); + Set foundEvents = new HashSet<>(); + int foundRelevantEvent = 0; + for (RecordedEvent event : events) { + RecordedMethod callerObject = event.getValue("caller"); + RecordedObject calleeObject = event.getValue("callee"); + MethodDesc caller = methodToMethodDesc(callerObject); + MethodDesc callee = ciMethodToMethodDesc(calleeObject); + // only TestCase.* -> TestCase.* OR TestCase.* -> Object. are tested/filtered + if (caller.className.equals(TEST_CASE_CLASS_NAME) && (callee.className.equals(TEST_CASE_CLASS_NAME) + || (callee.className.equals("java/lang/Object") && callee.methodName.equals("")))) { + System.out.println(event); + boolean succeeded = (boolean) event.getValue("succeeded"); + int bci = Events.assertField(event, "bci").atLeast(0).getValue(); + Call call = new Call(caller, callee, bci); + foundRelevantEvent++; + Boolean expected = expectedResult.get(call); + Asserts.assertNotNull(expected, "Unexpected inlined call : " + call); + Asserts.assertEquals(expected, succeeded, "Incorrect result for " + call); + Asserts.assertTrue(foundEvents.add(call), "repeated event for " + call); + } + } + Asserts.assertEquals(foundRelevantEvent, expectedResult.size(), String.format("not all events found at lavel %d. " + "found = '%s'. expected = '%s'", level, events, expectedResult.keySet())); + System.out.println(); + System.out.println(); + } + + private static int[] determineAvailableLevels() { + if (WHITE_BOX.getBooleanVMFlag("TieredCompilation")) { + return IntStream.rangeClosed(LEVEL_SIMPLE, WHITE_BOX.getIntxVMFlag("TieredStopAtLevel").intValue()).toArray(); + } + if (Platform.isServer() && !Platform.isEmulatedClient()) { + return new int[] { LEVEL_FULL_OPTIMIZATION }; + } + if (Platform.isClient() || Platform.isEmulatedClient()) { + return new int[] { LEVEL_SIMPLE }; + } + throw new Error("TESTBUG: unknown VM"); + } + + private static MethodDesc methodToMethodDesc(RecordedMethod method) { + String internalClassName = method.getType().getName().replace('.', '/'); + String methodName = method.getValue("name"); + String methodDescriptor = method.getValue("descriptor"); + return new MethodDesc(internalClassName, methodName, methodDescriptor); + } + + private static MethodDesc ciMethodToMethodDesc(RecordedObject ciMethod) { + String internalClassName = ciMethod.getValue("type"); + String methodName = ciMethod.getValue("name"); + String methodDescriptor = ciMethod.getValue("descriptor"); + return new MethodDesc(internalClassName, methodName, methodDescriptor); + } + + private static Method getMethod(Class aClass, String name, Class... params) { + try { + return aClass.getDeclaredMethod(name, params); + } catch (NoSuchMethodException | SecurityException e) { + throw new Error("TESTBUG : cannot get method " + name + Arrays.toString(params), e); + } + } + + private static Constructor getConstructor(Class aClass, Class... params) { + try { + return aClass.getDeclaredConstructor(params); + } catch (NoSuchMethodException | SecurityException e) { + throw new Error("TESTBUG : cannot get constructor" + Arrays.toString(params), e); + } + } +} + +class TestCase { + public TestCase() { + foo(); + } + + public void foo() { + qux(true); + bar(); + foo(2); + } + + private void foo(int i) { + } + + private void bar() { + baz(); + qux(false); + qux(true); + } + + protected static double baz() { + qux(false); + return .0; + } + + private static int qux(boolean b) { + qux(b); + return 0; + } +} + +/** + * data structure for method call + */ +class Call { + public final MethodDesc caller; + public final MethodDesc callee; + public final int bci; + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || !(o instanceof Call)) + return false; + + Call call = (Call) o; + + if (bci != call.bci) + return false; + if (!callee.equals(call.callee)) + return false; + if (!caller.equals(call.caller)) + return false; + + return true; + } + + @Override + public int hashCode() { + int result = caller.hashCode(); + result = 31 * result + callee.hashCode(); + result = 47 * result + bci; + return result; + } + + public Call(MethodDesc caller, MethodDesc callee, int bci) { + Objects.requireNonNull(caller); + Objects.requireNonNull(callee); + this.caller = caller; + this.callee = callee; + this.bci = bci; + } + + @Override + public String toString() { + return String.format("Call{caller='%s', callee='%s', bci=%d}", caller, callee, bci); + } +} + +/** + * data structure for method description + */ +class MethodDesc { + public final String className; + public final String methodName; + public final String descriptor; + + public MethodDesc(Class aClass, String methodName, String descriptor) { + this(aClass.getName().replace('.', '/'), methodName, descriptor); + } + + public MethodDesc(String className, String methodName, String descriptor) { + Objects.requireNonNull(className); + Objects.requireNonNull(methodName); + Objects.requireNonNull(descriptor); + this.className = className.replace('.', '/'); + this.methodName = methodName; + this.descriptor = descriptor; + } + + public MethodDesc(Executable executable) { + Class aClass = executable.getDeclaringClass(); + className = Type.getInternalName(aClass).replace('.', '/'); + + if (executable instanceof Constructor) { + methodName = ""; + descriptor = Type.getConstructorDescriptor((Constructor) executable); + } else { + methodName = executable.getName(); + descriptor = Type.getMethodDescriptor((Method) executable); + } + + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + MethodDesc that = (MethodDesc) o; + + if (!className.equals(that.className)) + return false; + if (!methodName.equals(that.methodName)) + return false; + if (!descriptor.equals(that.descriptor)) + return false; + + return true; + } + + @Override + public int hashCode() { + int result = className.hashCode(); + result = 31 * result + methodName.hashCode(); + result = 47 * result + descriptor.hashCode(); + return result; + } + + @Override + public String toString() { + return String.format("MethodDesc{className='%s', methodName='%s', descriptor='%s'}", className, methodName, descriptor); + } +} + +/** + * Aux class to get all calls in an arbitrary class. + */ +class InlineCalls { + private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); + + private final Collection calls; + private final Map inline; + + public InlineCalls(Class aClass) { + calls = getCalls(aClass); + inline = new HashMap<>(); + } + + /** + * @return expected inline events + */ + public Map getExpected(Executable entry) { + Map result = new HashMap<>(); + Queue methods = new ArrayDeque<>(); + Set finished = new HashSet<>(); + methods.add(new MethodDesc(entry)); + while (!methods.isEmpty()) { + MethodDesc method = methods.poll(); + if (finished.add(method)) { + inline.entrySet().stream().filter(k -> k.getKey().caller.equals(method)).forEach(k -> { + result.put(k.getKey(), k.getValue()); + if (k.getValue()) { + methods.add(k.getKey().callee); + } + }); + } + } + + return result; + } + + public void disableInline(Executable executable) { + WHITE_BOX.testSetDontInlineMethod(executable, true); + MethodDesc md = new MethodDesc(executable); + calls.stream().filter(c -> c.callee.equals(md)).forEach(c -> inline.put(c, false)); + } + + public void forceInline(Executable executable) { + WHITE_BOX.testSetForceInlineMethod(executable, true); + MethodDesc md = new MethodDesc(executable); + calls.stream().filter(c -> c.callee.equals(md)).forEach(c -> inline.putIfAbsent(c, true)); + } + + private static Collection getCalls(Class aClass) { + List calls = new ArrayList<>(); + ClassWriter cw; + ClassReader cr; + try { + cr = new ClassReader(aClass.getName()); + } catch (IOException e) { + throw new Error("TESTBUG : unexpected IOE during class reading", e); + } + cw = new ClassWriter(cr, 0); + ClassVisitor cv = new ClassVisitor(Opcodes.ASM5, cw) { + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String descriptor, String[] exceptions) { + System.out.println("Method: " +name); + MethodVisitor mv = super.visitMethod(access, name, desc, descriptor, exceptions); + return new CallTracer(aClass, name, desc, mv, calls); + } + }; + cr.accept(cv, 0); + + return calls; + } + + private static class CallTracer extends MethodVisitor { + private final MethodDesc caller; + private Collection calls; + + public CallTracer(Class aClass, String name, String desc, MethodVisitor mv, Collection calls) { + super(Opcodes.ASM5, mv); + caller = new MethodDesc(aClass.getName(), name, desc); + this.calls = calls; + } + + @Override + public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { + Label label = new Label(); + visitLabel(label); + super.visitMethodInsn(opcode, owner, name, desc, itf); + calls.add(new Call(caller, new MethodDesc(owner, name, desc), label.getOffset())); + } + } +} diff --git a/test/jdk/jfr/event/compiler/TestCompilerPhase.java b/test/jdk/jfr/event/compiler/TestCompilerPhase.java new file mode 100644 index 0000000000000000000000000000000000000000..256a833793b97af575bb7e1240a7ebf087c8c26f --- /dev/null +++ b/test/jdk/jfr/event/compiler/TestCompilerPhase.java @@ -0,0 +1,89 @@ +/* + * 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 + * 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.event.compiler; + +import java.lang.reflect.Method; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Utils; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; +import sun.hotspot.WhiteBox; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @build sun.hotspot.WhiteBox + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * @run main/othervm -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:CompileOnly=jdk.jfr.event.compiler.TestCompilerPhase::dummyMethod + * -Xbootclasspath/a:. + * jdk.jfr.event.compiler.TestCompilerPhase + */ +public class TestCompilerPhase { + private final static String EVENT_NAME = EventNames.CompilerPhase; + private final static String METHOD_NAME = "dummyMethod"; + private static final int COMP_LEVEL_SIMPLE = 1; + private static final int COMP_LEVEL_FULL_OPTIMIZATION = 4; + + public static void main(String[] args) throws Exception { + Recording recording = new Recording(); + recording.enable(EVENT_NAME); + recording.start(); + + // Provoke compilation + Method mtd = TestCompilerPhase.class.getDeclaredMethod(METHOD_NAME, new Class[0]); + WhiteBox WB = WhiteBox.getWhiteBox(); + if (!WB.enqueueMethodForCompilation(mtd, COMP_LEVEL_FULL_OPTIMIZATION)) { + WB.enqueueMethodForCompilation(mtd, COMP_LEVEL_SIMPLE); + } + Utils.waitForCondition(() -> WB.isMethodCompiled(mtd)); + dummyMethod(); + + recording.stop(); + + List events = Events.fromRecording(recording); + Events.hasEvents(events); + for (RecordedEvent event : events) { + System.out.println("Event:" + event); + Events.assertField(event, "phase").notEmpty(); + Events.assertField(event, "compileId").atLeast(0); + Events.assertField(event, "phaseLevel").atLeast((short)0).atMost((short)4); + Events.assertEventThread(event); + } + } + + static void dummyMethod() { + System.out.println("hello!"); + } +} diff --git a/test/jdk/jfr/event/compiler/TestCompilerStats.java b/test/jdk/jfr/event/compiler/TestCompilerStats.java new file mode 100644 index 0000000000000000000000000000000000000000..fc2a47304c9a264414d6d648fd85039f5d3d3c39 --- /dev/null +++ b/test/jdk/jfr/event/compiler/TestCompilerStats.java @@ -0,0 +1,68 @@ +/* + * 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 + * 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.event.compiler; + +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; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.compiler.TestCompilerStats + */ +public class TestCompilerStats { + private final static String EVENT_NAME = EventNames.CompilerStatistics; + + public static void main(String[] args) throws Exception { + Recording recording = new Recording(); + recording.enable(EVENT_NAME); + recording.start(); + recording.stop(); + + List events = Events.fromRecording(recording); + Events.hasEvents(events); + for (RecordedEvent event : events) { + System.out.println("Event:" + event); + Events.assertField(event, "compileCount").atLeast(0); + Events.assertField(event, "bailoutCount").atLeast(0); + Events.assertField(event, "invalidatedCount").atLeast(0); + Events.assertField(event, "osrCompileCount").atLeast(0); + Events.assertField(event, "standardCompileCount").atLeast(0); + Events.assertField(event, "osrBytesCompiled").atLeast(0L); + Events.assertField(event, "standardBytesCompiled").atLeast(0L); + Events.assertField(event, "nmetodsSize").atLeast(0L); + Events.assertField(event, "nmetodCodeSize").atLeast(0L); + Events.assertField(event, "peakTimeSpent").atLeast(0L); + Events.assertField(event, "totalTimeSpent").atLeast(0L); + } + } +} diff --git a/test/jdk/jfr/event/gc/collection/AppGCProvoker.java b/test/jdk/jfr/event/gc/collection/AppGCProvoker.java new file mode 100644 index 0000000000000000000000000000000000000000..dc7e653dc192f9058cfac4f6fbe3f962518a732b --- /dev/null +++ b/test/jdk/jfr/event/gc/collection/AppGCProvoker.java @@ -0,0 +1,57 @@ +/* + * 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. 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.event.gc.collection; + +import java.util.ArrayList; +import java.util.List; + +/** + * Simple application to provoke various kinds of GC. + */ +public class AppGCProvoker { + + private static List garbage = new ArrayList<>(); + public static Object trash; + + public static void main(String args[]) { + // young gc + for (int i = 0; i < 100; i++) { + trash = new byte[100_000]; + } + + // system gc + System.gc(); + + // full gc caused by OOM + try { + while(true) { + garbage.add(new byte[150_000]); + } + } catch (OutOfMemoryError e) { + garbage = null; + } + } +} diff --git a/test/jdk/jfr/event/gc/collection/GCEventAll.java b/test/jdk/jfr/event/gc/collection/GCEventAll.java new file mode 100644 index 0000000000000000000000000000000000000000..661dae028d9ab01e7a8e61df79bc1a37d88029f6 --- /dev/null +++ b/test/jdk/jfr/event/gc/collection/GCEventAll.java @@ -0,0 +1,531 @@ +/* + * 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 + * 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.event.gc.collection; + +import java.lang.management.ManagementFactory; +import java.time.Duration; +import java.time.Instant; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; +import java.util.stream.Collectors; + +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.EventNames; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.GCHelper; + +/** + * Tests for event garbage_collection. + * The test function is called from TestGCEvent*.java, with different worker threads. + * Groups all events belonging to the same garbage collection (the same gcId). + * The group of events belonging to the same GC is called a batch. + * + * This class contains the verifications done and the worker threads used to generate GCs. + * The helper logic are in class GCHelper. + * + * Summary of verifications: + * All gcIds in garbage_collection event are unique. + * + * All events in batch has the same gcId. + * + * Number of garbage_collection events == GarbageCollectionMXBean.getCollectionCount() + * + * garbage_collection.sum_pause_time approximately equals GarbageCollectionMXBean.getCollectionTime() + * + * Batch contains expected events depending on garbage_collection.name + * + * garbage_collection_start.timestamp == garbage_collection.startTime. + * + * garbage_collection.timestamp >= timestamp for all other events in batch. + * + * The start_garbage_collection and garbage_collection events must be synchronized. + * This means that there may be multiple start_garbage_collection before a garbage_collection, + * but garbage_collection.gcId must be equal to latest start_garbage_collection.gcId. + * + * start_garbage_collection must be the first event in the batch, + * that means no event with same gcId before garbage_collection_start event. + * + * garbage_collection.name matches what is expected by the collectors specified in initial_configuration. + * + * Duration for event "vm/gc/phases/pause" >= 1. Duration for phase level events >= 0. + * + * + */ +public class GCEventAll { + private String youngCollector = null; + private String oldCollector = null; + + /** + * Trigger GC events by generating garbage and calling System.gc() concurrently. + */ + public static void doTest() throws Throwable { + // Trigger GC events by generating garbage and calling System.gc() concurrently. + Thread[] workerThreads = new Thread[] { + new Thread(GCEventAll.GarbageRunner.create(10)), + new Thread(GCEventAll.SystemGcWaitRunner.create(10, 2, 1000))}; + GCEventAll test = new GCEventAll(); + test.doSingleTest(workerThreads); + } + + /** + * Runs the test once with given worker threads. + * @param workerThreads Threads that generates GCs. + * @param gcIds Set of all used gcIds + * @throws Exception + */ + private void doSingleTest(Thread[] workerThreads) throws Throwable { + Recording recording = new Recording(); + enableAllGcEvents(recording); + + // Start with a full GC to minimize risk of getting extra GC between + // getBeanCollectionCount() and recording.start(). + doSystemGc(); + GCHelper.CollectionSummary startBeanCount = GCHelper.CollectionSummary.createFromMxBeans(); + recording.start(); + + for (Thread t : workerThreads) { + t.start(); + } + for (Thread t : workerThreads) { + t.join(); + } + + // End with a full GC to minimize risk of getting extra GC between + // recording.stop and getBeanCollectionCount(). + doSystemGc(); + // Add an extra System.gc() to make sure we get at least one full garbage_collection batch at + // the end of the test. This extra System.gc() is only necessary when using "UseConcMarkSweepGC" and "+ExplicitGCInvokesConcurrent". + doSystemGc(); + + recording.stop(); + GCHelper.CollectionSummary deltaBeanCount = GCHelper.CollectionSummary.createFromMxBeans(); + deltaBeanCount = deltaBeanCount.calcDelta(startBeanCount); + + List events = Events.fromRecording(recording).stream() + .filter(evt -> EventNames.isGcEvent(evt.getEventType())) + .collect(Collectors.toList()); + RecordedEvent configEvent = GCHelper.getConfigEvent(events); + youngCollector = Events.assertField(configEvent, "youngCollector").notEmpty().getValue(); + oldCollector = Events.assertField(configEvent, "oldCollector").notEmpty().getValue(); + verify(events, deltaBeanCount); + } + + private void enableAllGcEvents(Recording recording) { + FlightRecorder flightrecorder = FlightRecorder.getFlightRecorder(); + for (EventType et : flightrecorder.getEventTypes()) { + if (EventNames.isGcEvent(et)) { + recording.enable(et.getName()); + System.out.println("Enabled GC event: " + et.getName()); + } + } + System.out.println("All GC events enabled"); + } + + private static synchronized void doSystemGc() { + System.gc(); + } + + /** + * Does all verifications of the received events. + * + * @param events All flight recorder events. + * @param beanCounts Number of collections and sum pause time reported by GarbageCollectionMXBeans. + * @param gcIds All used gcIds. Must be unique. + * @throws Exception + */ + private void verify(List events, GCHelper.CollectionSummary beanCounts) throws Throwable { + List gcBatches = null; + GCHelper.CollectionSummary eventCounts = null; + + // For some GC configurations, the JFR recording may have stopped before we received the last gc event. + try { + events = filterIncompleteGcBatch(events); + gcBatches = GCHelper.GcBatch.createFromEvents(events); + eventCounts = GCHelper.CollectionSummary.createFromEvents(gcBatches); + + verifyUniqueIds(gcBatches); + verifyCollectorNames(gcBatches); + verifyCollectionCause(gcBatches); + verifyCollectionCount(eventCounts, beanCounts); + verifyPhaseEvents(gcBatches); + verifySingleGcBatch(gcBatches); + } catch (Throwable t) { + log(events, gcBatches, eventCounts, beanCounts); + if (gcBatches != null) { + for (GCHelper.GcBatch batch : gcBatches) { + System.out.println(String.format("Batch:%n%s", batch.getLog())); + } + } + throw t; + } + } + + /** + * When using collector ConcurrentMarkSweep with -XX:+ExplicitGCInvokesConcurrent, the JFR recording may + * stop before we have received the last garbage_collection event. + * + * This function does 3 things: + * 1. Check if the last batch is incomplete. + * 2. If it is incomplete, then asserts that incomplete batches are allowed for this configuration. + * 3. If incomplete batches are allowed, then the incomplete batch is removed. + * + * @param events All events + * @return All events with any incomplete batch removed. + * @throws Throwable + */ + private List filterIncompleteGcBatch(List events) throws Throwable { + List returnEvents = new ArrayList(events); + int lastGcId = getLastGcId(events); + List lastBatchEvents = getEventsWithGcId(events, lastGcId); + String[] endEvents = {GCHelper.event_garbage_collection, GCHelper.event_old_garbage_collection, GCHelper.event_young_garbage_collection}; + boolean isComplete = containsAnyPath(lastBatchEvents, endEvents); + if (!isComplete) { + // The last GC batch does not contain an end event. The batch is incomplete. + // This is only allowed if we are using old_collector="ConcurrentMarkSweep" and "-XX:+ExplicitGCInvokesConcurrent" + boolean isExplicitGCInvokesConcurrent = hasInputArgument("-XX:+ExplicitGCInvokesConcurrent"); + boolean isConcurrentMarkSweep = GCHelper.gcConcurrentMarkSweep.equals(oldCollector); + String msg = String.format( + "Incomplete batch only allowed for '%s' with -XX:+ExplicitGCInvokesConcurrent", + GCHelper.gcConcurrentMarkSweep); + Asserts.assertTrue(isConcurrentMarkSweep && isExplicitGCInvokesConcurrent, msg); + + // Incomplete batch is allowed with the current settings. Remove incomplete batch. + returnEvents.removeAll(lastBatchEvents); + } + return returnEvents; + } + + private boolean hasInputArgument(String arg) { + return ManagementFactory.getRuntimeMXBean().getInputArguments().contains(arg); + } + + private List getEventsWithGcId(List events, int gcId) { + List batchEvents = new ArrayList<>(); + for (RecordedEvent event : events) { + if (GCHelper.isGcEvent(event) && GCHelper.getGcId(event) == gcId) { + batchEvents.add(event); + } + } + return batchEvents; + } + + private boolean containsAnyPath(List events, String[] paths) { + List pathList = Arrays.asList(paths); + for (RecordedEvent event : events) { + if (pathList.contains(event.getEventType().getName())) { + return true; + } + } + return false; + } + + private int getLastGcId(List events) { + int lastGcId = -1; + for (RecordedEvent event : events) { + if (GCHelper.isGcEvent(event)) { + int gcId = GCHelper.getGcId(event); + if (gcId > lastGcId) { + lastGcId = gcId; + } + } + } + Asserts.assertTrue(lastGcId != -1, "No gcId found"); + return lastGcId; + } + + /** + * Verifies collection count reported by flight recorder events against the values + * reported by GarbageCollectionMXBean. + * Number of collections should match exactly. + * Sum pause time are allowed some margin of error because of rounding errors in measurements. + */ + private void verifyCollectionCount(GCHelper.CollectionSummary eventCounts, GCHelper.CollectionSummary beanCounts) { + verifyCollectionCount(youngCollector, eventCounts.collectionCountYoung, beanCounts.collectionCountYoung); + verifyCollectionCount(oldCollector, eventCounts.collectionCountOld, beanCounts.collectionCountOld); + } + + private void verifyCollectionCount(String collector, long eventCounts, long beanCounts) { + if (GCHelper.gcConcurrentMarkSweep.equals(collector) || GCHelper.gcG1Old.equals(oldCollector)) { + // ConcurrentMarkSweep mixes old and new collections. Not same values as in MXBean. + // MXBean does not report old collections for G1Old, so we have nothing to compare with. + return; + } + // JFR events and GarbageCollectorMXBean events are not updated at the same time. + // This means that number of collections may diff. + // We allow a diff of +- 1 collection count. + long minCount = Math.max(0, beanCounts - 1); + long maxCount = beanCounts + 1; + Asserts.assertGreaterThanOrEqual(eventCounts, minCount, "Too few event counts for collector " + collector); + Asserts.assertLessThanOrEqual(eventCounts, maxCount, "Too many event counts for collector " + collector); + } + + /** + * Verifies that all events belonging to a single GC are ok. + * A GcBatch contains all flight recorder events that belong to a single GC. + */ + private void verifySingleGcBatch(List batches) { + for (GCHelper.GcBatch batch : batches) { + //System.out.println("batch:\r\n" + batch.getLog()); + try { + RecordedEvent endEvent = batch.getEndEvent(); + Asserts.assertNotNull(endEvent, "No end event in batch."); + Asserts.assertNotNull(batch.getName(), "No method name in end event."); + long longestPause = Events.assertField(endEvent, "longestPause").atLeast(0L).getValue(); + Events.assertField(endEvent, "sumOfPauses").atLeast(longestPause).getValue(); + Instant batchStartTime = endEvent.getStartTime(); + Instant batchEndTime = endEvent.getEndTime(); + for (RecordedEvent event : batch.getEvents()) { + if (event.getEventType().getName().contains("AllocationRequiringGC")) { + // Unlike other events, these are sent *before* a GC. + Asserts.assertLessThanOrEqual(event.getStartTime(), batchStartTime, "Timestamp in event after start event, should be sent before GC start"); + } else if (!event.getEventType().getName().contains("G1MMU")){ + // G1MMU event on JDK8 G1 can be out-of-order; don't check it here + Asserts.assertGreaterThanOrEqual(event.getStartTime(), batchStartTime, "startTime in event before batch start event, should be sent after GC start [" + event.getEventType().getName() + "]"); + } + Asserts.assertLessThanOrEqual(event.getEndTime(), batchEndTime, "endTime in event after batch end event, should be sent before GC end"); + } + + // Verify that all required events has been received. + String[] requiredEvents = GCHelper.requiredEvents.get(batch.getName()); + Asserts.assertNotNull(requiredEvents, "No required events specified for " + batch.getName()); + for (String requiredEvent : requiredEvents) { + boolean b = batch.containsEvent(requiredEvent); + Asserts.assertTrue(b, String.format("%s does not contain event %s", batch, requiredEvent)); + } + + // Verify that we have exactly one heap_summary "Before GC" and one "After GC". + int countBeforeGc = 0; + int countAfterGc = 0; + for (RecordedEvent event : batch.getEvents()) { + if (GCHelper.event_heap_summary.equals(event.getEventType().getName())) { + String when = Events.assertField(event, "when").notEmpty().getValue(); + if ("Before GC".equals(when)) { + countBeforeGc++; + } else if ("After GC".equals(when)) { + countAfterGc++; + } else { + Asserts.fail("Unknown value for heap_summary.when: '" + when + "'"); + } + } + } + if (!GCHelper.gcConcurrentMarkSweep.equals(batch.getName())) { + // We do not get heap_summary events for ConcurrentMarkSweep + Asserts.assertEquals(1, countBeforeGc, "Unexpected number of heap_summary.before_gc"); + Asserts.assertEquals(1, countAfterGc, "Unexpected number of heap_summary.after_gc"); + } + } catch (Throwable e) { + GCHelper.log("verifySingleGcBatch failed for gcEvent:"); + GCHelper.log(batch.getLog()); + throw e; + } + } + } + + private Set verifyUniqueIds(List batches) { + Set gcIds = new HashSet<>(); + for (GCHelper.GcBatch batch : batches) { + Integer gcId = new Integer(batch.getGcId()); + Asserts.assertFalse(gcIds.contains(gcId), "Duplicate gcId: " + gcId); + gcIds.add(gcId); + } + return gcIds; + } + + private void verifyPhaseEvents(List batches) { + for (GCHelper.GcBatch batch : batches) { + for(RecordedEvent event : batch.getEvents()) { + if (event.getEventType().getName().contains(GCHelper.pauseLevelEvent)) { + Instant batchStartTime = batch.getEndEvent().getStartTime(); + Asserts.assertGreaterThanOrEqual( + event.getStartTime(), batchStartTime, "Phase startTime >= batch startTime. Event:" + event); + + // Duration for event "vm/gc/phases/pause" must be >= 1. Other phase event durations must be >= 0. + Duration minDuration = Duration.ofNanos(GCHelper.event_phases_pause.equals(event.getEventType().getName()) ? 1 : 0); + Duration duration = event.getDuration(); + Asserts.assertGreaterThanOrEqual(duration, minDuration, "Wrong duration. Event:" + event); + } + } + } + } + + /** + * Verifies that the collector name in initial configuration matches the name in garbage configuration event. + * If the names are not equal, then we check if this is an expected collector override. + * For example, if old collector in initial config is "G1Old" we allow both event "G1Old" and "SerialOld". + */ + private void verifyCollectorNames(List batches) { + for (GCHelper.GcBatch batch : batches) { + String name = batch.getName(); + Asserts.assertNotNull(name, "garbage_collection.name was null"); + boolean isYoung = batch.isYoungCollection(); + String expectedName = isYoung ? youngCollector : oldCollector; + if (!expectedName.equals(name)) { + // Collector names not equal. Check if the collector has been overridden by an expected collector. + String overrideKey = expectedName + "." + name; + boolean isOverride = GCHelper.collectorOverrides.contains(overrideKey); + Asserts.assertTrue(isOverride, String.format("Unexpected event name(%s) for collectors(%s, %s)", name, youngCollector, oldCollector)); + } + } + } + + /** + * Verifies field "cause" in garbage_collection event. + * Only check that at cause is not null and that at least 1 cause is "System.gc()" + * We might want to check more cause reasons later. + */ + private void verifyCollectionCause(List batches) { + int systemGcCount = 0; + for (GCHelper.GcBatch batch : batches) { + RecordedEvent endEvent = batch.getEndEvent(); + String cause = Events.assertField(endEvent, "cause").notEmpty().getValue(); + // A System.GC() can be consolidated into a GCLocker GC + if (cause.equals("System.gc()") || cause.equals("GCLocker Initiated GC")) { + systemGcCount++; + } + Asserts.assertNotNull(batch.getName(), "garbage_collection.name was null"); + } + final String msg = "No event with cause=System.gc(), collectors(%s, %s)"; + Asserts.assertTrue(systemGcCount > 0, String.format(msg, youngCollector, oldCollector)); + } + + private void log(List events, List batches, + GCHelper.CollectionSummary eventCounts, GCHelper.CollectionSummary beanCounts) { + GCHelper.log("EventCounts:"); + if (eventCounts != null) { + GCHelper.log(eventCounts.toString()); + } + GCHelper.log("BeanCounts:"); + if (beanCounts != null) { + GCHelper.log(beanCounts.toString()); + } + } + + /** + * Thread that does a number of System.gc(). + */ + public static class SystemGcRunner implements Runnable { + private final int totalCollections; + + public SystemGcRunner(int totalCollections) { + this.totalCollections = totalCollections; + } + + public static SystemGcRunner create(int totalCollections) { + return new SystemGcRunner(totalCollections); + } + + public void run() { + for (int i = 0; i < totalCollections; i++) { + GCEventAll.doSystemGc(); + } + } + } + + /** + * Thread that creates garbage until a certain number of GCs has been run. + */ + public static class GarbageRunner implements Runnable { + private final int totalCollections; + public byte[] dummyBuffer = null; + + public GarbageRunner(int totalCollections) { + this.totalCollections = totalCollections; + } + + public static GarbageRunner create(int totalCollections) { + return new GarbageRunner(totalCollections); + } + + public void run() { + long currCollections = GCHelper.CollectionSummary.createFromMxBeans().sum(); + long endCollections = totalCollections + currCollections; + Random r = new Random(0); + while (true) { + for (int i = 0; i < 1000; i++) { + dummyBuffer = new byte[r.nextInt(10000)]; + } + if (GCHelper.CollectionSummary.createFromMxBeans().sum() >= endCollections) { + break; + } + } + } + } + + /** + * Thread that runs System.gc() and then wait for a number of GCs or a maximum time. + */ + public static class SystemGcWaitRunner implements Runnable { + private final int totalCollections; + private final int minWaitCollections; + private final long maxWaitMillis; + + public SystemGcWaitRunner(int totalCollections, int minWaitCollections, long maxWaitMillis) { + this.totalCollections = totalCollections; + this.minWaitCollections = minWaitCollections; + this.maxWaitMillis = maxWaitMillis; + } + + public static SystemGcWaitRunner create(int deltaCollections, int minWaitCollections, long maxWaitMillis) { + return new SystemGcWaitRunner(deltaCollections, minWaitCollections, maxWaitMillis); + } + + public void run() { + long currCount = GCHelper.CollectionSummary.createFromMxBeans().sum(); + long endCount = totalCollections + currCount; + long nextSystemGcCount = currCount + minWaitCollections; + long now = System.currentTimeMillis(); + long nextSystemGcMillis = now + maxWaitMillis; + + while (true) { + if (currCount >= nextSystemGcCount || System.currentTimeMillis() > nextSystemGcMillis) { + GCEventAll.doSystemGc(); + currCount = GCHelper.CollectionSummary.createFromMxBeans().sum(); + nextSystemGcCount = currCount + minWaitCollections; + } else { + try { + Thread.sleep(20); + } catch (InterruptedException e) { + e.printStackTrace(); + break; + } + } + currCount = GCHelper.CollectionSummary.createFromMxBeans().sum(); + if (currCount >= endCount) { + break; + } + } + } + } + +} diff --git a/test/jdk/jfr/event/gc/collection/GCGarbageCollectionUtil.java b/test/jdk/jfr/event/gc/collection/GCGarbageCollectionUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..acf43fa3ded94563f56a0e8ce25c11deb8e07843 --- /dev/null +++ b/test/jdk/jfr/event/gc/collection/GCGarbageCollectionUtil.java @@ -0,0 +1,105 @@ +/* + * 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 + * 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.event.gc.collection; + +import static jdk.test.lib.Asserts.assertGreaterThan; +import static jdk.test.lib.Asserts.assertTrue; + +import java.io.File; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.jfr.AppExecutorHelper; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.process.OutputAnalyzer; + + +/** + * Class to verify GarbageCollection event. + * It starts the application provoking GCGarbageCollection with enabled JFR, + * collects events and verify the 'name' and 'cause' fields to be expected. + * It's supposed to be invoked from tests. + */ +public class GCGarbageCollectionUtil { + private final static String EVENT_SETTINGS_FILE = + System.getProperty("test.src", ".") + File.separator + "gc-testsettings.jfc"; + + /** + * Verifies the 'name' and 'cause' fields of received events to be expected. + * @param testID - a string to identify test + * @param testFlags - VM flags including GC to start the app + * @param gcNames - expected values for the 'name' field + * @param gcCauses - expected values for the 'cause' field + * @throws Exception in case of any failure + */ + public static void test(String testID, String[] testFlags, + String[] gcNames, String... gcCauses) throws Exception { + + String jfrFile = testID + ".jfr"; + + List summaryFlags = new ArrayList<>(); + Collections.addAll(summaryFlags, testFlags); + summaryFlags.add("-Xmx100m"); + summaryFlags.add("-XX:+UnlockExperimentalVMOptions"); + summaryFlags.add("-XX:-UseFastUnorderedTimeStamps"); + summaryFlags.add("-XX:+PrintGCDetails"); + summaryFlags.add("-XX:+PrintGC"); + + + String args[] = {}; + OutputAnalyzer analyzer = AppExecutorHelper.executeAndRecord(EVENT_SETTINGS_FILE, jfrFile, + (String[])summaryFlags.toArray(new String[0]), AppGCProvoker.class.getName(), args); + analyzer.shouldHaveExitValue(0); + + Set gcValidNames = new HashSet<>(); + for (String n: gcNames) { + gcValidNames.add(n); + } + Set gcValidCauses = new HashSet<>(); + for (String n: gcCauses) { + gcValidCauses.add(n); + } + + int total = 0; + for (RecordedEvent event : RecordingFile.readAllEvents(Paths.get(jfrFile))) { + total++; + System.out.println("Event: " + event); + + final String name = Events.assertField(event, "name").notEmpty().getValue(); + assertTrue(gcValidNames.contains(name), "GC name '" + name + "' not in the valid list" + gcValidNames); + + final String cause = Events.assertField(event, "cause").notEmpty().getValue(); + assertTrue(gcValidCauses.contains(cause), "GC cause '" + cause + "' not in the valid causes" + gcValidCauses); + } + assertGreaterThan(total, 0, "Expected at least one event"); + } +} diff --git a/test/jdk/jfr/event/gc/collection/TestGCCauseWithCMSConcurrent.java b/test/jdk/jfr/event/gc/collection/TestGCCauseWithCMSConcurrent.java new file mode 100644 index 0000000000000000000000000000000000000000..568cf690aa36e1a0a2087ba67cf0d18448f961db --- /dev/null +++ b/test/jdk/jfr/event/gc/collection/TestGCCauseWithCMSConcurrent.java @@ -0,0 +1,47 @@ +/* + * 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 + * 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.event.gc.collection; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * + * @library /lib / + * @run driver jdk.jfr.event.gc.collection.TestGCCauseWithCMSConcurrent + */ +public class TestGCCauseWithCMSConcurrent { + public static void main(String[] args) throws Exception { + String testID = "CMSConcurrent"; + String[] vmFlags = {"-XX:+UseConcMarkSweepGC", "-XX:+ExplicitGCInvokesConcurrent"}; + String[] gcNames = {GCHelper.gcConcurrentMarkSweep, GCHelper.gcParNew, GCHelper.gcSerialOld}; + String[] gcCauses = {"CMS Concurrent Mark", "Allocation Failure", "System.gc()"}; + GCGarbageCollectionUtil.test(testID, vmFlags, gcNames, gcCauses); + } +} + diff --git a/test/jdk/jfr/event/gc/collection/TestGCCauseWithCMSMarkSweep.java b/test/jdk/jfr/event/gc/collection/TestGCCauseWithCMSMarkSweep.java new file mode 100644 index 0000000000000000000000000000000000000000..70097add4c854cd0c09134d77eef612d6173c4c9 --- /dev/null +++ b/test/jdk/jfr/event/gc/collection/TestGCCauseWithCMSMarkSweep.java @@ -0,0 +1,48 @@ +/* + * 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 + * 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.event.gc.collection; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * + * + * @library /lib / + * @run driver jdk.jfr.event.gc.collection.TestGCCauseWithCMSMarkSweep + */ +public class TestGCCauseWithCMSMarkSweep { + public static void main(String[] args) throws Exception { + String testID = "CMSMarkSweep"; + String[] vmFlags = {"-XX:+UseConcMarkSweepGC"}; + String[] gcNames = {GCHelper.gcConcurrentMarkSweep, GCHelper.gcParNew, GCHelper.gcSerialOld}; + String[] gcCauses = {"CMS Concurrent Mark", "Allocation Failure", "System.gc()"}; + GCGarbageCollectionUtil.test(testID, vmFlags, gcNames, gcCauses); + } +} + diff --git a/test/jdk/jfr/event/gc/collection/TestGCCauseWithG1ConcurrentMark.java b/test/jdk/jfr/event/gc/collection/TestGCCauseWithG1ConcurrentMark.java new file mode 100644 index 0000000000000000000000000000000000000000..21e1e68b71537e1f14d2fcb77bab8c636c123253 --- /dev/null +++ b/test/jdk/jfr/event/gc/collection/TestGCCauseWithG1ConcurrentMark.java @@ -0,0 +1,49 @@ +/* + * 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 + * 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.event.gc.collection; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * + * + * @library /lib / + * + * @run driver jdk.jfr.event.gc.collection.TestGCCauseWithG1ConcurrentMark + */ +public class TestGCCauseWithG1ConcurrentMark { + public static void main(String[] args) throws Exception { + String testID = "G1ConcurrentMark"; + String[] vmFlags = {"-XX:+UseG1GC", "-XX:+ExplicitGCInvokesConcurrent"}; + String[] gcNames = {GCHelper.gcG1New, GCHelper.gcG1Old, GCHelper.gcG1Full, GCHelper.gcSerialOld}; + String[] gcCauses = {"G1 Evacuation Pause", "Allocation Failure", "System.gc()"}; + GCGarbageCollectionUtil.test(testID, vmFlags, gcNames, gcCauses); + } +} + diff --git a/test/jdk/jfr/event/gc/collection/TestGCCauseWithG1FullCollection.java b/test/jdk/jfr/event/gc/collection/TestGCCauseWithG1FullCollection.java new file mode 100644 index 0000000000000000000000000000000000000000..93042ee18447e329b4384fa3d0d353c8ecd1cadd --- /dev/null +++ b/test/jdk/jfr/event/gc/collection/TestGCCauseWithG1FullCollection.java @@ -0,0 +1,48 @@ +/* + * 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 + * 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.event.gc.collection; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * + * + * @library /lib / + * + * @run driver jdk.jfr.event.gc.collection.TestGCCauseWithG1FullCollection + */ +public class TestGCCauseWithG1FullCollection { + public static void main(String[] args) throws Exception { + String testID = "G1FullCollection"; + String[] vmFlags = {"-XX:+UseG1GC"}; + String[] gcNames = {GCHelper.gcG1New, GCHelper.gcG1Old, GCHelper.gcG1Full, GCHelper.gcSerialOld}; + String[] gcCauses = {"G1 Evacuation Pause", "Allocation Failure", "System.gc()"}; + GCGarbageCollectionUtil.test(testID, vmFlags, gcNames, gcCauses); + } +} diff --git a/test/jdk/jfr/event/gc/collection/TestGCCauseWithPSMarkSweep.java b/test/jdk/jfr/event/gc/collection/TestGCCauseWithPSMarkSweep.java new file mode 100644 index 0000000000000000000000000000000000000000..8bd9dcd7c95d8daf8444fe6f6c1e6841427d39a6 --- /dev/null +++ b/test/jdk/jfr/event/gc/collection/TestGCCauseWithPSMarkSweep.java @@ -0,0 +1,49 @@ +/* + * 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 + * 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.event.gc.collection; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * + * @library /lib / + * + * @run driver jdk.jfr.event.gc.collection.TestGCCauseWithPSMarkSweep + */ +public class TestGCCauseWithPSMarkSweep { + public static void main(String[] args) throws Exception { + String testID = "PSMarkSweep"; + String[] vmFlags = {"-XX:+UseParallelGC", "-XX:-UseParallelOldGC"}; + String[] gcNames = {GCHelper.gcParallelScavenge, GCHelper.gcSerialOld}; + String[] gcCauses = {"Allocation Failure", "Ergonomics", "System.gc()"}; + GCGarbageCollectionUtil.test(testID, vmFlags, gcNames, gcCauses); + } +} + + diff --git a/test/jdk/jfr/event/gc/collection/TestGCCauseWithParallelOld.java b/test/jdk/jfr/event/gc/collection/TestGCCauseWithParallelOld.java new file mode 100644 index 0000000000000000000000000000000000000000..8a760ff0322627cf43b8d0809141d987539555cd --- /dev/null +++ b/test/jdk/jfr/event/gc/collection/TestGCCauseWithParallelOld.java @@ -0,0 +1,47 @@ +/* + * 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 + * 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.event.gc.collection; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * + * @library /lib / + * + * @run driver jdk.jfr.event.gc.collection.TestGCCauseWithParallelOld + */ +public class TestGCCauseWithParallelOld { + public static void main(String[] args) throws Exception { + String testID = "ParallelOld"; + String[] vmFlags = {"-XX:+UseParallelGC", "-XX:+UseParallelOldGC"}; + String[] gcNames = {GCHelper.gcParallelScavenge, GCHelper.gcParallelOld}; + String[] gcCauses = {"Allocation Failure", "Ergonomics", "System.gc()"}; + GCGarbageCollectionUtil.test(testID, vmFlags, gcNames, gcCauses); + } +} diff --git a/test/jdk/jfr/event/gc/collection/TestGCCauseWithSerial.java b/test/jdk/jfr/event/gc/collection/TestGCCauseWithSerial.java new file mode 100644 index 0000000000000000000000000000000000000000..861c45b520e98b44f05af79b2c47008a55714208 --- /dev/null +++ b/test/jdk/jfr/event/gc/collection/TestGCCauseWithSerial.java @@ -0,0 +1,47 @@ +/* + * 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 + * 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.event.gc.collection; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * + * @library /lib / + * + * @run driver jdk.jfr.event.gc.collection.TestGCCauseWithSerial + */ +public class TestGCCauseWithSerial { + public static void main(String[] args) throws Exception { + String testID = "Serial"; + String[] vmFlags = {"-XX:+UseSerialGC"}; + String[] gcNames = {GCHelper.gcDefNew, GCHelper.gcSerialOld}; + String[] gcCauses = {"Allocation Failure", "System.gc()"}; + GCGarbageCollectionUtil.test(testID, vmFlags, gcNames, gcCauses); + } +} diff --git a/test/jdk/jfr/event/gc/collection/TestGCEventMixedWithCMSConcurrent.java b/test/jdk/jfr/event/gc/collection/TestGCEventMixedWithCMSConcurrent.java new file mode 100644 index 0000000000000000000000000000000000000000..878e6e1b9aff58b30c44b183add72a2f2ca9a0df --- /dev/null +++ b/test/jdk/jfr/event/gc/collection/TestGCEventMixedWithCMSConcurrent.java @@ -0,0 +1,43 @@ +/* + * 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 + * 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.event.gc.collection; + +/** + * @test + * @key jfr + * + * + * + * @library /lib / + * + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -Xmx32m -Xmn8m -XX:+UseConcMarkSweepGC -XX:+ExplicitGCInvokesConcurrent jdk.jfr.event.gc.collection.TestGCEventMixedWithCMSConcurrent + * good debug flags:-XX:+PrintGCDetails -XX:+PrintGC + */ +public class TestGCEventMixedWithCMSConcurrent { + public static void main(String[] args) throws Throwable { + GCEventAll.doTest(); + } +} diff --git a/test/jdk/jfr/event/gc/collection/TestGCEventMixedWithCMSMarkSweep.java b/test/jdk/jfr/event/gc/collection/TestGCEventMixedWithCMSMarkSweep.java new file mode 100644 index 0000000000000000000000000000000000000000..ee357e739aba6df01b62e9f1fd552ce608443317 --- /dev/null +++ b/test/jdk/jfr/event/gc/collection/TestGCEventMixedWithCMSMarkSweep.java @@ -0,0 +1,43 @@ +/* + * 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 + * 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.event.gc.collection; + +/** + * @test + * @key jfr + * + * + * + * @library /lib / + * + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -Xmx32m -Xmn8m -XX:+UseConcMarkSweepGC -XX:-ExplicitGCInvokesConcurrent jdk.jfr.event.gc.collection.TestGCEventMixedWithCMSMarkSweep + * good debug flags:-XX:+PrintGCDetails -XX:+PrintGC + */ +public class TestGCEventMixedWithCMSMarkSweep { + public static void main(String[] args) throws Throwable { + GCEventAll.doTest(); + } +} diff --git a/test/jdk/jfr/event/gc/collection/TestGCEventMixedWithG1ConcurrentMark.java b/test/jdk/jfr/event/gc/collection/TestGCEventMixedWithG1ConcurrentMark.java new file mode 100644 index 0000000000000000000000000000000000000000..4838586c3331de23712d07d692cddb6f3f5ba4f4 --- /dev/null +++ b/test/jdk/jfr/event/gc/collection/TestGCEventMixedWithG1ConcurrentMark.java @@ -0,0 +1,44 @@ +/* + * 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 + * 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.event.gc.collection; + +/** + * @test + * @key jfr + * + * + * + * @library /lib / + * + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -Xmx32m -Xmn8m -XX:+UseG1GC -XX:+ExplicitGCInvokesConcurrent jdk.jfr.event.gc.collection.TestGCEventMixedWithG1ConcurrentMark + * good debug flags: -XX:+PrintGCDetails -XX:+PrintGC + */ +// TODO: Try to run without: -XX:+UnlockExperimentalVMOptions XX:-UseFastUnorderedTimeStamps +public class TestGCEventMixedWithG1ConcurrentMark { + public static void main(String[] args) throws Throwable { + GCEventAll.doTest(); + } +} diff --git a/test/jdk/jfr/event/gc/collection/TestGCEventMixedWithG1FullCollection.java b/test/jdk/jfr/event/gc/collection/TestGCEventMixedWithG1FullCollection.java new file mode 100644 index 0000000000000000000000000000000000000000..db98e06deea7ea87d8b307db999ca9d5f284bd53 --- /dev/null +++ b/test/jdk/jfr/event/gc/collection/TestGCEventMixedWithG1FullCollection.java @@ -0,0 +1,42 @@ +/* + * 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 + * 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.event.gc.collection; + +/** + * @test + * @key jfr + * + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -Xmx32m -Xmn8m -XX:+UseG1GC -XX:-ExplicitGCInvokesConcurrent jdk.jfr.event.gc.collection.TestGCEventMixedWithG1FullCollection + * good debug flags: -XX:+PrintGCDetails -XX:+PrintGC + */ +public class TestGCEventMixedWithG1FullCollection { + public static void main(String[] args) throws Throwable { + GCEventAll.doTest(); + } +} diff --git a/test/jdk/jfr/event/gc/collection/TestGCEventMixedWithPSMarkSweep.java b/test/jdk/jfr/event/gc/collection/TestGCEventMixedWithPSMarkSweep.java new file mode 100644 index 0000000000000000000000000000000000000000..777a4a1f26286cfe11be0aaef1f58592ddcf0d42 --- /dev/null +++ b/test/jdk/jfr/event/gc/collection/TestGCEventMixedWithPSMarkSweep.java @@ -0,0 +1,42 @@ +/* + * 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 + * 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.event.gc.collection; + +/** + * @test + * @key jfr + * + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -Xmx32m -Xmn8m -XX:+UseParallelGC -XX:-UseParallelOldGC jdk.jfr.event.gc.collection.TestGCEventMixedWithPSMarkSweep + * good debug flags:-XX:+PrintGCDetails -XX:+PrintGC + */ +public class TestGCEventMixedWithPSMarkSweep { + public static void main(String[] args) throws Throwable { + GCEventAll.doTest(); + } +} diff --git a/test/jdk/jfr/event/gc/collection/TestGCEventMixedWithParNew.java b/test/jdk/jfr/event/gc/collection/TestGCEventMixedWithParNew.java new file mode 100644 index 0000000000000000000000000000000000000000..25b15f6ee66a16252d24ab3dd7e70ccdf7ba0d42 --- /dev/null +++ b/test/jdk/jfr/event/gc/collection/TestGCEventMixedWithParNew.java @@ -0,0 +1,43 @@ +/* + * 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 + * 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.event.gc.collection; + +/** + * @test + * @key jfr + * + * + * + * @library /lib / + * @run main/othervm -Xmx32m -Xmn8m -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseConcMarkSweepGC jdk.jfr.event.gc.collection.TestGCEventMixedWithParNew + * good debug flags:-XX:+PrintGCDetails -XX:+PrintGC + */ + +public class TestGCEventMixedWithParNew { + public static void main(String[] args) throws Throwable { + GCEventAll.doTest(); + } +} diff --git a/test/jdk/jfr/event/gc/collection/TestGCEventMixedWithParallelOld.java b/test/jdk/jfr/event/gc/collection/TestGCEventMixedWithParallelOld.java new file mode 100644 index 0000000000000000000000000000000000000000..84b1c47c22a7972073a57b3f0fd8f125cf5b513b --- /dev/null +++ b/test/jdk/jfr/event/gc/collection/TestGCEventMixedWithParallelOld.java @@ -0,0 +1,42 @@ +/* + * 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 + * 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.event.gc.collection; + +/** + * @test + * @key jfr + * + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -Xmx32m -Xmn8m -XX:+UseParallelGC -XX:+UseParallelOldGC jdk.jfr.event.gc.collection.TestGCEventMixedWithParallelOld + * good debug flags: -XX:+PrintGCDetails -XX:+PrintGC -verbose:class + */ +public class TestGCEventMixedWithParallelOld { + public static void main(String[] args) throws Throwable { + GCEventAll.doTest(); + } +} diff --git a/test/jdk/jfr/event/gc/collection/TestGCEventMixedWithSerial.java b/test/jdk/jfr/event/gc/collection/TestGCEventMixedWithSerial.java new file mode 100644 index 0000000000000000000000000000000000000000..1b8e1a9c3fbaa3506c9b01f63ce9f1f8ff2b6eb3 --- /dev/null +++ b/test/jdk/jfr/event/gc/collection/TestGCEventMixedWithSerial.java @@ -0,0 +1,41 @@ +/* + * 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 + * 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.event.gc.collection; + +/** + * @test + * @key jfr + * + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -Xmx32m -Xmn8m -XX:+UseSerialGC jdk.jfr.event.gc.collection.TestGCEventMixedWithSerial + */ +public class TestGCEventMixedWithSerial { + public static void main(String[] args) throws Throwable { + GCEventAll.doTest(); + } +} diff --git a/test/jdk/jfr/event/gc/collection/TestGCGarbageCollectionEvent.java b/test/jdk/jfr/event/gc/collection/TestGCGarbageCollectionEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..7c024c28c858765d338345fe464d59f9399f56a9 --- /dev/null +++ b/test/jdk/jfr/event/gc/collection/TestGCGarbageCollectionEvent.java @@ -0,0 +1,68 @@ +/* + * 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 + * 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.event.gc.collection; + +import static jdk.test.lib.Asserts.assertTrue; + +import java.time.Duration; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm -XX:+PrintGCDetails -XX:+PrintGC -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps jdk.jfr.event.gc.collection.TestGCGarbageCollectionEvent + */ +public class TestGCGarbageCollectionEvent { + + private final static String EVENT_NAME = GCHelper.event_garbage_collection; + + public static void main(String[] args) throws Exception { + Recording recording = new Recording(); + recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(0)); + recording.start(); + System.gc(); + recording.stop(); + + boolean isAnyFound = false; + for (RecordedEvent event : Events.fromRecording(recording)) { + if (!EVENT_NAME.equals(event.getEventType().getName())) { + continue; + } + System.out.println("Event: " + event); + isAnyFound = true; + + long longestPause = Events.assertField(event, "longestPause").atLeast(0L).getValue(); + Events.assertField(event, "sumOfPauses").atLeast(longestPause); + } + assertTrue(isAnyFound, "No matching event found"); + } +} diff --git a/test/jdk/jfr/event/gc/collection/TestGCWithFasttime.java b/test/jdk/jfr/event/gc/collection/TestGCWithFasttime.java new file mode 100644 index 0000000000000000000000000000000000000000..5003680673ef93303435e8658760aaeac9622d7b --- /dev/null +++ b/test/jdk/jfr/event/gc/collection/TestGCWithFasttime.java @@ -0,0 +1,66 @@ +/* + * 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 + * 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.event.gc.collection; + +import java.time.Duration; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UseParallelGC -XX:+UseParallelOldGC jdk.jfr.event.gc.collection.TestGCWithFasttime + */ +public class TestGCWithFasttime { + private static final String EVENT_NAME = GCHelper.event_garbage_collection; + + // TODO: Check if all GC tests can be run with fast time. If so, this test is probably not needed. + public static void main(String[] args) throws Exception { + Recording recording = new Recording(); + recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(0)); + recording.start(); + System.gc(); + System.gc(); + recording.stop(); + + List events = Events.fromRecording(recording); + Events.hasEvents(events); + for (RecordedEvent event : events) { + if (!EVENT_NAME.equals(event.getEventType().getName())) { + continue; + } + Events.assertField(event, "name").notEmpty(); + Events.assertField(event, "cause").notEmpty(); + } + } +} diff --git a/test/jdk/jfr/event/gc/collection/TestYoungGarbageCollectionEventWithDefNew.java b/test/jdk/jfr/event/gc/collection/TestYoungGarbageCollectionEventWithDefNew.java new file mode 100644 index 0000000000000000000000000000000000000000..c03f7db6e779b6a726be0de00bcca59d9509c708 --- /dev/null +++ b/test/jdk/jfr/event/gc/collection/TestYoungGarbageCollectionEventWithDefNew.java @@ -0,0 +1,42 @@ +/* + * 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 + * 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.event.gc.collection; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -Xmx50m -Xmn2m -XX:+UseSerialGC -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+PrintGCDetails -XX:+PrintGC jdk.jfr.event.gc.collection.TestYoungGarbageCollectionEventWithDefNew + */ +public class TestYoungGarbageCollectionEventWithDefNew { + + public static void main(String[] args) throws Exception { + YoungGarbageCollectionEvent.test(); + } + +} diff --git a/test/jdk/jfr/event/gc/collection/TestYoungGarbageCollectionEventWithG1New.java b/test/jdk/jfr/event/gc/collection/TestYoungGarbageCollectionEventWithG1New.java new file mode 100644 index 0000000000000000000000000000000000000000..886f182f904d888406829be0cd08084a1e70294a --- /dev/null +++ b/test/jdk/jfr/event/gc/collection/TestYoungGarbageCollectionEventWithG1New.java @@ -0,0 +1,42 @@ +/* + * 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 + * 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.event.gc.collection; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -Xmx50m -Xmn2m -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+PrintGCDetails -XX:+PrintGC jdk.jfr.event.gc.collection.TestYoungGarbageCollectionEventWithG1New + */ +public class TestYoungGarbageCollectionEventWithG1New { + + public static void main(String[] args) throws Exception { + YoungGarbageCollectionEvent.test(); + } + +} diff --git a/test/jdk/jfr/event/gc/collection/TestYoungGarbageCollectionEventWithParNew.java b/test/jdk/jfr/event/gc/collection/TestYoungGarbageCollectionEventWithParNew.java new file mode 100644 index 0000000000000000000000000000000000000000..5a5877e531cc7469887b6c5c1cbe03ef2cb45e04 --- /dev/null +++ b/test/jdk/jfr/event/gc/collection/TestYoungGarbageCollectionEventWithParNew.java @@ -0,0 +1,42 @@ +/* + * 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 + * 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.event.gc.collection; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -Xmx50m -Xmn2m -XX:+UseConcMarkSweepGC -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+PrintGCDetails -XX:+PrintGC jdk.jfr.event.gc.collection.TestYoungGarbageCollectionEventWithParNew + */ +public class TestYoungGarbageCollectionEventWithParNew { + + public static void main(String[] args) throws Exception { + YoungGarbageCollectionEvent.test(); + } + +} diff --git a/test/jdk/jfr/event/gc/collection/TestYoungGarbageCollectionEventWithParallelScavenge.java b/test/jdk/jfr/event/gc/collection/TestYoungGarbageCollectionEventWithParallelScavenge.java new file mode 100644 index 0000000000000000000000000000000000000000..d5cbe2e8ef2532f6ffd1f0dc19f0ca6bcae07766 --- /dev/null +++ b/test/jdk/jfr/event/gc/collection/TestYoungGarbageCollectionEventWithParallelScavenge.java @@ -0,0 +1,42 @@ +/* + * 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 + * 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.event.gc.collection; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -Xmx50m -Xmn2m -XX:+UseParallelGC -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:-UseAdaptiveSizePolicy -XX:+PrintGCDetails -XX:+PrintGC jdk.jfr.event.gc.collection.TestYoungGarbageCollectionEventWithParallelScavenge + */ +public class TestYoungGarbageCollectionEventWithParallelScavenge { + + public static void main(String[] args) throws Exception { + YoungGarbageCollectionEvent.test(); + } + +} diff --git a/test/jdk/jfr/event/gc/collection/YoungGarbageCollectionEvent.java b/test/jdk/jfr/event/gc/collection/YoungGarbageCollectionEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..8973eccb61f3ceb9eed593d5748f2c65d73ea4a9 --- /dev/null +++ b/test/jdk/jfr/event/gc/collection/YoungGarbageCollectionEvent.java @@ -0,0 +1,79 @@ +/* + * 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 + * 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.event.gc.collection; + +import static jdk.test.lib.Asserts.assertGreaterThan; +import static jdk.test.lib.Asserts.assertTrue; + +import java.time.Duration; +import java.time.Instant; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.GCHelper; + + +public class YoungGarbageCollectionEvent { + + private static final String EVENT_NAME = GCHelper.event_young_garbage_collection; + + public static void test() throws Exception { + Recording recording = new Recording(); + recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(0)); + recording.start(); + triggerGC(); + recording.stop(); + + boolean isAnyFound = false; + for (RecordedEvent event : Events.fromRecording(recording)) { + if (!EVENT_NAME.equals(event.getEventType().getName())) { + continue; + } + System.out.println("Event: " + event); + isAnyFound = true; + Events.assertField(event, "gcId").atLeast(0); + Events.assertField(event, "tenuringThreshold").atLeast(1); + + Instant startTime = event.getStartTime(); + Instant endTime = event.getEndTime(); + Duration duration = event.getDuration(); + assertGreaterThan(startTime, Instant.EPOCH, "startTime should be at least 0"); + assertGreaterThan(endTime, Instant.EPOCH, "endTime should be at least 0"); + // TODO: Maybe we should accept duration of 0, but old test did not. + assertGreaterThan(duration, Duration.ZERO, "Duration should be above 0"); + assertGreaterThan(endTime, startTime, "End time should be after start time"); + } + assertTrue(isAnyFound, "No matching event found"); + } + + public static byte[] garbage; + private static void triggerGC() { + for (int i = 0; i < 3072; i++) { + garbage = new byte[1024]; + } + } +} diff --git a/test/jdk/jfr/event/gc/collection/gc-testsettings.jfc b/test/jdk/jfr/event/gc/collection/gc-testsettings.jfc new file mode 100644 index 0000000000000000000000000000000000000000..cfe73edca958db33caeae1681f0e4407957d2265 --- /dev/null +++ b/test/jdk/jfr/event/gc/collection/gc-testsettings.jfc @@ -0,0 +1,32 @@ + + + + + + true + 0 ms + + diff --git a/test/jdk/jfr/event/gc/configuration/GCHeapConfigurationEventTester.java b/test/jdk/jfr/event/gc/configuration/GCHeapConfigurationEventTester.java new file mode 100644 index 0000000000000000000000000000000000000000..14b72aacfd3c42e2135b727722c57b1d63566455 --- /dev/null +++ b/test/jdk/jfr/event/gc/configuration/GCHeapConfigurationEventTester.java @@ -0,0 +1,52 @@ +/* + * 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 + * 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.event.gc.configuration; + +import static jdk.test.lib.Asserts.assertGreaterThanOrEqual; + +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.EventVerifier; +import jdk.test.lib.jfr.Events; + + +public abstract class GCHeapConfigurationEventTester { + public void run() throws Exception { + Recording recording = new Recording(); + recording.enable(EventNames.GCHeapConfiguration); + recording.start(); + recording.stop(); + List events = Events.fromRecording(recording); + assertGreaterThanOrEqual(events.size(), 1, "Expected at least 1 event"); + EventVerifier v = createVerifier(events.get(0)); + v.verify(); + } + + protected abstract EventVerifier createVerifier(RecordedEvent e); +} diff --git a/test/jdk/jfr/event/gc/configuration/GCHeapConfigurationEventVerifier.java b/test/jdk/jfr/event/gc/configuration/GCHeapConfigurationEventVerifier.java new file mode 100644 index 0000000000000000000000000000000000000000..918fbabda2590dbd77395e66f2b0101877f8e86e --- /dev/null +++ b/test/jdk/jfr/event/gc/configuration/GCHeapConfigurationEventVerifier.java @@ -0,0 +1,68 @@ +/* + * 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 + * 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.event.gc.configuration; + +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.EventVerifier; + +public abstract class GCHeapConfigurationEventVerifier extends EventVerifier { + public GCHeapConfigurationEventVerifier(RecordedEvent e) { + super(e); + } + + protected void verifyMinHeapSizeIs(long expected) throws Exception { + verifyEquals("minSize", expected); + } + + protected void verifyInitialHeapSizeIs(long expected) throws Exception { + verifyEquals("initialSize", expected); + } + + protected void verifyMaxHeapSizeIs(long expected) throws Exception { + verifyEquals("maxSize", expected); + } + + protected void verifyUsesCompressedOopsIs(boolean expected) throws Exception { + verifyEquals("usesCompressedOops", expected); + } + + protected void verifyObjectAlignmentInBytesIs(int expected) throws Exception { + verifyEquals("objectAlignment", (long)expected); + } + + protected void verifyHeapAddressBitsIs(int expected) throws Exception { + verifyEquals("heapAddressBits", (byte)expected); + } + + protected void verifyCompressedOopModeIs(String expected) throws Exception { + verifyEquals("compressedOopsMode", expected); + } + + protected void verifyCompressedOopModeContains(String expected) throws Exception { + verifyContains("compressedOopsMode", expected); + } + +} diff --git a/test/jdk/jfr/event/gc/configuration/GCYoungGenerationConfigurationEventTester.java b/test/jdk/jfr/event/gc/configuration/GCYoungGenerationConfigurationEventTester.java new file mode 100644 index 0000000000000000000000000000000000000000..ecdc2f3f11cbfdc969be930844ac65a950ddc04d --- /dev/null +++ b/test/jdk/jfr/event/gc/configuration/GCYoungGenerationConfigurationEventTester.java @@ -0,0 +1,51 @@ +/* + * 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 + * 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.event.gc.configuration; + +import static jdk.test.lib.Asserts.assertGreaterThanOrEqual; + +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.EventVerifier; +import jdk.test.lib.jfr.Events; + +public abstract class GCYoungGenerationConfigurationEventTester { + public void run() throws Exception { + Recording recording = new Recording(); + recording.enable(EventNames.YoungGenerationConfiguration); + recording.start(); + recording.stop(); + List events = Events.fromRecording(recording); + assertGreaterThanOrEqual(events.size(), 1, "Expected at least 1 event"); + EventVerifier v = createVerifier(events.get(0)); + v.verify(); + } + + protected abstract EventVerifier createVerifier(RecordedEvent e); +} diff --git a/test/jdk/jfr/event/gc/configuration/TestGCConfigurationEvent.java b/test/jdk/jfr/event/gc/configuration/TestGCConfigurationEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..cf981c1fd272495238fc35969685670489e5c9b6 --- /dev/null +++ b/test/jdk/jfr/event/gc/configuration/TestGCConfigurationEvent.java @@ -0,0 +1,112 @@ +/* + * 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 + * 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.event.gc.configuration; + +import static jdk.test.lib.Asserts.assertGreaterThanOrEqual; + +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.EventVerifier; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:ParallelGCThreads=3 -XX:ConcGCThreads=2 -XX:+UseDynamicNumberOfGCThreads -XX:-ExplicitGCInvokesConcurrent -XX:-DisableExplicitGC -XX:MaxGCPauseMillis=800 -XX:GCTimeRatio=19 jdk.jfr.event.gc.configuration.TestGCConfigurationEvent + */ +public class TestGCConfigurationEvent { + public static void main(String[] args) throws Exception { + Recording recording = new Recording(); + recording.enable(EventNames.GCConfiguration); + recording.start(); + recording.stop(); + List events = Events.fromRecording(recording); + assertGreaterThanOrEqual(events.size(), 1, "Expected at least 1 event"); + GCConfigurationEventVerifier verifier = new GCConfigurationEventVerifier(events.get(0)); + verifier.verify(); + } +} + +class GCConfigurationEventVerifier extends EventVerifier { + public GCConfigurationEventVerifier(RecordedEvent event) { + super(event); + } + + @Override + public void verify() throws Exception { + verifyYoungGCIs("ParallelScavenge"); + verifyOldGCIs("ParallelOld"); + verifyParallelGCThreadsIs(3); + verifyConcurrentGCThreadsIs(2); + verifyUsesDynamicGCThreadsIs(true); + verifyIsExplicitGCConcurrentIs(false); + verifyIsExplicitGCDisabledIs(false); + verifyPauseTargetIs(800); + verifyGCTimeRatioIs(19); + } + + private void verifyYoungGCIs(String expected) throws Exception { + verifyEquals("youngCollector", expected); + } + + private void verifyOldGCIs(String expected) throws Exception { + verifyEquals("oldCollector", expected); + } + + private void verifyParallelGCThreadsIs(int expected) throws Exception { + verifyEquals("parallelGCThreads", expected); + } + + private void verifyConcurrentGCThreadsIs(int expected) throws Exception { + verifyEquals("concurrentGCThreads", expected); + } + + private void verifyUsesDynamicGCThreadsIs(boolean expected) throws Exception { + verifyEquals("usesDynamicGCThreads", expected); + } + + private void verifyIsExplicitGCConcurrentIs(boolean expected) throws Exception { + verifyEquals("isExplicitGCConcurrent", expected); + } + + private void verifyIsExplicitGCDisabledIs(boolean expected) throws Exception { + verifyEquals("isExplicitGCDisabled", expected); + } + + private void verifyPauseTargetIs(long expected) throws Exception { + verifyEquals("pauseTarget", expected); + } + + private void verifyGCTimeRatioIs(int expected) throws Exception { + verifyEquals("gcTimeRatio", expected); + } +} diff --git a/test/jdk/jfr/event/gc/configuration/TestGCConfigurationEventWithDefaultPauseTarget.java b/test/jdk/jfr/event/gc/configuration/TestGCConfigurationEventWithDefaultPauseTarget.java new file mode 100644 index 0000000000000000000000000000000000000000..2d3bd3d7ec39d6042e0a08fab8aa53eb599302a4 --- /dev/null +++ b/test/jdk/jfr/event/gc/configuration/TestGCConfigurationEventWithDefaultPauseTarget.java @@ -0,0 +1,67 @@ +/* + * 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 + * 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.event.gc.configuration; + +import static jdk.test.lib.Asserts.assertGreaterThanOrEqual; + +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.EventVerifier; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps jdk.jfr.event.gc.configuration.TestGCConfigurationEventWithDefaultPauseTarget + */ +public class TestGCConfigurationEventWithDefaultPauseTarget { + public static void main(String[] args) throws Exception { + Recording recording = new Recording(); + recording.enable(EventNames.GCConfiguration); + recording.start(); + recording.stop(); + List events = Events.fromRecording(recording); + assertGreaterThanOrEqual(events.size(), 1, "Expected at least 1 event"); + DefaultGCConfigurationVerifier verifier = new DefaultGCConfigurationVerifier(events.get(0)); + verifier.verify(); + } +} + +class DefaultGCConfigurationVerifier extends EventVerifier { + public DefaultGCConfigurationVerifier(RecordedEvent event) { + super(event); + } + + @Override + public void verify() throws Exception { + verifyEquals("pauseTarget", Long.MIN_VALUE); + } +} diff --git a/test/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWith32BitOops.java b/test/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWith32BitOops.java new file mode 100644 index 0000000000000000000000000000000000000000..ab0091b408d2888dc019e06bba3da6e7904f66b7 --- /dev/null +++ b/test/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWith32BitOops.java @@ -0,0 +1,64 @@ +/* + * 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 + * 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.event.gc.configuration; + +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.EventVerifier; +import jdk.test.lib.jfr.GCHelper; +import sun.hotspot.WhiteBox; + +/* See the shell script wrapper for the flags used when invoking the JVM */ +public class TestGCHeapConfigurationEventWith32BitOops extends GCHeapConfigurationEventTester { + public static void main(String[] args) throws Exception { + GCHeapConfigurationEventTester t = new TestGCHeapConfigurationEventWith32BitOops(); + t.run(); + } + + @Override + protected EventVerifier createVerifier(RecordedEvent e) { + return new ThirtyTwoBitsVerifier(e); + } +} + +class ThirtyTwoBitsVerifier extends GCHeapConfigurationEventVerifier { + public ThirtyTwoBitsVerifier(RecordedEvent event) { + super(event); + } + + @Override + public void verify() throws Exception { + WhiteBox wb = WhiteBox.getWhiteBox(); + long heapAlignment = wb.getHeapAlignment(); + long alignedHeapSize = GCHelper.alignUp(megabytes(100), heapAlignment); + verifyMinHeapSizeIs(megabytes(100)); + verifyInitialHeapSizeIs(alignedHeapSize); + verifyMaxHeapSizeIs(alignedHeapSize); + verifyUsesCompressedOopsIs(true); + verifyObjectAlignmentInBytesIs(8); + verifyHeapAddressBitsIs(32); + verifyCompressedOopModeIs("32-bit"); + } +} diff --git a/test/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWith32BitOops.sh b/test/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWith32BitOops.sh new file mode 100644 index 0000000000000000000000000000000000000000..062b7ee1528576862b953c54620a78f7fee57c10 --- /dev/null +++ b/test/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWith32BitOops.sh @@ -0,0 +1,61 @@ +# +# 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 +# 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 TestGCHeapConfigurationEventWith32BitOops +# @key jfr +# +# +# @library /lib / +# @build jdk.jfr.event.gc.configuration.TestGCHeapConfigurationEventWith32BitOops sun.hotspot.WhiteBox +# @run main ClassFileInstaller sun.hotspot.WhiteBox +# @run shell TestGCHeapConfigurationEventWith32BitOops.sh + +uses_64_bit_testjava() { + ${TESTJAVA}/bin/java ${TESTVMOPTS} -version 2>&1 | grep '64-Bit' > /dev/null +} + +uses_windows_or_linux() { + case `uname -s` in + Linux | CYGWIN* | Windows* ) + return 0 + ;; + esac + return 1 +} + +TEST='jdk.jfr.event.gc.configuration.TestGCHeapConfigurationEventWith32BitOops' + +OPTIONS='-XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:+UseCompressedOops -Xmx100m -Xms100m -XX:InitialHeapSize=100m -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI' + +if [ -z "${TESTCLASSPATH}" ]; then + echo "Using TESTCLASSES" + MY_CLASSPATH=${TESTCLASSES} +else + echo "Using TESTCLASSPATH" + MY_CLASSPATH=${TESTCLASSPATH} +fi + +if uses_windows_or_linux && uses_64_bit_testjava; then + printenv + echo "${TESTJAVA}/bin/java ${TESTVMOPTS} ${OPTIONS} -cp ${MY_CLASSPATH} ${TEST}" + ${TESTJAVA}/bin/java ${TESTVMOPTS} ${OPTIONS} -cp ${MY_CLASSPATH} ${TEST} +fi diff --git a/test/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithHeapBasedOops.java b/test/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithHeapBasedOops.java new file mode 100644 index 0000000000000000000000000000000000000000..fc816cb111132f7cf232b5a8712354a837f89ecd --- /dev/null +++ b/test/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithHeapBasedOops.java @@ -0,0 +1,59 @@ +/* + * 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 + * 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.event.gc.configuration; + +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.EventVerifier; + +/* See the shell script wrapper for the flags used when invoking the JVM */ +public class TestGCHeapConfigurationEventWithHeapBasedOops extends GCHeapConfigurationEventTester { + public static void main(String[] args) throws Exception { + GCHeapConfigurationEventTester t = new TestGCHeapConfigurationEventWithHeapBasedOops(); + t.run(); + } + + @Override + protected EventVerifier createVerifier(RecordedEvent e) { + return new HeapBasedOopsVerifier(e); + } +} + +class HeapBasedOopsVerifier extends GCHeapConfigurationEventVerifier { + public HeapBasedOopsVerifier(RecordedEvent e) { + super(e); + } + + @Override + public void verify() throws Exception { + // Can't verify min and initial heap size due to constraints on + // physical memory on tests machines + verifyMaxHeapSizeIs(gigabytes(31)); + verifyUsesCompressedOopsIs(true); + verifyObjectAlignmentInBytesIs(8); + verifyHeapAddressBitsIs(32); + verifyCompressedOopModeContains("Non-zero"); + } +} diff --git a/test/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithHeapBasedOops.sh b/test/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithHeapBasedOops.sh new file mode 100644 index 0000000000000000000000000000000000000000..f5c1cc8470042be7dad0fdf6be327769ad8e3304 --- /dev/null +++ b/test/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithHeapBasedOops.sh @@ -0,0 +1,63 @@ +# +# 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 +# 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 TestGCHeapConfigurationEventWithHeapBasedOops +# @key jfr +# +# +# @library /lib / +# @build jdk.jfr.event.gc.configuration.TestGCHeapConfigurationEventWithHeapBasedOops +# @run shell TestGCHeapConfigurationEventWithHeapBasedOops.sh + +uses_64_bit_testjava() { + ${TESTJAVA}/bin/java ${TESTVMOPTS} -version 2>&1 | grep '64-Bit' > /dev/null +} + +uses_windows_or_linux() { + case `uname -s` in + Linux | CYGWIN* | Windows* ) + return 0 + ;; + esac + return 1 +} + +TEST='jdk.jfr.event.gc.configuration.TestGCHeapConfigurationEventWithHeapBasedOops' + +# NOTE: Can't use 32g heap with UseCompressedOops. Hopefully the 31g heap will +# force HeapBased compressed oops to be enalbed by hoping that there isn't +# enough space in the lowest 1 GB of the virtual address space. +OPTIONS='-XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseParallelGC -XX:+UseParallelOldGC -Xmx31g -XX:+UseCompressedOops' + +if [ -z "${TESTCLASSPATH}" ]; then + echo "Using TESTCLASSES" + MY_CLASSPATH=${TESTCLASSES} +else + echo "Using TESTCLASSPATH" + MY_CLASSPATH=${TESTCLASSPATH} +fi + +if uses_windows_or_linux && uses_64_bit_testjava; then + printenv + echo "${TESTJAVA}/bin/java ${TESTVMOPTS} ${OPTIONS} -cp ${MY_CLASSPATH} ${TEST}" + ${TESTJAVA}/bin/java ${TESTVMOPTS} ${OPTIONS} -cp ${MY_CLASSPATH} ${TEST} +fi diff --git a/test/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithZeroBasedOops.java b/test/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithZeroBasedOops.java new file mode 100644 index 0000000000000000000000000000000000000000..4d3ddcf98888ec33b26056edd00b75fab17615f0 --- /dev/null +++ b/test/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithZeroBasedOops.java @@ -0,0 +1,60 @@ +/* + * 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 + * 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.event.gc.configuration; + +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.EventVerifier; + +/* See the shell script wrapper for the flags used when invoking the JVM */ +public class TestGCHeapConfigurationEventWithZeroBasedOops extends GCHeapConfigurationEventTester { + public static void main(String[] args) throws Exception { + GCHeapConfigurationEventTester t = new TestGCHeapConfigurationEventWithZeroBasedOops(); + t.run(); + } + + @Override + protected EventVerifier createVerifier(RecordedEvent e) { + return new ZeroBasedOopsVerifier(e); + } +} + +class ZeroBasedOopsVerifier extends GCHeapConfigurationEventVerifier { + public ZeroBasedOopsVerifier(RecordedEvent e) { + super(e); + } + + @Override + public void verify() throws Exception { + // Can't verify min and initial heap size due to constraints on + // physical memory on tests machines + + verifyMaxHeapSizeIs(gigabytes(4)); + verifyUsesCompressedOopsIs(true); + verifyObjectAlignmentInBytesIs(8); + verifyHeapAddressBitsIs(32); + verifyCompressedOopModeIs("Zero based"); + } +} diff --git a/test/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithZeroBasedOops.sh b/test/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithZeroBasedOops.sh new file mode 100644 index 0000000000000000000000000000000000000000..04ae2818cbd01093636362da0c4261edb40441fe --- /dev/null +++ b/test/jdk/jfr/event/gc/configuration/TestGCHeapConfigurationEventWithZeroBasedOops.sh @@ -0,0 +1,60 @@ +# +# 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 +# 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 TestGCHeapConfigurationEventWithZeroBasedOops +# @key jfr +# +# +# @library /lib / +# @build jdk.jfr.event.gc.configuration.TestGCHeapConfigurationEventWithZeroBasedOops +# @run shell TestGCHeapConfigurationEventWithZeroBasedOops.sh + +uses_64_bit_testjava() { + ${TESTJAVA}/bin/java ${TESTVMOPTS} -version 2>&1 | grep '64-Bit' > /dev/null +} + +uses_windows_or_linux() { + case `uname -s` in + Linux | CYGWIN* | Windows* ) + return 0 + ;; + esac + return 1 +} + +TEST='jdk.jfr.event.gc.configuration.TestGCHeapConfigurationEventWithZeroBasedOops' + +OPTIONS='-XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:+UseCompressedOops -Xmx4g' + +if [ -z "${TESTCLASSPATH}" ]; then + echo "Using TESTCLASSES" + MY_CLASSPATH=${TESTCLASSES} +else + echo "Using TESTCLASSPATH" + MY_CLASSPATH=${TESTCLASSPATH} +fi + +if uses_windows_or_linux && uses_64_bit_testjava; then + printenv + echo "${TESTJAVA}/bin/java ${TESTVMOPTS} ${OPTIONS} -cp ${MY_CLASSPATH} ${TEST}" + ${TESTJAVA}/bin/java ${TESTVMOPTS} ${OPTIONS} -cp ${MY_CLASSPATH} ${TEST} +fi diff --git a/test/jdk/jfr/event/gc/configuration/TestGCSurvivorConfigurationEvent.java b/test/jdk/jfr/event/gc/configuration/TestGCSurvivorConfigurationEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..bef7a49ab1b713b677428ffedd9e6c544efa72a4 --- /dev/null +++ b/test/jdk/jfr/event/gc/configuration/TestGCSurvivorConfigurationEvent.java @@ -0,0 +1,76 @@ +/* + * 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 + * 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.event.gc.configuration; + +import static jdk.test.lib.Asserts.assertGreaterThanOrEqual; + +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.EventVerifier; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:MaxTenuringThreshold=13 -XX:InitialTenuringThreshold=9 jdk.jfr.event.gc.configuration.TestGCSurvivorConfigurationEvent + */ +public class TestGCSurvivorConfigurationEvent { + public static void main(String[] args) throws Exception { + Recording recording = new Recording(); + recording.enable(EventNames.GCSurvivorConfiguration); + recording.start(); + recording.stop(); + List events = Events.fromRecording(recording); + assertGreaterThanOrEqual(events.size(), 1, "Expected at least 1 event"); + GCSurvivorConfigurationEventVerifier verifier = new GCSurvivorConfigurationEventVerifier(events.get(0)); + verifier.verify(); + } +} + +class GCSurvivorConfigurationEventVerifier extends EventVerifier { + public GCSurvivorConfigurationEventVerifier(RecordedEvent event) { + super(event); + } + + public void verify() throws Exception { + verifyMaxTenuringThresholdIs(13); + verifyInitialTenuringThresholdIs(9); + } + + private void verifyMaxTenuringThresholdIs(int expected) throws Exception { + verifyEquals("maxTenuringThreshold", (byte)expected); + } + + private void verifyInitialTenuringThresholdIs(int expected) throws Exception { + verifyEquals("initialTenuringThreshold", (byte)expected); + } +} diff --git a/test/jdk/jfr/event/gc/configuration/TestGCTLABConfigurationEvent.java b/test/jdk/jfr/event/gc/configuration/TestGCTLABConfigurationEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..e81dd6da940bd95169fb8e6b8979cc8dd62d9a1c --- /dev/null +++ b/test/jdk/jfr/event/gc/configuration/TestGCTLABConfigurationEvent.java @@ -0,0 +1,86 @@ +/* + * 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 + * 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.event.gc.configuration; + +import static jdk.test.lib.Asserts.assertGreaterThanOrEqual; + +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.EventVerifier; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:+UseTLAB -XX:MinTLABSize=3k -XX:TLABRefillWasteFraction=96 jdk.jfr.event.gc.configuration.TestGCTLABConfigurationEvent + */ +public class TestGCTLABConfigurationEvent { + public static void main(String[] args) throws Exception { + Recording recording = new Recording(); + recording.enable(EventNames.GCTLABConfiguration); + recording.start(); + recording.stop(); + List events = Events.fromRecording(recording); + assertGreaterThanOrEqual(events.size(), 1, "Expected at least 1 event"); + GCTLABConfigurationEventVerifier verifier = new GCTLABConfigurationEventVerifier(events.get(0)); + verifier.verify(); + } +} + +class GCTLABConfigurationEventVerifier extends EventVerifier { + public GCTLABConfigurationEventVerifier(RecordedEvent event) { + super(event); + } + + @Override + public void verify() throws Exception { + verifyUsesTLABsIs(true); + verifyMinTLABSizeIs(kilobyte(3)); + verifyTLABRefillWasteLimitIs(96); + } + + void verifyUsesTLABsIs(boolean expected) throws Exception { + verifyEquals("usesTLABs", expected); + } + + void verifyMinTLABSizeIs(long expected) throws Exception { + verifyEquals("minTLABSize", expected); + } + + void verifyTLABRefillWasteLimitIs(long expected) throws Exception { + verifyEquals("tlabRefillWasteLimit", expected); + } + + private int kilobyte(int num) { + return 1024 * num; + } +} diff --git a/test/jdk/jfr/event/gc/configuration/TestGCYoungGenerationConfigurationEventWithMinAndMaxSize.java b/test/jdk/jfr/event/gc/configuration/TestGCYoungGenerationConfigurationEventWithMinAndMaxSize.java new file mode 100644 index 0000000000000000000000000000000000000000..bb1e776072be0bd416a5d670ae70f6ebdd5cf082 --- /dev/null +++ b/test/jdk/jfr/event/gc/configuration/TestGCYoungGenerationConfigurationEventWithMinAndMaxSize.java @@ -0,0 +1,88 @@ +/* + * 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 + * 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.event.gc.configuration; + +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.EventVerifier; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run driver jdk.jfr.event.gc.configuration.TestGCYoungGenerationConfigurationEventWithMinAndMaxSize + */ +public class TestGCYoungGenerationConfigurationEventWithMinAndMaxSize { + public static void main(String[] args) throws Exception { + String[] jvm_args = {"-XX:+UnlockExperimentalVMOptions", + "-XX:-UseFastUnorderedTimeStamps", + "-XX:NewSize=12m", + "-cp", + System.getProperty("java.class.path"), + "-XX:MaxNewSize=16m", + "-Xms32m", + "-Xmx64m", + Tester.class.getName()}; + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(jvm_args); + OutputAnalyzer analyzer = ProcessTools.executeProcess(pb); + analyzer.shouldHaveExitValue(0); + } +} + +class Tester extends GCYoungGenerationConfigurationEventTester { + public static void main(String[] args) throws Exception { + new Tester().run(); + } + + @Override protected EventVerifier createVerifier(RecordedEvent e) { + return new MinAndMaxSizeVerifier(e); + } +} + +class MinAndMaxSizeVerifier extends EventVerifier { + public MinAndMaxSizeVerifier(RecordedEvent e) { + super(e); + } + + @Override public void verify() throws Exception { + verifyMinSizeIs(megabytes(12)); + verifyMaxSizeIs(megabytes(16)); + + // Can't test newRatio at the same time as minSize and maxSize, + // because the NewRatio flag can't be set when the flags NewSize and + // MaxNewSize are set. + } + + private void verifyMinSizeIs(long expected) throws Exception { + verifyEquals("minSize", expected); + } + + private void verifyMaxSizeIs(long expected) throws Exception { + verifyEquals("maxSize", expected); + } +} diff --git a/test/jdk/jfr/event/gc/configuration/TestGCYoungGenerationConfigurationEventWithNewRatio.java b/test/jdk/jfr/event/gc/configuration/TestGCYoungGenerationConfigurationEventWithNewRatio.java new file mode 100644 index 0000000000000000000000000000000000000000..556cbefa8fc26b7727ba12919bd0c4356e72bd58 --- /dev/null +++ b/test/jdk/jfr/event/gc/configuration/TestGCYoungGenerationConfigurationEventWithNewRatio.java @@ -0,0 +1,66 @@ +/* + * 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 + * 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.event.gc.configuration; + +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.EventVerifier; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:NewRatio=4 jdk.jfr.event.gc.configuration.TestGCYoungGenerationConfigurationEventWithNewRatio + */ +public class TestGCYoungGenerationConfigurationEventWithNewRatio + extends GCYoungGenerationConfigurationEventTester { + public static void main(String[] args) throws Exception { + GCYoungGenerationConfigurationEventTester t = new TestGCYoungGenerationConfigurationEventWithNewRatio(); + t.run(); + } + + @Override protected EventVerifier createVerifier(RecordedEvent e) { + return new NewRatioVerifier(e); + } +} + +class NewRatioVerifier extends EventVerifier { + public NewRatioVerifier(RecordedEvent event) { + super(event); + } + + @Override public void verify() throws Exception { + verifyNewRatioIs(4); + + // Can't test minSize and maxSize at the same time as newRatio, + // because the NewSize and MaxNewSize flags can't be set when the flag + // MaxNewSize is set. + } + + private void verifyNewRatioIs(int expected) throws Exception { + verifyEquals("newRatio", expected); + } +} diff --git a/test/jdk/jfr/event/gc/detailed/ExecuteOOMApp.java b/test/jdk/jfr/event/gc/detailed/ExecuteOOMApp.java new file mode 100644 index 0000000000000000000000000000000000000000..03158ea0031a62e2adbfa9bef5b5dc47cac79f2f --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/ExecuteOOMApp.java @@ -0,0 +1,63 @@ +/* + * 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. 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.event.gc.detailed; + +import jdk.test.lib.jfr.AppExecutorHelper; +import jdk.test.lib.process.OutputAnalyzer; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class ExecuteOOMApp { + /** + * Executes OOM application with JFR recording and returns true if OOM error happened in the + * test thread. Adds -XX:-UseGCOverheadLimit option to avoid "java.lang.OutOfMemoryError: GC overhead limit exceeded". + * + * @param settings JFR settings file + * @param jfrFilename JFR resulting recording filename + * @param additionalVmFlags additional VM flags passed to the java + * @param bytesToAllocate number of bytes to allocate in new object every cycle in OOM application + * @return true - OOM application is finished as expected,i.e. OOM happened in the test thead + * false - OOM application is finished with OOM error which happened in the non test thread + */ + public static boolean execute(String settings, String jfrFilename, String[] additionalVmFlags, int bytesToAllocate) throws Exception { + List additionalVmFlagsList = new ArrayList<>(Arrays.asList(additionalVmFlags)); + additionalVmFlagsList.add("-XX:-UseGCOverheadLimit"); + + OutputAnalyzer out = AppExecutorHelper.executeAndRecord(settings, jfrFilename, additionalVmFlagsList.toArray(new String[0]), + OOMApp.class.getName(), String.valueOf(bytesToAllocate)); + + if ((out.getExitValue() == 1 && out.getOutput().contains("Exception: java.lang.OutOfMemoryError"))) { + return false; + } + + out.shouldHaveExitValue(0); + System.out.println(out.getOutput()); + + return true; + } +} diff --git a/test/jdk/jfr/event/gc/detailed/OOMApp.java b/test/jdk/jfr/event/gc/detailed/OOMApp.java new file mode 100644 index 0000000000000000000000000000000000000000..48d97268182db78b8897d0d11f71bcf260af3521 --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/OOMApp.java @@ -0,0 +1,68 @@ +/* + * 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. 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.event.gc.detailed; + +import java.util.List; +import java.util.LinkedList; + +/** + * Helper class which triggers and handles out of memory error to generate + * JFR events + */ +public class OOMApp { + + public static List dummyList; + + public static void main(String[] args) { + int bytesToAllocate; + + if (args.length > 0) { + bytesToAllocate = Integer.parseInt(args[0]); + } else { + bytesToAllocate = 1024; + } + System.gc(); + dummyList = new LinkedList(); + System.out.println("## Initiate OOM ##"); + try { + while (true) { + dummyList.add(new DummyObject(bytesToAllocate)); + } + } catch (OutOfMemoryError e) { + System.out.println("## Got OOM ##"); + dummyList = null; + } + System.gc(); + } + + public static class DummyObject { + public byte[] payload; + + DummyObject(int bytesToAllocate) { + payload = new byte[bytesToAllocate]; + } + } +} diff --git a/test/jdk/jfr/event/gc/detailed/PromotionEvent.java b/test/jdk/jfr/event/gc/detailed/PromotionEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..c3fa2e9ae9d13fdf9b363bbdce27db23e7472f81 --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/PromotionEvent.java @@ -0,0 +1,205 @@ +/* + * 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 + * 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.event.gc.detailed; + +import static jdk.test.lib.Asserts.assertEquals; +import static jdk.test.lib.Asserts.assertNotEquals; +import static jdk.test.lib.Asserts.assertNotNull; +import static jdk.test.lib.Asserts.assertTrue; + +import java.lang.management.GarbageCollectorMXBean; +import java.lang.management.ManagementFactory; +import java.util.List; +import java.util.concurrent.ThreadLocalRandom; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * This is a base class for testing Promotion Events + * + * See TestPromotionEventWith* for actual test classes. Tests must set + * -XX:MaxTenuringThreshold=5 -XX:InitialTenuringThreshold=5 + * + * @author Staffan Friberg + */ +public class PromotionEvent { + + private final static String PROMOTION_IN_NEW_PLAB_NAME = EventNames.PromoteObjectInNewPLAB; + private final static String PROMOTION_OUTSIDE_PLAB_NAME = EventNames.PromoteObjectOutsidePLAB; + + // This value needs to match the command line option set above + private final static int MAX_TENURING_THRESHOLD = 5; + + // Keep track of the collection count just before and after JFR recording + private static int startGCCount = 0; + + // Dummy objects to keep things alive and assure allocation happens + public static Object dummy; + public static Object[] keepAlive = new Object[128]; + public static Object[] age = new Object[128]; + + public static void test() throws Exception { + GarbageCollectorMXBean ycBean = null; + + List gcBeans = ManagementFactory.getGarbageCollectorMXBeans(); + for (GarbageCollectorMXBean gcBean : gcBeans) { + if ("PS Scavenge".equals(gcBean.getName()) + || "G1 Young Generation".equals(gcBean.getName()) + || ("ParNew".equals(gcBean.getName()))) { + ycBean = gcBean; + } + + if (ycBean != null) { + break; + } + } + + if (ycBean == null) { + assertNotNull(ycBean, "Test failed since the MXBean for the Young Collector could not be found."); + return; // To remove IDE warning + } + + System.gc(); // Clear nusery before recording + + // Get total GC count before recording + for (GarbageCollectorMXBean gcBean : gcBeans) { + startGCCount += gcBean.getCollectionCount(); + } + + Recording recording = new Recording(); + recording.enable(PROMOTION_IN_NEW_PLAB_NAME); + recording.enable(PROMOTION_OUTSIDE_PLAB_NAME); + recording.start(); + + byte[] largeBytes = new byte[1024 * 10]; + byte[] smallBytes = new byte[64]; + + // Some large strings to keep alive for tenuring + for (int i = 0; i < keepAlive.length / 2; i++) { + ThreadLocalRandom.current().nextBytes(largeBytes); + keepAlive[i] = new String(largeBytes); + } + + // Some small strings to keep alive for tenuring + for (int i = keepAlive.length / 2; i < keepAlive.length; i++) { + ThreadLocalRandom.current().nextBytes(smallBytes); + keepAlive[i] = new String(smallBytes); + } + + // Allocate temp data to force GCs until we have promoted the live data + for (int gcCount = 0; gcCount < MAX_TENURING_THRESHOLD * 2; gcCount++) { + long currentGCCount = ycBean.getCollectionCount(); + + // some large strings to age + for (int i = 0; i < age.length / 2; i++) { + ThreadLocalRandom.current().nextBytes(largeBytes); + age[i] = new String(largeBytes); + } + + // Some small strings to age + for (int i = age.length / 2; i < age.length; i++) { + ThreadLocalRandom.current().nextBytes(smallBytes); + age[i] = new String(smallBytes); + } + + while (ycBean.getCollectionCount() <= currentGCCount + 3) { + ThreadLocalRandom.current().nextBytes(smallBytes); + dummy = new String(smallBytes); + } + } + + recording.stop(); + + List events = Events.fromRecording(recording); + + verifyPromotionSampleEvents(events); + + recording.close(); + } + + private static void verifyPromotionSampleEvents(List events) + throws Exception { + + boolean objectWasPromotedInNewPLAB = false; + boolean objectPromotedInNewPLABWasAged = false; + boolean objectPromotedInNewPLABWasTenured = false; + boolean objectWasPromotedOutsidePLAB = false; + boolean objectPromotedOutsidePLABWasAged = false; + boolean objectPromotedOutsidePLABWasTenured = false; + + Events.hasEvents(events); + + for (RecordedEvent event : events) { + // Read all common fields + Events.assertField(event, "gcId").atLeast(startGCCount).getValue(); + String className = (event.getEventType()).getName().toString(); + Events.assertField(event, "tenuringAge").atLeast(0).atMost(MAX_TENURING_THRESHOLD).getValue(); + Boolean tenured = Events.assertField(event, "tenured").getValue(); + Long objectSize = Events.assertField(event, "objectSize").above(0L).getValue(); + + // Verify Class Name + assertNotNull(className, "Class name is null. Event: " + event); + assertNotEquals(className.length(), 0, "Class name is of zero length. Event: " + event); + + // Verify PLAB size and direct allocation + if (PROMOTION_IN_NEW_PLAB_NAME.equals(event.getEventType().getName())) { + // Read event specific fields + Long plabSize = Events.assertField(event, "plabSize").above(0L).getValue(); + assertTrue(plabSize >= objectSize, "PLAB size is smaller than object size. Event: " + event); + objectWasPromotedInNewPLAB = true; + // Verify tenured is hard to do as objects might be tenured earlier than the max threshold + // but at least verify that we got the field set at least once during the test + if (tenured) { + objectPromotedInNewPLABWasTenured = true; + } else { + objectPromotedInNewPLABWasAged = true; + } + } else if (PROMOTION_OUTSIDE_PLAB_NAME.equals(event.getEventType().getName())) { + objectWasPromotedOutsidePLAB = true; + // Verify tenured is hard to do as objects might be tenured earlier than the max threshold + // but at least verify that we got the field set at least once during the test + if (tenured) { + objectPromotedOutsidePLABWasTenured = true; + } else { + objectPromotedOutsidePLABWasAged = true; + } + } else { + assertEquals(event.getEventType().getName(), "Unreachable...", "Got wrong type of event " + event); + } + + } + + // Verify that at least one event of these types occured during test + assertTrue(objectWasPromotedInNewPLAB, "No object in new plab was promoted in test"); + assertTrue(objectPromotedInNewPLABWasAged, "No object in new plab was aged in test"); + assertTrue(objectPromotedInNewPLABWasTenured, "No object in new plab was tenured in test"); + assertTrue(objectWasPromotedOutsidePLAB, "No object outside plab was promoted in test"); + assertTrue(objectPromotedOutsidePLABWasAged, "No object outside plab was aged in test"); + assertTrue(objectPromotedOutsidePLABWasTenured, "No object outside plab was tenured in test"); + } +} diff --git a/test/jdk/jfr/event/gc/detailed/PromotionFailedEvent.java b/test/jdk/jfr/event/gc/detailed/PromotionFailedEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..f075aedc699faf7e6a65df8a8e7356a04c983862 --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/PromotionFailedEvent.java @@ -0,0 +1,63 @@ +/* + * 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 + * 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.event.gc.detailed; + +import java.io.File; +import java.nio.file.Paths; +import java.util.List; + +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +public class PromotionFailedEvent { + + private final static String EVENT_SETTINGS_FILE = System.getProperty("test.src", ".") + File.separator + "promotionfailed-testsettings.jfc"; + private final static int BYTES_TO_ALLOCATE = 1024; + + public static void test(String testName, String[] vmFlags) throws Throwable { + String jfr_file = testName + ".jfr"; + + if (!ExecuteOOMApp.execute(EVENT_SETTINGS_FILE, jfr_file, vmFlags, BYTES_TO_ALLOCATE)) { + System.out.println("OOM happened in the other thread(not test thread). Skip test."); + // Skip test, process terminates due to the OOME error in the different thread + return; + } + + // This test can not always trigger the expected event. + // Test is ok even if no events found. + List events = RecordingFile.readAllEvents(Paths.get(jfr_file)); + for (RecordedEvent event : events) { + System.out.println("Event: " + event); + long smallestSize = Events.assertField(event, "promotionFailed.smallestSize").atLeast(1L).getValue(); + long firstSize = Events.assertField(event, "promotionFailed.firstSize").atLeast(smallestSize).getValue(); + long totalSize = Events.assertField(event, "promotionFailed.totalSize").atLeast(firstSize).getValue(); + long objectCount = Events.assertField(event, "promotionFailed.objectCount").atLeast(1L).getValue(); + Asserts.assertLessThanOrEqual(smallestSize * objectCount, totalSize, "smallestSize * objectCount <= totalSize"); + } + } +} diff --git a/test/jdk/jfr/event/gc/detailed/StressAllocationGCEvents.java b/test/jdk/jfr/event/gc/detailed/StressAllocationGCEvents.java new file mode 100644 index 0000000000000000000000000000000000000000..f61349dc8c7aee542f9b8abaa3c654d407f543a4 --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/StressAllocationGCEvents.java @@ -0,0 +1,201 @@ +/* + * 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. 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.event.gc.detailed; + +import static jdk.test.lib.Asserts.assertEquals; +import static jdk.test.lib.Asserts.assertNotEquals; +import static jdk.test.lib.Asserts.assertTrue; + +import java.util.List; +import java.util.Random; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Semaphore; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedFrame; +import jdk.jfr.consumer.RecordedStackTrace; +import jdk.jfr.consumer.RecordedThread; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * Starts several threads which allocate a lot of objects that remain in young + * and old generations with defined ratio. Expects event + * vm/gc/detailed/allocation_requiring_gc recorded. + */ +public class StressAllocationGCEvents { + + private Semaphore threadsCompleted; + + public void run(String[] args) throws Exception { + threadsCompleted = new Semaphore(0); + System.out.println("Total memory= " + Runtime.getRuntime().maxMemory() + " bytes"); + + int obj_size = DEFAULT_OBJ_SIZE; + if (args.length > 0) { + obj_size = Integer.parseInt(args[0]); + } + + System.out.println("Objects size= " + obj_size + " bytes"); + ExecutorService executor + = Executors.newFixedThreadPool(THREAD_COUNT, new NamedThreadFactory()); + Recording r = new Recording(); + r.enable(EVENT_NAME_ALLOCATION_REQUIRING_GC); + r.start(); + + System.out.println("Starting " + THREAD_COUNT + " threads"); + + for (int i = 0; i < THREAD_COUNT; i++) { + executor.execute(new Runner(obj_size)); + } + + // Wait for all threads to complete + threadsCompleted.acquire(THREAD_COUNT); + executor.shutdownNow(); + + if (!executor.awaitTermination(10, TimeUnit.SECONDS)) { + System.err.println("Thread pool did not terminate after 10 seconds after shutdown"); + } + + r.stop(); + + List allocationEvents + = Events.fromRecording(r); + + System.out.println(EVENT_NAME_ALLOCATION_REQUIRING_GC + " " + allocationEvents.size()); + + Events.hasEvents(allocationEvents); + + // check stacktrace depth + for (RecordedEvent event : allocationEvents) { + checkEvent(event); + } + } + + class Runner extends Thread { + + public Runner(int obj_size) { + this.startTime = System.currentTimeMillis(); + this.OBJ_SIZE = obj_size; + this.OLD_OBJ_COUNT = Math.max(1, (int) ((float) Runtime.getRuntime().maxMemory() / 2 / THREAD_COUNT / OBJ_SIZE)); + this.old_garbage = new Object[OLD_OBJ_COUNT]; + + System.out.println(String.format("In \"%s\" old objects count = %d, recursion depth = %d", + this.getName(), OLD_OBJ_COUNT, RECURSION_DEPTH)); + } + + @Override + public void run() { + diver(RECURSION_DEPTH); + threadsCompleted.release(); + System.out.println("Completed after " + (System.currentTimeMillis() - startTime) + " ms"); + } + + private void diver(int stack) { + if (stack > 1) { + diver(stack - 1); + } else { + long endTime = startTime + (SECONDS_TO_RUN * 1000); + Random r = new Random(startTime); + while (endTime > System.currentTimeMillis()) { + byte[] garbage = new byte[OBJ_SIZE]; + if (r.nextInt(100) > OLD_GEN_RATE) { + old_garbage[r.nextInt(OLD_OBJ_COUNT)] = garbage; + } + } + } + } + + private final long startTime; + private final Object[] old_garbage; + private final int OBJ_SIZE; + private final int OLD_OBJ_COUNT; + } + + ///< check stacktrace depth + private void checkEvent(RecordedEvent event) throws Exception { + // skip check if allocation failure comes not from diver + + RecordedThread thread = event.getThread(); + String threadName = thread.getJavaName(); + + if (!threadName.contains(THREAD_NAME)) { + System.out.println("Skip event not from pool (from internals)"); + System.out.println(" Thread Id: " + thread.getJavaThreadId() + + " Thread name: " + threadName); + return; + } + + RecordedStackTrace stackTrace = event.getStackTrace(); + + List frames = stackTrace.getFrames(); + //String[] stacktrace = StackTraceHelper.buildStackTraceFromFrames(frames); + + if (!(frames.get(0).getMethod().getName().equals(DIVER_FRAME_NAME))) { + System.out.println("Skip stacktrace check for: \n" + + String.join("\n", threadName)); + return; + } + + assertTrue(frames.size() > RECURSION_DEPTH, + "Stack trace should contain at least one more entry than the ones generated by the test recursion"); + for (int i = 0; i < RECURSION_DEPTH; i++) { + assertEquals(frames.get(i).getMethod().getName(), DIVER_FRAME_NAME, + "Frame " + i + " is wrong: \n" + + String.join("\n", threadName)); + } + assertNotEquals(frames.get(RECURSION_DEPTH).getMethod().getName(), DIVER_FRAME_NAME, + "Too many diver frames: \n" + + String.join("\n", threadName)); + } + + class NamedThreadFactory implements ThreadFactory { + + private int threadNum = 0; + + @Override + public Thread newThread(Runnable r) { + return new Thread(r, THREAD_NAME + (threadNum++)); + } + } + + // Because each thread will keep some number of objects live we need to limit + // the number of threads to ensure we don't run out of heap space. The big + // allocation tests uses 256m heap and 1m allocations, so a 64 thread limit + // should be fine. + private final static int THREAD_COUNT_LIMIT = 64; + private final static int THREAD_COUNT = Math.min(1 + (int) (Runtime.getRuntime().availableProcessors() * 2), THREAD_COUNT_LIMIT); + private final static int SECONDS_TO_RUN = 60; + private final static int DEFAULT_OBJ_SIZE = 1024; + private final static int OLD_GEN_RATE = 60; // from 0 to 100 + private final static int RECURSION_DEPTH = 5; + private final static String EVENT_NAME_ALLOCATION_REQUIRING_GC = EventNames.AllocationRequiringGC; + private static final String THREAD_NAME = "JFRTest-"; + private static final String DIVER_FRAME_NAME = "StressAllocationGCEvents$Runner.diver"; +} diff --git a/test/jdk/jfr/event/gc/detailed/TestCMSConcurrentModeFailureEvent.java b/test/jdk/jfr/event/gc/detailed/TestCMSConcurrentModeFailureEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..ab56d8549c70e355fb61ac90b8c0556cc03fff1d --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/TestCMSConcurrentModeFailureEvent.java @@ -0,0 +1,88 @@ +/* + * 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 + * 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.event.gc.detailed; + +import java.io.IOException; +import java.io.File; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Optional; + +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; + +/** + * @test + * @key jfr + * + * + * + * @library /lib / + * + * @run main jdk.jfr.event.gc.detailed.TestCMSConcurrentModeFailureEvent + */ +public class TestCMSConcurrentModeFailureEvent { + + private final static String EVENT_NAME = EventNames.ConcurrentModeFailure; + private final static String EVENT_SETTINGS_FILE = System.getProperty("test.src", ".") + File.separator + "concurrentmodefailure-testsettings.jfc"; + private final static String JFR_FILE = "TestCMSConcurrentModeFailureEvent.jfr"; + private final static int BYTES_TO_ALLOCATE = 1024 * 512; + + public static void main(String[] args) throws Exception { + String[] vmFlags = {"-Xmx128m", "-XX:MaxTenuringThreshold=0", "-Xloggc:testCMSGC.log", "-verbose:gc", + "-XX:+UseConcMarkSweepGC", "-XX:+UnlockExperimentalVMOptions", "-XX:-UseFastUnorderedTimeStamps"}; + + if (!ExecuteOOMApp.execute(EVENT_SETTINGS_FILE, JFR_FILE, vmFlags, BYTES_TO_ALLOCATE)) { + System.out.println("OOM happened in the other thread(not test thread). Skip test."); + // Skip test, process terminates due to the OOME error in the different thread + return; + } + + Optional event = RecordingFile.readAllEvents(Paths.get(JFR_FILE)).stream().findFirst(); + if (event.isPresent()) { + Asserts.assertEquals(EVENT_NAME, event.get().getEventType().getName(), "Wrong event type"); + } else { + // No event received. Check if test did trigger the event. + boolean isEventTriggered = fileContainsString("testCMSGC.log", "concurrent mode failure"); + System.out.println("isEventTriggered=" +isEventTriggered); + Asserts.assertFalse(isEventTriggered, "Event found in log, but not in JFR"); + } + } + + private static boolean fileContainsString(String filename, String text) throws IOException { + Path p = Paths.get(filename); + for (String line : Files.readAllLines(p, Charset.defaultCharset())) { + if (line.contains(text)) { + return true; + } + } + return false; + } +} diff --git a/test/jdk/jfr/event/gc/detailed/TestEvacuationFailedEvent.java b/test/jdk/jfr/event/gc/detailed/TestEvacuationFailedEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..c2f101831ec52bd95bba016ca1343da61c55d271 --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/TestEvacuationFailedEvent.java @@ -0,0 +1,75 @@ +/* + * 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 + * 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.event.gc.detailed; + +import java.io.File; +import java.nio.file.Paths; +import java.util.List; + +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * + * + * @run main jdk.jfr.event.gc.detailed.TestEvacuationFailedEvent + */ +public class TestEvacuationFailedEvent { + + private final static String EVENT_SETTINGS_FILE = System.getProperty("test.src", ".") + File.separator + "evacuationfailed-testsettings.jfc"; + private final static String JFR_FILE = "TestEvacuationFailedEvent.jfr"; + private final static int BYTES_TO_ALLOCATE = 1024 * 512; + + public static void main(String[] args) throws Exception { + String[] vmFlags = {"-XX:+UnlockExperimentalVMOptions", "-XX:-UseFastUnorderedTimeStamps", + "-Xmx64m", "-Xmn60m", "-XX:-UseDynamicNumberOfGCThreads", "-XX:ParallelGCThreads=3", + "-XX:MaxTenuringThreshold=0", "-verbose:gc", "-XX:+UseG1GC"}; + + if (!ExecuteOOMApp.execute(EVENT_SETTINGS_FILE, JFR_FILE, vmFlags, BYTES_TO_ALLOCATE)) { + System.out.println("OOM happened in the other thread(not test thread). Skip test."); + // Skip test, process terminates due to the OOME error in the different thread + return; + } + + List events = RecordingFile.readAllEvents(Paths.get(JFR_FILE)); + + Events.hasEvents(events); + for (RecordedEvent event : events) { + long objectCount = Events.assertField(event, "evacuationFailed.objectCount").atLeast(1L).getValue(); + long smallestSize = Events.assertField(event, "evacuationFailed.smallestSize").atLeast(1L).getValue(); + long firstSize = Events.assertField(event, "evacuationFailed.firstSize").atLeast(smallestSize).getValue(); + long totalSize = Events.assertField(event, "evacuationFailed.totalSize").atLeast(firstSize).getValue(); + Asserts.assertLessThanOrEqual(smallestSize * objectCount, totalSize, "smallestSize * objectCount <= totalSize"); + } + } +} diff --git a/test/jdk/jfr/event/gc/detailed/TestEvacuationInfoEvent.java b/test/jdk/jfr/event/gc/detailed/TestEvacuationInfoEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..a625e7b24b5b796b9af033f854984896408c73d7 --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/TestEvacuationInfoEvent.java @@ -0,0 +1,137 @@ +/* + * 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 + * 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.event.gc.detailed; + +import java.time.Duration; +import java.util.List; +import java.util.Optional; +import java.util.Random; + +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; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:G1HeapRegionSize=1m -Xmx64m -Xmn16m -XX:+UseG1GC jdk.jfr.event.gc.detailed.TestEvacuationInfoEvent + */ +public class TestEvacuationInfoEvent { + private final static String EVENT_INFO_NAME = EventNames.EvacuationInformation; + private final static String EVENT_FAILED_NAME = EventNames.EvacuationFailed; + + public static void main(String[] args) throws Throwable { + final long g1HeapRegionSize = 1024 * 1024; + Recording recording = new Recording(); + recording.enable(EVENT_INFO_NAME).withThreshold(Duration.ofMillis(0)); + recording.enable(EVENT_FAILED_NAME).withThreshold(Duration.ofMillis(0)); + recording.start(); + allocate(); + recording.stop(); + + List events = Events.fromRecording(recording); + Asserts.assertFalse(events.isEmpty(), "No events found"); + for (RecordedEvent event : events) { + if (!Events.isEventType(event, EVENT_INFO_NAME)) { + continue; + } + System.out.println("Event: " + event); + + int setRegions = Events.assertField(event, "cSetRegions").atLeast(0).getValue(); + long setUsedAfter = Events.assertField(event, "cSetUsedAfter").atLeast(0L).getValue(); + long setUsedBefore = Events.assertField(event, "cSetUsedBefore").atLeast(setUsedAfter).getValue(); + int allocationRegions = Events.assertField(event, "allocationRegions").atLeast(0).getValue(); + long allocRegionsUsedBefore = Events.assertField(event, "allocationRegionsUsedBefore").atLeast(0L).getValue(); + long allocRegionsUsedAfter = Events.assertField(event, "allocationRegionsUsedAfter").atLeast(0L).getValue(); + long bytesCopied = Events.assertField(event, "bytesCopied").atLeast(0L).getValue(); + int regionsFreed = Events.assertField(event, "regionsFreed").atLeast(0).getValue(); + + Asserts.assertEquals(allocRegionsUsedBefore + bytesCopied, allocRegionsUsedAfter, "allocRegionsUsedBefore + bytesCopied = allocRegionsUsedAfter"); + Asserts.assertGreaterThanOrEqual(setRegions, regionsFreed, "setRegions >= regionsFreed"); + Asserts.assertGreaterThanOrEqual(g1HeapRegionSize * allocationRegions, allocRegionsUsedAfter, "G1HeapRegionSize * allocationRegions >= allocationRegionsUsedAfter"); + Asserts.assertGreaterThanOrEqual(g1HeapRegionSize * setRegions, setUsedAfter, "G1HeapRegionSize * setRegions >= setUsedAfter"); + Asserts.assertGreaterThanOrEqual(g1HeapRegionSize * setRegions, setUsedBefore, "G1HeapRegionSize * setRegions >= setUsedBefore"); + Asserts.assertGreaterThanOrEqual(g1HeapRegionSize, allocRegionsUsedBefore, "G1HeapRegionSize >= allocRegionsUsedBefore"); + + int gcId = Events.assertField(event, "gcId").getValue(); + boolean isEvacuationFailed = containsEvacuationFailed(events, gcId); + if (isEvacuationFailed) { + Asserts.assertGreaterThan(setUsedAfter, 0L, "EvacuationFailure -> setUsedAfter > 0"); + Asserts.assertGreaterThan(setRegions, regionsFreed, "EvacuationFailure -> setRegions > regionsFreed"); + } else { + Asserts.assertEquals(setUsedAfter, 0L, "No EvacuationFailure -> setUsedAfter = 0"); + Asserts.assertEquals(setRegions, regionsFreed, "No EvacuationFailure -> setRegions = regionsFreed"); + } + } + } + + private static boolean containsEvacuationFailed(List events, int gcId) { + Optional failedEvent = events.stream() + .filter(e -> Events.isEventType(e, EVENT_FAILED_NAME)) + .filter(e -> gcId == (int)Events.assertField(e, "gcId").getValue()) + .findAny(); + System.out.println("Failed event: " + (failedEvent.isPresent() ? failedEvent.get() : "None")); + return failedEvent.isPresent(); + } + + public static DummyObject[] dummys = new DummyObject[6000]; + + /** + * Allocate memory to trigger garbage collections. + * We want the allocated objects to have different life time, because we want both "young" and "old" objects. + * This is done by keeping the objects in an array and step the current index by a small random number in the loop. + * The loop will continue until we have allocated a fixed number of bytes. + */ + private static void allocate() { + Random r = new Random(0); + long bytesToAllocate = 256 * 1024 * 1024; + int currPos = 0; + while (bytesToAllocate > 0) { + int allocSize = 1000 + (r.nextInt(4000)); + bytesToAllocate -= allocSize; + dummys[currPos] = new DummyObject(allocSize); + + // Skip a few positions to get different duration on the objects. + currPos = (currPos + r.nextInt(20)) % dummys.length; + } + for (int c=0; c event = RecordingFile.readAllEvents(Paths.get(JFR_FILE)).stream().findFirst(); + if (event.isPresent()) { + Asserts.assertEquals(EVENT_NAME, event.get().getEventType().getName(), "Wrong event type"); + } else { + // No event received. Check if test did trigger the event. + boolean isEventTriggered = fileContainsString("testG1GC.log", "concurrent-mark-abort"); + System.out.println("isEventTriggered=" +isEventTriggered); + Asserts.assertFalse(isEventTriggered, "Event found in log, but not in JFR"); + } + } + + private static boolean fileContainsString(String filename, String text) throws IOException { + Path p = Paths.get(filename); + for (String line : Files.readAllLines(p, Charset.defaultCharset())) { + if (line.contains(text)) { + return true; + } + } + return false; + } +} diff --git a/test/jdk/jfr/event/gc/detailed/TestG1EvacMemoryStatsEvent.java b/test/jdk/jfr/event/gc/detailed/TestG1EvacMemoryStatsEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..b23e13d268adc69aaf4ce4bcb922fad7501de323 --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/TestG1EvacMemoryStatsEvent.java @@ -0,0 +1,76 @@ +/* + * 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. 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.event.gc.detailed; + +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; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:NewSize=2m -XX:MaxNewSize=2m -Xmx32m -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps jdk.jfr.event.gc.detailed.TestG1EvacMemoryStatsEvent + */ +public class TestG1EvacMemoryStatsEvent { + + public static byte[] bytes; + + public static void runTest(String event_name) throws Exception { + + Recording recording = new Recording(); + + // activate the event we are interested in and start recording + recording.enable(event_name); + recording.start(); + + // Setting NewSize and MaxNewSize will limit eden, so + // allocating 1024 5k byte arrays should trigger at + // least one Young GC. + for (int i = 0; i < 1024; i++) { + bytes = new byte[5 * 1024]; + } + recording.stop(); + + // Verify recording + List all = Events.fromRecording(recording); + for (RecordedEvent e : all) { + Events.assertField(e, "statistics.gcId").above(0); + } + + recording.close(); + } + + public static void main(String[] args) throws Exception { + runTest(EventNames.G1EvacuationYoungStatistics); + runTest(EventNames.G1EvacuationOldStatistics); + } + +} diff --git a/test/jdk/jfr/event/gc/detailed/TestG1HeapRegionInformationEvent.java b/test/jdk/jfr/event/gc/detailed/TestG1HeapRegionInformationEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..027c72ac5c0e95474e39ae9a77c7eeaa8c3db292 --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/TestG1HeapRegionInformationEvent.java @@ -0,0 +1,74 @@ +/* + * 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. 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.event.gc.detailed; + +import java.nio.file.Paths; +import java.util.List; + +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.EventNames; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.GCHelper; + +public class TestG1HeapRegionInformationEvent { + private final static String EVENT_NAME = EventNames.G1HeapRegionInformation; + public static void main(String[] args) throws Exception { + Recording recording = null; + try { + recording = new Recording(); + // activate the event we are interested in and start recording + for (EventType t : FlightRecorder.getFlightRecorder().getEventTypes()) { + System.out.println(t.getName()); + } + recording.enable(EVENT_NAME); + recording.start(); + recording.stop(); + + // Verify recording + List events = Events.fromRecording(recording); + Events.hasEvents(events); + + for (RecordedEvent event : events) { + Events.assertField(event, "index").notEqual(-1); + Asserts.assertTrue(GCHelper.isValidG1HeapRegionType(Events.assertField(event, "type").getValue())); + Events.assertField(event, "used").atMost(1L*1024*1024); + } + + } catch (Throwable t) { + if (recording != null) { + recording.dump(Paths.get("TestG1HeapRegionInformationEvent.jfr")); + } + throw t; + } finally { + if (recording != null) { + recording.close(); + } + } + } +} diff --git a/test/jdk/jfr/event/gc/detailed/TestG1HeapRegionTypeChangeEvent.java b/test/jdk/jfr/event/gc/detailed/TestG1HeapRegionTypeChangeEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..1e4c7c5120aaaadccce0a8693cd4f68b31e9f651 --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/TestG1HeapRegionTypeChangeEvent.java @@ -0,0 +1,89 @@ +/* + * 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. 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.event.gc.detailed; + +import java.nio.file.Paths; +import java.time.Duration; +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.jfr.GCHelper; + +/** + * @test + * @bug 8149650 + * + * + * @key jfr + * @library /lib / + * @run main/othervm -XX:NewSize=2m -XX:MaxNewSize=2m -Xmx32m -XX:G1HeapRegionSize=1m -XX:+UseG1GC jdk.jfr.event.gc.detailed.TestG1HeapRegionTypeChangeEvent + */ + +public class TestG1HeapRegionTypeChangeEvent { + private final static String EVENT_NAME = EventNames.G1HeapRegionTypeChange; + + public static void main(String[] args) throws Exception { + Recording recording = null; + try { + recording = new Recording(); + // activate the event we are interested in and start recording + recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(0)); + recording.start(); + + // Setting NewSize and MaxNewSize will limit eden, so + // allocating 1024 20k byte arrays should trigger at + // least a few Young GCs. + byte[][] array = new byte[1024][]; + for (int i = 0; i < array.length; i++) { + array[i] = new byte[20 * 1024]; + } + recording.stop(); + + // Verify recording + List events = Events.fromRecording(recording); + Asserts.assertFalse(events.isEmpty(), "No events found"); + + for (RecordedEvent event : events) { + Events.assertField(event, "index").notEqual(-1); + Asserts.assertTrue(GCHelper.isValidG1HeapRegionType(Events.assertField(event, "from").getValue())); + Asserts.assertTrue(GCHelper.isValidG1HeapRegionType(Events.assertField(event, "to").getValue())); + Events.assertField(event, "used").atMost(1L*1024*1024); + } + } catch (Throwable t) { + if (recording != null) { + recording.dump(Paths.get("TestG1HeapRegionTypeChangeEvent.jfr")); + } + throw t; + } finally { + if (recording != null) { + recording.close(); + } + } + } +} diff --git a/test/jdk/jfr/event/gc/detailed/TestG1MMUEvent.java b/test/jdk/jfr/event/gc/detailed/TestG1MMUEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..9c5eb7e9465b3357ce7dc174255d41e14cbc0152 --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/TestG1MMUEvent.java @@ -0,0 +1,82 @@ +/* + * 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. 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.event.gc.detailed; + +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; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:NewSize=2m -XX:MaxNewSize=2m -Xmx32m -XX:+UseG1GC -XX:MaxGCPauseMillis=75 -XX:GCPauseIntervalMillis=150 -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps jdk.jfr.event.gc.detailed.TestG1MMUEvent + */ +public class TestG1MMUEvent { + + // Corresponds to command-line setting -XX:GCPauseIntervalMillis=150 + private final static double TIME_SLICE = 0.15; + + // Corresponds to command-line setting -XX:MaxGCPauseMillis=75 + private final static double MAX_GC_TIME = 0.075; + + private final static String EVENT_NAME = EventNames.G1MMU; + + public static byte[] bytes; + + public static void main(String[] args) throws Exception { + + Recording recording = new Recording(); + + // activate the event we are interested in and start recording + recording.enable(EVENT_NAME); + recording.start(); + + // Setting NewSize and MaxNewSize will limit eden, so + // allocating 1024 5k byte arrays should trigger at + // least one Young GC. + for (int i = 0; i < 1024; i++) { + bytes = new byte[5 * 1024]; + } + recording.stop(); + + // Verify recording + List all = Events.fromRecording(recording); + Events.hasEvents(all); + + for (RecordedEvent e : all) { + Events.assertField(e, "gcId").above(0); + Events.assertField(e, "timeSlice").isEqual(TIME_SLICE); + Events.assertField(e, "pauseTarget").isEqual(MAX_GC_TIME); + } + + recording.close(); + } +} diff --git a/test/jdk/jfr/event/gc/detailed/TestPromotionEventWithG1.java b/test/jdk/jfr/event/gc/detailed/TestPromotionEventWithG1.java new file mode 100644 index 0000000000000000000000000000000000000000..9cd119d2a6be22ca31702a5e79c053cec475ff02 --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/TestPromotionEventWithG1.java @@ -0,0 +1,44 @@ +/* + * 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. 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.event.gc.detailed; + +/** + * @test + * @key jfr + * @summary Test that events are created when an object is aged or promoted during a GC and the copying of the object requires a new PLAB or direct heap allocation + * + * + * + * & vm.opt.ExplicitGCInvokesConcurrent != true + * @library /lib / + * @run main/othervm -Xmx32m -Xms32m -Xmn12m -XX:+UseG1GC -XX:-UseStringDeduplication -XX:MaxTenuringThreshold=5 -XX:InitialTenuringThreshold=5 + * jdk.jfr.event.gc.detailed.TestPromotionEventWithG1 + */ +public class TestPromotionEventWithG1 { + + public static void main(String[] args) throws Throwable { + PromotionEvent.test(); + } +} diff --git a/test/jdk/jfr/event/gc/detailed/TestPromotionEventWithParallelScavenge.java b/test/jdk/jfr/event/gc/detailed/TestPromotionEventWithParallelScavenge.java new file mode 100644 index 0000000000000000000000000000000000000000..85b43b1dfcf25a01b98d3a5fa44cea3a6746917d --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/TestPromotionEventWithParallelScavenge.java @@ -0,0 +1,42 @@ +/* + * 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 + * 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.event.gc.detailed; + +/** + * @test + * @key jfr + * @summary Test that events are created when an object is aged or promoted during a GC and the copying of the object requires a new PLAB or direct heap allocation + * + * + * + * @library /lib / + * @run main/othervm -Xmx32m -Xms32m -Xmn12m -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:MaxTenuringThreshold=5 -XX:InitialTenuringThreshold=5 jdk.jfr.event.gc.detailed.TestPromotionEventWithParallelScavenge + */ +public class TestPromotionEventWithParallelScavenge { + + public static void main(String[] args) throws Throwable { + PromotionEvent.test(); + } +} diff --git a/test/jdk/jfr/event/gc/detailed/TestPromotionFailedEventWithDefNew.java b/test/jdk/jfr/event/gc/detailed/TestPromotionFailedEventWithDefNew.java new file mode 100644 index 0000000000000000000000000000000000000000..96cbcaccb3b832b411b0d01f0f39e454e2055ed1 --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/TestPromotionFailedEventWithDefNew.java @@ -0,0 +1,43 @@ +/* + * 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 + * 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.event.gc.detailed; + +/** + * @test + * @key jfr + * + * + * + * @library /lib / + * @run main jdk.jfr.event.gc.detailed.TestPromotionFailedEventWithDefNew + */ +public class TestPromotionFailedEventWithDefNew { + public static void main(String[] args) throws Throwable { + PromotionFailedEvent.test("TestPromotionFailedEventWithDefNew", new String[] {"-XX:+UnlockExperimentalVMOptions", + "-XX:-UseFastUnorderedTimeStamps", "-XX:+PrintGCDetails", "-XX:+PrintGC", "-Xmx32m", "-Xmn30m", + "-XX:-UseDynamicNumberOfGCThreads", "-XX:MaxTenuringThreshold=0", "-XX:+UseSerialGC"}); + } +} diff --git a/test/jdk/jfr/event/gc/detailed/TestPromotionFailedEventWithParNew.java b/test/jdk/jfr/event/gc/detailed/TestPromotionFailedEventWithParNew.java new file mode 100644 index 0000000000000000000000000000000000000000..824193bd8cedcc1f0d1d031f61df39cc56f0f964 --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/TestPromotionFailedEventWithParNew.java @@ -0,0 +1,45 @@ +/* + * 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 + * 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.event.gc.detailed; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm jdk.jfr.event.gc.detailed.TestPromotionFailedEventWithParNew + */ +public class TestPromotionFailedEventWithParNew { + + public static void main(String[] args) throws Throwable { + PromotionFailedEvent.test("TestPromotionFailedEventWithParNew", + new String[]{"-Xmx32m", "-Xmn30m", "-XX:-UseDynamicNumberOfGCThreads", + "-XX:ParallelGCThreads=3", "-XX:MaxTenuringThreshold=0", + "-XX:+PrintGCDetails", "-XX:+PrintGC", "-XX:+UseConcMarkSweepGC", + "-XX:+UnlockExperimentalVMOptions", "-XX:-UseFastUnorderedTimeStamps"}); + } + +} diff --git a/test/jdk/jfr/event/gc/detailed/TestPromotionFailedEventWithParallelScavenge.java b/test/jdk/jfr/event/gc/detailed/TestPromotionFailedEventWithParallelScavenge.java new file mode 100644 index 0000000000000000000000000000000000000000..7dfe79c7452070d414e11d062b21ecf6ad22a835 --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/TestPromotionFailedEventWithParallelScavenge.java @@ -0,0 +1,44 @@ +/* + * 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 + * 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.event.gc.detailed; + +/** + * @test + * @key jfr + * + * + * + * @library /lib / + * @run main jdk.jfr.event.gc.detailed.TestPromotionFailedEventWithParallelScavenge + */ +public class TestPromotionFailedEventWithParallelScavenge { + public static void main(String[] args) throws Throwable { + PromotionFailedEvent.test("TestPromotionFailedEventWithParallelScavenge", + new String[] {"-XX:+UnlockExperimentalVMOptions", "-XX:-UseFastUnorderedTimeStamps", + "-Xmx32m", "-Xmn30m", "-XX:-UseDynamicNumberOfGCThreads", "-XX:ParallelGCThreads=3", + "-XX:MaxTenuringThreshold=0", "-verbose:gc", "-XX:+UseParallelGC"}); + } +} diff --git a/test/jdk/jfr/event/gc/detailed/TestStressAllocationGCEventsWithCMS.java b/test/jdk/jfr/event/gc/detailed/TestStressAllocationGCEventsWithCMS.java new file mode 100644 index 0000000000000000000000000000000000000000..f25dda889002639968e2ca0665b798332728d55c --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/TestStressAllocationGCEventsWithCMS.java @@ -0,0 +1,39 @@ +/* + * 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. 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.event.gc.detailed; + +/** + * @test + * + * + * @library /lib / + * @run main/othervm -XX:+UseConcMarkSweepGC -Xmx64m jdk.jfr.event.gc.detailed.TestStressAllocationGCEventsWithCMS + */ +public class TestStressAllocationGCEventsWithCMS { + + public static void main(String[] args) throws Exception { + new StressAllocationGCEvents().run(args); + } +} diff --git a/test/jdk/jfr/event/gc/detailed/TestStressAllocationGCEventsWithDefNew.java b/test/jdk/jfr/event/gc/detailed/TestStressAllocationGCEventsWithDefNew.java new file mode 100644 index 0000000000000000000000000000000000000000..f69359d60a3994d7d09f3f84dc17add7ef3a0e0e --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/TestStressAllocationGCEventsWithDefNew.java @@ -0,0 +1,39 @@ +/* + * 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. 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.event.gc.detailed; + +/** + * @test + * + * + * @library /lib / + * @run main/othervm -XX:+UseSerialGC -Xmx64m jdk.jfr.event.gc.detailed.TestStressAllocationGCEventsWithDefNew + */ +public class TestStressAllocationGCEventsWithDefNew { + + public static void main(String[] args) throws Exception { + new StressAllocationGCEvents().run(args); + } +} diff --git a/test/jdk/jfr/event/gc/detailed/TestStressAllocationGCEventsWithG1.java b/test/jdk/jfr/event/gc/detailed/TestStressAllocationGCEventsWithG1.java new file mode 100644 index 0000000000000000000000000000000000000000..d8659723a218e3b5f9880b9a4760be3348af5829 --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/TestStressAllocationGCEventsWithG1.java @@ -0,0 +1,39 @@ +/* + * 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. 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.event.gc.detailed; + +/** + * @test + * + * + * @library /lib / + * @run main/othervm -XX:+UseG1GC -Xmx64m jdk.jfr.event.gc.detailed.TestStressAllocationGCEventsWithG1 + */ +public class TestStressAllocationGCEventsWithG1 { + + public static void main(String[] args) throws Exception { + new StressAllocationGCEvents().run(args); + } +} diff --git a/test/jdk/jfr/event/gc/detailed/TestStressAllocationGCEventsWithParNew.java b/test/jdk/jfr/event/gc/detailed/TestStressAllocationGCEventsWithParNew.java new file mode 100644 index 0000000000000000000000000000000000000000..7e5a9a867e607f4464cd5f74f2522a85b174c675 --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/TestStressAllocationGCEventsWithParNew.java @@ -0,0 +1,39 @@ +/* + * 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. 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.event.gc.detailed; + +/** + * @test + * + * + * @library /lib / + * @run main/othervm -XX:+UseConcMarkSweepGC -Xmx64m jdk.jfr.event.gc.detailed.TestStressAllocationGCEventsWithParNew + */ +public class TestStressAllocationGCEventsWithParNew { + + public static void main(String[] args) throws Exception { + new StressAllocationGCEvents().run(args); + } +} diff --git a/test/jdk/jfr/event/gc/detailed/TestStressAllocationGCEventsWithParallel.java b/test/jdk/jfr/event/gc/detailed/TestStressAllocationGCEventsWithParallel.java new file mode 100644 index 0000000000000000000000000000000000000000..420da591233995e0a68e8311a8d747932f475d17 --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/TestStressAllocationGCEventsWithParallel.java @@ -0,0 +1,39 @@ +/* + * 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. 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.event.gc.detailed; + +/** + * @test + * + * + * @library /lib / + * @run main/othervm -XX:+UseParallelGC -Xmx64m jdk.jfr.event.gc.detailed.TestStressAllocationGCEventsWithParallel + */ +public class TestStressAllocationGCEventsWithParallel { + + public static void main(String[] args) throws Exception { + new StressAllocationGCEvents().run(args); + } +} diff --git a/test/jdk/jfr/event/gc/detailed/TestStressBigAllocationGCEventsWithCMS.java b/test/jdk/jfr/event/gc/detailed/TestStressBigAllocationGCEventsWithCMS.java new file mode 100644 index 0000000000000000000000000000000000000000..ce9a1f3409dc94146ed2fd27c06aa6a6809613bb --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/TestStressBigAllocationGCEventsWithCMS.java @@ -0,0 +1,39 @@ +/* + * 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. 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.event.gc.detailed; + +/** + * @test + * + * + * @library /lib / + * @run main/othervm -XX:+UseConcMarkSweepGC -Xmx256m jdk.jfr.event.gc.detailed.TestStressBigAllocationGCEventsWithCMS 1048576 + */ +public class TestStressBigAllocationGCEventsWithCMS { + + public static void main(String[] args) throws Exception { + new StressAllocationGCEvents().run(args); + } +} diff --git a/test/jdk/jfr/event/gc/detailed/TestStressBigAllocationGCEventsWithDefNew.java b/test/jdk/jfr/event/gc/detailed/TestStressBigAllocationGCEventsWithDefNew.java new file mode 100644 index 0000000000000000000000000000000000000000..afd31af27691129361351fb1e68a4ad0bdceee50 --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/TestStressBigAllocationGCEventsWithDefNew.java @@ -0,0 +1,39 @@ +/* + * 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. 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.event.gc.detailed; + +/** + * @test + * + * + * @library /lib / + * @run main/othervm -XX:+UseSerialGC -Xmx256m jdk.jfr.event.gc.detailed.TestStressBigAllocationGCEventsWithDefNew 1048576 + */ +public class TestStressBigAllocationGCEventsWithDefNew { + + public static void main(String[] args) throws Exception { + new StressAllocationGCEvents().run(args); + } +} diff --git a/test/jdk/jfr/event/gc/detailed/TestStressBigAllocationGCEventsWithG1.java b/test/jdk/jfr/event/gc/detailed/TestStressBigAllocationGCEventsWithG1.java new file mode 100644 index 0000000000000000000000000000000000000000..2390a04e99665bdc6f376baf3179775b57c452ae --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/TestStressBigAllocationGCEventsWithG1.java @@ -0,0 +1,45 @@ +/* + * 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. 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.event.gc.detailed; + +/** + * @test + * @summary Test allocates humongous objects with G1 GC. Objects + * considered humongous when it allocates equals or more than one region. As + * we're passing the size of byte array we need adjust it that entire structure + * fits exactly to one region, if not - G1 will allocate another almost empty + * region as a continue of humongous. Thus we will exhaust memory very fast and + * test will fail with OOME. + * + * + * @library /lib / + * @run main/othervm -XX:+UseG1GC -XX:MaxNewSize=5m -Xmx256m -XX:G1HeapRegionSize=1048576 jdk.jfr.event.gc.detailed.TestStressBigAllocationGCEventsWithG1 1048544 + */ +public class TestStressBigAllocationGCEventsWithG1 { + + public static void main(String[] args) throws Exception { + new StressAllocationGCEvents().run(args); + } +} diff --git a/test/jdk/jfr/event/gc/detailed/TestStressBigAllocationGCEventsWithParNew.java b/test/jdk/jfr/event/gc/detailed/TestStressBigAllocationGCEventsWithParNew.java new file mode 100644 index 0000000000000000000000000000000000000000..66919fec8cd99880d52243380fb242c76d20cf2c --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/TestStressBigAllocationGCEventsWithParNew.java @@ -0,0 +1,39 @@ +/* + * 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. 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.event.gc.detailed; + +/** + * @test + * + * + * @library /lib / + * @run main/othervm -XX:+UseConcMarkSweepGC -Xmx256m jdk.jfr.event.gc.detailed.TestStressBigAllocationGCEventsWithParNew 1048576 + */ +public class TestStressBigAllocationGCEventsWithParNew { + + public static void main(String[] args) throws Exception { + new StressAllocationGCEvents().run(args); + } +} diff --git a/test/jdk/jfr/event/gc/detailed/TestStressBigAllocationGCEventsWithParallel.java b/test/jdk/jfr/event/gc/detailed/TestStressBigAllocationGCEventsWithParallel.java new file mode 100644 index 0000000000000000000000000000000000000000..2865030ca83e0fe3161c2aa425cd690c9aa018d3 --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/TestStressBigAllocationGCEventsWithParallel.java @@ -0,0 +1,39 @@ +/* + * 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. 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.event.gc.detailed; + +/** + * @test + * + * + * @library /lib / + * @run main/othervm -XX:+UseParallelGC -Xmx256m jdk.jfr.event.gc.detailed.TestStressBigAllocationGCEventsWithParallel 1048576 + */ +public class TestStressBigAllocationGCEventsWithParallel { + + public static void main(String[] args) throws Exception { + new StressAllocationGCEvents().run(args); + } +} diff --git a/test/jdk/jfr/event/gc/detailed/TestTenuringDistributionEvent.java b/test/jdk/jfr/event/gc/detailed/TestTenuringDistributionEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..d03a34292190435aeb3fd47c968799975588dac5 --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/TestTenuringDistributionEvent.java @@ -0,0 +1,87 @@ +/* + * 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. 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.event.gc.detailed; + +import java.nio.file.Paths; +import java.time.Duration; +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; + +/** + * @test + * @bug 8009538 + * + * + * @key jfr + * @library /lib / + * @run main/othervm -XX:NewSize=2m -XX:MaxNewSize=2m -Xmx32m -XX:+UseG1GC -XX:+NeverTenure jdk.jfr.event.gc.detailed.TestTenuringDistributionEvent + */ + +public class TestTenuringDistributionEvent { + private final static String EVENT_NAME = EventNames.TenuringDistribution; + + public static void main(String[] args) throws Exception { + Recording recording = null; + try { + recording = new Recording(); + // activate the event we are interested in and start recording + recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(0)); + recording.start(); + + // Setting NewSize and MaxNewSize will limit eden, so + // allocating 1024 20k byte arrays should trigger at + // least a few Young GCs. + byte[][] array = new byte[1024][]; + for (int i = 0; i < array.length; i++) { + array[i] = new byte[20 * 1024]; + } + recording.stop(); + + // Verify recording + List events = Events.fromRecording(recording); + Asserts.assertFalse(events.isEmpty(), "No events found"); + for (RecordedEvent event : events) { + Events.assertField(event, "gcId").notEqual(-1); + Events.assertField(event, "age").notEqual(0); + Events.assertField(event, "size").atLeast(0L); + } + + } catch (Throwable t) { + if (recording != null) { + recording.dump(Paths.get("TestTenuringDistribution.jfr")); + } + throw t; + } finally { + if (recording != null) { + recording.close(); + } + } + } +} diff --git a/test/jdk/jfr/event/gc/detailed/concurrentmodefailure-testsettings.jfc b/test/jdk/jfr/event/gc/detailed/concurrentmodefailure-testsettings.jfc new file mode 100644 index 0000000000000000000000000000000000000000..e8ae59b4b4dd5c8ef011a751590c44b87d50bfc8 --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/concurrentmodefailure-testsettings.jfc @@ -0,0 +1,32 @@ + + + + + + true + 0 ms + + diff --git a/test/jdk/jfr/event/gc/detailed/evacuationfailed-testsettings.jfc b/test/jdk/jfr/event/gc/detailed/evacuationfailed-testsettings.jfc new file mode 100644 index 0000000000000000000000000000000000000000..8dcd14fb750b20827bc323582d9d355508a13dfe --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/evacuationfailed-testsettings.jfc @@ -0,0 +1,32 @@ + + + + + + true + 0 ms + + diff --git a/test/jdk/jfr/event/gc/detailed/promotionfailed-testsettings.jfc b/test/jdk/jfr/event/gc/detailed/promotionfailed-testsettings.jfc new file mode 100644 index 0000000000000000000000000000000000000000..1404e4d2cbed8d0b122da544e998f930f3294b32 --- /dev/null +++ b/test/jdk/jfr/event/gc/detailed/promotionfailed-testsettings.jfc @@ -0,0 +1,32 @@ + + + + + + true + 0 ms + + diff --git a/test/jdk/jfr/event/gc/heapsummary/HeapSummaryEventAllGcs.java b/test/jdk/jfr/event/gc/heapsummary/HeapSummaryEventAllGcs.java new file mode 100644 index 0000000000000000000000000000000000000000..74d5bd2e9ce4d41df3d5b32d9a442e7210f88b2f --- /dev/null +++ b/test/jdk/jfr/event/gc/heapsummary/HeapSummaryEventAllGcs.java @@ -0,0 +1,225 @@ +/* + * 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 + * 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.event.gc.heapsummary; + +import java.time.Duration; +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.jfr.GCHelper; + +public class HeapSummaryEventAllGcs { + + public static void test(String expectedYoungCollector, String expectedOldCollector) throws Exception { + Recording recording = new Recording(); + recording.enable(EventNames.GCConfiguration); + recording.enable(EventNames.GCHeapSummary); + recording.enable(EventNames.G1HeapSummary); + recording.enable(EventNames.PSHeapSummary); + recording.enable(EventNames.MetaspaceSummary).withThreshold(Duration.ofMillis(0)); + + recording.start(); + // To eliminate the risk of being in the middle of a GC when the recording starts/stops, + // we run 5 System.gc() and ignores the first and last GC. + GCHelper.callSystemGc(5, true); + recording.stop(); + + if (!checkCollectors(recording, expectedYoungCollector, expectedOldCollector)) { + return; + } + List events = GCHelper.removeFirstAndLastGC(Events.fromRecording(recording)); + for (RecordedEvent event : events) { + System.out.println("Event:" + event); + } + + Asserts.assertFalse(events.isEmpty(), "Expected at least one event."); + Asserts.assertEquals(events.size() % 2, 0, "Events should come in pairs"); + + int lastHeapGcId = -1; + int lastG1GcId = -1; + int lastPSGcId = -1; + int lastMetaspaceGcId = -1; + + for (RecordedEvent event : events) { + final String eventName = event.getEventType().getName(); + switch (eventName) { + case EventNames.GCHeapSummary: + lastHeapGcId = checkGcId(event, lastHeapGcId); + checkHeapEventContent(event); + break; + case EventNames.G1HeapSummary: + lastG1GcId = checkGcId(event, lastG1GcId); + checkG1EventContent(event); + break; + case EventNames.PSHeapSummary: + lastPSGcId = checkGcId(event, lastPSGcId); + checkPSEventContent(event); + break; + case EventNames.MetaspaceSummary: + lastMetaspaceGcId = checkGcId(event, lastMetaspaceGcId); + checkMetaspaceEventContent(event); + break; + default: + System.out.println("Failed event: " + event); + Asserts.fail("Unknown event type: " + eventName); + } + } + + // Sanity check. Not complete. + Asserts.assertEquals(lastHeapGcId, lastMetaspaceGcId, "Should have gotten perm gen events for all GCs"); + } + + private static void checkMetaspaceEventContent(RecordedEvent event) { + long totalUsed = Events.assertField(event, "metaspace.used").atLeast(0L).getValue(); + long totalCommitted = Events.assertField(event, "metaspace.committed").atLeast(totalUsed).getValue(); + long totalReserved = Events.assertField(event, "metaspace.reserved").atLeast(totalCommitted).getValue(); + + long dataUsed = Events.assertField(event, "dataSpace.used").atLeast(0L).getValue(); + long dataCommitted = Events.assertField(event, "dataSpace.committed").atLeast(dataUsed).getValue(); + long dataReserved = Events.assertField(event, "dataSpace.reserved").atLeast(dataCommitted).getValue(); + + long classUsed = Events.assertField(event, "classSpace.used").atLeast(0L).getValue(); + long classCommitted = Events.assertField(event, "classSpace.committed").atLeast(classUsed).getValue(); + long classReserved = Events.assertField(event, "classSpace.reserved").atLeast(classCommitted).getValue(); + + Asserts.assertEquals(dataCommitted + classCommitted, totalCommitted, "Wrong committed memory"); + Asserts.assertEquals(dataUsed + classUsed, totalUsed, "Wrong used memory"); + Asserts.assertEquals(dataReserved + classReserved, totalReserved, "Wrong reserved memory"); + } + + private static int checkGcId(RecordedEvent event, int currGcId) { + int gcId = Events.assertField(event, "gcId").getValue(); + String when = Events.assertField(event, "when").notEmpty().getValue(); + if ("Before GC".equals(when)) { + Asserts.assertGreaterThan(gcId, currGcId, "gcId should be increasing"); + } else { + Asserts.assertEquals(gcId, currGcId, "After should have same gcId as last Before event"); + } + return gcId; + } + + private static void checkHeapEventContent(RecordedEvent event) { + checkVirtualSpace(event, "heapSpace"); + long heapUsed = Events.assertField(event, "heapUsed").atLeast(0L).getValue(); + long start = Events.assertField(event, "heapSpace.start").atLeast(0L).getValue(); + long committedEnd = Events.assertField(event, "heapSpace.committedEnd").above(start).getValue(); + Asserts.assertLessThanOrEqual(heapUsed, committedEnd- start, "used can not exceed size"); + } + + private static void checkG1EventContent(RecordedEvent event) { + long edenUsedSize = Events.assertField(event, "edenUsedSize").atLeast(0L).getValue(); + long edenTotalSize = Events.assertField(event, "edenTotalSize").atLeast(0L).getValue(); + Asserts.assertLessThanOrEqual(edenUsedSize, edenTotalSize, "used can not exceed size"); + Events.assertField(event, "survivorUsedSize").atLeast(0L); + Events.assertField(event, "numberOfRegions").atLeast(0); + } + + private static void checkPSEventContent(RecordedEvent event) { + checkVirtualSpace(event, "oldSpace"); + checkVirtualSpace(event, "youngSpace"); + checkSpace(event, "oldObjectSpace"); + checkSpace(event, "edenSpace"); + checkSpace(event, "fromSpace"); + checkSpace(event, "toSpace"); + + checkPSYoungSizes(event); + checkPSYoungStartEnd(event); + } + + private static void checkPSYoungSizes(RecordedEvent event) { + long youngSize = (long)Events.assertField(event, "youngSpace.committedEnd").getValue() - + (long)Events.assertField(event, "youngSpace.start").getValue(); + long edenSize = (long)Events.assertField(event, "edenSpace.end").getValue() - + (long)Events.assertField(event, "edenSpace.start").getValue(); + long fromSize = (long)Events.assertField(event, "fromSpace.end").getValue() - + (long)Events.assertField(event, "fromSpace.start").getValue(); + long toSize = (long)Events.assertField(event, "toSpace.end").getValue() - + (long)Events.assertField(event, "toSpace.start").getValue(); + Asserts.assertGreaterThanOrEqual(youngSize, edenSize + fromSize + toSize, "Young sizes don't match"); + } + + private static void checkPSYoungStartEnd(RecordedEvent event) { + long oldEnd = Events.assertField(event, "oldSpace.reservedEnd").getValue(); + long youngStart = Events.assertField(event, "youngSpace.start").getValue(); + long youngEnd = Events.assertField(event, "youngSpace.committedEnd").getValue(); + long edenStart = Events.assertField(event, "edenSpace.start").getValue(); + long edenEnd = Events.assertField(event, "edenSpace.end").getValue(); + long fromStart = Events.assertField(event, "fromSpace.start").getValue(); + long fromEnd = Events.assertField(event, "fromSpace.end").getValue(); + long toStart = Events.assertField(event, "toSpace.start").getValue(); + long toEnd = Events.assertField(event, "toSpace.end").getValue(); + Asserts.assertEquals(oldEnd, youngStart, "Young should start where old ends"); + Asserts.assertEquals(youngStart, edenStart, "Eden should be placed first in young"); + if (fromStart < toStart) { + // [eden][from][to] + Asserts.assertGreaterThanOrEqual(fromStart, edenEnd, "From should start after eden"); + Asserts.assertLessThanOrEqual(fromEnd, toStart, "To should start after From"); + Asserts.assertLessThanOrEqual(toEnd, youngEnd, "To should start after From"); + } else { + // [eden][to][from] + Asserts.assertGreaterThanOrEqual(toStart, edenEnd, "From should start after eden"); + Asserts.assertLessThanOrEqual(toEnd, fromStart, "To should start after From"); + Asserts.assertLessThanOrEqual(fromEnd, youngEnd, "To should start after From"); + } + } + + private static void checkVirtualSpace(RecordedEvent event, String structName) { + long start = Events.assertField(event, structName + ".start").atLeast(0L).getValue(); + long committedEnd = Events.assertField(event, structName + ".committedEnd").above(start).getValue(); + Events.assertField(event, structName + ".reservedEnd").atLeast(committedEnd); + long committedSize = Events.assertField(event, structName + ".committedSize").atLeast(0L).getValue(); + Events.assertField(event, structName + ".reservedSize").atLeast(committedSize); + } + + private static void checkSpace(RecordedEvent event, String structName) { + long start = Events.assertField(event, structName + ".start").atLeast(0L).getValue(); + long end = Events.assertField(event, structName + ".end").above(start).getValue(); + long used = Events.assertField(event, structName + ".used").atLeast(0L).getValue(); + long size = Events.assertField(event, structName + ".size").atLeast(used).getValue(); + Asserts.assertEquals(size, end - start, "Size mismatch"); + } + + private static boolean checkCollectors(Recording recording, String expectedYoung, String expectedOld) throws Exception { + for (RecordedEvent event : Events.fromRecording(recording)) { + if (Events.isEventType(event, EventNames.GCConfiguration)) { + final String young = Events.assertField(event, "youngCollector").notEmpty().getValue(); + final String old = Events.assertField(event, "oldCollector").notEmpty().getValue(); + if (young.equals(expectedYoung) && old.equals(expectedOld)) { + return true; + } + // TODO: We treat wrong collector types as an error. Old test only warned. Not sure what is correct. + Asserts.fail(String.format("Wrong collector types: got('%s','%s'), expected('%s','%s')", + young, old, expectedYoung, expectedOld)); + } + } + Asserts.fail("Missing event type " + EventNames.GCConfiguration); + return false; + } +} diff --git a/test/jdk/jfr/event/gc/heapsummary/TestHeapSummaryCommittedSize.java b/test/jdk/jfr/event/gc/heapsummary/TestHeapSummaryCommittedSize.java new file mode 100644 index 0000000000000000000000000000000000000000..7e95789d1a4e13bd8c9c80bb9e0b3f38a90d42c6 --- /dev/null +++ b/test/jdk/jfr/event/gc/heapsummary/TestHeapSummaryCommittedSize.java @@ -0,0 +1,92 @@ +/* + * 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 + * 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.event.gc.heapsummary; + +import java.time.Duration; + +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.EventVerifier; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.GCHelper; +import sun.hotspot.WhiteBox; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @build sun.hotspot.WhiteBox + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -XX:+UnlockExperimentalVMOptions + -XX:-UseFastUnorderedTimeStamps -Xmx16m -XX:+UseParallelGC + -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + jdk.jfr.event.gc.heapsummary.TestHeapSummaryCommittedSize + */ +public class TestHeapSummaryCommittedSize { + private final static String EVENT_NAME = EventNames.GCHeapSummary; + + public static void main(String[] args) throws Exception { + Recording recording = new Recording(); + recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(0)); + + recording.start(); + System.gc(); + recording.stop(); + + boolean isAnyFound = false; + for (RecordedEvent event : Events.fromRecording(recording)) { + System.out.println("Event: " + event); + if (!Events.isEventType(event, EVENT_NAME)) { + continue; + } + isAnyFound = true; + CommittedHeapSizeVerifier verifier = new CommittedHeapSizeVerifier(event); + verifier.verify(); + } + Asserts.assertTrue(isAnyFound, "No matching event"); + } +} + +class CommittedHeapSizeVerifier extends EventVerifier { + private final static long MAX_UNALIGNED_COMMITTED_SIZE = 16 * 1024 * 1024; + private final long MAX_ALIGNED_COMMITTED_SIZE; + + public CommittedHeapSizeVerifier(RecordedEvent event) { + super(event); + WhiteBox wb = WhiteBox.getWhiteBox(); + long heapAlignment = wb.getHeapAlignment(); + MAX_ALIGNED_COMMITTED_SIZE = GCHelper.alignUp( + MAX_UNALIGNED_COMMITTED_SIZE,heapAlignment); + } + + public void verify() throws Exception { + Events.assertField(event, "heapSpace.committedSize").atLeast(0L).atMost(MAX_ALIGNED_COMMITTED_SIZE); + } +} diff --git a/test/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventConcurrentCMS.java b/test/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventConcurrentCMS.java new file mode 100644 index 0000000000000000000000000000000000000000..024bf71290748464405e75c03c9b227e34b63e4a --- /dev/null +++ b/test/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventConcurrentCMS.java @@ -0,0 +1,94 @@ +/* + * 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 + * 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.event.gc.heapsummary; + +import java.time.Duration; +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.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseConcMarkSweepGC -XX:+ExplicitGCInvokesConcurrent jdk.jfr.event.gc.heapsummary.TestHeapSummaryEventConcurrentCMS + */ +public class TestHeapSummaryEventConcurrentCMS { + + public static void main(String[] args) throws Exception { + Recording recording = new Recording(); + recording.enable(EventNames.GarbageCollection).withThreshold(Duration.ofMillis(0)); + recording.enable(EventNames.GCHeapSummary).withThreshold(Duration.ofMillis(0)); + + recording.start(); + // Need several GCs to ensure at least one heap summary event from concurrent CMS + GCHelper.callSystemGc(6, true); + recording.stop(); + + // Remove first and last GCs which can be incomplete + List events = GCHelper.removeFirstAndLastGC(Events.fromRecording(recording)); + Asserts.assertFalse(events.isEmpty(), "No events found"); + for (RecordedEvent event : events) { + System.out.println("Event: " + event); + if (!isCmsGcEvent(event)) { + continue; + } + int gcId = Events.assertField(event, "gcId").getValue(); + verifyHeapSummary(events, gcId, "Before GC"); + verifyHeapSummary(events, gcId, "After GC"); + } + } + + private static boolean isCmsGcEvent(RecordedEvent event) { + if (!Events.isEventType(event, EventNames.GarbageCollection)) { + return false; + } + final String gcName = Events.assertField(event, "name").notEmpty().getValue(); + return "ConcurrentMarkSweep".equals(gcName); + } + + private static void verifyHeapSummary(List events, int gcId, String when) { + for (RecordedEvent event : events) { + if (!Events.isEventType(event, EventNames.GCHeapSummary)) { + continue; + } + if (gcId == (int)Events.assertField(event, "gcId").getValue() && + when.equals(Events.assertField(event, "when").getValue())) { + System.out.printf("Found " + EventNames.GCHeapSummary + " for id=%d, when=%s%n", gcId, when); + return; + } + } + Asserts.fail(String.format("No " + EventNames.GCHeapSummary + " for id=%d, when=%s", gcId, when)); + } + +} diff --git a/test/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventDefNewSerial.java b/test/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventDefNewSerial.java new file mode 100644 index 0000000000000000000000000000000000000000..c02a12c5a1d3e1b3e8c43feb964ff94f6ed6eec9 --- /dev/null +++ b/test/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventDefNewSerial.java @@ -0,0 +1,41 @@ +/* + * 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 + * 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.event.gc.heapsummary; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UseSerialGC jdk.jfr.event.gc.heapsummary.TestHeapSummaryEventDefNewSerial + */ +public class TestHeapSummaryEventDefNewSerial { + public static void main(String[] args) throws Exception { + HeapSummaryEventAllGcs.test(GCHelper.gcDefNew, GCHelper.gcSerialOld); + } +} diff --git a/test/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventG1.java b/test/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventG1.java new file mode 100644 index 0000000000000000000000000000000000000000..86dd1d9a4724bc89de4ec10a21f3fc17c3b4cebd --- /dev/null +++ b/test/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventG1.java @@ -0,0 +1,41 @@ +/* + * 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 + * 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.event.gc.heapsummary; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseG1GC jdk.jfr.event.gc.heapsummary.TestHeapSummaryEventG1 + */ +public class TestHeapSummaryEventG1 { + public static void main(String[] args) throws Exception { + HeapSummaryEventAllGcs.test(GCHelper.gcG1New, GCHelper.gcG1Old); + } +} diff --git a/test/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventPSParOld.java b/test/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventPSParOld.java new file mode 100644 index 0000000000000000000000000000000000000000..0facc7a6eb24ca255b801f51a9fd6c2577c78c3e --- /dev/null +++ b/test/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventPSParOld.java @@ -0,0 +1,41 @@ +/* + * 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 + * 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.event.gc.heapsummary; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseParallelGC jdk.jfr.event.gc.heapsummary.TestHeapSummaryEventPSParOld + */ +public class TestHeapSummaryEventPSParOld { + public static void main(String[] args) throws Exception { + HeapSummaryEventAllGcs.test(GCHelper.gcParallelScavenge, GCHelper.gcParallelOld); + } +} diff --git a/test/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventPSSerial.java b/test/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventPSSerial.java new file mode 100644 index 0000000000000000000000000000000000000000..902eba0244d3957b80d2bbbad8e4f9015cc1430e --- /dev/null +++ b/test/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventPSSerial.java @@ -0,0 +1,41 @@ +/* + * 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 + * 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.event.gc.heapsummary; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:-UseParallelOldGC -XX:+UseParallelGC jdk.jfr.event.gc.heapsummary.TestHeapSummaryEventPSSerial + */ +public class TestHeapSummaryEventPSSerial { + public static void main(String[] args) throws Exception { + HeapSummaryEventAllGcs.test(GCHelper.gcParallelScavenge, GCHelper.gcSerialOld); + } +} diff --git a/test/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventParNewCMS.java b/test/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventParNewCMS.java new file mode 100644 index 0000000000000000000000000000000000000000..91462d15c9ab64b85ae581eba4a509abe0662827 --- /dev/null +++ b/test/jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventParNewCMS.java @@ -0,0 +1,41 @@ +/* + * 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 + * 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.event.gc.heapsummary; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseConcMarkSweepGC jdk.jfr.event.gc.heapsummary.TestHeapSummaryEventParNewCMS + */ +public class TestHeapSummaryEventParNewCMS { + public static void main(String[] args) throws Exception { + HeapSummaryEventAllGcs.test(GCHelper.gcParNew, GCHelper.gcConcurrentMarkSweep); + } +} diff --git a/test/jdk/jfr/event/gc/objectcount/ObjectCountAfterGCEvent.java b/test/jdk/jfr/event/gc/objectcount/ObjectCountAfterGCEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..d1d807abd27fec2a57bcdf53930a33326bbcbcbc --- /dev/null +++ b/test/jdk/jfr/event/gc/objectcount/ObjectCountAfterGCEvent.java @@ -0,0 +1,98 @@ +/* + * 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 + * 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.event.gc.objectcount; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +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; + + +public class ObjectCountAfterGCEvent { + + private static final String objectCountEventPath = EventNames.ObjectCountAfterGC; + private static final String gcEventPath = EventNames.GarbageCollection; + private static final String heapSummaryEventPath = EventNames.GCHeapSummary; + + public static void test(String gcName) throws Exception { + Recording recording = new Recording(); + recording.enable(objectCountEventPath); + recording.enable(gcEventPath); + recording.enable(heapSummaryEventPath); + + ObjectCountEventVerifier.createTestData(); + recording.start(); + System.gc(); + System.gc(); + recording.stop(); + + System.out.println("gcName=" + gcName); + for (RecordedEvent event : Events.fromRecording(recording)) { + System.out.println("Event: " + event); + } + + List events= Events.fromRecording(recording); + Optional gcEvent = events.stream() + .filter(e -> isMySystemGc(e, gcName)) + .findFirst(); + Asserts.assertTrue(gcEvent.isPresent(), "No event System.gc event of type " + gcEventPath); + System.out.println("Found System.gc event: " + gcEvent.get()); + int gcId = Events.assertField(gcEvent.get(), "gcId").getValue(); + + List objCountEvents = events.stream() + .filter(e -> Events.isEventType(e, objectCountEventPath)) + .filter(e -> isGcId(e, gcId)) + .collect(Collectors.toList()); + Asserts.assertFalse(objCountEvents.isEmpty(), "No objCountEvents for gcId=" + gcId); + + Optional heapSummaryEvent = events.stream() + .filter(e -> Events.isEventType(e, heapSummaryEventPath)) + .filter(e -> isGcId(e, gcId)) + .filter(e -> "After GC".equals(Events.assertField(e, "when").getValue())) + .findFirst(); + Asserts.assertTrue(heapSummaryEvent.isPresent(), "No heapSummary for gcId=" + gcId); + System.out.println("Found heapSummaryEvent: " + heapSummaryEvent.get()); + + Events.assertField(heapSummaryEvent.get(), "heapUsed").atLeast(0L).getValue(); + ObjectCountEventVerifier.verify(objCountEvents); + } + + private static boolean isGcId(RecordedEvent event, int gcId) { + return gcId == (int)Events.assertField(event, "gcId").getValue(); + } + + private static boolean isMySystemGc(RecordedEvent event, String gcName) { + return Events.isEventType(event, gcEventPath) && + gcName.equals(Events.assertField(event, "name").getValue()) && + "System.gc()".equals(Events.assertField(event, "cause").getValue()); + } + +} diff --git a/test/jdk/jfr/event/gc/objectcount/ObjectCountEventVerifier.java b/test/jdk/jfr/event/gc/objectcount/ObjectCountEventVerifier.java new file mode 100644 index 0000000000000000000000000000000000000000..f94ef96a2a80d03f0635dd05e141eb430eec6eec --- /dev/null +++ b/test/jdk/jfr/event/gc/objectcount/ObjectCountEventVerifier.java @@ -0,0 +1,80 @@ +/* + * 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 + * 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.event.gc.objectcount; + +import java.util.List; +import java.util.HashMap; + +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +class Foo { +} + +class Constants { + public static final int oneMB = 1048576; +} + +public class ObjectCountEventVerifier { + public static Foo[] foos; + + public static void createTestData() { + foos = new Foo[Constants.oneMB]; + } + + public static void verify(List objectCountEvents) throws Exception { + Asserts.assertFalse(objectCountEvents.isEmpty(), "Expected at least one object count event"); + // Object count events should be sent only for those classes which instances occupy over 0.5% + // of the heap. Therefore there can't be more than 200 events + Asserts.assertLessThanOrEqual(objectCountEvents.size(), 200, "Expected at most 200 object count events"); + + HashMap numInstancesOfClass = new HashMap(); + HashMap sizeOfInstances = new HashMap(); + + for (RecordedEvent event : objectCountEvents) { + String className = Events.assertField(event, "objectClass.name").notEmpty().getValue(); + long count = Events.assertField(event, "count").atLeast(0L).getValue(); + long totalSize = Events.assertField(event, "totalSize").atLeast(1L).getValue(); + System.out.println(className); + numInstancesOfClass.put(className, count); + sizeOfInstances.put(className, totalSize); + } + System.out.println(numInstancesOfClass); + final String fooArrayName = "[Ljdk/jfr/event/gc/objectcount/Foo;"; + Asserts.assertTrue(numInstancesOfClass.containsKey(fooArrayName), "Expected an event for the Foo array"); + Asserts.assertEquals(sizeOfInstances.get(fooArrayName), expectedFooArraySize(Constants.oneMB), "Wrong size of the Foo array"); + } + + private static long expectedFooArraySize(long count) { + boolean runsOn32Bit = System.getProperty("sun.arch.data.model").equals("32"); + int bytesPerWord = runsOn32Bit ? 4 : 8; + int objectHeaderSize = bytesPerWord * 3; // length will be aligned on 64 bits + int alignmentInOopArray = runsOn32Bit ? 4 : 0; + int ptrSize = bytesPerWord; + return objectHeaderSize + alignmentInOopArray + count * ptrSize; + } +} diff --git a/test/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithCMSConcurrent.java b/test/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithCMSConcurrent.java new file mode 100644 index 0000000000000000000000000000000000000000..5a5ac2fda65882d062946ef8e1832065762271b8 --- /dev/null +++ b/test/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithCMSConcurrent.java @@ -0,0 +1,41 @@ +/* + * 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 + * 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.event.gc.objectcount; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseConcMarkSweepGC -XX:+ExplicitGCInvokesConcurrent -XX:MarkSweepDeadRatio=0 -XX:-UseCompressedOops -XX:+IgnoreUnrecognizedVMOptions jdk.jfr.event.gc.objectcount.TestObjectCountAfterGCEventWithCMSConcurrent + */ +public class TestObjectCountAfterGCEventWithCMSConcurrent { + public static void main(String[] args) throws Exception { + ObjectCountAfterGCEvent.test(GCHelper.gcConcurrentMarkSweep); + } +} diff --git a/test/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithCMSMarkSweep.java b/test/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithCMSMarkSweep.java new file mode 100644 index 0000000000000000000000000000000000000000..6c8e06682a26bffc957d5b73f6e49bb2c79ee66e --- /dev/null +++ b/test/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithCMSMarkSweep.java @@ -0,0 +1,41 @@ +/* + * 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 + * 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.event.gc.objectcount; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseConcMarkSweepGC -XX:MarkSweepDeadRatio=0 -XX:-UseCompressedOops -XX:+IgnoreUnrecognizedVMOptions jdk.jfr.event.gc.objectcount.TestObjectCountAfterGCEventWithCMSMarkSweep + */ +public class TestObjectCountAfterGCEventWithCMSMarkSweep { + public static void main(String[] args) throws Exception { + ObjectCountAfterGCEvent.test(GCHelper.gcSerialOld); + } +} diff --git a/test/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithG1ConcurrentMark.java b/test/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithG1ConcurrentMark.java new file mode 100644 index 0000000000000000000000000000000000000000..1e00e7c043d725d9fcdfe1d89e71da5405b1d381 --- /dev/null +++ b/test/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithG1ConcurrentMark.java @@ -0,0 +1,41 @@ +/* + * 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 + * 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.event.gc.objectcount; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:+ExplicitGCInvokesConcurrent -XX:MarkSweepDeadRatio=0 -XX:-UseCompressedOops -XX:+IgnoreUnrecognizedVMOptions jdk.jfr.event.gc.objectcount.TestObjectCountAfterGCEventWithG1ConcurrentMark + */ +public class TestObjectCountAfterGCEventWithG1ConcurrentMark { + public static void main(String[] args) throws Exception { + ObjectCountAfterGCEvent.test(GCHelper.gcG1Old); + } +} diff --git a/test/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithG1FullCollection.java b/test/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithG1FullCollection.java new file mode 100644 index 0000000000000000000000000000000000000000..9eb036954783a8e50aa69469f9baba83b3e5c5d9 --- /dev/null +++ b/test/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithG1FullCollection.java @@ -0,0 +1,41 @@ +/* + * 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 + * 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.event.gc.objectcount; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseG1GC -XX:MarkSweepDeadRatio=0 -XX:-UseCompressedOops -XX:+IgnoreUnrecognizedVMOptions jdk.jfr.event.gc.objectcount.TestObjectCountAfterGCEventWithG1FullCollection + */ +public class TestObjectCountAfterGCEventWithG1FullCollection { + public static void main(String[] args) throws Exception { + ObjectCountAfterGCEvent.test(GCHelper.gcSerialOld); + } +} diff --git a/test/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithPSMarkSweep.java b/test/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithPSMarkSweep.java new file mode 100644 index 0000000000000000000000000000000000000000..9ba729568d8236af0fb8fab4c483d5b4e5cee4bc --- /dev/null +++ b/test/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithPSMarkSweep.java @@ -0,0 +1,41 @@ +/* + * 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 + * 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.event.gc.objectcount; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UseParallelGC -XX:-UseParallelOldGC -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:MarkSweepDeadRatio=0 -XX:-UseCompressedOops -XX:+IgnoreUnrecognizedVMOptions jdk.jfr.event.gc.objectcount.TestObjectCountAfterGCEventWithPSMarkSweep + */ +public class TestObjectCountAfterGCEventWithPSMarkSweep { + public static void main(String[] args) throws Exception { + ObjectCountAfterGCEvent.test(GCHelper.gcSerialOld); + } +} diff --git a/test/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithParallelOld.java b/test/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithParallelOld.java new file mode 100644 index 0000000000000000000000000000000000000000..5aa77c291e95aab45d26e909c31bd6c846d87a5c --- /dev/null +++ b/test/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithParallelOld.java @@ -0,0 +1,41 @@ +/* + * 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 + * 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.event.gc.objectcount; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:MarkSweepDeadRatio=0 -XX:-UseCompressedOops -XX:+IgnoreUnrecognizedVMOptions jdk.jfr.event.gc.objectcount.TestObjectCountAfterGCEventWithParallelOld + */ +public class TestObjectCountAfterGCEventWithParallelOld { + public static void main(String[] args) throws Exception { + ObjectCountAfterGCEvent.test(GCHelper.gcParallelOld); + } +} diff --git a/test/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithSerial.java b/test/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithSerial.java new file mode 100644 index 0000000000000000000000000000000000000000..d017a8adefe781baf9c5017c8f8035a6d1959a07 --- /dev/null +++ b/test/jdk/jfr/event/gc/objectcount/TestObjectCountAfterGCEventWithSerial.java @@ -0,0 +1,41 @@ +/* + * 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 + * 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.event.gc.objectcount; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseSerialGC -XX:MarkSweepDeadRatio=0 -XX:-UseCompressedOops -XX:+IgnoreUnrecognizedVMOptions jdk.jfr.event.gc.objectcount.TestObjectCountAfterGCEventWithSerial + */ +public class TestObjectCountAfterGCEventWithSerial { + public static void main(String[] args) throws Exception { + ObjectCountAfterGCEvent.test(GCHelper.gcSerialOld); + } +} diff --git a/test/jdk/jfr/event/gc/objectcount/TestObjectCountEvent.java b/test/jdk/jfr/event/gc/objectcount/TestObjectCountEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..2e0f034bea7b2ddc56b3d5a3713f933248b69fe2 --- /dev/null +++ b/test/jdk/jfr/event/gc/objectcount/TestObjectCountEvent.java @@ -0,0 +1,86 @@ +/* + * 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 + * 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.event.gc.objectcount; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +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; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseSerialGC -XX:-UseCompressedOops -XX:MarkSweepDeadRatio=0 -XX:+IgnoreUnrecognizedVMOptions jdk.jfr.event.gc.objectcount.TestObjectCountEvent + */ +public class TestObjectCountEvent { + private static final String objectCountEventPath = EventNames.ObjectCount; + private static final String heapSummaryEventPath = EventNames.GCHeapSummary; + + public static void main(String[] args) throws Exception { + Recording recording = new Recording(); + recording.enable(objectCountEventPath); + recording.enable(heapSummaryEventPath); + + ObjectCountEventVerifier.createTestData(); + System.gc(); + recording.start(); + recording.stop(); + + List events = Events.fromRecording(recording); + for (RecordedEvent event : events) { + System.out.println("Event: " + event); + } + + Optional heapSummaryEvent = events.stream() + .filter(e -> Events.isEventType(e, heapSummaryEventPath)) + .filter(e -> "After GC".equals(Events.assertField(e, "when").getValue())) + .findFirst(); + Asserts.assertTrue(heapSummaryEvent.isPresent(), "No heapSummary with cause='After GC'"); + System.out.println("Found heapSummaryEvent: " + heapSummaryEvent.get()); + Events.assertField(heapSummaryEvent.get(), "heapUsed").atLeast(0L).getValue(); + int gcId = Events.assertField(heapSummaryEvent.get(), "gcId").getValue(); + + List objCountEvents = events.stream() + .filter(e -> Events.isEventType(e, objectCountEventPath)) + .filter(e -> isGcId(e, gcId)) + .collect(Collectors.toList()); + Asserts.assertFalse(objCountEvents.isEmpty(), "No objCountEvents for gcId=" + gcId); + ObjectCountEventVerifier.verify(objCountEvents); + } + + private static boolean isGcId(RecordedEvent event, int gcId) { + return gcId == (int)Events.assertField(event, "gcId").getValue(); + } + +} diff --git a/test/jdk/jfr/event/gc/refstat/RefStatEvent.java b/test/jdk/jfr/event/gc/refstat/RefStatEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..ca59794cc7af24be99f3a6a652d69cb3d20807ee --- /dev/null +++ b/test/jdk/jfr/event/gc/refstat/RefStatEvent.java @@ -0,0 +1,102 @@ +/* + * 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 + * 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.event.gc.refstat; + +import java.time.Duration; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +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.jfr.GCHelper; + + +public class RefStatEvent { + + private static final String gcEventPath = EventNames.GarbageCollection; + private static final String refStatsEventPath = EventNames.GCReferenceStatistics; + public static byte[] garbage; + + public static void test(String gcName) throws Exception { + Recording recording = new Recording(); + recording.enable(refStatsEventPath).withThreshold(Duration.ofMillis(0)); + recording.enable(gcEventPath).withThreshold(Duration.ofMillis(0)); + + recording.start(); + GCHelper.callSystemGc(6, true); + recording.stop(); + + System.out.println("gcName=" + gcName); + List events = GCHelper.removeFirstAndLastGC(Events.fromRecording(recording)); + Events.hasEvents(events); + for (RecordedEvent event : events) { + System.out.println("Event: " + event); + } + + for (RecordedEvent event : events) { + if (!Events.isEventType(event, gcEventPath)) { + continue; + } + System.out.println("Event: " + event); + final int gcId = Events.assertField(event, "gcId").getValue(); + final String name = Events.assertField(event, "name").notEmpty().getValue(); + if (gcName.equals(name)) { + verifyRefStatEvents(events, gcId); + } + } + } + + // Check that we have a refStat event for each type for this GC. + private static void verifyRefStatEvents(List events, int gcId) { + List expectedTypes = Arrays.asList("Soft reference", "Weak reference", "Final reference", "Phantom reference"); + List actualTypes = new ArrayList<>(); + try { + for (RecordedEvent event : events) { + if (!Events.isEventType(event, refStatsEventPath)) { + continue; + } + Events.assertField(event, "count").atLeast(0L); + if (Events.assertField(event, "gcId").isEqual(gcId)) { + actualTypes.add(Events.assertField(event, "type").notEmpty().getValue()); + } + } + + Asserts.assertEquals(actualTypes.size(), expectedTypes.size(), "Wrong number of refStat events"); + Asserts.assertTrue(expectedTypes.containsAll(actualTypes), "Found unknown refStat types"); + Asserts.assertTrue(actualTypes.containsAll(expectedTypes), "Missning refStat types"); + } catch (Exception e) { + System.out.println("Expected refStatTypes: " + expectedTypes.stream().collect(Collectors.joining(", "))); + System.out.println("Got refStatTypes: " + actualTypes.stream().collect(Collectors.joining(", "))); + throw e; + } + } + +} diff --git a/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithCMSConcurrent.java b/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithCMSConcurrent.java new file mode 100644 index 0000000000000000000000000000000000000000..39e0d0f84c0962e1024c5c9d6137e5948663a3fd --- /dev/null +++ b/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithCMSConcurrent.java @@ -0,0 +1,41 @@ +/* + * 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 + * 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.event.gc.refstat; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+PrintGCDetails -XX:+PrintGC -XX:+UseConcMarkSweepGC -XX:+ExplicitGCInvokesConcurrent jdk.jfr.event.gc.refstat.TestRefStatEventWithCMSConcurrent + */ +public class TestRefStatEventWithCMSConcurrent { + public static void main(String[] args) throws Exception { + RefStatEvent.test(GCHelper.gcConcurrentMarkSweep); + } +} diff --git a/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithCMSMarkSweep.java b/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithCMSMarkSweep.java new file mode 100644 index 0000000000000000000000000000000000000000..ea32fd277ac96d7f49179f43576dcbe0c71770f0 --- /dev/null +++ b/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithCMSMarkSweep.java @@ -0,0 +1,41 @@ +/* + * 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 + * 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.event.gc.refstat; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+PrintGCDetails -XX:+PrintGC -XX:+UseConcMarkSweepGC jdk.jfr.event.gc.refstat.TestRefStatEventWithCMSMarkSweep + */ +public class TestRefStatEventWithCMSMarkSweep { + public static void main(String[] args) throws Exception { + RefStatEvent.test(GCHelper.gcSerialOld); + } +} diff --git a/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithDefNew.java b/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithDefNew.java new file mode 100644 index 0000000000000000000000000000000000000000..c4b2b29849b8b30a714e554bb36578e67fc2665f --- /dev/null +++ b/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithDefNew.java @@ -0,0 +1,41 @@ +/* + * 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 + * 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.event.gc.refstat; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+PrintGCDetails -XX:+PrintGC -Xmx50m -Xmn2m -XX:+UseSerialGC jdk.jfr.event.gc.refstat.TestRefStatEventWithDefNew + */ +public class TestRefStatEventWithDefNew { + public static void main(String[] args) throws Exception { + RefStatEvent.test(GCHelper.gcDefNew); + } +} diff --git a/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithG1ConcurrentMark.java b/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithG1ConcurrentMark.java new file mode 100644 index 0000000000000000000000000000000000000000..be23de050e6dea3cc72342124eef9f55200adc47 --- /dev/null +++ b/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithG1ConcurrentMark.java @@ -0,0 +1,41 @@ +/* + * 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 + * 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.event.gc.refstat; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+PrintGCDetails -XX:+PrintGC -XX:+UseG1GC -XX:+ExplicitGCInvokesConcurrent jdk.jfr.event.gc.refstat.TestRefStatEventWithG1ConcurrentMark + */ +public class TestRefStatEventWithG1ConcurrentMark { + public static void main(String[] args) throws Exception { + RefStatEvent.test(GCHelper.gcG1Old); + } +} diff --git a/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithG1FullCollection.java b/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithG1FullCollection.java new file mode 100644 index 0000000000000000000000000000000000000000..2287a1294c4874c2c64685a108bf07ba10f409ad --- /dev/null +++ b/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithG1FullCollection.java @@ -0,0 +1,41 @@ +/* + * 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 + * 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.event.gc.refstat; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+PrintGCDetails -XX:+PrintGC -XX:+UseG1GC jdk.jfr.event.gc.refstat.TestRefStatEventWithG1FullCollection + */ +public class TestRefStatEventWithG1FullCollection { + public static void main(String[] args) throws Exception { + RefStatEvent.test(GCHelper.gcG1Full); + } +} diff --git a/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithG1New.java b/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithG1New.java new file mode 100644 index 0000000000000000000000000000000000000000..50f8bf917bb6fc296473c60663de39611ac17636 --- /dev/null +++ b/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithG1New.java @@ -0,0 +1,41 @@ +/* + * 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 + * 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.event.gc.refstat; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+PrintGCDetails -XX:+PrintGC -Xmx50m -Xmn2m -XX:+UseG1GC jdk.jfr.event.gc.refstat.TestRefStatEventWithG1New + */ +public class TestRefStatEventWithG1New { + public static void main(String[] args) throws Exception { + RefStatEvent.test(GCHelper.gcG1New); + } +} diff --git a/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithPSMarkSweep.java b/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithPSMarkSweep.java new file mode 100644 index 0000000000000000000000000000000000000000..19cec3226ccd17ef4fb01010af9cebb3e5636228 --- /dev/null +++ b/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithPSMarkSweep.java @@ -0,0 +1,41 @@ +/* + * 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 + * 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.event.gc.refstat; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+PrintGCDetails -XX:+PrintGC -XX:+UseParallelGC -XX:-UseParallelOldGC jdk.jfr.event.gc.refstat.TestRefStatEventWithPSMarkSweep + */ +public class TestRefStatEventWithPSMarkSweep { + public static void main(String[] args) throws Exception { + RefStatEvent.test(GCHelper.gcSerialOld); + } +} diff --git a/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithParallelOld.java b/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithParallelOld.java new file mode 100644 index 0000000000000000000000000000000000000000..da83ce14d4e30b134cab3685bf0e301830961ec0 --- /dev/null +++ b/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithParallelOld.java @@ -0,0 +1,41 @@ +/* + * 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 + * 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.event.gc.refstat; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+PrintGCDetails -XX:+PrintGC -XX:+UseParallelGC -XX:+UseParallelOldGC jdk.jfr.event.gc.refstat.TestRefStatEventWithParallelOld + */ +public class TestRefStatEventWithParallelOld { + public static void main(String[] args) throws Exception { + RefStatEvent.test(GCHelper.gcParallelOld); + } +} diff --git a/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithParallelScavenge.java b/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithParallelScavenge.java new file mode 100644 index 0000000000000000000000000000000000000000..e2a95b5ee9e8ab9004c72a4efcb20dae2bae69c6 --- /dev/null +++ b/test/jdk/jfr/event/gc/refstat/TestRefStatEventWithParallelScavenge.java @@ -0,0 +1,41 @@ +/* + * 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 + * 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.event.gc.refstat; +import jdk.test.lib.jfr.GCHelper; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+PrintGCDetails -XX:+PrintGC -Xmx50m -Xmn2m -XX:-UseLargePages -XX:+UseParallelGC -XX:-UseAdaptiveSizePolicy jdk.jfr.event.gc.refstat.TestRefStatEventWithParallelScavenge + */ +public class TestRefStatEventWithParallelScavenge { + public static void main(String[] args) throws Exception { + RefStatEvent.test(GCHelper.gcParallelScavenge); + } +} diff --git a/test/jdk/jfr/event/gc/stacktrace/AllocationStackTrace.java b/test/jdk/jfr/event/gc/stacktrace/AllocationStackTrace.java new file mode 100644 index 0000000000000000000000000000000000000000..1ed20f83aa050cbbdb4761bc6ad6111a70abfe8f --- /dev/null +++ b/test/jdk/jfr/event/gc/stacktrace/AllocationStackTrace.java @@ -0,0 +1,497 @@ +/* + * 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. 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.event.gc.stacktrace; + +import javax.management.MBeanServer; +import java.lang.management.ManagementFactory; +import com.sun.management.GarbageCollectorMXBean; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedStackTrace; +import jdk.jfr.consumer.RecordedFrame; +import jdk.jfr.consumer.RecordedMethod; +import jdk.jfr.consumer.RecordedThread; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +import java.util.List; +import java.util.ArrayList; + +import java.net.URL; +import java.net.URLClassLoader; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; + +abstract class MemoryAllocator { + + public static final int KB = 1024; + public static final int MB = 1024 * KB; + + public static Object garbage = null; + + abstract public void allocate(); + public void clear() { + garbage = null; + } +} + +class EdenMemoryAllocator extends MemoryAllocator { + + @Override + public void allocate() { + garbage = new byte[10 * KB]; + } +} + +class HumongousMemoryAllocator extends MemoryAllocator { + + @Override + public void allocate() { + garbage = new byte[5 * MB]; + } +} + +/** + * Attempts to fill up young gen and allocate in old gen + */ +class OldGenMemoryAllocator extends MemoryAllocator { + + private List list = new ArrayList(); + private int counter = 6000; + + @Override + public void allocate() { + if (counter-- > 0) { + list.add(new byte[10 * KB]); + } else { + list = new ArrayList(); + counter = 6000; + } + + garbage = list; + } + + @Override + public void clear(){ + list = null; + super.clear(); + } +} + +class MetaspaceMemoryAllocator extends MemoryAllocator { + + private static int counter = 0; + + /** + * Imitates class loading. Each invocation of this method causes a new class + * loader object is created and a new class is loaded by this class loader. + * Method throws OOM when run out of memory. + */ + static protected void loadNewClass() { + try { + String jarUrl = "file:" + (counter++) + ".jar"; + URL[] urls = new URL[]{new URL(jarUrl)}; + URLClassLoader cl = new URLClassLoader(urls); + Proxy.newProxyInstance( + cl, + new Class[]{Foo.class}, + new FooInvocationHandler(new FooBar())); + } catch (java.net.MalformedURLException badThing) { + // should never occur + System.err.println("Unexpected error: " + badThing); + throw new RuntimeException(badThing); + } + } + + @Override + public void allocate() { + try { + loadNewClass(); + } catch (OutOfMemoryError e) { + /* empty */ + } + } + + public static interface Foo { + } + + public static class FooBar implements Foo { + } + + static class FooInvocationHandler implements InvocationHandler { + + private final Foo foo; + + FooInvocationHandler(Foo foo) { + this.foo = foo; + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + return method.invoke(foo, args); + } + } +} + +/** + * Utility class to peform JFR recording, GC provocation/detection and + * stacktrace verification for related JFR events + */ +public class AllocationStackTrace { + + /** + * Tests event stacktrace for young GC if -XX:+UseSerialGC is used + */ + public static void testDefNewAllocEvent() throws Exception { + GarbageCollectorMXBean bean = garbageCollectorMXBean("Copy"); + MemoryAllocator memory = new EdenMemoryAllocator(); + + String[] expectedStack = new String[]{ + "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testAllocEvent", + "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testDefNewAllocEvent" + }; + + testAllocEvent(bean, memory, expectedStack); + } + + /** + * Tests event stacktrace for old GC if -XX:+UseSerialGC is used + */ + public static void testMarkSweepCompactAllocEvent() throws Exception { + GarbageCollectorMXBean bean = garbageCollectorMXBean("MarkSweepCompact"); + MemoryAllocator memory = new OldGenMemoryAllocator(); + + String[] expectedStack = new String[]{ + "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testAllocEvent", + "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testMarkSweepCompactAllocEvent" + }; + + testAllocEvent(bean, memory, expectedStack); + } + + /** + * Tests event stacktrace during metaspace GC threshold if -XX:+UseSerialGC + * is used + */ + public static void testMetaspaceSerialGCAllocEvent() throws Exception { + GarbageCollectorMXBean bean = garbageCollectorMXBean("MarkSweepCompact"); + MemoryAllocator memory = new MetaspaceMemoryAllocator(); + + String[] expectedStack = new String[]{ + "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testAllocEvent", + "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testMetaspaceSerialGCAllocEvent" + }; + + testAllocEvent(bean, memory, expectedStack); + } + + /** + * Tests event stacktrace for young GC if -XX:+UseConcMarkSweepGC is used + */ + public static void testParNewAllocEvent() throws Exception { + GarbageCollectorMXBean bean = garbageCollectorMXBean("ParNew"); + MemoryAllocator memory = new EdenMemoryAllocator(); + + String[] expectedStack = new String[]{ + "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testAllocEvent", + "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testParNewAllocEvent" + }; + + testAllocEvent(bean, memory, expectedStack); + } + + /** + * Tests event stacktrace for old GC if -XX:+UseConcMarkSweepGC is used + */ + public static void testConcMarkSweepAllocEvent() throws Exception { + GarbageCollectorMXBean bean = garbageCollectorMXBean("ConcurrentMarkSweep"); + MemoryAllocator memory = new OldGenMemoryAllocator(); + + String[] expectedStack = new String[]{ + "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testAllocEvent", + "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testConcMarkSweepAllocEvent" + }; + + testAllocEvent(bean, memory, expectedStack); + } + + /** + * Tests event stacktrace during metaspace GC threshold if + * -XX:+UseConcMarkSweepGC is used + */ + public static void testMetaspaceConcMarkSweepGCAllocEvent() throws Exception { + GarbageCollectorMXBean bean = garbageCollectorMXBean("ConcurrentMarkSweep"); + MemoryAllocator memory = new MetaspaceMemoryAllocator(); + + String[] expectedStack = new String[]{ + "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testAllocEvent", + "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testMetaspaceConcMarkSweepGCAllocEvent" + }; + + testAllocEvent(bean, memory, expectedStack); + } + + /** + * Tests event stacktrace for young GC if -XX:+UseParallelGC is used + */ + public static void testParallelScavengeAllocEvent() throws Exception { + GarbageCollectorMXBean bean = garbageCollectorMXBean("PS Scavenge"); + MemoryAllocator memory = new EdenMemoryAllocator(); + + String[] expectedStack = new String[]{ + "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testAllocEvent", + "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testParallelScavengeAllocEvent" + }; + + testAllocEvent(bean, memory, expectedStack); + } + + /** + * Tests event stacktrace for old GC if -XX:+UseParallelGC is used + */ + public static void testParallelMarkSweepAllocEvent() throws Exception { + GarbageCollectorMXBean bean = garbageCollectorMXBean("PS MarkSweep"); + MemoryAllocator memory = new OldGenMemoryAllocator(); + + String[] expectedStack = new String[]{ + "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testAllocEvent", + "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testParallelMarkSweepAllocEvent" + }; + + testAllocEvent(bean, memory, expectedStack); + } + + /** + * Tests event stacktrace during metaspace GC threshold if + * -XX:+UseParallelGC is used + */ + public static void testMetaspaceParallelGCAllocEvent() throws Exception { + GarbageCollectorMXBean bean = garbageCollectorMXBean("PS MarkSweep"); + MemoryAllocator memory = new MetaspaceMemoryAllocator(); + + String[] expectedStack = new String[]{ + "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testAllocEvent", + "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testMetaspaceParallelGCAllocEvent" + }; + + testAllocEvent(bean, memory, expectedStack); + } + + /** + * Tests event stacktrace for young GC if -XX:+UseG1GC is used + */ + public static void testG1YoungAllocEvent() throws Exception { + GarbageCollectorMXBean bean = garbageCollectorMXBean("G1 Young Generation"); + MemoryAllocator memory = new EdenMemoryAllocator(); + + String[] expectedStack = new String[]{ + "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testAllocEvent", + "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testG1YoungAllocEvent" + }; + + testAllocEvent(bean, memory, expectedStack); + } + + /** + * Tests event stacktrace for old GC if -XX:+UseG1GC is used + */ + public static void testG1OldAllocEvent() throws Exception { + GarbageCollectorMXBean bean = garbageCollectorMXBean("G1 Old Generation"); + MemoryAllocator memory = new OldGenMemoryAllocator(); + + String[] expectedStack = new String[]{ + "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testAllocEvent", + "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testG1OldAllocEvent" + }; + + testAllocEvent(bean, memory, expectedStack); + } + + /** + * Tests event stacktrace during metaspace GC threshold if -XX:+UseG1GC is + * used + */ + public static void testMetaspaceG1GCAllocEvent() throws Exception { + GarbageCollectorMXBean bean = garbageCollectorMXBean("G1 Young Generation"); + MemoryAllocator memory = new MetaspaceMemoryAllocator(); + + String[] expectedStack = new String[]{ + "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testAllocEvent", + "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testMetaspaceG1GCAllocEvent" + }; + + testAllocEvent(bean, memory, expectedStack); + } + + /** + * Tests event stacktrace for GC caused by humongous allocations if + * -XX:+UseG1GC is used + */ + public static void testG1HumonAllocEvent() throws Exception { + // G1 tries to reclaim humongous objects at every young collection + // after doing a conservative estimate of its liveness + GarbageCollectorMXBean bean = garbageCollectorMXBean("G1 Young Generation"); + MemoryAllocator memory = new HumongousMemoryAllocator(); + + String[] expectedStack = new String[]{ + "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testAllocEvent", + "jdk.jfr.event.gc.stacktrace.AllocationStackTrace.testG1HumonAllocEvent" + }; + + testAllocEvent(bean, memory, expectedStack); + } + + private static GarbageCollectorMXBean garbageCollectorMXBean(String name) throws Exception { + MBeanServer server = ManagementFactory.getPlatformMBeanServer(); + GarbageCollectorMXBean bean = ManagementFactory.newPlatformMXBeanProxy( + server, "java.lang:type=GarbageCollector,name=" + name, GarbageCollectorMXBean.class); + return bean; + } + + /** + * Performs JFR recording, GC provocation/detection and stacktrace + * verification for JFR event. In case of verification failure + * repeats several times. + * + * @param bean MX bean for desired GC + * @param memory allocator for desired type of allocations + * @param expectedStack array of expected frames + */ + private static void testAllocEvent(GarbageCollectorMXBean bean, MemoryAllocator memory, String[] expectedStack) throws Exception { + // The test checks the stacktrace of events and expects all the events are fired + // in the current thread. But compilation may also trigger GC. + // So to filter out such cases the test performs several iterations and expects + // that the memory allocations made by the test will produce the desired JFR event. + final int iterations = 5; + for (int i = 0; i < iterations; i++) { + if (allocAndCheck(bean, memory, expectedStack)) { + return; + } else { + System.out.println("Attempt: " + i + " out of " + iterations+": no matching stack trace found."); + } + memory.clear(); + } + throw new AssertionError("No matching stack trace found"); + } + + /** + * Performs JFR recording, GC provocation/detection and stacktrace + * verification for JFR event. + * + * @param bean MX bean for desired GC + * @param memory allocator for desired type of allocations + * @param expectedStack array of expected frames + * @throws Exception + */ + private static boolean allocAndCheck(GarbageCollectorMXBean bean, MemoryAllocator memory, + String[] expectedStack) throws Exception { + String threadName = Thread.currentThread().getName(); + String event = EventNames.AllocationRequiringGC; + + Recording r = new Recording(); + r.enable(event).withStackTrace(); + r.start(); + + long prevCollectionCount = bean.getCollectionCount(); + long collectionCount = -1; + + long iterationCount = 0; + + do { + memory.allocate(); + collectionCount = bean.getCollectionCount(); + iterationCount++; + } while (collectionCount == prevCollectionCount); + + System.out.println("Allocation num: " + iterationCount); + System.out.println("GC detected: " + collectionCount); + + r.stop(); + List events = Events.fromRecording(r); + + System.out.println("JFR GC events found: " + events.size()); + + // Find any event that matched the expected stack trace + for (RecordedEvent e : events) { + System.out.println("Event: " + e); + RecordedThread thread = e.getThread(); + String eventThreadName = thread.getJavaName(); + if (!threadName.equals(eventThreadName)) { + continue; + } + if (matchingStackTrace(e.getStackTrace(), expectedStack)) { + return true; + } + } + return false; + } + + private static boolean matchingStackTrace(RecordedStackTrace stack, String[] expectedStack) { + if (stack == null) { + return false; + } + + List frames = stack.getFrames(); + int pos = findFramePos(frames, expectedStack[0]); + + if (pos == -1) { + return false; + } + + for (String expectedFrame : expectedStack) { + RecordedFrame f = frames.get(pos++); + String frame = frameToString(f); + + if (!frame.equals(expectedFrame)) { + return false; + } + } + + return true; + } + + private static int findFramePos(List frames, String frame) { + int pos = 0; + + for (RecordedFrame f : frames) { + if (frame.equals(frameToString(f))) { + return pos; + } + pos++; + } + + return -1; + } + + private static String frameToString(RecordedFrame f) { + RecordedMethod m = f.getMethod(); + String methodName = m.getName(); + String className = m.getType().getName(); + return className + "." + methodName; + } + +} diff --git a/test/jdk/jfr/event/gc/stacktrace/TEST.properties b/test/jdk/jfr/event/gc/stacktrace/TEST.properties new file mode 100644 index 0000000000000000000000000000000000000000..b6ae4201475d78fe1387acf4465158ea7239b402 --- /dev/null +++ b/test/jdk/jfr/event/gc/stacktrace/TEST.properties @@ -0,0 +1,2 @@ +modules = jdk.management + diff --git a/test/jdk/jfr/event/gc/stacktrace/TestConcMarkSweepAllocationPendingStackTrace.java b/test/jdk/jfr/event/gc/stacktrace/TestConcMarkSweepAllocationPendingStackTrace.java new file mode 100644 index 0000000000000000000000000000000000000000..febaa531614de43f9a11fb2c97768d02fd13c286 --- /dev/null +++ b/test/jdk/jfr/event/gc/stacktrace/TestConcMarkSweepAllocationPendingStackTrace.java @@ -0,0 +1,41 @@ +/* + * 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. 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.event.gc.stacktrace; + +/** + * @test + * @key jfr + * + * + * + * @library /lib / + * @run main/othervm -XX:MaxNewSize=10M -Xmx64M -XX:+UseConcMarkSweepGC -XX:+PrintGCDetails -XX:+PrintGC jdk.jfr.event.gc.stacktrace.TestConcMarkSweepAllocationPendingStackTrace + */ +public class TestConcMarkSweepAllocationPendingStackTrace { + + public static void main(String[] args) throws Exception { + AllocationStackTrace.testConcMarkSweepAllocEvent(); + } +} diff --git a/test/jdk/jfr/event/gc/stacktrace/TestDefNewAllocationPendingStackTrace.java b/test/jdk/jfr/event/gc/stacktrace/TestDefNewAllocationPendingStackTrace.java new file mode 100644 index 0000000000000000000000000000000000000000..3af2fa56a5bfd003720ea438f98aa02d61650471 --- /dev/null +++ b/test/jdk/jfr/event/gc/stacktrace/TestDefNewAllocationPendingStackTrace.java @@ -0,0 +1,41 @@ +/* + * 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. 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.event.gc.stacktrace; + +/** + * @test + * @key jfr + * + * + * + * @library /lib / + * @run main/othervm -XX:+UseSerialGC -XX:+PrintGCDetails -XX:+PrintGC jdk.jfr.event.gc.stacktrace.TestDefNewAllocationPendingStackTrace + */ +public class TestDefNewAllocationPendingStackTrace { + + public static void main(String[] args) throws Exception { + AllocationStackTrace.testDefNewAllocEvent(); + } +} diff --git a/test/jdk/jfr/event/gc/stacktrace/TestG1HumongousAllocationPendingStackTrace.java b/test/jdk/jfr/event/gc/stacktrace/TestG1HumongousAllocationPendingStackTrace.java new file mode 100644 index 0000000000000000000000000000000000000000..e882f9e382eb39933a71b42fb7006475630e7c34 --- /dev/null +++ b/test/jdk/jfr/event/gc/stacktrace/TestG1HumongousAllocationPendingStackTrace.java @@ -0,0 +1,41 @@ +/* + * 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. 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.event.gc.stacktrace; + +/** + * @test + * @key jfr + * + * + * + * @library /lib / + * @run main/othervm -XX:+UseG1GC -XX:+PrintGCDetails -XX:+PrintGC -Xmx64M -XX:InitiatingHeapOccupancyPercent=100 jdk.jfr.event.gc.stacktrace.TestG1HumongousAllocationPendingStackTrace + */ +public class TestG1HumongousAllocationPendingStackTrace { + + public static void main(String[] args) throws Exception { + AllocationStackTrace.testG1HumonAllocEvent(); + } +} diff --git a/test/jdk/jfr/event/gc/stacktrace/TestG1OldAllocationPendingStackTrace.java b/test/jdk/jfr/event/gc/stacktrace/TestG1OldAllocationPendingStackTrace.java new file mode 100644 index 0000000000000000000000000000000000000000..62c974eb51a1d2796985e39a3063bcd8bd4766d9 --- /dev/null +++ b/test/jdk/jfr/event/gc/stacktrace/TestG1OldAllocationPendingStackTrace.java @@ -0,0 +1,41 @@ +/* + * 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. 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.event.gc.stacktrace; + +/** + * @test + * @key jfr + * + * + * + * @library /lib / + * @run main/othervm -XX:MaxNewSize=10M -Xmx128M -XX:+UseG1GC -XX:+PrintGCDetails -XX:+PrintGC jdk.jfr.event.gc.stacktrace.TestG1OldAllocationPendingStackTrace + */ +public class TestG1OldAllocationPendingStackTrace { + + public static void main(String[] args) throws Exception { + AllocationStackTrace.testG1OldAllocEvent(); + } +} diff --git a/test/jdk/jfr/event/gc/stacktrace/TestG1YoungAllocationPendingStackTrace.java b/test/jdk/jfr/event/gc/stacktrace/TestG1YoungAllocationPendingStackTrace.java new file mode 100644 index 0000000000000000000000000000000000000000..26296bd8e55ac32700de8f15b1e3947407673b28 --- /dev/null +++ b/test/jdk/jfr/event/gc/stacktrace/TestG1YoungAllocationPendingStackTrace.java @@ -0,0 +1,41 @@ +/* + * 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. 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.event.gc.stacktrace; + +/** + * @test + * @key jfr + * + * + * + * @library /lib / + * @run main/othervm -XX:+UseG1GC -XX:+PrintGCDetails -XX:+PrintGC jdk.jfr.event.gc.stacktrace.TestG1YoungAllocationPendingStackTrace + */ +public class TestG1YoungAllocationPendingStackTrace { + + public static void main(String[] args) throws Exception { + AllocationStackTrace.testG1YoungAllocEvent(); + } +} diff --git a/test/jdk/jfr/event/gc/stacktrace/TestMarkSweepCompactAllocationPendingStackTrace.java b/test/jdk/jfr/event/gc/stacktrace/TestMarkSweepCompactAllocationPendingStackTrace.java new file mode 100644 index 0000000000000000000000000000000000000000..070a5448f3fc5ee2ce166464716c84e8ed5b5776 --- /dev/null +++ b/test/jdk/jfr/event/gc/stacktrace/TestMarkSweepCompactAllocationPendingStackTrace.java @@ -0,0 +1,41 @@ +/* + * 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. 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.event.gc.stacktrace; + +/** + * @test + * @key jfr + * + * + * + * @library /lib / + * @run main/othervm -XX:MaxNewSize=10M -Xmx64M -XX:+UseSerialGC -XX:+PrintGCDetails -XX:+PrintGC jdk.jfr.event.gc.stacktrace.TestMarkSweepCompactAllocationPendingStackTrace + */ +public class TestMarkSweepCompactAllocationPendingStackTrace { + + public static void main(String[] args) throws Exception { + AllocationStackTrace.testMarkSweepCompactAllocEvent(); + } +} diff --git a/test/jdk/jfr/event/gc/stacktrace/TestMetaspaceConcMarkSweepGCAllocationPendingStackTrace.java b/test/jdk/jfr/event/gc/stacktrace/TestMetaspaceConcMarkSweepGCAllocationPendingStackTrace.java new file mode 100644 index 0000000000000000000000000000000000000000..3143a82ee763f183d85128b10a53740fa62179ee --- /dev/null +++ b/test/jdk/jfr/event/gc/stacktrace/TestMetaspaceConcMarkSweepGCAllocationPendingStackTrace.java @@ -0,0 +1,42 @@ +/* + * 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. 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.event.gc.stacktrace; + +/** + * @test + * @key jfr + * + * + * + * + * @library /lib / + * @run main/othervm -XX:+UseConcMarkSweepGC -XX:MaxMetaspaceSize=64M -XX:+PrintGCDetails -XX:+PrintGC jdk.jfr.event.gc.stacktrace.TestMetaspaceConcMarkSweepGCAllocationPendingStackTrace + */ +public class TestMetaspaceConcMarkSweepGCAllocationPendingStackTrace { + + public static void main(String[] args) throws Exception { + AllocationStackTrace.testMetaspaceConcMarkSweepGCAllocEvent(); + } +} diff --git a/test/jdk/jfr/event/gc/stacktrace/TestMetaspaceG1GCAllocationPendingStackTrace.java b/test/jdk/jfr/event/gc/stacktrace/TestMetaspaceG1GCAllocationPendingStackTrace.java new file mode 100644 index 0000000000000000000000000000000000000000..1b533e062a8708bd7986371b4295ec3b33b49512 --- /dev/null +++ b/test/jdk/jfr/event/gc/stacktrace/TestMetaspaceG1GCAllocationPendingStackTrace.java @@ -0,0 +1,42 @@ +/* + * 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. 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.event.gc.stacktrace; +/** + * @test + * @key jfr + * + * + * + * + * @library /lib / + * @run main/othervm -XX:+UseG1GC -XX:+PrintGCDetails -XX:+PrintGC -XX:MaxMetaspaceSize=64M jdk.jfr.event.gc.stacktrace.TestMetaspaceG1GCAllocationPendingStackTrace + */ + +public class TestMetaspaceG1GCAllocationPendingStackTrace { + + public static void main(String[] args) throws Exception { + AllocationStackTrace.testMetaspaceG1GCAllocEvent(); + } +} diff --git a/test/jdk/jfr/event/gc/stacktrace/TestMetaspaceParallelGCAllocationPendingStackTrace.java b/test/jdk/jfr/event/gc/stacktrace/TestMetaspaceParallelGCAllocationPendingStackTrace.java new file mode 100644 index 0000000000000000000000000000000000000000..1a3c26593051dcfb6c5c5bc3f7e0db4bffe39043 --- /dev/null +++ b/test/jdk/jfr/event/gc/stacktrace/TestMetaspaceParallelGCAllocationPendingStackTrace.java @@ -0,0 +1,42 @@ +/* + * 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. 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.event.gc.stacktrace; + +/** + * @test + * @key jfr + * + * + * + * + * @library /lib / + * @run main/othervm -XX:+UseParallelGC -XX:+PrintGCDetails -XX:+PrintGC -XX:MaxMetaspaceSize=64M jdk.jfr.event.gc.stacktrace.TestMetaspaceParallelGCAllocationPendingStackTrace + */ +public class TestMetaspaceParallelGCAllocationPendingStackTrace { + + public static void main(String[] args) throws Exception { + AllocationStackTrace.testMetaspaceParallelGCAllocEvent(); + } +} diff --git a/test/jdk/jfr/event/gc/stacktrace/TestMetaspaceSerialGCAllocationPendingStackTrace.java b/test/jdk/jfr/event/gc/stacktrace/TestMetaspaceSerialGCAllocationPendingStackTrace.java new file mode 100644 index 0000000000000000000000000000000000000000..941e185f2ee188cdd28867dd308ec39c3cc2bcda --- /dev/null +++ b/test/jdk/jfr/event/gc/stacktrace/TestMetaspaceSerialGCAllocationPendingStackTrace.java @@ -0,0 +1,42 @@ +/* + * 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. 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.event.gc.stacktrace; + +/** + * @test + * @key jfr + * + * + * + * + * @library /lib / + * @run main/othervm -XX:+UseSerialGC -XX:+PrintGCDetails -XX:+PrintGC -XX:MaxMetaspaceSize=64M -XX:+FlightRecorder jdk.jfr.event.gc.stacktrace.TestMetaspaceSerialGCAllocationPendingStackTrace + */ +public class TestMetaspaceSerialGCAllocationPendingStackTrace { + + public static void main(String[] args) throws Exception { + AllocationStackTrace.testMetaspaceSerialGCAllocEvent(); + } +} diff --git a/test/jdk/jfr/event/gc/stacktrace/TestParNewAllocationPendingStackTrace.java b/test/jdk/jfr/event/gc/stacktrace/TestParNewAllocationPendingStackTrace.java new file mode 100644 index 0000000000000000000000000000000000000000..e1ccb303af541a9af4770268fe7ee86b7319ab8a --- /dev/null +++ b/test/jdk/jfr/event/gc/stacktrace/TestParNewAllocationPendingStackTrace.java @@ -0,0 +1,41 @@ +/* + * 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. 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.event.gc.stacktrace; + +/** + * @test + * @key jfr + * + * + * + * @library /lib / + * @run main/othervm -XX:+UseConcMarkSweepGC -XX:+PrintGCDetails -XX:+PrintGC -XX:+FlightRecorder jdk.jfr.event.gc.stacktrace.TestParNewAllocationPendingStackTrace + */ +public class TestParNewAllocationPendingStackTrace { + + public static void main(String[] args) throws Exception { + AllocationStackTrace.testParNewAllocEvent(); + } +} diff --git a/test/jdk/jfr/event/gc/stacktrace/TestParallelMarkSweepAllocationPendingStackTrace.java b/test/jdk/jfr/event/gc/stacktrace/TestParallelMarkSweepAllocationPendingStackTrace.java new file mode 100644 index 0000000000000000000000000000000000000000..fcc0b1912c4c7704fca525c7f7c9ec7132d7d061 --- /dev/null +++ b/test/jdk/jfr/event/gc/stacktrace/TestParallelMarkSweepAllocationPendingStackTrace.java @@ -0,0 +1,41 @@ +/* + * 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. 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.event.gc.stacktrace; + +/** + * @test + * @key jfr + * + * + * + * @library /lib / + * @run main/othervm -XX:MaxNewSize=10M -Xmx64M -XX:+UseParallelGC -XX:+PrintGCDetails -XX:+PrintGC -XX:+FlightRecorder jdk.jfr.event.gc.stacktrace.TestParallelMarkSweepAllocationPendingStackTrace + */ +public class TestParallelMarkSweepAllocationPendingStackTrace { + + public static void main(String[] args) throws Exception { + AllocationStackTrace.testParallelMarkSweepAllocEvent(); + } +} diff --git a/test/jdk/jfr/event/gc/stacktrace/TestParallelScavengeAllocationPendingStackTrace.java b/test/jdk/jfr/event/gc/stacktrace/TestParallelScavengeAllocationPendingStackTrace.java new file mode 100644 index 0000000000000000000000000000000000000000..b5a771d3e0da10273e78e4f324a67e2981be615d --- /dev/null +++ b/test/jdk/jfr/event/gc/stacktrace/TestParallelScavengeAllocationPendingStackTrace.java @@ -0,0 +1,41 @@ +/* + * 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. 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.event.gc.stacktrace; + +/** + * @test + * @key jfr + * + * + * + * @library /lib / + * @run main/othervm -XX:+UseParallelGC -XX:+PrintGCDetails -XX:+PrintGC -XX:+FlightRecorder jdk.jfr.event.gc.stacktrace.TestParallelScavengeAllocationPendingStackTrace + */ +public class TestParallelScavengeAllocationPendingStackTrace { + + public static void main(String[] args) throws Exception { + AllocationStackTrace.testParallelScavengeAllocEvent(); + } +} diff --git a/test/jdk/jfr/event/io/EvilInstrument.java b/test/jdk/jfr/event/io/EvilInstrument.java new file mode 100644 index 0000000000000000000000000000000000000000..2f1b8b105f125601e8f0e8a381777cb48f6eee03 --- /dev/null +++ b/test/jdk/jfr/event/io/EvilInstrument.java @@ -0,0 +1,158 @@ +/* + * 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.event.io; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.RandomAccessFile; +import java.lang.instrument.ClassFileTransformer; +import java.lang.instrument.Instrumentation; +import java.net.ServerSocket; +import java.net.Socket; +import java.security.ProtectionDomain; +import java.util.concurrent.CountDownLatch; + + +/** + * @test + * @key jfr + * @summary This test runs JFR with a javaagent that reads/writes files and + * sockets during every class definition. This is to verify that the i/o + * instrumentation in JFR does not interfere with javaagents. + * + * + * @library /lib / + * + * + * @run shell MakeJAR.sh EvilInstrument 'Can-Redefine-Classes: true' + * @run main/othervm -javaagent:EvilInstrument.jar jdk.jfr.event.io.EvilInstrument + */ + +public class EvilInstrument { + + CountDownLatch socketEchoReady = new CountDownLatch(1); + ServerSocket ss; + + /** + * Thread that echos everything from a socket. + */ + class SocketEcho extends Thread + { + public SocketEcho() { + setDaemon(true); + } + + public void run() { + try { + Socket s = ss.accept(); + OutputStream os = s.getOutputStream(); + InputStream is = s.getInputStream(); + socketEchoReady.countDown(); + for(;;) { + int b = is.read(); + os.write(b); + } + } catch(Exception ex) { + ex.printStackTrace(); + System.exit(1); + } + } + } + + public static File createScratchFile() throws IOException { + return File.createTempFile("EvilTransformer", null, new File(".")).getAbsoluteFile(); + } + + class EvilTransformer implements ClassFileTransformer { + File scratch; + Socket s; + volatile boolean inited = false; + + public EvilTransformer() throws Exception { + scratch = createScratchFile(); + ss = new ServerSocket(0); + new SocketEcho().start(); + s = new Socket(ss.getInetAddress(), ss.getLocalPort()); + socketEchoReady.await(); + inited = true; + } + + public byte[] transform(ClassLoader loader, String className, + Class classBeingRedefined, + ProtectionDomain protectionDomain, + byte[] classfileBuffer) + { + if (!inited) { + return null; + } + // Do i/o operations during every transform call. + try { + FileOutputStream fos = new FileOutputStream(scratch); + fos.write(31); + fos.close(); + + FileInputStream fis = new FileInputStream(scratch); + fis.read(); + fis.close(); + + RandomAccessFile raf = new RandomAccessFile(scratch, "rw"); + raf.read(); + raf.write(31); + raf.close(); + + s.getOutputStream().write(31); + s.getInputStream().read(); + + } catch(Exception ex) { + ex.printStackTrace(); + System.exit(1); + } + return null; + } + } + + public static void premain(String agentArgs, Instrumentation inst) { + new EvilInstrument().addTransformer(inst); + } + + private void addTransformer(Instrumentation inst) { + try { + inst.addTransformer(new EvilTransformer()); + } catch(Exception ex) { + ex.printStackTrace(); + System.exit(1); + } + } + + public static void main(String... args) throws Exception { + System.out.println("Hello"); + } + +} diff --git a/test/jdk/jfr/event/io/IOEvent.java b/test/jdk/jfr/event/io/IOEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..e3939fbf88afd5384cda839ab66ea203c19b58ef --- /dev/null +++ b/test/jdk/jfr/event/io/IOEvent.java @@ -0,0 +1,210 @@ +/* + * 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.event.io; + +import java.io.File; +import java.io.IOException; +import java.net.Socket; + +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedThread; +import jdk.test.lib.jfr.EventField; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +// Contains data from a JFR IO event. +public class IOEvent { + public final String thread; + public final EventType eventType; + public final long size; + public final String address; // Name of file or socket address. + public final boolean endOfStream; + + // Constructor is private. Use IOEvent.create... + private IOEvent(String thread, EventType eventType, long size, String address, boolean endOfStream) { + this.thread = thread; + this.eventType = eventType; + this.size = size; + this.address = address; + this.endOfStream = endOfStream; + } + + @Override + public String toString() { + String key = String.format("thread: %s, type: %s, size: %d, address: %s endOfStream: %s", thread, eventType, size, address, endOfStream); + return key; + } + + @Override + public boolean equals(Object object) { + if (object == null || !(object instanceof IOEvent)) { + return false; + } + return toString().equals(object.toString()); + } + + @Override + public int hashCode() { + return toString().hashCode(); + } + + public static final String EVENT_UNKNOWN = "unknown-event??"; + public static final String EVENT_FILE_FORCE = EventNames.FileForce; + public static final String EVENT_FILE_READ = EventNames.FileRead; + public static final String EVENT_FILE_WRITE = EventNames.FileWrite; + public static final String EVENT_SOCKET_READ = EventNames.SocketRead; + public static final String EVENT_SOCKET_WRITE = EventNames.SocketWrite; + + public enum EventType { UnknownEvent, FileForce, FileRead, FileWrite, SocketRead, SocketWrite } + + private static final String[] eventPaths = { + EVENT_UNKNOWN, EVENT_FILE_FORCE, EVENT_FILE_READ, EVENT_FILE_WRITE, EVENT_SOCKET_READ, EVENT_SOCKET_WRITE + }; + + public static boolean isWriteEvent(EventType eventType) { + return (eventType == EventType.SocketWrite || eventType == EventType.FileWrite); + } + + public static boolean isReadEvent(EventType eventType) { + return (eventType == EventType.SocketRead || eventType == EventType.FileRead); + } + + public static boolean isFileEvent(EventType eventType) { + return (eventType == EventType.FileForce || eventType == EventType.FileWrite || eventType == EventType.FileRead); + } + + public static IOEvent createSocketWriteEvent(long size, Socket s) { + if (size < 0) { + size = 0; + } + return new IOEvent(Thread.currentThread().getName(), EventType.SocketWrite, size, getAddress(s), false); + } + + public static IOEvent createSocketReadEvent(long size, Socket s) { + boolean endOfStream = false; + if (size < 0) { + size = 0; + endOfStream = true; + } + return new IOEvent(Thread.currentThread().getName(), EventType.SocketRead, size, getAddress(s), endOfStream); + } + + public static IOEvent createFileForceEvent(File file) { + String address = null; + try { + address = file.getCanonicalPath(); + } catch(IOException ex) { + throw new RuntimeException(); + } + return new IOEvent(Thread.currentThread().getName(), EventType.FileForce, 0, address, false); + } + + public static IOEvent createFileReadEvent(long size, File file) { + boolean endOfStream = false; + if (size < 0) { + endOfStream = true; + size = 0; + } + String address = null; + try { + address = file.getCanonicalPath(); + } catch(IOException ex) { + throw new RuntimeException(); + } + return new IOEvent(Thread.currentThread().getName(), EventType.FileRead, size, address, endOfStream); + } + + public static IOEvent createFileWriteEvent(long size, File file) { + if (size < 0) { + size = 0; + } + String address = null; + try { + address = file.getCanonicalPath(); + } catch(IOException ex) { + throw new RuntimeException(); + } + return new IOEvent(Thread.currentThread().getName(), EventType.FileWrite, size, address, false); + } + + public static EventType getEventType(RecordedEvent event) { + final String path = event.getEventType().getName(); + for (int i = 0; i < eventPaths.length; ++i) { + if (path.endsWith(eventPaths[i])) { + return EventType.values()[i]; + } + } + return EventType.UnknownEvent; + } + + public static IOEvent createTestEvent(RecordedEvent event) { + EventType eventType = getEventType(event); + if (eventType == EventType.UnknownEvent) { + return null; + } + EventField ev = Events.assertField(event, "eventThread"); + RecordedThread t = ev.getValue(); + String thread = t.getJavaName(); + long size = 0L; + if (isWriteEvent(eventType)) { + size = Events.assertField(event, "bytesWritten").getValue(); + } else if (isReadEvent(eventType)) { + size = Events.assertField(event, "bytesRead").getValue(); + } + String address = getEventAddress(event); + boolean endOfStream = false; + if (event.hasField("endOfStream")) { + endOfStream = event.getValue("endOfStream"); + } + if (event.hasField("endOfFile")) { + endOfStream = event.getValue("endOfFile"); + } + return new IOEvent(thread, eventType, size, address, endOfStream); + } + + public static String getEventAddress(RecordedEvent event) { + if (isFileEvent(getEventType(event))) { + String address = Events.assertField(event, "path").getValue(); + // must ensure canonical format + String canonical_path = null; + try { + canonical_path = new File(address).getCanonicalPath(); + } catch (IOException ex) { + throw new RuntimeException(); + } + return canonical_path; + } else { + return String.format("%s/%s:%d", + event.getValue("host"), + event.getValue("address"), + event.getValue("port")); + } + } + + private static String getAddress(Socket s) { + return s.getInetAddress().toString() + ":" + s.getPort(); + } +} diff --git a/test/jdk/jfr/event/io/IOHelper.java b/test/jdk/jfr/event/io/IOHelper.java new file mode 100644 index 0000000000000000000000000000000000000000..f1f2055290716dc5b8016233c8c40ec5cbd75857 --- /dev/null +++ b/test/jdk/jfr/event/io/IOHelper.java @@ -0,0 +1,129 @@ +/* + * 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.event.io; + +import static jdk.test.lib.Asserts.assertEquals; +import static jdk.test.lib.Asserts.assertTrue; + +import java.util.List; +import java.util.stream.Collectors; + +import jdk.jfr.event.io.IOEvent.EventType; + +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.Events; + + +// Helper class to match actual RecordedEvents to expected events. +public class IOHelper { + + public static void verifyEqualsInOrder(List events, List expectedEvents) throws Throwable { + List actualEvents = getTestEvents(events, expectedEvents); + try { + assertEquals(actualEvents.size(), expectedEvents.size(), "Wrong number of events."); + for (int i = 0; i < actualEvents.size(); ++i) { + assertEquals(actualEvents.get(i), expectedEvents.get(i), "Wrong event at pos " + i); + } + } catch (Throwable t) { + logEvents(actualEvents, expectedEvents); + throw t; + } + } + + + public static void verifyEquals(List events, List expectedEvents) throws Throwable { + List actualEvents = getTestEvents(events, expectedEvents); + try { + assertEquals(actualEvents.size(), expectedEvents.size(), "Wrong number of events"); + assertTrue(actualEvents.containsAll(expectedEvents), "Not all expected events received"); + assertTrue(expectedEvents.containsAll(actualEvents), "Received unexpected events"); + } catch (Throwable t) { + logEvents(actualEvents, expectedEvents); + throw t; + } + } + + + private static List getTestEvents(List events, List expectedEvents) throws Throwable { + // Log all events + for (RecordedEvent event : events) { + String msg = event.getEventType().getName(); + boolean isSocket = IOEvent.EVENT_SOCKET_READ.equals(msg) || IOEvent.EVENT_SOCKET_WRITE.equals(msg); + boolean isFile = IOEvent.EVENT_FILE_FORCE.equals(msg) || IOEvent.EVENT_FILE_READ.equals(msg) || IOEvent.EVENT_FILE_WRITE.equals(msg); + boolean isFileReadOrWrite = IOEvent.EVENT_FILE_READ.equals(msg) || IOEvent.EVENT_FILE_WRITE.equals(msg); + boolean isRead = IOEvent.EVENT_FILE_READ.equals(msg) || IOEvent.EVENT_SOCKET_READ.equals(msg); + if (isFile) { + msg += " : " + Events.assertField(event, "path").getValue(); + } else if (isSocket) { + msg += " - " + Events.assertField(event, "host").getValue(); + msg += "." + Events.assertField(event, "address").getValue(); + msg += "." + Events.assertField(event, "port").getValue(); + } + if (isSocket || isFileReadOrWrite) { + String field = isRead ? "bytesRead" : "bytesWritten"; + msg += " : " + Events.assertField(event, field).getValue(); + } + System.out.println(msg); + } + + return events.stream() + .filter(event -> isTestEvent(event, expectedEvents)) + .map(event -> IOEvent.createTestEvent(event)) + .collect(Collectors.toList()); + } + + // A recording may contain extra events that are not part of the test. + // This function filters out events that not belong to the test. + public static boolean isTestEvent(RecordedEvent event, List testEvents) { + EventType eventType = IOEvent.getEventType(event); + if (eventType == EventType.UnknownEvent) { + return false; + } + + // Only care about threads in the expected threads. + final String threadName = event.getThread().getJavaName(); + if (testEvents.stream().noneMatch(te -> te.thread.equals(threadName))) { + return false; + } + + // Only care about files and sockets in expected events. + final String address = IOEvent.getEventAddress(event); + if (testEvents.stream().noneMatch(te -> te.address.equals(address))) { + return false; + } + return true; + } + + private static void logEvents(List actualEvents, List expectedEvents) { + for (int i = 0; i < actualEvents.size(); ++i) { + System.out.println("actual event[" + i + "] = " + actualEvents.get(i)); + } + for (int i = 0; i < expectedEvents.size(); ++i) { + System.out.println("expected event[" + i + "] = " + expectedEvents.get(i)); + } + } + +} diff --git a/test/jdk/jfr/event/io/InstrumentationCallback.java b/test/jdk/jfr/event/io/InstrumentationCallback.java new file mode 100644 index 0000000000000000000000000000000000000000..7ccec702133e807a64d9727ed5a249efa5d5f8f3 --- /dev/null +++ b/test/jdk/jfr/event/io/InstrumentationCallback.java @@ -0,0 +1,49 @@ +/* + * 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.event.io; +import java.util.Set; +import java.util.HashSet; + +// Will be used by the TestInstrumentation.java as a callback from +// instrumented classes. +public class InstrumentationCallback { + + private static Set keys = new HashSet(); + + public static synchronized void callback(String key) { + if (!keys.contains(key)) { + keys.add(key); + } + } + + public static synchronized void clear() { + keys.clear(); + } + + public static synchronized Set getKeysCopy() { + return new HashSet(keys); + } +} diff --git a/test/jdk/jfr/event/io/MakeJAR.sh b/test/jdk/jfr/event/io/MakeJAR.sh new file mode 100644 index 0000000000000000000000000000000000000000..de4d1f3da3f4ac95cc63b1f0cab6365fc71bdcab --- /dev/null +++ b/test/jdk/jfr/event/io/MakeJAR.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +AGENT="$1" + +if [ "${TESTSRC}" = "" ] +then + echo "TESTSRC not set. Test cannot execute. Failed." + exit 1 +fi +echo "TESTSRC=${TESTSRC}" + +if [ "${TESTJAVA}" = "" ] +then + echo "TESTJAVA not set. Test cannot execute. Failed." + exit 1 +fi +echo "TESTJAVA=${TESTJAVA}" + +if [ "${TESTCLASSES}" = "" ] +then + echo "TESTCLASSES not set. Test cannot execute. Failed." + exit 1 +fi + +if [ -z "${COMPILEJAVA}" ] +then + COMPILEJAVA=${TESTJAVA} +fi + +JAVAC="${COMPILEJAVA}/bin/javac -g" +JAR="${COMPILEJAVA}/bin/jar" + +cp ${TESTSRC}/${AGENT}.java . +${JAVAC} -cp ${TESTCLASSPATH} ${AGENT}.java + +echo "Manifest-Version: 1.0" > ${AGENT}.mf +echo Premain-Class: jdk.jfr.event.io.${AGENT} >> ${AGENT}.mf +shift +while [ $# != 0 ] ; do + echo $1 >> ${AGENT}.mf + shift +done + + +${JAR} cvfm ${AGENT}.jar ${AGENT}.mf ${AGENT}*.class diff --git a/test/jdk/jfr/event/io/TestDisabledEvents.java b/test/jdk/jfr/event/io/TestDisabledEvents.java new file mode 100644 index 0000000000000000000000000000000000000000..aad1b217f36e3dbce9dd733082ab8add56dbea80 --- /dev/null +++ b/test/jdk/jfr/event/io/TestDisabledEvents.java @@ -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. 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.event.io; + +import static jdk.test.lib.Asserts.assertEquals; +import static jdk.test.lib.Asserts.assertNotEquals; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.RandomAccessFile; +import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Test with FlightRecorder enabled but with the events disabled. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.io.TestDisabledEvents + */ + +// Verify that IO operations are correct and that no events are generated. +public class TestDisabledEvents { + + private static final int writeInt = 'A'; + private static final byte[] writeBuf = { 'B', 'C', 'D' }; + + public static void main(String[] args) throws Throwable { + File tmp = File.createTempFile("TestDisabledEvents", ".tmp", new File(".")); + tmp.deleteOnExit(); + Recording recording = new Recording(); + recording.disable(IOEvent.EVENT_FILE_READ); + recording.disable(IOEvent.EVENT_FILE_WRITE); + recording.start(); + + useRandomAccessFile(tmp); + useFileStreams(tmp); + useFileChannel(tmp); + + recording.stop(); + for (RecordedEvent event : Events.fromRecording(recording)) { + final String eventName = event.getEventType().getName(); + System.out.println("Got eventName:" + eventName); + assertNotEquals(eventName, IOEvent.EVENT_FILE_READ, "Got disabled read event"); + assertNotEquals(eventName, IOEvent.EVENT_FILE_WRITE, "Got disabled write event"); + } + } + + private static void useRandomAccessFile(File tmp) throws Throwable { + tmp.delete(); + try (RandomAccessFile ras = new RandomAccessFile(tmp, "rw")) { + ras.write(writeInt); + ras.write(writeBuf); + ras.seek(0); + int readInt = ras.read(); + assertEquals(readInt, writeInt, "Wrong readInt"); + byte[] readBuf = new byte[writeBuf.length]; + int readSize = ras.read(readBuf); + assertEquals(readSize, writeBuf.length, "Wrong readSize"); + // Try to read more which should generate EOF. + readInt = ras.read(); + assertEquals(readInt, -1, "Wrong readInt after EOF"); + } + } + + private static void useFileStreams(File tmp) throws Throwable { + tmp.delete(); + try (FileOutputStream fos = new FileOutputStream(tmp)) { + fos.write(writeInt); + fos.write(writeBuf); + } + + try (FileInputStream fis = new FileInputStream(tmp)) { + int readInt = fis.read(); + assertEquals(readInt, writeInt, "Wrong readInt"); + byte[] readBuf = new byte[writeBuf.length]; + int readSize = fis.read(readBuf); + assertEquals(readSize, writeBuf.length, "Wrong readSize"); + // Try to read more which should generate EOF. + readInt = fis.read(); + assertEquals(readInt, -1, "Wrong readInt after EOF"); + } + } + + private static void useFileChannel(File tmp) throws Throwable { + tmp.delete(); + try (RandomAccessFile rf = new RandomAccessFile(tmp, "rw"); + FileChannel ch = rf.getChannel()) { + final String bufContent = "0123456789"; + final int bufSize = bufContent.length(); + ByteBuffer writeBuf = ByteBuffer.allocateDirect(bufSize); + writeBuf.put(bufContent.getBytes()); + + writeBuf.flip(); + int writeSize = ch.write(writeBuf); + assertEquals(writeSize, bufSize, "Wrong writeSize for FileChannel"); + + ch.position(0); + ByteBuffer readBuf = ByteBuffer.allocateDirect(bufSize); + int readSize = ch.read(readBuf); + assertEquals(readSize, bufSize, "Wrong readSize full for FileChannel"); + assertEquals(0, writeBuf.compareTo(readBuf), "Unexpected readBuf content"); + } + } +} diff --git a/test/jdk/jfr/event/io/TestFileChannelEvents.java b/test/jdk/jfr/event/io/TestFileChannelEvents.java new file mode 100644 index 0000000000000000000000000000000000000000..cb90bc54f28f94f560723f951aa14acbb209af4b --- /dev/null +++ b/test/jdk/jfr/event/io/TestFileChannelEvents.java @@ -0,0 +1,123 @@ +/* + * 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.event.io; + +import static jdk.test.lib.Asserts.assertEquals; + +import java.io.File; +import java.io.RandomAccessFile; +import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.io.TestFileChannelEvents + */ +public class TestFileChannelEvents { + public static void main(String[] args) throws Throwable { + File tmp = File.createTempFile("TestFileChannelEvents", ".tmp", new File(".")); + tmp.deleteOnExit(); + Recording recording = new Recording(); + List expectedEvents = new ArrayList<>(); + + try (RandomAccessFile rf = new RandomAccessFile(tmp, "rw"); FileChannel ch = rf.getChannel();) { + recording.enable(IOEvent.EVENT_FILE_FORCE).withThreshold(Duration.ofMillis(0)); + recording.enable(IOEvent.EVENT_FILE_READ).withThreshold(Duration.ofMillis(0)); + recording.enable(IOEvent.EVENT_FILE_WRITE).withThreshold(Duration.ofMillis(0)); + recording.start(); + + ByteBuffer bufA = ByteBuffer.allocateDirect(10); + ByteBuffer bufB = ByteBuffer.allocateDirect(20); + bufA.put("1234567890".getBytes()); + bufB.put("1234567890".getBytes()); + + // test write(ByteBuffer) + bufA.flip(); + long size = ch.write(bufA); + expectedEvents.add(IOEvent.createFileWriteEvent(size, tmp)); + + // test write(ByteBuffer, long) + bufA.flip(); + size = ch.write(bufA, bufA.capacity() / 2); + expectedEvents.add(IOEvent.createFileWriteEvent(size, tmp)); + + // test write(ByteBuffer[]) + bufA.flip(); + bufA.limit(5); + bufB.flip(); + bufB.limit(5); + size = ch.write(new ByteBuffer[] { bufA, bufB }); + expectedEvents.add(IOEvent.createFileWriteEvent(size, tmp)); + + // test force(boolean) + ch.force(true); + expectedEvents.add(IOEvent.createFileForceEvent(tmp)); + + // reset file + ch.position(0); + + // test read(ByteBuffer) + bufA.clear(); + size = ch.read(bufA); + expectedEvents.add(IOEvent.createFileReadEvent(size, tmp)); + + // test read(ByteBuffer, long) + bufA.clear(); + size = ch.read(bufA, bufA.capacity() / 2); + expectedEvents.add(IOEvent.createFileReadEvent(size, tmp)); + + // test read(ByteBuffer[]) + bufA.clear(); + bufA.limit(5); + bufB.clear(); + bufB.limit(5); + size = ch.read(new ByteBuffer[] { bufA, bufB }); + expectedEvents.add(IOEvent.createFileReadEvent(size, tmp)); + + // Read at EOF. Should get size -1 in event. + ch.position(ch.size()); + bufA.clear(); + size = ch.read(bufA); + assertEquals(size, -1L, "Expected size -1 when read at EOF"); + expectedEvents.add(IOEvent.createFileReadEvent(size, tmp)); + + ch.close(); + recording.stop(); + List events = Events.fromRecording(recording); + IOHelper.verifyEqualsInOrder(events, expectedEvents); + } + } +} diff --git a/test/jdk/jfr/event/io/TestFileReadOnly.java b/test/jdk/jfr/event/io/TestFileReadOnly.java new file mode 100644 index 0000000000000000000000000000000000000000..065ebadc39746497be41f2a8745a8553575b675f --- /dev/null +++ b/test/jdk/jfr/event/io/TestFileReadOnly.java @@ -0,0 +1,101 @@ +/* + * 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.event.io; + +import static jdk.test.lib.Asserts.fail; + +import java.io.File; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.io.TestFileReadOnly + */ +public class TestFileReadOnly { + + public static void main(String[] args) throws Throwable { + File tmp = File.createTempFile("TestFileReadOnly", ".tmp", new File(".")); + tmp.deleteOnExit(); + Recording recording = new Recording(); + List expectedEvents = new ArrayList<>(); + + recording.enable(IOEvent.EVENT_FILE_READ).withThreshold(Duration.ofMillis(0)); + recording.enable(IOEvent.EVENT_FILE_WRITE).withThreshold(Duration.ofMillis(0)); + recording.start(); + + final byte[] buf = { 1, 2, 3 }; + + // Create the file. + try (RandomAccessFile f = new RandomAccessFile(tmp, "rw")) { + f.write(buf); + expectedEvents.add(IOEvent.createFileWriteEvent(buf.length, tmp)); + } + + // Reopen the file as ReadOnly and try to write to it. + // Should generate an event with bytesWritten = -1. + try (RandomAccessFile f = new RandomAccessFile(tmp, "r")) { + try { + f.write(buf); + fail("No exception for ReadOnly File"); + } catch (IOException e) { + // Expected exception + expectedEvents.add(IOEvent.createFileWriteEvent(-1, tmp)); + } + } + + // Try to write to read-only FileChannel. + try (RandomAccessFile f = new RandomAccessFile(tmp, "r"); FileChannel ch = f.getChannel()) { + ByteBuffer writeBuf = ByteBuffer.allocateDirect(buf.length); + writeBuf.put(buf); + writeBuf.flip(); + ch.position(0); + try { + ch.write(writeBuf); + fail("No exception for ReadOnly FileChannel"); + } catch (java.nio.channels.NonWritableChannelException e) { + // Expected exception + expectedEvents.add(IOEvent.createFileWriteEvent(-1, tmp)); + } + } + + recording.stop(); + List events = Events.fromRecording(recording); + IOHelper.verifyEqualsInOrder(events, expectedEvents); + } +} diff --git a/test/jdk/jfr/event/io/TestFileStreamEvents.java b/test/jdk/jfr/event/io/TestFileStreamEvents.java new file mode 100644 index 0000000000000000000000000000000000000000..46c7b80f3cdf0ee68d3647d509b9c52d0b472c91 --- /dev/null +++ b/test/jdk/jfr/event/io/TestFileStreamEvents.java @@ -0,0 +1,96 @@ +/* + * 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.event.io; + +import static jdk.test.lib.Asserts.assertEquals; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.Events; + +/** + * @test TestFileStreamEvents + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.io.TestFileStreamEvents + */ + +public class TestFileStreamEvents { + public static void main(String[] args) throws Throwable { + File tmp = File.createTempFile("TestFileStreamEvents", ".tmp", new File(".")); + tmp.deleteOnExit(); + Recording recording = new Recording(); + List expectedEvents = new ArrayList<>(); + + try(FileOutputStream fos = new FileOutputStream(tmp); FileInputStream fis = new FileInputStream(tmp);) { + recording.enable(IOEvent.EVENT_FILE_READ).withThreshold(Duration.ofMillis(0)); + recording.enable(IOEvent.EVENT_FILE_WRITE).withThreshold(Duration.ofMillis(0)); + recording.start(); + + int writeByte = 47; + byte[] writeBuf = {11, 12, 13, 14}; + + // Write + fos.write(writeByte); + expectedEvents.add(IOEvent.createFileWriteEvent(1, tmp)); + fos.write(writeBuf); + expectedEvents.add(IOEvent.createFileWriteEvent(writeBuf.length, tmp)); + fos.write(writeBuf, 0, 2); + expectedEvents.add(IOEvent.createFileWriteEvent(2, tmp)); + + // Read + int readByte = fis.read(); + assertEquals(readByte, writeByte, "Wrong byte read"); + expectedEvents.add(IOEvent.createFileReadEvent(1, tmp)); + + byte[] readBuf = new byte[writeBuf.length]; + long size = fis.read(readBuf); + assertEquals(size, (long)writeBuf.length, "Wrong size when reading byte[]"); + expectedEvents.add(IOEvent.createFileReadEvent(size, tmp)); + + size = fis.read(readBuf, 0, 2); + assertEquals(size, 2L, "Wrong size when reading 2 bytes"); + expectedEvents.add(IOEvent.createFileReadEvent(size, tmp)); + + // We are at EOF. Read more and verify we get size -1. + size = fis.read(readBuf); + assertEquals(size, -1L, "Size should be -1 at EOF"); + expectedEvents.add(IOEvent.createFileReadEvent(size, tmp)); + + recording.stop(); + List events = Events.fromRecording(recording); + IOHelper.verifyEqualsInOrder(events, expectedEvents); + } + } +} diff --git a/test/jdk/jfr/event/io/TestInstrumentation.java b/test/jdk/jfr/event/io/TestInstrumentation.java new file mode 100644 index 0000000000000000000000000000000000000000..d5430e6c6ff38090a97b32093afccf27aa903907 --- /dev/null +++ b/test/jdk/jfr/event/io/TestInstrumentation.java @@ -0,0 +1,373 @@ +/* + * 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.event.io; + +import java.util.Arrays; +import java.util.Set; +import java.util.HashSet; +import java.io.File; +import java.security.ProtectionDomain; +import java.lang.instrument.ClassFileTransformer; +import java.lang.instrument.Instrumentation; +import java.lang.instrument.IllegalClassFormatException; + +import jdk.internal.org.objectweb.asm.ClassReader; +import jdk.internal.org.objectweb.asm.ClassVisitor; +import jdk.internal.org.objectweb.asm.MethodVisitor; +import jdk.internal.org.objectweb.asm.ClassWriter; +import jdk.internal.org.objectweb.asm.Opcodes; +import jdk.internal.org.objectweb.asm.Type; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +/* + * @test + * @summary Test that will instrument the same classes that JFR will also instrument. + * @key jfr + * + * + * @library /lib / + * + + * + * @run main/othervm jdk.jfr.event.io.TestInstrumentation + */ + +// Test that will instrument the same classes that JFR will also instrument. +// +// The methods that will be instrumented, for example java.io.RandomAccessFile.write, +// will add the following code at the start of the method: +// InstrumentationCallback.callback("::"); +// +// The class InstrumentationCallback will log all keys added by the callback() function. +// +// With this instrumentation in place, we will run some existing jfr.io tests +// to verify that our instrumentation has not broken the JFR instrumentation. +// +// After the tests have been run, we verify that the callback() function have been +// called from all instrumented classes and methods. This will verify that JFR has not +// broken our instrumentation. +// +// To use instrumentation, the test must be run in a new java process with +// the -javaagent option. +// We must also create two jars: +// TestInstrumentation.jar: The javaagent for the instrumentation. +// InstrumentationCallback.jar: This is a separate jar with the instrumentation +// callback() function. It is in a separate jar because it must be added to +// the bootclasspath to be called from java.io classes. +// +// The test contains 3 parts: +// Setup part that will create jars and launch the new test instance. +// Agent part that contains the instrumentation code. +// The actual test part is in the TestMain class. +// +public class TestInstrumentation implements ClassFileTransformer { + + private static Instrumentation instrumentation = null; + private static TestInstrumentation testTransformer = null; + + // All methods that will be instrumented. + private static final String[] instrMethodKeys = { + "java/io/RandomAccessFile::seek::(J)V", + "java/io/RandomAccessFile::read::()I", + "java/io/RandomAccessFile::read::([B)I", + "java/io/RandomAccessFile::write::([B)V", + "java/io/RandomAccessFile::write::(I)V", + "java/io/RandomAccessFile::close::()V", + "java/io/FileInputStream::read::([BII)I", + "java/io/FileInputStream::read::([B)I", + "java/io/FileInputStream::read::()I", + "java/io/FileOutputStream::write::(I)V", + "java/io/FileOutputStream::write::([B)V", + "java/io/FileOutputStream::write::([BII)V", + "java/net/SocketInputStream::read::()I", + "java/net/SocketInputStream::read::([B)I", + "java/net/SocketInputStream::read::([BII)I", + "java/net/SocketInputStream::close::()V", + "java/net/SocketOutputStream::write::(I)V", + "java/net/SocketOutputStream::write::([B)V", + "java/net/SocketOutputStream::write::([BII)V", + "java/net/SocketOutputStream::close::()V", + "java/nio/channels/FileChannel::read::([Ljava/nio/ByteBuffer;)J", + "java/nio/channels/FileChannel::write::([Ljava/nio/ByteBuffer;)J", + "java/nio/channels/SocketChannel::open::()Ljava/nio/channels/SocketChannel;", + "java/nio/channels/SocketChannel::open::(Ljava/net/SocketAddress;)Ljava/nio/channels/SocketChannel;", + "java/nio/channels/SocketChannel::read::([Ljava/nio/ByteBuffer;)J", + "java/nio/channels/SocketChannel::write::([Ljava/nio/ByteBuffer;)J", + "sun/nio/ch/FileChannelImpl::read::(Ljava/nio/ByteBuffer;)I", + "sun/nio/ch/FileChannelImpl::write::(Ljava/nio/ByteBuffer;)I", + }; + + private static String getInstrMethodKey(String className, String methodName, String signature) { + // This key is used to identify a class and method. It is sent to callback(key) + return className + "::" + methodName + "::" + signature; + } + + private static String getClassFromMethodKey(String methodKey) { + return methodKey.split("::")[0]; + } + + // Set of all classes targeted for instrumentation. + private static Set instrClassesTarget = null; + + // Set of all classes where instrumentation has been completed. + private static Set instrClassesDone = null; + + static { + // Split class names from InstrMethodKeys. + instrClassesTarget = new HashSet(); + instrClassesDone = new HashSet(); + for (String s : instrMethodKeys) { + String className = getClassFromMethodKey(s); + instrClassesTarget.add(className); + } + } + + private static void log(String msg) { + System.out.println("TestTransformation: " + msg); + } + + + //////////////////////////////////////////////////////////////////// + // This is the actual test part. + // A batch of jfr io tests will be run twice with a + // retransfromClasses() in between. After each test batch we verify + // that all callbacks have been called. + //////////////////////////////////////////////////////////////////// + + public static class TestMain { + + private enum TransformStatus { Transformed, Retransformed, Removed } + + public static void main(String[] args) throws Throwable { + runAllTests(TransformStatus.Transformed); + + // Retransform all classes and then repeat tests + Set> classes = new HashSet>(); + for (String className : instrClassesTarget) { + Class clazz = Class.forName(className.replaceAll("/", ".")); + classes.add(clazz); + log("Will retransform " + clazz.getName()); + } + instrumentation.retransformClasses(classes.toArray(new Class[0])); + + // Clear all callback keys so we don't read keys from the previous test run. + InstrumentationCallback.clear(); + runAllTests(TransformStatus.Retransformed); + + // Remove my test transformer and run tests again. Should not get any callbacks. + instrumentation.removeTransformer(testTransformer); + instrumentation.retransformClasses(classes.toArray(new Class[0])); + InstrumentationCallback.clear(); + runAllTests(TransformStatus.Removed); + } + + // This is not all available jfr io tests, but a reasonable selection. + public static void runAllTests(TransformStatus status) throws Throwable { + log("runAllTests, TransformStatus: " + status); + try { + String[] noArgs = new String[0]; + TestRandomAccessFileEvents.main(noArgs); + TestSocketEvents.main(noArgs); + TestSocketChannelEvents.main(noArgs); + TestFileChannelEvents.main(noArgs); + TestFileStreamEvents.main(noArgs); + TestDisabledEvents.main(noArgs); + + // Verify that all expected callbacks have been called. + Set callbackKeys = InstrumentationCallback.getKeysCopy(); + for (String key : instrMethodKeys) { + boolean gotCallback = callbackKeys.contains(key); + boolean expectsCallback = isClassInstrumented(status, key); + String msg = String.format("key:%s, expects:%b", key, expectsCallback); + if (gotCallback != expectsCallback) { + throw new Exception("Wrong callback() for " + msg); + } else { + log("Correct callback() for " + msg); + } + } + } catch (Throwable t) { + log("Test failed in phase " + status); + t.printStackTrace(); + throw t; + } + } + + private static boolean isClassInstrumented(TransformStatus status, String key) throws Throwable { + switch (status) { + case Retransformed: + return true; + case Removed: + return false; + case Transformed: + String className = getClassFromMethodKey(key); + return instrClassesDone.contains(className); + } + throw new Exception("Test error: Unknown TransformStatus: " + status); + } + } + + + //////////////////////////////////////////////////////////////////// + // This is the setup part. It will create needed jars and + // launch a new java instance that will run the internal class TestMain. + // This setup step is needed because we must use a javaagent jar to + // transform classes. + //////////////////////////////////////////////////////////////////// + + public static void main(String[] args) throws Throwable { + buildJar("TestInstrumentation", true); + buildJar("InstrumentationCallback", false); + launchTest(); + } + + private static void buildJar(String jarName, boolean withManifest) throws Throwable { + final String slash = File.separator; + final String packageName = "jdk/jfr/event/io".replace("/", slash); + System.out.println("buildJar packageName: " + packageName); + + String testClasses = System.getProperty("test.classes", "?"); + String testSrc = System.getProperty("test.src", "?"); + String jarPath = testClasses + slash + jarName + ".jar"; + String manifestPath = testSrc + slash + jarName + ".mf"; + String className = packageName + slash + jarName + ".class"; + + String[] args = null; + if (withManifest) { + args = new String[] {"-cfm", jarPath, manifestPath, "-C", testClasses, className}; + } else { + args = new String[] {"-cf", jarPath, "-C", testClasses, className}; + } + + log("Running jar " + Arrays.toString(args)); + sun.tools.jar.Main jarTool = new sun.tools.jar.Main(System.out, System.err, "jar"); + if (!jarTool.run(args)) { + throw new Exception("jar failed: args=" + Arrays.toString(args)); + } + } + + // Launch the test instance. Will run the internal class TestMain. + private static void launchTest() throws Throwable { + final String slash = File.separator; + + // Need to add jdk/lib/tools.jar to classpath. + String classpath = + System.getProperty("test.class.path", "") + File.pathSeparator + + System.getProperty("test.jdk", ".") + slash + "lib" + slash + "tools.jar"; + String testClassDir = System.getProperty("test.classes", "") + slash; + + String[] args = { + "-Xbootclasspath/a:" + testClassDir + "InstrumentationCallback.jar", + /* "--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED",*/ + "-classpath", classpath, + "-javaagent:" + testClassDir + "TestInstrumentation.jar", + "jdk.jfr.event.io.TestInstrumentation$TestMain" }; + OutputAnalyzer output = ProcessTools.executeTestJvm(args); + output.shouldHaveExitValue(0); + } + + + //////////////////////////////////////////////////////////////////// + // This is the java agent part. Used to transform classes. + // + // Each transformed method will add this call: + // InstrumentationCallback.callback("::"); + //////////////////////////////////////////////////////////////////// + + public static void premain(String args, Instrumentation inst) throws Exception { + instrumentation = inst; + testTransformer = new TestInstrumentation(); + inst.addTransformer(testTransformer, true); + } + + public byte[] transform( + ClassLoader classLoader, String className, Class classBeingRedefined, + ProtectionDomain pd, byte[] bytes) throws IllegalClassFormatException { + // Check if this class should be instrumented. + if (!instrClassesTarget.contains(className)) { + return null; + } + + boolean isRedefinition = classBeingRedefined != null; + log("instrument class(" + className + ") " + (isRedefinition ? "redef" : "load")); + + ClassReader reader = new ClassReader(bytes); + ClassWriter writer = new ClassWriter( + reader, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); + CallbackClassVisitor classVisitor = new CallbackClassVisitor(writer); + reader.accept(classVisitor, 0); + instrClassesDone.add(className); + return writer.toByteArray(); + } + + private static class CallbackClassVisitor extends ClassVisitor { + private String className; + + public CallbackClassVisitor(ClassVisitor cv) { + super(Opcodes.ASM5, cv); + } + + @Override + public void visit( + int version, int access, String name, String signature, + String superName, String[] interfaces) { + cv.visit(version, access, name, signature, superName, interfaces); + className = name; + } + + @Override + public MethodVisitor visitMethod( + int access, String methodName, String desc, String signature, String[] exceptions) { + String methodKey = getInstrMethodKey(className, methodName, desc); + boolean isInstrumentedMethod = Arrays.asList(instrMethodKeys).contains(methodKey); + MethodVisitor mv = cv.visitMethod(access, methodName, desc, signature, exceptions); + if (isInstrumentedMethod && mv != null) { + mv = new CallbackMethodVisitor(mv, methodKey); + log("instrumented " + methodKey); + } + return mv; + } + } + + public static class CallbackMethodVisitor extends MethodVisitor { + private String logMessage; + + public CallbackMethodVisitor(MethodVisitor mv, String logMessage) { + super(Opcodes.ASM5, mv); + this.logMessage = logMessage; + } + + @Override + public void visitCode() { + mv.visitCode(); + String methodDescr = Type.getMethodDescriptor(Type.VOID_TYPE, Type.getType(String.class)); + String className = InstrumentationCallback.class.getName().replace('.', '/'); + mv.visitLdcInsn(logMessage); + mv.visitMethodInsn(Opcodes.INVOKESTATIC, className, "callback", methodDescr); + } + } + +} diff --git a/test/jdk/jfr/event/io/TestInstrumentation.mf b/test/jdk/jfr/event/io/TestInstrumentation.mf new file mode 100644 index 0000000000000000000000000000000000000000..c430c43a2da1808ae982d29b5e899de85e501f09 --- /dev/null +++ b/test/jdk/jfr/event/io/TestInstrumentation.mf @@ -0,0 +1,4 @@ +Manifest-Version: 1.0 +Premain-Class: jdk.jfr.event.io.TestInstrumentation +Can-Redefine-Classes: true +Can-Retransform-Classes: true diff --git a/test/jdk/jfr/event/io/TestRandomAccessFileEvents.java b/test/jdk/jfr/event/io/TestRandomAccessFileEvents.java new file mode 100644 index 0000000000000000000000000000000000000000..959ed4d2226d500e4434b9a94ffc4a1b060293b8 --- /dev/null +++ b/test/jdk/jfr/event/io/TestRandomAccessFileEvents.java @@ -0,0 +1,116 @@ +/* + * 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.event.io; + +import static jdk.test.lib.Asserts.assertEquals; + +import java.io.File; +import java.io.RandomAccessFile; +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.io.TestRandomAccessFileEvents + */ +public class TestRandomAccessFileEvents { + + public static void main(String[] args) throws Throwable { + File tmp = File.createTempFile("TestRandomAccessFileEvents", ".tmp", new File(".")); + tmp.deleteOnExit(); + Recording recording = new Recording(); + List expectedEvents = new ArrayList<>(); + + recording.enable(IOEvent.EVENT_FILE_WRITE).withThreshold(Duration.ofMillis(0)); + recording.enable(IOEvent.EVENT_FILE_READ).withThreshold(Duration.ofMillis(0)); + recording.start(); + + RandomAccessFile ras = new RandomAccessFile(tmp, "rw"); + int writeInt = 47; + byte[] writeBuffer = {10,11,12,13}; + + // Write an int and a buffer. + ras.write(writeInt); + expectedEvents.add(IOEvent.createFileWriteEvent(1, tmp)); + ras.write(writeBuffer); + expectedEvents.add(IOEvent.createFileWriteEvent(writeBuffer.length, tmp)); + + ras.seek(0); + + // Read int and buffer + int readInt = ras.read(); + assertEquals(readInt, writeInt, "wrong int read"); + expectedEvents.add(IOEvent.createFileReadEvent(1, tmp)); + byte[] readBuffer = new byte [writeBuffer.length]; + int size = ras.read(readBuffer); + verifyBufferEquals(readBuffer, writeBuffer); + expectedEvents.add(IOEvent.createFileReadEvent(readBuffer.length, tmp)); + + // Read beyond EOF + readInt = ras.read(); + assertEquals(-1, readInt, "wrong read after EOF"); + expectedEvents.add(IOEvent.createFileReadEvent(-1, tmp)); + + // Seek to beginning and verify we can read after EOF. + ras.seek(0); + readInt = ras.read(); + assertEquals(readInt, writeInt, "wrong int read after seek(0)"); + expectedEvents.add(IOEvent.createFileReadEvent(1, tmp)); + + // seek beyond EOF and verify we get EOF when reading. + ras.seek(10); + readInt = ras.read(); + assertEquals(-1, readInt, "wrong read after seek beyond EOF"); + expectedEvents.add(IOEvent.createFileReadEvent(-1, tmp)); + + // Read partial buffer. + int partialSize = writeBuffer.length - 2; + ras.seek(ras.length()-partialSize); + size = ras.read(readBuffer); + assertEquals(size, partialSize, "Wrong size partial buffer read"); + expectedEvents.add(IOEvent.createFileReadEvent(size, tmp)); + + ras.close(); + recording.stop(); + List events = Events.fromRecording(recording); + IOHelper.verifyEqualsInOrder(events, expectedEvents); + } + + private static void verifyBufferEquals(byte[] a, byte[] b) { + assertEquals(a.length, b.length, "Wrong buffer size"); + for (int i = 0; i < a.length; ++i) { + assertEquals(a[i], b[i], "Wrong buffer content at pos " + i); + } + } +} diff --git a/test/jdk/jfr/event/io/TestRandomAccessFileThread.java b/test/jdk/jfr/event/io/TestRandomAccessFileThread.java new file mode 100644 index 0000000000000000000000000000000000000000..b6200fd6678dfaf54e8cfc8cfbda57424d86ce10 --- /dev/null +++ b/test/jdk/jfr/event/io/TestRandomAccessFileThread.java @@ -0,0 +1,226 @@ +/* + * 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.event.io; + +import java.io.File; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.time.Duration; +import java.time.Instant; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.thread.TestThread; +import jdk.test.lib.thread.XRun; + + +/** + * @test + * @summary Verify the event time stamp and thread name + * @key jfr + * + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps jdk.jfr.event.io.TestRandomAccessFileThread + */ + +// TODO: This test should work without -XX:-UseFastUnorderedTimeStamps + +// The test uses 2 threads to read and write to a file. +// The number of bytes in each read/write operation is increased by 1. +// By looking at the number of bytes in each event, we know in what order +// the events should arrive. This is used to verify the event time stamps. +public class TestRandomAccessFileThread { + private static final int OP_COUNT = 100; // Total number of read/write operations. + private static volatile int writeCount = 0; // Number of writes executed. + + public static void main(String[] args) throws Throwable { + File tmp = File.createTempFile("TestRandomAccessFileThread", ".tmp", new File(".")); + tmp.deleteOnExit(); + + Recording recording = new Recording(); + recording.enable(IOEvent.EVENT_FILE_READ).withThreshold(Duration.ofMillis(0)); + recording.enable(IOEvent.EVENT_FILE_WRITE).withThreshold(Duration.ofMillis(0)); + recording.start(); + + TestThread writerThread = new TestThread(new XRun() { + @Override + public void xrun() throws IOException { + final byte[] buf = new byte[OP_COUNT]; + for (int i = 0; i < buf.length; ++i) { + buf[i] = (byte)((i + 'a') % 255); + } + try (RandomAccessFile raf = new RandomAccessFile(tmp, "rwd")) { + for(int i = 0; i < OP_COUNT; ++i) { + raf.write(buf, 0, i + 1); + writeCount++; + } + } + }}, "TestWriterThread"); + + TestThread readerThread = new TestThread(new XRun() { + @Override + public void xrun() throws IOException { + try (RandomAccessFile raf = new RandomAccessFile(tmp, "r")) { + byte[] buf = new byte[OP_COUNT]; + for(int i = 0; i < OP_COUNT; ++i) { + while (writeCount <= i) { + // No more data to read. Wait for writer thread. + Thread.yield(); + } + int expectedSize = i + 1; + int actualSize = raf.read(buf, 0, expectedSize); + Asserts.assertEquals(actualSize, expectedSize, "Wrong read size. Probably test error."); + } + } + }}, "TestReaderThread"); + + readerThread.start(); + writerThread.start(); + writerThread.joinAndThrow(); + readerThread.joinAndThrow(); + recording.stop(); + + List events = Events.fromRecording(recording); + events.sort(new EventComparator()); + + List readEvents = new ArrayList<>(); + List writeEvents = new ArrayList<>(); + for (RecordedEvent event : events) { + if (!isOurEvent(event, tmp)) { + continue; + } + logEventSummary(event); + if (Events.isEventType(event,IOEvent.EVENT_FILE_READ)) { + readEvents.add(event); + } else { + writeEvents.add(event); + } + } + + verifyThread(readEvents, readerThread); + verifyThread(writeEvents, writerThread); + verifyBytes(readEvents, "bytesRead"); + verifyBytes(writeEvents, "bytesWritten"); + verifyTimes(readEvents); + verifyTimes(writeEvents); + verifyReadWriteTimes(readEvents, writeEvents); + + Asserts.assertEquals(readEvents.size(), OP_COUNT, "Wrong number of read events"); + Asserts.assertEquals(writeEvents.size(), OP_COUNT, "Wrong number of write events"); + } + + private static void logEventSummary(RecordedEvent event) { + boolean isRead = Events.isEventType(event, IOEvent.EVENT_FILE_READ); + String name = isRead ? "read " : "write"; + String bytesField = isRead ? "bytesRead" : "bytesWritten"; + long bytes = Events.assertField(event, bytesField).getValue(); + long commit = Events.assertField(event, "startTime").getValue(); + Instant start = event.getStartTime(); + Instant end = event.getEndTime(); + System.out.printf("%s: bytes=%d, commit=%d, start=%s, end=%s%n", name, bytes, commit, start, end); + } + + private static void verifyThread(List events, Thread thread) { + events.stream().forEach(e -> Events.assertEventThread(e, thread)); + } + + private static void verifyBytes(List events, String fieldName) { + long expectedBytes = 0; + for (RecordedEvent event : events) { + Events.assertField(event, fieldName).equal(++expectedBytes); + } + } + + // Verify that all times are increasing + private static void verifyTimes(List events) { + RecordedEvent prev = null; + for (RecordedEvent curr : events) { + if (prev != null) { + try { + Asserts.assertGreaterThanOrEqual(curr.getStartTime(), prev.getStartTime(), "Wrong startTime"); + Asserts.assertGreaterThanOrEqual(curr.getEndTime(), prev.getEndTime(), "Wrong endTime"); + long commitPrev = Events.assertField(prev, "startTime").getValue(); + long commitCurr = Events.assertField(curr, "startTime").getValue(); + Asserts.assertGreaterThanOrEqual(commitCurr, commitPrev, "Wrong commitTime"); + } catch (Exception e) { + System.out.println("Error: " + e.getMessage()); + System.out.println("Prev Event: " + prev); + System.out.println("Curr Event: " + curr); + throw e; + } + } + prev = curr; + } + } + + // Verify that all times are increasing + private static void verifyReadWriteTimes(List readEvents, List writeEvents) { + List events = new ArrayList<>(); + events.addAll(readEvents); + events.addAll(writeEvents); + events.sort(new EventComparator()); + + int countRead = 0; + int countWrite = 0; + for (RecordedEvent event : events) { + if (Events.isEventType(event, IOEvent.EVENT_FILE_READ)) { + ++countRead; + } else { + ++countWrite; + } + // We can not read from the file before it has been written. + // This check verifies that times of different threads are correct. + // Since the read and write are from different threads, it is possible that the read + // is committed before the same write. + // But read operation may only be 1 step ahead of the write operation. + Asserts.assertLessThanOrEqual(countRead, countWrite + 1, "read must be after write"); + } + } + + private static boolean isOurEvent(RecordedEvent event, File file) { + if (!Events.isEventType(event, IOEvent.EVENT_FILE_READ) && + !Events.isEventType(event, IOEvent.EVENT_FILE_WRITE)) { + return false; + } + String path = Events.assertField(event, "path").getValue(); + return file.getPath().equals(path); + } + + private static class EventComparator implements Comparator { + @Override + public int compare(RecordedEvent a, RecordedEvent b) { + long commitA = Events.assertField(a, "startTime").getValue(); + long commitB = Events.assertField(b, "startTime").getValue(); + return Long.compare(commitA, commitB); + } + } + +} diff --git a/test/jdk/jfr/event/io/TestSocketChannelEvents.java b/test/jdk/jfr/event/io/TestSocketChannelEvents.java new file mode 100644 index 0000000000000000000000000000000000000000..dbd43adbf03182e1f329f537d5594fc95e99933a --- /dev/null +++ b/test/jdk/jfr/event/io/TestSocketChannelEvents.java @@ -0,0 +1,130 @@ +/* + * 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.event.io; + +import static jdk.test.lib.Asserts.assertEquals; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.channels.ServerSocketChannel; +import java.nio.channels.SocketChannel; +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.thread.TestThread; +import jdk.test.lib.thread.XRun; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.io.TestSocketChannelEvents + */ +public class TestSocketChannelEvents { + private static final int bufSizeA = 10; + private static final int bufSizeB = 20; + + private List expectedEvents = new ArrayList<>(); + private synchronized void addExpectedEvent(IOEvent event) { + expectedEvents.add(event); + } + + public static void main(String[] args) throws Throwable { + new TestSocketChannelEvents().test(); + } + + public void test() throws Throwable { + Recording recording = new Recording(); + + try (ServerSocketChannel ss = ServerSocketChannel.open()) { + recording.enable(IOEvent.EVENT_SOCKET_READ).withThreshold(Duration.ofMillis(0)); + recording.enable(IOEvent.EVENT_SOCKET_WRITE).withThreshold(Duration.ofMillis(0)); + recording.start(); + + ss.socket().setReuseAddress(true); + ss.socket().bind(null); + + TestThread readerThread = new TestThread(new XRun() { + @Override + public void xrun() throws IOException { + ByteBuffer bufA = ByteBuffer.allocate(bufSizeA); + ByteBuffer bufB = ByteBuffer.allocate(bufSizeB); + try (SocketChannel sc = ss.accept()) { + int readSize = sc.read(bufA); + assertEquals(readSize, bufSizeA, "Wrong readSize bufA"); + addExpectedEvent(IOEvent.createSocketReadEvent(bufSizeA, sc.socket())); + + bufA.clear(); + bufA.limit(1); + readSize = (int)sc.read(new ByteBuffer[] { bufA, bufB }); + assertEquals(readSize, 1 + bufSizeB, "Wrong readSize 1+bufB"); + addExpectedEvent(IOEvent.createSocketReadEvent(readSize, sc.socket())); + + // We try to read, but client have closed. Should get EOF. + bufA.clear(); + bufA.limit(1); + readSize = sc.read(bufA); + assertEquals(readSize, -1, "Wrong readSize at EOF"); + addExpectedEvent(IOEvent.createSocketReadEvent(-1, sc.socket())); + } + } + }); + readerThread.start(); + + try (SocketChannel sc = SocketChannel.open(ss.socket().getLocalSocketAddress())) { + ByteBuffer bufA = ByteBuffer.allocateDirect(bufSizeA); + ByteBuffer bufB = ByteBuffer.allocateDirect(bufSizeB); + for (int i = 0; i < bufSizeA; ++i) { + bufA.put((byte)('a' + (i % 20))); + } + for (int i = 0; i < bufSizeB; ++i) { + bufB.put((byte)('A' + (i % 20))); + } + bufA.flip(); + bufB.flip(); + + sc.write(bufA); + addExpectedEvent(IOEvent.createSocketWriteEvent(bufSizeA, sc.socket())); + + bufA.clear(); + bufA.limit(1); + int bytesWritten = (int)sc.write(new ByteBuffer[] { bufA, bufB }); + assertEquals(bytesWritten, 1 + bufSizeB, "Wrong bytesWritten 1+bufB"); + addExpectedEvent(IOEvent.createSocketWriteEvent(bytesWritten, sc.socket())); + } + + readerThread.joinAndThrow(); + recording.stop(); + List events= Events.fromRecording(recording); + IOHelper.verifyEquals(events, expectedEvents); + } + } +} diff --git a/test/jdk/jfr/event/io/TestSocketEvents.java b/test/jdk/jfr/event/io/TestSocketEvents.java new file mode 100644 index 0000000000000000000000000000000000000000..c0b64aa7dec8712c2d06ff559a2b17beeea57a8a --- /dev/null +++ b/test/jdk/jfr/event/io/TestSocketEvents.java @@ -0,0 +1,121 @@ +/* + * 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.event.io; + +import static jdk.test.lib.Asserts.assertEquals; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.ServerSocket; +import java.net.Socket; +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.thread.TestThread; +import jdk.test.lib.thread.XRun; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.io.TestSocketEvents + */ +public class TestSocketEvents { + + private static final int writeInt = 'A'; + private static final byte[] writeBuf = { 'B', 'C', 'D', 'E' }; + + private List expectedEvents = new ArrayList<>(); + private synchronized void addExpectedEvent(IOEvent event) { + expectedEvents.add(event); + } + + public static void main(String[] args) throws Throwable { + new TestSocketEvents().test(); + } + + private void test() throws Throwable { + Recording recording = new Recording(); + + try (ServerSocket ss = new ServerSocket()) { + recording.enable(IOEvent.EVENT_SOCKET_READ).withThreshold(Duration.ofMillis(0)); + recording.enable(IOEvent.EVENT_SOCKET_WRITE).withThreshold(Duration.ofMillis(0)); + recording.start(); + + ss.setReuseAddress(true); + ss.bind(null); + + TestThread readerThread = new TestThread(new XRun() { + @Override + public void xrun() throws IOException { + byte[] bs = new byte[4]; + try (Socket s = ss.accept(); InputStream is = s.getInputStream()) { + int readInt = is.read(); + assertEquals(readInt, writeInt, "Wrong readInt"); + addExpectedEvent(IOEvent.createSocketReadEvent(1, s)); + + int bytesRead = is.read(bs, 0, 3); + assertEquals(bytesRead, 3, "Wrong bytesRead partial buffer"); + addExpectedEvent(IOEvent.createSocketReadEvent(bytesRead, s)); + + bytesRead = is.read(bs); + assertEquals(bytesRead, writeBuf.length, "Wrong bytesRead full buffer"); + addExpectedEvent(IOEvent.createSocketReadEvent(bytesRead, s)); + + // Try to read more, but writer have closed. Should get EOF. + readInt = is.read(); + assertEquals(readInt, -1, "Wrong readInt at EOF"); + addExpectedEvent(IOEvent.createSocketReadEvent(-1, s)); + } + } + }); + readerThread.start(); + + try (Socket s = new Socket()) { + s.connect(ss.getLocalSocketAddress()); + try (OutputStream os = s.getOutputStream()) { + os.write(writeInt); + addExpectedEvent(IOEvent.createSocketWriteEvent(1, s)); + os.write(writeBuf, 0, 3); + addExpectedEvent(IOEvent.createSocketWriteEvent(3, s)); + os.write(writeBuf); + addExpectedEvent(IOEvent.createSocketWriteEvent(writeBuf.length, s)); + } + } + + readerThread.joinAndThrow(); + recording.stop(); + List events = Events.fromRecording(recording); + IOHelper.verifyEquals(events, expectedEvents); + } + } +} diff --git a/test/jdk/jfr/event/metadata/TestDefaultConfigurations.java b/test/jdk/jfr/event/metadata/TestDefaultConfigurations.java new file mode 100644 index 0000000000000000000000000000000000000000..0d19419b1dd49b0916b0a2b2a504410d2ee9fa50 --- /dev/null +++ b/test/jdk/jfr/event/metadata/TestDefaultConfigurations.java @@ -0,0 +1,204 @@ +/* + * 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.event.metadata; + +import java.io.IOException; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import jdk.jfr.Configuration; +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorder; +import jdk.jfr.SettingDescriptor; +import jdk.test.lib.jfr.EventNames; + +import org.w3c.dom.Attr; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * + + * + * @run main/othervm jdk.jfr.event.metadata.TestDefaultConfigurations + */ +public class TestDefaultConfigurations { + + private static final String LINE_SEPARATOR = System.getProperty("line.separator"); + + public static void main(String[] args) throws Exception { + List errors = new ArrayList<>(); + + errors.addAll(testConfiguration(Configuration.getConfiguration("default"))); + errors.addAll(testConfiguration(Configuration.getConfiguration("profile"))); + + if (!errors.isEmpty()) { + throwExceptionWithErrors(errors); + } + } + + private static List testConfiguration(Configuration config) throws ParserConfigurationException, SAXException, IOException { + List errors = new ArrayList<>(); + + Map eventTypeLookup = new HashMap<>(); + for (EventType t : FlightRecorder.getFlightRecorder().getEventTypes()) { + eventTypeLookup.put(t.getName(), t); + } + String content = config.getContents(); + Document doc = createDocument(content); + Element configuration = doc.getDocumentElement(); + errors.addAll(checkConfiguration(configuration)); + for (Element event : getChildElements(configuration, "event")) { + String name = event.getAttribute("name"); + + EventType cd = eventTypeLookup.get(name); + if (cd != null) { + errors.addAll(checkSettings(config, cd, event)); + } else { + errors.add("Preset '" + config.getName() + "' reference unknown event '" + name + "'"); + } + eventTypeLookup.remove(name); + } + for (String name : eventTypeLookup.keySet()) { + errors.add("Preset '" + config.getName() + "' doesn't configure event '" + name + "'"); + } + + return errors; + } + + private static void throwExceptionWithErrors(List errors) throws Exception { + StringBuilder sb = new StringBuilder(); + for (String error : errors) { + sb.append(error); + sb.append(LINE_SEPARATOR); + } + throw new Exception(sb.toString()); + } + + private static List checkConfiguration(Element configuration) { + List errors = new ArrayList<>(); + if (configuration.getAttribute("description").length() < 2) { + errors.add("Configuration should have a valid description!"); + } + if (configuration.getAttribute("label").length() < 2) { + errors.add("Configuration should have a label!"); + } + if (!configuration.getAttribute("provider").equals("Oracle")) { + errors.add("Configuration should set provider to 'Oracle'!"); + } + return errors; + } + + private static List checkSettings(Configuration config, EventType eventType, Element event) { + List errors = new ArrayList<>(); + + Set requiredSettings = createRequiredSettingNameSet(eventType); + for (Element setting : getChildElements(event, "setting")) { + String settingName = setting.getAttribute("name"); + if (requiredSettings.contains(settingName)) { + requiredSettings.remove(settingName); + } else { + errors.add("Setting '" + settingName + "' for event '" + eventType.getName() + "' should not be part of confirguaration '" + config.getName() + + "' since it won't have an impact on the event."); + } + } + for (String required : requiredSettings) { + errors.add("Setting '" + required + "' in event '" + eventType.getName() + "' was not configured in the configuration '" + config.getName() + "'"); + } + + return errors; + } + + private static Set createRequiredSettingNameSet(EventType cd) { + Set requiredSettings = new HashSet<>(); + for (SettingDescriptor s : cd.getSettingDescriptors()) { + requiredSettings.add(s.getName()); + } + return requiredSettings; + } + + private static Document createDocument(String content) throws ParserConfigurationException, SAXException, IOException { + DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); + Document doc = dBuilder.parse(new InputSource(new StringReader(content))); + doc.getDocumentElement().normalize(); + // Don't want to add these settings to the jfc-files we ship since they + // are not useful to configure. They are however needed to make the test + // pass. + insertSetting(doc, EventNames.ActiveSetting, "stackTrace", "false"); + insertSetting(doc, EventNames.ActiveSetting, "threshold", "0 ns"); + insertSetting(doc, EventNames.ActiveRecording, "stackTrace", "false"); + insertSetting(doc, EventNames.ActiveRecording, "threshold", "0 ns"); + insertSetting(doc, EventNames.JavaExceptionThrow, "threshold", "0 ns"); + insertSetting(doc, EventNames.JavaErrorThrow, "threshold", "0 ns"); + return doc; + } + + private static void insertSetting(Document doc, String eventName, String settingName, String settingValue) { + for (Element event : getChildElements(doc.getDocumentElement(), "event")) { + Attr attribute = event.getAttributeNode("name"); + if (attribute != null) { + if (eventName.equals(attribute.getValue())) { + Element setting = doc.createElement("setting"); + setting.setAttribute("name", settingName); + setting.setTextContent(settingValue); + event.appendChild(setting); + } + } + } + } + + private static Collection getChildElements(Element parent, String name) { + NodeList elementsByTagName = parent.getElementsByTagName(name); + List elements = new ArrayList<>(); + for (int i = 0; i < elementsByTagName.getLength(); i++) { + Node node = elementsByTagName.item(i); + if (node.getNodeType() == Node.ELEMENT_NODE) { + elements.add((Element) node); + } + } + return elements; + } +} diff --git a/test/jdk/jfr/event/metadata/TestEventMetadata.java b/test/jdk/jfr/event/metadata/TestEventMetadata.java new file mode 100644 index 0000000000000000000000000000000000000000..c6811c5a7827aca8c4f31e2d6b81c122dd651f27 --- /dev/null +++ b/test/jdk/jfr/event/metadata/TestEventMetadata.java @@ -0,0 +1,216 @@ +/* + * 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 + * 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.event.metadata; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorder; +import jdk.jfr.ValueDescriptor; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.metadata.TestEventMetadata + */ + +public class TestEventMetadata { + + /* + * Short guide to writing event metadata + * ===================================== + + * Name + * ---- + * + * Symbolic name that is used to identify an event, or a field. Referred to + * as "id" and "field" in trace.xml-files and @Name in the Java API. If it is + * the name of an event, the name should be prefixed "jdk.", which + * happens automatically for native events. + * + * The name should be short, but not so brief that collision is likely with + * future events or fields. It should only consist of letters and numbers. + * Use Java naming convention , i.e. "FileRead" for an event and + * "allocationRate" for a field. Do not use "_" and don't add the word + * "Event" to the event name. + * + * Abbreviations should be avoided, but may be acceptable if the name + * becomes long, or if it is a well established acronym. Write whole words, + * i.e. "allocation" instead of "alloc". The name should not be a reserved + * Java keyword, i.e "void" or "class". + * + * Label + * ----- + * + * Describes a human-readable name, typically 1-3 words. Use headline-style + * capitalization, capitalize the first and last words, and all nouns, + * pronouns, adjectives, verbs and adverbs. Do not include ending + * punctuation. + * + * Description + * ----------- + * + * Describes an event with a sentence or two. It's better to omit the + * description then copying the label. Use sentence-style + * capitalization, capitalize the first letter of the first word, and any + * proper names such as the word Java. If the description is one sentence, + * period should not be included. + * + * + * Do not forget to set proper units for fields, i.e "NANOS", "MILLS", + * "TICKSPAN" ,"BYETS", "PECENTAGE" etc. in native and @Timespan, @Timespan + * etc. in Java. + */ + public static void main(String[] args) throws Exception { + Set types = new HashSet<>(); + List eventTypes = FlightRecorder.getFlightRecorder().getEventTypes(); + Set eventNames= new HashSet<>(); + for (EventType eventType : eventTypes) { + verifyEventType(eventType); + verifyValueDesscriptors(eventType.getFields(), types); + System.out.println(); + String eventName = eventType.getName(); + if (eventNames.contains(eventName)) { + throw new Exception("Event with name " +eventName+ " already exists"); + } + eventNames.add(eventName); + Set fieldNames = new HashSet<>(); + for (ValueDescriptor v : eventType.getFields()) { + String fieldName = v.getName(); + if (fieldNames.contains(fieldName)) { + throw new Exception("Field with name " + fieldName +" is already in use in event name " +eventName); + } + fieldNames.add(fieldName); + } + } + } + + private static void verifyValueDesscriptors(List fields, Set visitedTypes) { + for (ValueDescriptor v : fields) { + if (!visitedTypes.contains(v.getTypeName())) { + visitedTypes.add(v.getTypeName()); + verifyValueDesscriptors(v.getFields(), visitedTypes); + } + verifyValueDescriptor(v); + } + } + + private static void verifyValueDescriptor(ValueDescriptor v) { + verifyName(v.getName()); + verifyLabel(v.getLabel()); + verifyDescription(v.getDescription()); + } + + private static void verifyDescription(String description) { + if (description == null) { + return; + } + Asserts.assertTrue(description.length() > 10, "Description must be at least ten characters"); + Asserts.assertTrue(description.length() < 300, "Description should not exceed 300 characters. Found " + description); + Asserts.assertTrue(description.length() == description.trim().length(), "Description should not have trim character at start or end"); + Asserts.assertFalse(description.endsWith(".") && description.indexOf(".") == description.length() - 1, "Single sentence descriptions should not use end punctuation"); + } + + private static void verifyName(String name) { + System.out.println("Verifying name: " + name); + Asserts.assertNotEquals(name, null, "Name not allowed to be null"); + Asserts.assertTrue(name.length() > 1, "Name must be at least two characters"); + Asserts.assertTrue(name.length() < 32, "Name should not exceed 32 characters"); + Asserts.assertFalse(isReservedKeyword(name),"Name must not be reserved keyword in the Java language (" + name + ")"); + char firstChar = name.charAt(0); + Asserts.assertTrue(Character.isAlphabetic(firstChar), "Name must start with a character"); + Asserts.assertTrue(Character.isLowerCase(firstChar), "Name must start with lower case letter"); + Asserts.assertTrue(Character.isJavaIdentifierStart(firstChar), "Not valid first character for Java identifier"); + for (int i = 1; i < name.length(); i++) { + Asserts.assertTrue(Character.isJavaIdentifierPart(name.charAt(i)), "Not valid character for a Java identifier"); + Asserts.assertTrue(Character.isAlphabetic(name.charAt(i)), "Name must consists of characters, found '" + name.charAt(i) + "'"); + } + Asserts.assertFalse(name.contains("ID"), "'ID' should not be used in name, consider using 'Id'"); + checkCommonAbbreviations(name); + } + + private static void verifyLabel(String label) { + Asserts.assertNotEquals(label, null, "Label not allowed to be null"); + Asserts.assertTrue(label.length() > 1, "Name must be at least two characters"); + Asserts.assertTrue(label.length() < 45, "Label should not exceed 45 characters, use description to explain " + label); + Asserts.assertTrue(label.length() == label.trim().length(), "Label should not have trim character at start and end"); + Asserts.assertTrue(Character.isUpperCase(label.charAt(0)), "Label should start with upper case letter"); + for (int i = 0; i < label.length(); i++) { + char c = label.charAt(i); + Asserts.assertTrue(Character.isDigit(c) || Character.isAlphabetic(label.charAt(i)) || c == ' ' || c == '(' || c == ')' || c == '-', "Label should only consist of letters or space, found '" + label.charAt(i) + + "'"); + } + } + + private static void verifyEventType(EventType eventType) { + System.out.println("Verifying event: " + eventType.getName()); + verifyDescription(eventType.getDescription()); + verifyLabel(eventType.getLabel()); + Asserts.assertNotEquals(eventType.getName(), null, "Name not allowed to be null"); + Asserts.assertTrue(eventType.getName().startsWith(EventNames.PREFIX), "OpenJDK events must start with " + EventNames.PREFIX); + String name = eventType.getName().substring(EventNames.PREFIX.length()); + Asserts.assertFalse(isReservedKeyword(name),"Name must not be reserved keyword in the Java language (" + name + ")"); + checkCommonAbbreviations(name); + char firstChar = name.charAt(0); + Asserts.assertFalse(name.contains("ID"), "'ID' should not be used in name, consider using 'Id'"); + Asserts.assertTrue(Character.isAlphabetic(firstChar), "Name " + name + " must start with a character"); + Asserts.assertTrue(Character.isUpperCase(firstChar), "Name " + name + " must start with upper case letter"); + for (int i = 0; i < name.length(); i++) { + char c = name.charAt(i); + Asserts.assertTrue(Character.isAlphabetic(c) || Character.isDigit(c), "Name " + name + " must consists of characters or numbers, found '" + name.charAt(i) + "'"); + } + } + + static boolean isReservedKeyword(String s) { + String[] keywords = new String[] { + // "module", "requires", "exports", "to", "uses", "provides", "with", module-info.java + "abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "default", "do", "double", "else", "enum", + "extends", "false", "final", "finally", "float", "for", "goto", "if", "implements", "import", "instanceof", "int", "interface", "long", "native", "new", "null", "package", "private", + "protected", "public", "return", "short", "static", "strictfp", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "true", "try", "void", "volatile", "while" }; + for (int i = 0; i < keywords.length; i++) { + if (s.equals(keywords[i])) { + return true; + } + } + return false; + } + + private static void checkCommonAbbreviations(String name) { + String lowerCased = name.toLowerCase(); + Asserts.assertFalse(lowerCased.contains("info") && !lowerCased.contains("information"), "Use 'information' instead 'info' in name"); + Asserts.assertFalse(lowerCased.contains("alloc") && !lowerCased.contains("alloca"), "Use 'allocation' instead 'alloc' in name"); + Asserts.assertFalse(lowerCased.contains("config") && !lowerCased.contains("configuration"), "Use 'configuration' instead of 'config' in name"); + Asserts.assertFalse(lowerCased.contains("evac") && !lowerCased.contains("evacu"), "Use 'evacuation' instead of 'evac' in name"); + Asserts.assertFalse(lowerCased.contains("stat") && !(lowerCased.contains("state") ||lowerCased.contains("statistic")) , "Use 'statistics' instead of 'stat' in name"); + Asserts.assertFalse(name.contains("ID") , "Use 'id' or 'Id' instead of 'ID' in name"); + } +} diff --git a/test/jdk/jfr/event/metadata/TestLookForUntestedEvents.java b/test/jdk/jfr/event/metadata/TestLookForUntestedEvents.java new file mode 100644 index 0000000000000000000000000000000000000000..93e4e4aae5fe21cb192861496f10420f86bc8d30 --- /dev/null +++ b/test/jdk/jfr/event/metadata/TestLookForUntestedEvents.java @@ -0,0 +1,217 @@ +/* + * 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.event.metadata; + +import java.io.IOException; +import java.lang.reflect.Field; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import jdk.jfr.EventType; +import jdk.jfr.Experimental; +import jdk.jfr.FlightRecorder; +import jdk.test.lib.Utils; +import jdk.test.lib.jfr.EventNames; + +/** + * @test Check for JFR events not covered by tests + * @key jfr + * @library /lib / + * @run main jdk.jfr.event.metadata.TestLookForUntestedEvents + */ +public class TestLookForUntestedEvents { + private static final Path jfrTestRoot = Paths.get(Utils.TEST_SRC).getParent().getParent(); + private static final String MSG_SEPARATOR = "=========================="; + private static Set jfrEventTypes = new HashSet<>(); + + private static final Set hardToTestEvents = new HashSet<>( + Arrays.asList( + "DataLoss", "IntFlag", "ReservedStackActivation", + "DoubleFlag", "UnsignedLongFlagChanged", "IntFlagChanged", + "UnsignedIntFlag", "UnsignedIntFlagChanged", "DoubleFlagChanged") + ); + + // GC uses specific framework to test the events, instead of using event names literally. + // GC tests were inspected, as well as runtime output of GC tests. + // The following events below are know to be covered based on that inspection. + private static final Set coveredGcEvents = new HashSet<>( + Arrays.asList( + "MetaspaceGCThreshold", "MetaspaceAllocationFailure", "MetaspaceOOM", + "MetaspaceChunkFreeListSummary", "G1HeapSummary", "ParallelOldGarbageCollection", + "OldGarbageCollection", "G1GarbageCollection", "GCPhasePause", + "GCPhasePauseLevel1", "GCPhasePauseLevel2", "GCPhasePauseLevel3", + "GCPhasePauseLevel4", "GCPhaseConcurrent") + ); + + // This is a "known failure list" for this test. + // NOTE: if the event is not covered, a bug should be open, and bug number + // noted in the comments for this set. + private static final Set knownNotCoveredEvents = new HashSet<>( + Arrays.asList( + // DumpReason: JDK-8213918 + "DumpReason", + // No G1 IHOP in JDK 8 + "G1BasicIHOP", + "G1AdaptiveIHOP", + // Missing CI in JDK 8 + "CodeSweeperStatistics" + ) + ); + + + public static void main(String[] args) throws Exception { + for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) { + if (type.getAnnotation(Experimental.class) == null) { + jfrEventTypes.add(type.getName().replace("jdk.", "")); + } + } + + checkEventNamesClass(); + lookForEventsNotCoveredByTests(); + } + + // Look thru JFR tests to make sure JFR events are referenced in the tests + private static void lookForEventsNotCoveredByTests() throws Exception { + List paths = Files.walk(jfrTestRoot) + .filter(Files::isRegularFile) + .filter(path -> isJavaFile(path)) + .collect(Collectors.toList()); + + Set eventsNotCoveredByTest = new HashSet<>(jfrEventTypes); + for (String event : jfrEventTypes) { + for (Path p : paths) { + if (findStringInFile(p, event)) { + eventsNotCoveredByTest.remove(event); + break; + } + } + } + + // Account for hard-to-test, experimental and GC tested events + eventsNotCoveredByTest.removeAll(hardToTestEvents); + eventsNotCoveredByTest.removeAll(coveredGcEvents); + + eventsNotCoveredByTest.removeAll(knownNotCoveredEvents); + + if (!eventsNotCoveredByTest.isEmpty()) { + print(MSG_SEPARATOR + " Events not covered by test"); + for (String event: eventsNotCoveredByTest) { + print(event); + } + print(MSG_SEPARATOR); + throw new RuntimeException("Found JFR events not covered by tests"); + } + } + + // Make sure all the JFR events are accounted for in jdk.test.lib.jfr.EventNames + private static void checkEventNamesClass() throws Exception { + // jdk.test.lib.jfr.EventNames + Set eventsFromEventNamesClass = new HashSet<>(); + for (Field f : EventNames.class.getFields()) { + String name = f.getName(); + if (!name.equals("PREFIX")) { + String eventName = (String) f.get(null); + eventName = eventName.replace(EventNames.PREFIX, ""); + eventsFromEventNamesClass.add(eventName); + } + } + + if (!jfrEventTypes.equals(eventsFromEventNamesClass)) { + String exceptionMsg = "Events declared in jdk.test.lib.jfr.EventNames differ " + + "from events returned by FlightRecorder.getEventTypes()"; + print(MSG_SEPARATOR); + print(exceptionMsg); + print(""); + printSetDiff(jfrEventTypes, eventsFromEventNamesClass, + "jfrEventTypes", "eventsFromEventNamesClass"); + print(""); + + print("This could be because:"); + print("1) You forgot to write a unit test. Please do so in test/jdk/jdk/jfr/event/"); + print("2) You wrote a unit test, but you didn't reference the event in"); + print(" test/lib/jdk/test/lib/jfr/EventNames.java. "); + print("3) It is not feasible to test the event, not even a sanity test. "); + print(" Add the event name to test/lib/jdk/test/lib/jfr/EventNames.java "); + print(" and a short comment why it can't be tested"); + print("4) The event is experimental. Please add 'experimental=\"true\"' to "); + print(" element in metadata.xml if it is a native event, or @Experimental if it is a "); + print(" Java event. The event will now not show up in JMC"); + System.out.println(MSG_SEPARATOR); + throw new RuntimeException(exceptionMsg); + } + } + + // ================ Helper methods + private static boolean isJavaFile(Path p) { + String fileName = p.getFileName().toString(); + int i = fileName.lastIndexOf('.'); + if ( (i < 0) || (i > fileName.length()) ) { + return false; + } + return "java".equals(fileName.substring(i+1)); + } + + private static boolean findStringInFile(Path p, String searchTerm) throws IOException { + long c = 0; + try (Stream stream = Files.lines(p)) { + c = stream + .filter(line -> line.contains(searchTerm)) + .count(); + } + return (c != 0); + } + + private static void printSetDiff(Set a, Set b, + String setAName, String setBName) { + if (a.size() > b.size()) { + a.removeAll(b); + System.out.printf("Set %s has more elements than set %s:", setAName, setBName); + System.out.println(); + printSet(a); + } else { + b.removeAll(a); + System.out.printf("Set %s has more elements than set %s:", setBName, setAName); + System.out.println(); + printSet(b); + } + } + + private static void printSet(Set set) { + for (String e : set) { + System.out.println(e); + } + } + + private static void print(String s) { + System.out.println(s); + } +} diff --git a/test/jdk/jfr/event/oldobject/OldObjects.java b/test/jdk/jfr/event/oldobject/OldObjects.java new file mode 100644 index 0000000000000000000000000000000000000000..660c331acc8fff1153c1fccb2b72512d29fcf392 --- /dev/null +++ b/test/jdk/jfr/event/oldobject/OldObjects.java @@ -0,0 +1,281 @@ +/* + * 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. 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.event.oldobject; + +import java.io.IOException; +import java.util.List; +import java.util.function.Predicate; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedClass; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedFrame; +import jdk.jfr.consumer.RecordedMethod; +import jdk.jfr.consumer.RecordedObject; +import jdk.jfr.consumer.RecordedStackTrace; +import jdk.test.lib.jfr.Events; + +/** + * Utility class to perform Old Object provocation/detection and + * stack trace/object verification for the Old Object Sample JFR event + */ +final public class OldObjects { + + public static final int MIN_SIZE = 99901; // prime number + public final static int LEAK_CONTEXT = 100; // length of chain assiociated with the object sample + public final static int ROOT_CONTEXT = 100; // length of chain assoicated with the root + public final static int MAX_CHAIN_LENGTH = LEAK_CONTEXT + ROOT_CONTEXT; // the VM should not construct chains longer than this + + private static String[] getFrames(String expectedFrame) { + if (expectedFrame != null) { + return new String[] { expectedFrame }; + } else { + return null; + } + } + + /** + * + * @param r + * A recording + * @param expectedFrame + * A frame that must be found on the stack. Null if no check is required. + * @param fieldType + * The object type (of the field). Null if no check is required. + * @param fieldName + * The field name. Null if no check is required. + * @param referrerType + * The class name. Null if no check is required. + * @param minDuration + * The minimum duration of the event, -1 if not applicable. + * @return The count of matching events + * @throws IOException + */ + public static long countMatchingEvents(Recording r, String expectedFrame, Class fieldType, String fieldName, Class referrerType, long minDuration) throws IOException { + return countMatchingEvents(r, getFrames(expectedFrame), fieldType, fieldName, referrerType, minDuration); + } + + /** + * Gets the OldObjectSample events from the provided recording through a dump + * and counts how many events matches the provided parameters. + * + * @param r + * A recording + * @param expectedStack + * Some frames that must be found on the stack. Null if no check is required. + * @param fieldType + * The object type (of the field). Null if no check is required. + * @param fieldName + * The field name. Null if no check is required. + * @param referrerType + * The class name. Null if no check is required. + * @param minDuration + * The minimum duration of the event, -1 if not applicable. + * @return The count of matching events + * @throws IOException + */ + public static long countMatchingEvents(Recording r, String[] expectedStack, Class fieldType, String fieldName, Class referrerType, long minDuration) throws IOException { + return countMatchingEvents(Events.fromRecording(r), fieldType, fieldName, referrerType, minDuration, expectedStack); + } + + /** + * + * @param events + * A list of RecordedEvent. + * @param expectedFrame + * A frame that must be found on the stack. Null if no check is required. + * @param fieldType + * The object type (of the field). Null if no check is required. + * @param fieldName + * The field name. Null if no check is required. + * @param referrerType + * The class name. Null if no check is required. + * @param minDuration + * The minimum duration of the event, -1 if not applicable. + * @return The count of matching events + * @throws IOException + */ + public static long countMatchingEvents(List events, String expectedFrame, Class fieldType, String fieldName, Class referrerType, long minDuration) throws IOException { + return countMatchingEvents(events, fieldType, fieldName, referrerType, minDuration, getFrames(expectedFrame)); + } + + /** + * + * @param events + * The list of events to find matching events in + * @param expectedStack + * Some frames that must be found on the stack. Null if no check is required. + * @param fieldType + * The object type (of the field). Null if no check is required. + * @param fieldName + * The field name. Null if no check is required. + * @param referrerType + * The class name. Null if no check is required. + * @param minDuration + * The minimum duration of the event, -1 if not applicable. + * @return The count of matching events + * @throws IOException + */ + public static long countMatchingEvents(List events, Class fieldType, String fieldName, Class referrerType, long minDuration, String... expectedStack) throws IOException { + String currentThread = Thread.currentThread().getName(); + return events.stream() + .filter(hasJavaThread(currentThread)) + .filter(fieldIsType(fieldType)) + .filter(hasFieldName(fieldName)) + .filter(isReferrerType(referrerType)) + .filter(durationAtLeast(minDuration)) + .filter(hasStackTrace(expectedStack)) + .count(); + } + + private static Predicate hasJavaThread(String expectedThread) { + if (expectedThread != null) { + return e -> e.getThread() != null && expectedThread.equals(e.getThread().getJavaName()); + } else { + return e -> true; + } + } + + private static Predicate hasStackTrace(String[] expectedStack) { + if (expectedStack != null) { + return e -> matchingStackTrace(e.getStackTrace(), expectedStack); + } else { + return e -> true; + } + } + + private static Predicate fieldIsType(Class fieldType) { + if (fieldType != null) { + return e -> e.hasField("object.type") && ((RecordedClass) e.getValue("object.type")).getName().equals(fieldType.getName()); + } else { + return e -> true; + } + } + + private static Predicate hasFieldName(String fieldName) { + if (fieldName != null) { + return e -> { + RecordedObject referrer = e.getValue("object.referrer"); + return referrer != null ? referrer.hasField("field.name") && referrer.getValue("field.name").equals(fieldName) : false; + }; + } else { + return e -> true; + } + } + + private static Predicate isReferrerType(Class referrerType) { + if (referrerType != null) { + return e -> { + RecordedObject referrer = e.getValue("object.referrer"); + return referrer != null ? referrer.hasField("object.type") && + ((RecordedClass) referrer.getValue("object.type")).getName().equals(referrerType.getName()) : false; + }; + } else { + return e -> true; + } + } + + private static Predicate durationAtLeast(long minDurationMs) { + if (minDurationMs > 0) { + return e -> e.getDuration().toMillis() >= minDurationMs; + } else { + return e -> true; + } + } + + public static boolean matchingReferrerClass(RecordedEvent event, String className) { + RecordedObject referrer = event.getValue("object.referrer"); + if (referrer != null) { + if (!referrer.hasField("object.type")) { + return false; + } + + String reportedClass = ((RecordedClass) referrer.getValue("object.type")).getName(); + if (reportedClass.equals(className)) { + return true; + } + } + return false; + } + + public static String getReferrerFieldName(RecordedEvent event) { + RecordedObject referrer = event.getValue("object.referrer"); + return referrer != null && referrer.hasField("field.name") ? referrer.getValue("field.name") : null; + } + + public static boolean matchingStackTrace(RecordedStackTrace stack, String[] expectedStack) { + if (stack == null) { + return false; + } + + List frames = stack.getFrames(); + int pos = findFramePos(frames, expectedStack[0]); + + if (pos == -1) { + return false; + } + + for (String expectedFrame : expectedStack) { + RecordedFrame f = frames.get(pos++); + String frame = frameToString(f); + + if (!frame.contains(expectedFrame)) { + return false; + } + } + return true; + } + + private static int findFramePos(List frames, String frame) { + int pos = 0; + for (RecordedFrame f : frames) { + if (frameToString(f).contains(frame)) { + return pos; + } + pos++; + } + return -1; + } + + private static String frameToString(RecordedFrame f) { + RecordedMethod m = f.getMethod(); + String methodName = m.getName(); + String className = m.getType().getName(); + return className + "." + methodName; + } + + public static void validateReferenceChainLimit(RecordedEvent e, int maxLength) { + int length = 0; + RecordedObject object = e.getValue("object"); + while (object != null) { + ++length; + RecordedObject referrer = object.getValue("referrer"); + object = referrer != null ? referrer.getValue("object") : null; + } + if (length > maxLength) { + throw new RuntimeException("Reference chain max length not respected. Found a chain of length " + length); + } + } +} diff --git a/test/jdk/jfr/event/oldobject/TestAllocationTime.java b/test/jdk/jfr/event/oldobject/TestAllocationTime.java new file mode 100644 index 0000000000000000000000000000000000000000..d82ab849db979c38179417696f496fe4b9b0167f --- /dev/null +++ b/test/jdk/jfr/event/oldobject/TestAllocationTime.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.jfr.event.oldobject; + +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Event; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedClass; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedObject; +import jdk.jfr.internal.test.WhiteBox; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * + * @run main/othervm -XX:TLABSize=2k -XX:-FastTLABRefill jdk.jfr.event.oldobject.TestAllocationTime + */ +public class TestAllocationTime { + + private static class BeforeLeakEvent extends Event { + } + private static class AfterLeakEvent extends Event { + } + private static class Leak { + } + + public static List leak = new ArrayList<>(OldObjects.MIN_SIZE); + + public static void main(String[] args) throws Exception { + WhiteBox.setWriteAllObjectSamples(true); + + while(true) { + try (Recording recording = new Recording()) { + leak.clear(); + recording.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "1 h"); + recording.start(); + + BeforeLeakEvent be = new BeforeLeakEvent(); + be.commit(); + + // Allocate array to trigger sampling code path for interpreter / c1 + for (int i = 0; i < OldObjects.MIN_SIZE; i++) { + leak.add(new Leak[0]); + } + + AfterLeakEvent ae = new AfterLeakEvent(); + ae.commit(); + + recording.stop(); + + List events = Events.fromRecording(recording); + Events.hasEvents(events); + RecordedObject sample = findLeak(events, BeforeLeakEvent.class.getName()); + if (sample != null) { + long beforeTime = find(events, BeforeLeakEvent.class.getName()).getValue("startTime"); + long allocationTime = sample.getValue("allocationTime"); + long afterTime = find(events, AfterLeakEvent.class.getName()).getValue("startTime"); + System.out.println("Before time : " + beforeTime); + System.out.println("Allocation time : " + allocationTime); + System.out.println("After time : " + afterTime); + + if (allocationTime < beforeTime) { + throw new Exception("Allocation should not happen this early"); + } + if (allocationTime > afterTime) { + throw new Exception("Allocation should not happen this late"); + } + return; // sample ok + } + } + } + } + + private static RecordedObject findLeak(List events, String name) throws Exception { + for (RecordedEvent e : events) { + if (e.getEventType().getName().equals(EventNames.OldObjectSample)) { + RecordedObject object = e.getValue("object"); + RecordedClass rc = object.getValue("type"); + if (rc.getName().equals(Leak[].class.getName())) { + return e; + } + } + } + return null; + } + + private static RecordedEvent find(List events, String name) throws Exception { + for (RecordedEvent e : events) { + if (e.getEventType().getName().equals(name)) { + return e; + } + } + throw new Exception("Could not find event with name " + name); + } +} diff --git a/test/jdk/jfr/event/oldobject/TestArrayInformation.java b/test/jdk/jfr/event/oldobject/TestArrayInformation.java new file mode 100644 index 0000000000000000000000000000000000000000..1c6050d0218f9a118816f9b024386bb220ce1cee --- /dev/null +++ b/test/jdk/jfr/event/oldobject/TestArrayInformation.java @@ -0,0 +1,125 @@ +/* + * 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.event.oldobject; + +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedClass; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedObject; +import jdk.jfr.internal.test.WhiteBox; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * + * @run main/othervm -XX:TLABSize=2k jdk.jfr.event.oldobject.TestArrayInformation + */ +public class TestArrayInformation { + + private static class ArrayLeak { + } + + private static final int CHAIN_DEPTH = 50; + private static final int ARRAY_SIZE = 52; + private static final int ARRAY_INDEX = 26; + + public static List leak = new ArrayList<>(25); + + public static void main(String[] args) throws Exception { + WhiteBox.setWriteAllObjectSamples(true); + + try (Recording recording = new Recording()) { + recording.enable(EventNames.OldObjectSample).withoutStackTrace().with("cutoff", "infinity"); + recording.start(); + for(int i = 0; i < 25; i++) { + leak.add( buildNestedArray(CHAIN_DEPTH)); + } + recording.stop(); + List events = Events.fromRecording(recording); + Events.hasEvents(events); + verifyObjectArray(events); + } + } + + private static void verifyObjectArray(List events) throws Exception { + for (RecordedEvent e : events) { + RecordedObject object = e.getValue("object"); + RecordedClass objectType = object.getValue("type"); + RecordedObject referrer = object.getValue("referrer"); + System.out.println(objectType.getName()); + if (objectType.getName().equals(ArrayLeak[].class.getName())) { + for (int i = 0; i < CHAIN_DEPTH; i++) { + object = referrer.getValue("object"); + if (object == null) { + throw new Exception("Expected referrer object"); + } + objectType = object.getValue("type"); + if (!objectType.getName().equals(Object[].class.getName())) { + throw new Exception("Expect array class to be named " + Object[].class + " but found " + objectType.getName()); + } + RecordedObject field = referrer.getValue("field"); + if (field != null) { + throw new Exception("Didn't expect to find field"); + } + RecordedObject array = referrer.getValue("array"); + if (array == null) { + throw new Exception("Expected array object, but got null"); + } + int index = referrer.getValue("array.index"); + if (index != ARRAY_INDEX) { + throw new Exception("Expected array index: " + ARRAY_INDEX + ", but got " + index); + } + int size = referrer.getValue("array.size"); + if (size != ARRAY_SIZE) { + throw new Exception("Expected array size: " + ARRAY_SIZE + ", but got " + size); + } + referrer = object.getValue("referrer"); + } + return; + } + } + throw new Exception("Could not find event with " + ArrayLeak[].class + " as (leak) object"); + } + + private static Object buildNestedArray(int depth) { + if (depth > 0) { + Object[] array = new Object[ARRAY_SIZE]; + array[ARRAY_INDEX] = buildNestedArray(depth - 1); + return array; + } else { + return new ArrayLeak[OldObjects.MIN_SIZE]; + } + } + +} diff --git a/test/jdk/jfr/event/oldobject/TestCMS.java b/test/jdk/jfr/event/oldobject/TestCMS.java new file mode 100644 index 0000000000000000000000000000000000000000..2ee8140093f5cd7e49f07512e49afda6e280ab88 --- /dev/null +++ b/test/jdk/jfr/event/oldobject/TestCMS.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. 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.event.oldobject; + +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.internal.test.WhiteBox; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * + * @summary Test leak profiler with CMS GC + * @library /lib / + * + * @run main/othervm -XX:TLABSize=2k -XX:+UseConcMarkSweepGC jdk.jfr.event.oldobject.TestCMS + */ +public class TestCMS { + + static private class FindMe { + } + + public static List list = new ArrayList<>(OldObjects.MIN_SIZE); + + public static void main(String[] args) throws Exception { + WhiteBox.setWriteAllObjectSamples(true); + + try (Recording r = new Recording()) { + r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity"); + r.start(); + allocateFindMe(); + System.gc(); + r.stop(); + List events = Events.fromRecording(r); + System.out.println(events); + if (OldObjects.countMatchingEvents(events, FindMe[].class, null, null, -1, "allocateFindMe") == 0) { + throw new Exception("Could not find leak with " + FindMe[].class); + } + } + } + + public static void allocateFindMe() { + for (int i = 0; i < OldObjects.MIN_SIZE; i++) { + // Allocate array to trigger sampling code path for interpreter / c1 + list.add(new FindMe[0]); + } + } + +} diff --git a/test/jdk/jfr/event/oldobject/TestCircularReference.java b/test/jdk/jfr/event/oldobject/TestCircularReference.java new file mode 100644 index 0000000000000000000000000000000000000000..b068bdb2cb74928b5396b51291236e559dad5a7b --- /dev/null +++ b/test/jdk/jfr/event/oldobject/TestCircularReference.java @@ -0,0 +1,86 @@ +/* + * 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. 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.event.oldobject; + +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.internal.test.WhiteBox; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * + * @run main/othervm -XX:TLABSize=2k jdk.jfr.event.oldobject.TestCircularReference + */ +public class TestCircularReference { + + static class TestCircularReferrer { + // Allocate array to trigger sampling code path for interpreter / c1 + final byte[] leak = new byte[1_0000_000]; + TestCircularReferrer reference; + + public void setReference(TestCircularReferrer reference) { + this.reference = reference; + } + } + + public final static List referenceHolder = new ArrayList<>(OldObjects.MIN_SIZE); + + public static void main(String[] args) throws Exception { + WhiteBox.setWriteAllObjectSamples(true); + + try (Recording r = new Recording()) { + r.enable(EventNames.OldObjectSample).with("cutoff", "infinity").withStackTrace(); + r.start(); + + TestCircularReferrer a = new TestCircularReferrer(); + TestCircularReferrer b = new TestCircularReferrer(); + TestCircularReferrer c = new TestCircularReferrer(); + a.setReference(b); + b.setReference(c); + c.setReference(a); + referenceHolder.add(a); + + TestCircularReferrer selfReflector = new TestCircularReferrer(); + selfReflector.setReference(selfReflector); + referenceHolder.add(selfReflector); + + r.stop(); + + List events = Events.fromRecording(r); + if (events.isEmpty()) { + throw new AssertionError("Expected Old Object Sample events!"); + } + } + } +} diff --git a/test/jdk/jfr/event/oldobject/TestClassLoader.java b/test/jdk/jfr/event/oldobject/TestClassLoader.java new file mode 100644 index 0000000000000000000000000000000000000000..827edf7a095da94397a096640cdc7e8509ecea68 --- /dev/null +++ b/test/jdk/jfr/event/oldobject/TestClassLoader.java @@ -0,0 +1,127 @@ +/* + * 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.event.oldobject; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.io.ByteArrayOutputStream; + +/* + * A special class loader that will, for our test class, make sure that each + * load will become a unique class + */ +public final class TestClassLoader extends ClassLoader { + + public static final class TestClass0000000 { + public static final byte[] oneByte = new byte[1]; + } + + static byte[] classByteCode = readTestClassBytes(); + private static int classIdCounter; + + TestClassLoader() { + super(TestClassLoader.class.getClassLoader()); + } + + public List> loadClasses(int count) throws Exception { + List> classes = new ArrayList<>(); + for (int i = 0; i < count; i++) { + String className = "jdk.jfr.event.oldobject.TestClassLoader$"; + className += "TestClass" + String.format("%07d", classIdCounter++); + Class clazz = Class.forName(className, true, this); + classes.add(clazz); + } + return classes; + } + + @Override + protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { + // If not loading the test class, just go on with the normal class loader + if (!name.contains("TestClass")) { + return super.loadClass(name, resolve); + } + String[] classNameParts = name.split("\\$"); + String newName = classNameParts[1]; + String oldName = "TestClass0000000"; + if (oldName.length() != newName.length()) { + throw new AssertionError("String lengths don't match. Unable to replace class name"); + } + byte[] newBytes = classByteCode.clone(); + replaceBytes(newBytes, oldName.getBytes(), newName.getBytes()); + Class c = defineClass(name, newBytes, 0, newBytes.length); + if (resolve) { + resolveClass(c); + } + return c; + } + + static void replaceBytes(byte[] bytes, byte[] find, byte[] replacement) { + for (int index = 0; index < bytes.length - find.length; index++) { + if (matches(bytes, index, find)) { + replace(bytes, index, replacement); + } + } + } + + private static void replace(byte[] bytes, int startIndex, byte[] replacement) { + for (int index = 0; index < replacement.length; index++) { + bytes[startIndex + index] = replacement[index]; + } + } + + private static boolean matches(byte[] bytes, int startIndex, byte[] matching) { + for (int i = 0; i < matching.length; i++) { + if (bytes[startIndex + i] != matching[i]) { + return false; + } + } + return true; + } + + private static byte[] readTestClassBytes() { + try { + String classFileName = "jdk/jfr/event/oldobject/TestClassLoader$TestClass0000000.class"; + InputStream is = TestClassLoader.class.getClassLoader().getResourceAsStream(classFileName); + if (is == null) { + throw new RuntimeException("Culd not find class file " + classFileName); + } + //byte[] b;= is.readAllBytes(); + //is.read(b); + ByteArrayOutputStream os = new ByteArrayOutputStream(); + byte[] buffer = new byte[0xFFFF]; + for (int len = is.read(buffer); len != -1; len = is.read(buffer)) { + os.write(buffer, 0, len); + } + is.close(); + return os.toByteArray(); + } catch (IOException ioe) { + ioe.printStackTrace(); + throw new RuntimeException(ioe); + } + } +} diff --git a/test/jdk/jfr/event/oldobject/TestClassLoaderLeak.java b/test/jdk/jfr/event/oldobject/TestClassLoaderLeak.java new file mode 100644 index 0000000000000000000000000000000000000000..2aa68f8d56f6d2c41f2d7266aa9b1f0a7fd2dad5 --- /dev/null +++ b/test/jdk/jfr/event/oldobject/TestClassLoaderLeak.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.jfr.event.oldobject; + +import java.lang.reflect.Array; +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedClass; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedObject; +import jdk.jfr.internal.test.WhiteBox; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * + * @run main/othervm -XX:TLABSize=2k jdk.jfr.event.oldobject.TestClassLoaderLeak + */ +public class TestClassLoaderLeak { + + public static List classObjects = new ArrayList<>(OldObjects.MIN_SIZE); + + public static void main(String[] args) throws Exception { + WhiteBox.setWriteAllObjectSamples(true); + + try (Recording r = new Recording()) { + r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity"); + r.start(); + TestClassLoader testClassLoader = new TestClassLoader(); + for (Class clazz : testClassLoader.loadClasses(OldObjects.MIN_SIZE / 20)) { + // Allocate array to trigger sampling code path for interpreter / c1 + for (int i = 0; i < 20; i++) { + Object classArray = Array.newInstance(clazz, 20); + Array.set(classArray, i, clazz.newInstance()); + classObjects.add(classArray); + } + } + r.stop(); + List events = Events.fromRecording(r); + Events.hasEvents(events); + for (RecordedEvent e : events) { + RecordedObject object = e.getValue("object"); + RecordedClass rc = object.getValue("type"); + if (rc.getName().contains("TestClass")) { + return; + } + } + Asserts.fail("Could not find class leak"); + } + } +} diff --git a/test/jdk/jfr/event/oldobject/TestFieldInformation.java b/test/jdk/jfr/event/oldobject/TestFieldInformation.java new file mode 100644 index 0000000000000000000000000000000000000000..4d20728cfdf93dab28e4f462ccaf34bf2916f201 --- /dev/null +++ b/test/jdk/jfr/event/oldobject/TestFieldInformation.java @@ -0,0 +1,121 @@ +/* + * 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.event.oldobject; + +import java.lang.reflect.Modifier; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedObject; +import jdk.jfr.internal.test.WhiteBox; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * + * @run main/othervm -XX:TLABSize=2k -XX:+PrintGCDetails -XX:+PrintGC -verbose:class jdk.jfr.event.oldobject.TestFieldInformation + */ +public class TestFieldInformation { + + public static final Object[] testField = new Object[50]; + + public static void main(String[] args) throws Exception { + WhiteBox.setWriteAllObjectSamples(true); + + try (Recording recording = new Recording()) { + recording.enable(EventNames.OldObjectSample).withoutStackTrace().with("cutoff", "infinity"); + recording.start(); + + addToTestField(); + + recording.stop(); + + List events = Events.fromRecording(recording); + Events.hasEvents(events); + for (RecordedEvent e : events) { + if (hasValidField(e)) { + return; + } + } + System.out.println(events); + Asserts.fail("Could not find old object with field 'testField'"); + } + } + + private static boolean hasValidField(RecordedEvent e) throws Exception { + RecordedObject object = e.getValue("object"); + Set visited = new HashSet<>(); + while (object != null) { + Long address = object.getValue("address"); + if (visited.contains(address)) { + return false; + } + visited.add(address); + RecordedObject referrer = object.getValue("referrer"); + RecordedObject fieldObject = referrer != null ? referrer.getValue("field") : null; + if (fieldObject != null) { + String name = fieldObject.getValue("name"); + if (name != null && name.equals("testField")) { + int modifiers = (short) fieldObject.getValue("modifiers"); + if (!Modifier.isStatic(modifiers)) { + throw new Exception("Field should be static"); + } + if (!Modifier.isPublic(modifiers)) { + throw new Exception("Field should be private"); + } + if (!Modifier.isFinal(modifiers)) { + throw new Exception("Field should be final"); + } + if (Modifier.isTransient(modifiers)) { + throw new Exception("Field should not be transient"); + } + if (Modifier.isVolatile(modifiers)) { + throw new Exception("Field should not be volatile"); + } + return true; + } + } + object = referrer != null ? referrer.getValue("object") : null; + } + return false; + } + + private static void addToTestField() { + for (int i = 0; i < testField.length; i++) { + // Allocate array to trigger sampling code path for interpreter / c1 + testField[i] = new Object[1_000_000]; + } + } +} diff --git a/test/jdk/jfr/event/oldobject/TestG1.java b/test/jdk/jfr/event/oldobject/TestG1.java new file mode 100644 index 0000000000000000000000000000000000000000..238971fe516504170c591993fee7d7386ca6f4f9 --- /dev/null +++ b/test/jdk/jfr/event/oldobject/TestG1.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. 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.event.oldobject; + +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.internal.test.WhiteBox; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * + * @summary Test leak profiler with G1 GC + * @library /lib / + * + * @run main/othervm -XX:TLABSize=2k -XX:+UseG1GC jdk.jfr.event.oldobject.TestG1 + */ +public class TestG1 { + + static private class FindMe { + } + + public static List list = new ArrayList<>(OldObjects.MIN_SIZE); + + public static void main(String[] args) throws Exception { + WhiteBox.setWriteAllObjectSamples(true); + + try (Recording r = new Recording()) { + r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity"); + r.start(); + allocateFindMe(); + System.gc(); + r.stop(); + List events = Events.fromRecording(r); + System.out.println(events); + if (OldObjects.countMatchingEvents(events, FindMe[].class, null, null, -1, "allocateFindMe") == 0) { + throw new Exception("Could not find leak with " + FindMe[].class); + } + } + } + + public static void allocateFindMe() { + for (int i = 0; i < OldObjects.MIN_SIZE; i++) { + // Allocate array to trigger sampling code path for interpreter / c1 + list.add(new FindMe[0]); + } + } + +} diff --git a/test/jdk/jfr/event/oldobject/TestHeapDeep.java b/test/jdk/jfr/event/oldobject/TestHeapDeep.java new file mode 100644 index 0000000000000000000000000000000000000000..11f9df9d7bb88e8dc1ff7c1a7ee734d53d1d2832 --- /dev/null +++ b/test/jdk/jfr/event/oldobject/TestHeapDeep.java @@ -0,0 +1,87 @@ +/* + * 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. 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.event.oldobject; + +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.internal.test.WhiteBox; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * + * @run main/othervm -XX:TLABSize=2k jdk.jfr.event.oldobject.TestHeapDeep + */ +public class TestHeapDeep { + + final static class ChainNode { + final ChainNode next; + List leaks; + + public ChainNode(ChainNode node) { + next = node; + } + } + + public static ChainNode leak; + + public static void main(String[] args) throws Exception { + WhiteBox.setWriteAllObjectSamples(true); + + try (Recording r = new Recording()) { + r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity"); + r.start(); + leak = createChain(); + List events = Events.fromRecording(r); + if (OldObjects.countMatchingEvents(events, byte[].class, null, null, -1, "createChain") == 0) { + throw new Exception("Could not find ChainNode"); + } + for (RecordedEvent e : events) { + OldObjects.validateReferenceChainLimit(e, OldObjects.MAX_CHAIN_LENGTH); + } + } + } + + private static ChainNode createChain() { + ChainNode node = new ChainNode(null); + node.leaks = new ArrayList<>(); + for (int i = 0; i < 100; i++) { + // Allocate arrays to trigger sampling code path for interpreter / c1 + node.leaks.add(new byte[10_000]); + } + for (int i = 0; i < OldObjects.MIN_SIZE; i++) { + node = new ChainNode(node); + } + return node; + } +} diff --git a/test/jdk/jfr/event/oldobject/TestHeapShallow.java b/test/jdk/jfr/event/oldobject/TestHeapShallow.java new file mode 100644 index 0000000000000000000000000000000000000000..bb81e0c729a846da153fa2059a14c1e92cd6c13b --- /dev/null +++ b/test/jdk/jfr/event/oldobject/TestHeapShallow.java @@ -0,0 +1,83 @@ +/* + * 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.event.oldobject; + +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.internal.test.WhiteBox; +import jdk.test.lib.jfr.EventNames; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * + * @run main/othervm -XX:TLABSize=2k jdk.jfr.event.oldobject.TestHeapShallow + */ +public class TestHeapShallow { + private final static long LARGE_OBJECT_FACTOR = 509; // prime number + + static class LeakObject { + Object object = null; + + public LeakObject(Object object) { + this.object = object; + } + } + + public static ArrayList leak = new ArrayList<>(OldObjects.MIN_SIZE); + + public static void main(String[] args) throws Exception { + WhiteBox.setWriteAllObjectSamples(true); + + try (Recording recording = new Recording()) { + recording.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity"); + recording.start(); + + addObjectsToShallowArray(leak); + recording.stop(); + if (OldObjects.countMatchingEvents(recording, "addObjectsToShallowArray", byte[].class, "object", LeakObject.class, -1) < 1) { + throw new Exception("Could not find shallow leak object"); + } + } + } + + private static void addObjectsToShallowArray(List list) { + for (int i = 0; i < OldObjects.MIN_SIZE; i++) { + if (i % LARGE_OBJECT_FACTOR == 0) { + // Triggers allocation outside TLAB path + list.add(new LeakObject(new byte[16384])); + } else { + // Triggers allocation in TLAB path + list.add(new LeakObject(new byte[10])); + } + } + } +} diff --git a/test/jdk/jfr/event/oldobject/TestLargeRootSet.java b/test/jdk/jfr/event/oldobject/TestLargeRootSet.java new file mode 100644 index 0000000000000000000000000000000000000000..f2f29d45a6c5b2f50dd04d47fdb4e562fd18f566 --- /dev/null +++ b/test/jdk/jfr/event/oldobject/TestLargeRootSet.java @@ -0,0 +1,127 @@ +/* + * 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. 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.event.oldobject; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.BrokenBarrierException; +import java.util.concurrent.CyclicBarrier; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedClass; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedObject; +import jdk.jfr.internal.test.WhiteBox; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * + * @run main/othervm -XX:TLABSize=2k -XX:-FastTLABRefill jdk.jfr.event.oldobject.TestLargeRootSet + */ +public class TestLargeRootSet { + + private static final int THREAD_COUNT = 50; + + private static class RootThread extends Thread { + private final CyclicBarrier barrier; + private int maxDepth = OldObjects.MIN_SIZE / THREAD_COUNT; + + public List temporaries = new ArrayList<>(maxDepth); + + RootThread(CyclicBarrier cb) { + this.barrier = cb; + } + + public void run() { + buildRootObjects(); + } + + private void buildRootObjects() { + if (maxDepth-- > 0) { + // Allocate array to trigger sampling code path for interpreter / c1 + StackObject[] stackObject = new StackObject[0]; + temporaries.add(stackObject); // make sure object escapes + buildRootObjects(); + } else { + temporaries.clear(); + try { + barrier.await(); // wait for gc + barrier.await(); // wait for recording to be stopped + } catch (InterruptedException e) { + System.err.println("Thread was unexpected interrupted: " + e.getMessage()); + } catch (BrokenBarrierException e) { + System.err.println("Unexpected barrier exception: " + e.getMessage()); + } + return; + } + } + } + + private static class StackObject { + } + + public static void main(String[] args) throws Exception { + WhiteBox.setWriteAllObjectSamples(true); + + List threads = new ArrayList<>(); + try (Recording r = new Recording()) { + r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity"); + r.start(); + CyclicBarrier cb = new CyclicBarrier(THREAD_COUNT + 1); + for (int i = 0; i < THREAD_COUNT; i++) { + RootThread t = new RootThread(cb); + t.start(); + if (i % 10 == 0) { + // Give threads some breathing room before starting next batch + Thread.sleep(100); + } + threads.add(t); + } + cb.await(); + System.gc(); + r.stop(); + cb.await(); + List events = Events.fromRecording(r); + Events.hasEvents(events); + for (RecordedEvent e : events) { + RecordedObject ro = e.getValue("object"); + RecordedClass rc = ro.getValue("type"); + System.out.println(rc.getName()); + if (rc.getName().equals(StackObject[].class.getName())) { + return; // ok + } + } + Asserts.fail("Could not find root object"); + } + } +} + diff --git a/test/jdk/jfr/event/oldobject/TestLastKnownHeapUsage.java b/test/jdk/jfr/event/oldobject/TestLastKnownHeapUsage.java new file mode 100644 index 0000000000000000000000000000000000000000..b2aa71f61d1d29a2be8d3c37fd23ead0ace1faa9 --- /dev/null +++ b/test/jdk/jfr/event/oldobject/TestLastKnownHeapUsage.java @@ -0,0 +1,87 @@ +/* + * 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. 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.event.oldobject; + +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.jfr.internal.test.WhiteBox; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * + * @run main/othervm -XX:TLABSize=2k -XX:-FastTLABRefill jdk.jfr.event.oldobject.TestLastKnownHeapUsage + */ +public class TestLastKnownHeapUsage { + + public final static List heap = new ArrayList<>(); + + public static void main(String[] args) throws Exception { + WhiteBox.setWriteAllObjectSamples(true); + long last = 0; + for (int i = 1; i <= 5; i++) { + long heapUsage = recordOldObjects(i); + System.out.println("Recording: " + i + " heapUsage=" + heapUsage); + if (heapUsage < last) { + throw new Exception("Unexpect decrease of heap usage"); + } + } + } + + private static long recordOldObjects(int index) throws IOException { + try (Recording r = new Recording()) { + r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity"); + r.start(); + System.gc(); + for (int i = 0; i < 20; i++) { + heap.add(new byte[1_000_000]); + } + System.gc(); + r.stop(); + Path p = Paths.get("recording-" + index + ".jfr"); + r.dump(p); + List events = RecordingFile.readAllEvents(p); + Events.hasEvents(events); + long max = 0; + for (RecordedEvent e : RecordingFile.readAllEvents(p)) { + long heapUsage = Events.assertField(e, "lastKnownHeapUsage").atLeast(0L).below(1_000_000_000L).getValue(); + max = Math.max(max, heapUsage); + } + return max; + } + } +} diff --git a/test/jdk/jfr/event/oldobject/TestListenerLeak.java b/test/jdk/jfr/event/oldobject/TestListenerLeak.java new file mode 100644 index 0000000000000000000000000000000000000000..54329e97fc785d5ad90bc6cf3051988b47575976 --- /dev/null +++ b/test/jdk/jfr/event/oldobject/TestListenerLeak.java @@ -0,0 +1,102 @@ +/* + * 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.event.oldobject; + +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.internal.test.WhiteBox; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * + * @run main/othervm -XX:TLABSize=2k jdk.jfr.event.oldobject.TestListenerLeak + */ +public class TestListenerLeak { + + private interface TestListener { + void onListen(); + } + + static class Stuff { + } + + static class ListenerThread extends Thread { + + private List stuff; + + public ListenerThread(List stuff) { + this.stuff = stuff; + } + + public void run() { + listener.add(new TestListener() { + @Override + public void onListen() { + System.out.println(stuff); + } + }); + } + } + + private static List listener = new ArrayList<>(); + + public static void main(String[] args) throws Exception { + WhiteBox.setWriteAllObjectSamples(true); + + try (Recording r = new Recording()) { + r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity"); + r.start(); + listenerLeak(); + r.stop(); + List events = Events.fromRecording(r); + if (OldObjects.countMatchingEvents(events, Stuff[].class, null, null, -1, "listenerLeak") == 0) { + throw new Exception("Could not find leak with " + Stuff[].class); + } + } + } + + private static void listenerLeak() throws InterruptedException { + List stuff = new ArrayList<>(OldObjects.MIN_SIZE); + for (int i = 0; i < OldObjects.MIN_SIZE; i++) { + // Allocate array to trigger sampling code path for interpreter / c1 + stuff.add(new Stuff[0]); + } + + ListenerThread t = new ListenerThread(stuff); + t.start(); + t.join(); + } + +} diff --git a/test/jdk/jfr/event/oldobject/TestMetadataObject.java b/test/jdk/jfr/event/oldobject/TestMetadataObject.java new file mode 100644 index 0000000000000000000000000000000000000000..fb54d4426d852f6afe5df2af42c1c5ca8efb23a1 --- /dev/null +++ b/test/jdk/jfr/event/oldobject/TestMetadataObject.java @@ -0,0 +1,50 @@ +/* + * 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.event.oldobject; + +/** + * Purpose of this class is to generate a stack trace + * that can be used in a different class loader + * to test metadata retention + * + */ +public final class TestMetadataObject { + public static Object startRecurse() { + return recurse(50); + } + + public static Object recurse(int depth) { + if (depth > 0) { + return recurse(depth - 1); + } else { + return makeMemoryLeak(); + } + } + + public static byte[] makeMemoryLeak() { + return new byte[OldObjects.MIN_SIZE]; + } +} diff --git a/test/jdk/jfr/event/oldobject/TestMetadataRetention.java b/test/jdk/jfr/event/oldobject/TestMetadataRetention.java new file mode 100644 index 0000000000000000000000000000000000000000..269b59fa36119dc5b4d173196222db5c9307a313 --- /dev/null +++ b/test/jdk/jfr/event/oldobject/TestMetadataRetention.java @@ -0,0 +1,189 @@ +/* + * 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. 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.event.oldobject; + +import java.time.Instant; +import java.util.List; + +import jdk.jfr.Event; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedClass; +import jdk.jfr.consumer.RecordedClassLoader; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedFrame; +import jdk.jfr.consumer.RecordedStackTrace; +import jdk.jfr.consumer.RecordedThread; +import jdk.jfr.internal.test.WhiteBox; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.TestClassLoader; + +/** + * @test + * @summary The test verifies that an old object sample maintains references to "stale" metadata + * + * + * @key jfr + * + * @library /lib / + * @build jdk.jfr.event.oldobject.TestMetadataObject + * @run main/othervm -XX:TLABSize=2k -Xmx16m jdk.jfr.event.oldobject.TestMetadataRetention + */ +public final class TestMetadataRetention { + private final static String TEST_PACKAGE = TestMetadataRetention.class.getPackage().getName(); + private final static String TEST_CLASS_LOADER_NAME = "jdk/test/lib/jfr/TestClassLoader"; // see TestClassLoader.java, was "JFR TestClassLoader"; + private final static String TEST_CLASS_NAME = TEST_PACKAGE + ".TestMetadataObject"; + private final static String ALLOCATOR_THREAD_NAME = "TestAllocationThread"; + + public static ClassLoader testClassLoader; + public static Object leakObject; + public static Thread allocatorThread; + public static Class testClass; + + static class ChunkRotation extends Event { + } + + public static void main(String[] args) throws Throwable { + WhiteBox.setWriteAllObjectSamples(true); + int failedAttempts = 0; + while (true) { + try (Recording recording = new Recording()) { + recording.enable(EventNames.OldObjectSample).withStackTrace(); + recording.enable(EventNames.ClassUnload); + recording.start(); + + // Setup metadata on the Java heap (class, stack trace and thread) + testClassLoader = new TestClassLoader(); + testClass = testClassLoader.loadClass(TEST_CLASS_NAME); + allocatorThread = new Thread(TestMetadataRetention::allocateLeak, ALLOCATOR_THREAD_NAME); + allocatorThread.start(); + allocatorThread.join(); + + // Clear out metadata on the heap + testClassLoader = null; + testClass = null; + allocatorThread = null; + + // System.gc() will trigger class unloading if -XX:+ExplicitGCInvokesConcurrent + // is NOT set. If this flag is set G1 will never unload classes on System.gc() + // and CMS will not guarantee that all semantically dead classes will be + // unloaded. As far as the "jfr" key guarantees no VM flags are set from the + // outside it should be enough with System.gc(). + System.gc(); + + // Provoke a chunk rotation, which will flush out ordinary metadata. + provokeChunkRotation(); + ChunkRotation cr = new ChunkRotation(); + cr.commit(); + recording.stop(); + + List events = Events.fromRecording(recording); + RecordedEvent chunkRotation = findChunkRotationEvent(events); + try { + // Sanity check that class was unloaded + Events.hasEvent(recording, EventNames.ClassUnload); + validateClassUnloadEvent(events); + // Validate that metadata for old object event has survived chunk rotation + Events.hasEvent(recording, EventNames.OldObjectSample); + validateOldObjectEvent(events, chunkRotation.getStartTime()); + } catch (Throwable t) { + t.printStackTrace(); + System.err.println("Number of failed attempts " + ++failedAttempts); + continue; + } + break; + } + } + } + + private static RecordedEvent findChunkRotationEvent(List events) { + for (RecordedEvent e : events) { + if (e.getEventType().getName().equals(ChunkRotation.class.getName())) { + return e; + } + } + Asserts.fail("Could not find chunk rotation event"); + return null; // Can't happen; + } + + private static void allocateLeak() { + try { + leakObject = testClass.getMethod("startRecurse").invoke(null); + } catch (Exception e) { + System.out.println("Could not allocate memory leak!"); + e.printStackTrace(); + } + } + + private static void provokeChunkRotation() { + try (Recording r = new Recording()) { + r.start(); + r.stop(); + } + } + + private static void validateClassUnloadEvent(List events) throws Throwable { + for (RecordedEvent event : events) { + if (event.getEventType().getName().equals(EventNames.ClassUnload)) { + RecordedClass unloadedClass = event.getValue("unloadedClass"); + if (TEST_CLASS_NAME.equals(unloadedClass.getName())) { + RecordedClassLoader definingClassLoader = unloadedClass.getClassLoader(); + Asserts.assertEquals(TEST_CLASS_LOADER_NAME, definingClassLoader.getName(), "Expected " + TEST_CLASS_LOADER_NAME + ", got " + definingClassLoader.getType().getName()); + return; + } + } + } + } + + private static void validateOldObjectEvent(List events, Instant chunkRotation) throws Throwable { + for (RecordedEvent event : events) { + if (event.getEventType().getName().equals(EventNames.OldObjectSample)) { + // Only check event after the rotation + if (!event.getStartTime().isBefore(chunkRotation)) { + System.out.println(event); + RecordedThread rt = event.getThread(); + if (rt.getJavaName().equals(ALLOCATOR_THREAD_NAME)) { + RecordedStackTrace s = event.getStackTrace(); + assertStackTrace(s, "startRecurse"); + assertStackTrace(s, "recurse"); + return; + } + } + } + } + + Asserts.fail("Did not find an old object event with thread " + ALLOCATOR_THREAD_NAME); + } + + private static void assertStackTrace(RecordedStackTrace stacktrace, final String methodName) { + for (RecordedFrame f : stacktrace.getFrames()) { + if (f.getMethod().getName().equals(methodName)) { + return; + } + } + Asserts.fail("Could not find class " + methodName + " in stack trace " + stacktrace); + } +} diff --git a/test/jdk/jfr/event/oldobject/TestObjectDescription.java b/test/jdk/jfr/event/oldobject/TestObjectDescription.java new file mode 100644 index 0000000000000000000000000000000000000000..cac1b4448a57f8d33f6a23d263a074fa450b184c --- /dev/null +++ b/test/jdk/jfr/event/oldobject/TestObjectDescription.java @@ -0,0 +1,216 @@ +/* + * 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.event.oldobject; + +import java.lang.reflect.Array; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.Callable; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedObject; +import jdk.jfr.internal.test.WhiteBox; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * + * @run main/othervm -XX:TLABSize=2k jdk.jfr.event.oldobject.TestObjectDescription + */ +public class TestObjectDescription { + + private static final int OBJECT_DESCRIPTION_MAX_SIZE = 100; + private static final String CLASS_NAME = TestClassLoader.class.getName() + "$TestClass"; + public static List leaks; + + public final static class MyThreadGroup extends ThreadGroup { + public final static String NAME = "My Thread Group"; + + public MyThreadGroup(String name) { + super(name); + } + + // Allocate array to trigger sampling code path for interpreter / c1 + byte[] bytes = new byte[10]; + } + + public final static class MyThread extends Thread { + public final static String NAME = "My Thread"; + + public MyThread() { + super(NAME); + } + + // Allocate array to trigger sampling code path for interpreter / c1 + byte[] bytes = new byte[10]; + } + + public static void main(String[] args) throws Exception { + WhiteBox.setWriteAllObjectSamples(true); + + testThreadGroupName(); + testThreadName(); + testClassName(); + testSize(); + testEllipsis(); + } + + private static void testThreadName() throws Exception { + asseertObjectDescription(() -> { + List threads = new ArrayList<>(OldObjects.MIN_SIZE); + for (int i = 0; i < OldObjects.MIN_SIZE; i++) { + threads.add(new MyThread()); + } + return threads; + }, "Thread Name: " + MyThread.NAME); + } + + private static void testThreadGroupName() throws Exception { + asseertObjectDescription(() -> { + List groups = new ArrayList<>(OldObjects.MIN_SIZE); + for (int i = 0; i < OldObjects.MIN_SIZE; i++) { + groups.add(new MyThreadGroup("My Thread Group")); + } + return groups; + }, "Thread Group: " + "My Thread Group"); + } + + private static void testClassName() throws Exception { + asseertObjectDescription(() -> { + TestClassLoader testClassLoader = new TestClassLoader(); + List classObjects = new ArrayList<>(OldObjects.MIN_SIZE); + for (Class clazz : testClassLoader.loadClasses(OldObjects.MIN_SIZE / 20)) { + // Allocate array to trigger sampling code path for interpreter / c1 + for (int i = 0; i < 20; i++) { + Object classArray = Array.newInstance(clazz, 20); + Array.set(classArray, i, clazz.newInstance()); + classObjects.add(classArray); + } + } + return classObjects; + }, "Class Name: " + CLASS_NAME); + } + + private static void testSize() throws Exception { + asseertObjectDescription(() -> { + List arrayLists = new ArrayList<>(OldObjects.MIN_SIZE); + for (int i = 0; i < OldObjects.MIN_SIZE; i++) { + List arrayList = new ArrayList<>(); + arrayList.add(new Object()); + arrayList.add(new Object()); + arrayList.add(new Object()); + arrayLists.add(arrayList); + } + return arrayLists; + }, "Size: 3"); + } + + private static void testEllipsis() throws Exception { + asseertObjectDescription(() -> { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < 2 * OBJECT_DESCRIPTION_MAX_SIZE; i++) { + sb.append("x"); + } + String threadName = sb.toString(); + List threads = new ArrayList<>(); + for (int i = 0; i < OldObjects.MIN_SIZE; i++) { + threads.add(new Thread(threadName)); + } + return threads; + }, "xxx..."); + } + + private static void asseertObjectDescription(Callable> callable, String text) throws Exception { + int iteration = 1; + while (true) { + try (Recording recording = new Recording()) { + System.out.println("Iteration: " + iteration); + recording.enable(EventNames.OldObjectSample).withoutStackTrace().with("cutoff", "infinity"); + recording.start(); + leaks = null; + System.gc(); + leaks = callable.call(); + + recording.stop(); + + List events = Events.fromRecording(recording); + Set objectDescriptions = extractObjectDecriptions(events); + for (String s : objectDescriptions) { + if (s.contains(text)) { + printDescriptions(objectDescriptions); + return; + } + } + System.out.println("Could not find object description containing text \"" + text + "\""); + printDescriptions(objectDescriptions); + System.out.println(); + iteration++; + } + } + } + + private static void printDescriptions(Set objectDescriptions) { + System.out.println("Found descriptions:"); + for (String t : objectDescriptions) { + System.out.println(t); + } + } + + private static Set extractObjectDecriptions(List events) { + Set objectDescriptions = new HashSet<>(); + for (RecordedEvent e : events) { + objectDescriptions.addAll(extractObjectDescriptions(e.getValue("object"))); + } + return objectDescriptions; + } + + private static Set extractObjectDescriptions(RecordedObject o) { + Set visited = new HashSet<>(); + Set descriptions = new HashSet<>(); + while (o != null) { + Long memoryAddress = o.getValue("address"); + if (visited.contains(memoryAddress)) { + return descriptions; + } + visited.add(memoryAddress); + String od = o.getValue("description"); + if (od != null) { + descriptions.add(od); + } + RecordedObject referrer = o.getValue("referrer"); + o = referrer != null ? referrer.getValue("object") : null; + } + return descriptions; + } +} diff --git a/test/jdk/jfr/event/oldobject/TestParallel.java b/test/jdk/jfr/event/oldobject/TestParallel.java new file mode 100644 index 0000000000000000000000000000000000000000..797c9369b10fb1a9013f4c1263b5303789d51a23 --- /dev/null +++ b/test/jdk/jfr/event/oldobject/TestParallel.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. 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.event.oldobject; + +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.internal.test.WhiteBox; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * + * @summary Test leak profiler with Parallel GC + * @library /lib / + * + * @run main/othervm -XX:TLABSize=2k -XX:+UseParallelGC jdk.jfr.event.oldobject.TestParallel + */ +public class TestParallel { + + static private class FindMe { + } + + public static List list = new ArrayList<>(OldObjects.MIN_SIZE); + + public static void main(String[] args) throws Exception { + WhiteBox.setWriteAllObjectSamples(true); + + try (Recording r = new Recording()) { + r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity"); + r.start(); + allocateFindMe(); + System.gc(); + r.stop(); + List events = Events.fromRecording(r); + System.out.println(events); + if (OldObjects.countMatchingEvents(events, FindMe[].class, null, null, -1, "allocateFindMe") == 0) { + throw new Exception("Could not find leak with " + FindMe[].class); + } + } + } + + public static void allocateFindMe() { + for (int i = 0; i < OldObjects.MIN_SIZE; i++) { + // Allocate array to trigger sampling code path for interpreter / c1 + list.add(new FindMe[0]); + } + } + +} diff --git a/test/jdk/jfr/event/oldobject/TestParallelOld.java b/test/jdk/jfr/event/oldobject/TestParallelOld.java new file mode 100644 index 0000000000000000000000000000000000000000..866818c7bd6bfeab26df1ca682111c0ad38b468e --- /dev/null +++ b/test/jdk/jfr/event/oldobject/TestParallelOld.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. 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.event.oldobject; + +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.internal.test.WhiteBox; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * + * @summary Test leak profiler with Parallel Old GC + * @library /lib / + * + * @run main/othervm -XX:TLABSize=2k -XX:+UseParallelOldGC jdk.jfr.event.oldobject.TestParallelOld + */ +public class TestParallelOld { + + static private class FindMe { + } + + public static List list = new ArrayList<>(OldObjects.MIN_SIZE); + + public static void main(String[] args) throws Exception { + WhiteBox.setWriteAllObjectSamples(true); + + try (Recording r = new Recording()) { + r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity"); + r.start(); + allocateFindMe(); + System.gc(); + r.stop(); + List events = Events.fromRecording(r); + System.out.println(events); + if (OldObjects.countMatchingEvents(events, FindMe[].class, null, null, -1, "allocateFindMe") == 0) { + throw new Exception("Could not find leak with " + FindMe[].class); + } + } + } + + public static void allocateFindMe() { + for (int i = 0; i < OldObjects.MIN_SIZE; i++) { + // Allocate array to trigger sampling code path for interpreter / c1 + list.add(new FindMe[0]); + } + } + +} diff --git a/test/jdk/jfr/event/oldobject/TestReferenceChainLimit.java b/test/jdk/jfr/event/oldobject/TestReferenceChainLimit.java new file mode 100644 index 0000000000000000000000000000000000000000..20dd5933571544b35c96130657b7084efa85dddc --- /dev/null +++ b/test/jdk/jfr/event/oldobject/TestReferenceChainLimit.java @@ -0,0 +1,84 @@ +/* + * 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. 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.event.oldobject; + +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.internal.test.WhiteBox; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * + * @run main/othervm -XX:TLABSize=2k jdk.jfr.event.oldobject.TestReferenceChainLimit + */ +public class TestReferenceChainLimit { + private final static int TEST_CHAIN_LENGTH_FACTOR = 10; // scaling factor for the how long chain to be used in the test + + final static class ChainNode { + final ChainNode next; + byte[] leak; + + public ChainNode(ChainNode node) { + next = node; + leak = new byte[10_000]; + } + } + + private static ChainNode createChain() { + ChainNode node = null; + final int testChainLength = OldObjects.MAX_CHAIN_LENGTH * TEST_CHAIN_LENGTH_FACTOR; + for (int i = 0; i < testChainLength; i++) { + node = new ChainNode(node); + } + return node; + } + + public static ChainNode leak; + + public static void main(String[] args) throws Exception { + WhiteBox.setWriteAllObjectSamples(true); + + try (Recording r = new Recording()) { + r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity"); + r.start(); + leak = createChain(); + List events = Events.fromRecording(r); + if (OldObjects.countMatchingEvents(events, byte[].class, null, null, -1, "createChain") == 0) { + throw new Exception("Could not find ChainNode"); + } + for (RecordedEvent e : events) { + OldObjects.validateReferenceChainLimit(e, OldObjects.MAX_CHAIN_LENGTH); + } + } + } +} diff --git a/test/jdk/jfr/event/oldobject/TestSanityDefault.java b/test/jdk/jfr/event/oldobject/TestSanityDefault.java new file mode 100644 index 0000000000000000000000000000000000000000..6607c7800a46fdbeb56996f7b68bbab48282fbbb --- /dev/null +++ b/test/jdk/jfr/event/oldobject/TestSanityDefault.java @@ -0,0 +1,88 @@ +/* + * 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.event.oldobject; + +import java.util.ArrayList; +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; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * @summary Purpose of this test is to run leak profiler without command line tweaks or WhiteBox hacks until we succeed + * @run main/othervm jdk.jfr.event.oldobject.TestSanityDefault + */ +public class TestSanityDefault { + + static private class FindMe { + } + + public static List list = new ArrayList<>(OldObjects.MIN_SIZE); + + public static void main(String[] args) throws Exception { + // Should not use WhiteBox API, we want to execute actual code paths + + // Trigger c2 compilation, so we get sample + for (long i = 0; i < 100_000_000; i++) { + allocateFindMe(true); + } + + + // It's hard to get samples with interpreter / C1 so loop until we do + while (true) { + try (Recording r = new Recording()) { + r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity"); + r.start(); + allocateFindMe(false); + System.gc(); + r.stop(); + List events = Events.fromRecording(r); + if (OldObjects.countMatchingEvents(events, FindMe.class, null, null, -1, "allocateFindMe") > 0) { + return; + } + // no events found, retry + } + } + } + + public static void allocateFindMe(boolean doNothing) { + if (doNothing) { + return; + } + for (int i = 0; i < OldObjects.MIN_SIZE; i++) { + // Purposely don't allocate array, so we at least + // in one old-object test check an ordinary object. + list.add(new FindMe()); + } + } +} diff --git a/test/jdk/jfr/event/oldobject/TestSerial.java b/test/jdk/jfr/event/oldobject/TestSerial.java new file mode 100644 index 0000000000000000000000000000000000000000..e2cbc46bd33d0524050c4a7a1faec92e2cce5c2a --- /dev/null +++ b/test/jdk/jfr/event/oldobject/TestSerial.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. 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.event.oldobject; + +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.internal.test.WhiteBox; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * + * @summary Test leak profiler with Serial GC + * @library /lib / + * + * @run main/othervm -XX:TLABSize=2k -XX:+UseSerialGC jdk.jfr.event.oldobject.TestSerial + */ +public class TestSerial { + + static private class FindMe { + } + + public static List list = new ArrayList<>(OldObjects.MIN_SIZE); + + public static void main(String[] args) throws Exception { + WhiteBox.setWriteAllObjectSamples(true); + + try (Recording r = new Recording()) { + r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity"); + r.start(); + allocateFindMe(); + System.gc(); + r.stop(); + List events = Events.fromRecording(r); + System.out.println(events); + if (OldObjects.countMatchingEvents(events, FindMe[].class, null, null, -1, "allocateFindMe") == 0) { + throw new Exception("Could not find leak with " + FindMe[].class); + } + } + } + + public static void allocateFindMe() { + for (int i = 0; i < OldObjects.MIN_SIZE; i++) { + // Allocate array to trigger sampling code path for interpreter / c1 + list.add(new FindMe[0]); + } + } + +} diff --git a/test/jdk/jfr/event/oldobject/TestThreadLocalLeak.java b/test/jdk/jfr/event/oldobject/TestThreadLocalLeak.java new file mode 100644 index 0000000000000000000000000000000000000000..b7c76f5e94b68210d0041770f26bcb78d4ec1e18 --- /dev/null +++ b/test/jdk/jfr/event/oldobject/TestThreadLocalLeak.java @@ -0,0 +1,79 @@ +/* + * 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.event.oldobject; + +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.internal.test.WhiteBox; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * @library /lib / + * + * @run main/othervm -XX:TLABSize=2k jdk.jfr.event.oldobject.TestThreadLocalLeak + */ +public class TestThreadLocalLeak { + + private static ThreadLocal> threadLocal = new ThreadLocal>() { + @Override + public List initialValue() { + return new ArrayList(OldObjects.MIN_SIZE); + } + }; + + static class ThreadLocalObject { + } + + public static void main(String[] args) throws Exception { + WhiteBox.setWriteAllObjectSamples(true); + + try (Recording r = new Recording()) { + r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity"); + r.start(); + allocateThreadLocal(); + r.stop(); + List events = Events.fromRecording(r); + if (OldObjects.countMatchingEvents(events, ThreadLocalObject[].class, null, null, -1, "allocateThreadLocal") == 0) { + throw new Exception("Could not find thread local object " + ThreadLocalObject.class); + } + } + } + + private static void allocateThreadLocal() { + for (int i = 0; i < OldObjects.MIN_SIZE; i++) { + // Allocate array to trigger sampling code path for interpreter / c1 + threadLocal.get().add(new ThreadLocalObject[0]); + } + } + +} diff --git a/test/jdk/jfr/event/os/TestCPUInformation.java b/test/jdk/jfr/event/os/TestCPUInformation.java new file mode 100644 index 0000000000000000000000000000000000000000..282b8352cdf8cba1f050eeaec7ba155854d332e0 --- /dev/null +++ b/test/jdk/jfr/event/os/TestCPUInformation.java @@ -0,0 +1,61 @@ +/* + * 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 + * 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.event.os; + +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; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.os.TestCPUInformation + */ +public class TestCPUInformation { + private final static String EVENT_NAME = EventNames.CPUInformation; + + public static void main(String[] args) throws Throwable { + Recording recording = new Recording(); + recording.enable(EVENT_NAME); + recording.start(); + recording.stop(); + List events = Events.fromRecording(recording); + Events.hasEvents(events); + for (RecordedEvent event : events) { + System.out.println("Event: " + event); + Events.assertField(event, "hwThreads").atLeast(1); + 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"); + } + } +} diff --git a/test/jdk/jfr/event/os/TestCPULoad.java b/test/jdk/jfr/event/os/TestCPULoad.java new file mode 100644 index 0000000000000000000000000000000000000000..614889766f64e17344467e5a847effd648fab87f --- /dev/null +++ b/test/jdk/jfr/event/os/TestCPULoad.java @@ -0,0 +1,79 @@ +/* + * 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 + * 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.event.os; + +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; + + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.os.TestCPULoad + */ +public class TestCPULoad { + private final static String EVENT_NAME = EventNames.CPULoad; + + public static void main(String[] args) throws Throwable { + Recording recording = new Recording(); + recording.enable(EVENT_NAME); + recording.start(); + // Need to sleep so a time delta can be calculated + Thread.sleep(100); + recording.stop(); + + List events = Events.fromRecording(recording); + if (events.isEmpty()) { + // CPU Load events are unreliable on Windows because + // the way processes are identified with perf. counters. + // See BUG 8010378. + // Workaround is to detect Windows and allow + // test to pass if events are missing. + if (isWindows()) { + return; + } + throw new AssertionError("Expected at least one event"); + } + for (RecordedEvent event : events) { + System.out.println("Event: " + event); + for (String loadName : loadNames) { + Events.assertField(event, loadName).atLeast(0.0f).atMost(1.0f); + } + } + } + + private static final String[] loadNames = {"jvmUser", "jvmSystem", "machineTotal"}; + + private static boolean isWindows() { + return System.getProperty("os.name").startsWith("Windows"); + } +} diff --git a/test/jdk/jfr/event/os/TestCPUTimeStampCounter.java b/test/jdk/jfr/event/os/TestCPUTimeStampCounter.java new file mode 100644 index 0000000000000000000000000000000000000000..00fefe729b88e011a306add4ee133ad84aac973e --- /dev/null +++ b/test/jdk/jfr/event/os/TestCPUTimeStampCounter.java @@ -0,0 +1,60 @@ +/* + * 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 + * 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.event.os; + +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; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.os.TestCPUTimeStampCounter + */ +public class TestCPUTimeStampCounter { + private final static String EVENT_NAME = EventNames.CPUTimeStampCounter; + + public static void main(String[] args) throws Throwable { + Recording recording = new Recording(); + recording.enable(EVENT_NAME); + recording.start(); + recording.stop(); + List events = Events.fromRecording(recording); + Events.hasEvents(events); + for (RecordedEvent event : events) { + System.out.println("Event: " + event); + Events.assertField(event, "fastTimeEnabled"); + Events.assertField(event, "fastTimeAutoEnabled"); + Events.assertField(event, "osFrequency").atLeast(0L); + Events.assertField(event, "fastTimeFrequency").atLeast(0L); + } + } +} diff --git a/test/jdk/jfr/event/os/TestInitialEnvironmentVariable.java b/test/jdk/jfr/event/os/TestInitialEnvironmentVariable.java new file mode 100644 index 0000000000000000000000000000000000000000..80c55080fb4b4ea72a7cd863fcfc9390aba91da1 --- /dev/null +++ b/test/jdk/jfr/event/os/TestInitialEnvironmentVariable.java @@ -0,0 +1,65 @@ +/* + * 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 + * 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.event.os; + +import static jdk.test.lib.Asserts.assertEquals; +import static jdk.test.lib.Asserts.assertTrue; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +public class TestInitialEnvironmentVariable { + private final static String EVENT_NAME = EventNames.InitialEnvironmentVariable; + + public static void main(String[] args) throws Exception { + Map env = new HashMap<>(); + env.put("keytest1", "value1"); + env.put("keytest2", "value 2"); + + Recording recording = new Recording(); + recording.enable(EVENT_NAME); + recording.start(); + recording.stop(); + List events = Events.fromRecording(recording); + Events.hasEvents(events); + for (RecordedEvent event : events) { + System.out.println("Event: " + event); + String key = Events.assertField(event, "key").notNull().getValue(); + String value = Events.assertField(event, "value").notNull().getValue(); + if (env.containsKey(key)) { + assertEquals(value, env.get(key), "Wrong value for key: " + key); + env.remove(key); + } + } + assertTrue(env.isEmpty(), "Missing env keys " + env.keySet()); + } +} diff --git a/test/jdk/jfr/event/os/TestInitialEnvironmentVariable.sh b/test/jdk/jfr/event/os/TestInitialEnvironmentVariable.sh new file mode 100644 index 0000000000000000000000000000000000000000..08bfef9919493ff68763d3fa6516958d3ef39a34 --- /dev/null +++ b/test/jdk/jfr/event/os/TestInitialEnvironmentVariable.sh @@ -0,0 +1,38 @@ +# +# 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 +# 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 +# @key jfr +# +# @library /lib / +# @build jdk.jfr.event.os.TestInitialEnvironmentVariable +# @run shell TestInitialEnvironmentVariable.sh + +echo ------------------------------------------------------------- +echo "TESTCLASSES='$TESTCLASSES'" +echo "TESTSRC='$TESTSRC'" +echo Launching test for `basename $0 .sh` +echo ------------------------------------------------------------- +keytest1="value1";export keytest1 +keytest2="value 2";export keytest2 +${TESTJAVA}/bin/java -cp ${TESTCLASSPATH} jdk.jfr.event.os.TestInitialEnvironmentVariable +exit $? diff --git a/test/jdk/jfr/event/os/TestOSInfo.java b/test/jdk/jfr/event/os/TestOSInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..1629bcb08fa0161aaaabee2c3beaf7eb6595edce --- /dev/null +++ b/test/jdk/jfr/event/os/TestOSInfo.java @@ -0,0 +1,57 @@ +/* + * 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 + * 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.event.os; + +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; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.os.TestOSInfo + */ +public class TestOSInfo { + private final static String EVENT_NAME = EventNames.OSInformation; + + public static void main(String[] args) throws Throwable { + Recording recording = new Recording(); + recording.enable(EVENT_NAME); + recording.start(); + recording.stop(); + List events = Events.fromRecording(recording); + Events.hasEvents(events); + for (RecordedEvent event : events) { + System.out.println("Event: " + event); + Events.assertField(event, "osVersion").notEmpty(); + } + } +} diff --git a/test/jdk/jfr/event/os/TestPhysicalMemoryEvent.java b/test/jdk/jfr/event/os/TestPhysicalMemoryEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..be224ad03cea50e9eedef1fde43fe4e2ceebb36d --- /dev/null +++ b/test/jdk/jfr/event/os/TestPhysicalMemoryEvent.java @@ -0,0 +1,58 @@ +/* + * 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 + * 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.event.os; + +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; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.os.TestPhysicalMemoryEvent + */ +public class TestPhysicalMemoryEvent { + private final static String EVENT_NAME = EventNames.PhysicalMemory; + + public static void main(String[] args) throws Throwable { + Recording recording = new Recording(); + recording.enable(EVENT_NAME); + recording.start(); + recording.stop(); + List events = Events.fromRecording(recording); + Events.hasEvents(events); + for (RecordedEvent event : events) { + System.out.println("Event: " + event); + long totalSize = Events.assertField(event, "totalSize").atLeast(0L).getValue(); + Events.assertField(event, "usedSize").atLeast(0L).atMost(totalSize); + } + } +} diff --git a/test/jdk/jfr/event/os/TestSystemProcess.java b/test/jdk/jfr/event/os/TestSystemProcess.java new file mode 100644 index 0000000000000000000000000000000000000000..9d3f4bede0f04725c4da97cea8ba911c8c82c4ac --- /dev/null +++ b/test/jdk/jfr/event/os/TestSystemProcess.java @@ -0,0 +1,57 @@ +/* + * 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 + * 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.event.os; + +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; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.os.TestSystemProcess + */ +public class TestSystemProcess { + private final static String EVENT_NAME = EventNames.SystemProcess; + + public static void main(String[] args) throws Throwable { + Recording recording = new Recording(); + recording.enable(EVENT_NAME); + recording.start(); + recording.stop(); + List events = Events.fromRecording(recording); + Events.hasEvents(events); + for (RecordedEvent event : events) { + System.out.println("Event: " + event); + Events.assertField(event, "pid").notEmpty(); + } + } +} diff --git a/test/jdk/jfr/event/os/TestThreadContextSwitches.java b/test/jdk/jfr/event/os/TestThreadContextSwitches.java new file mode 100644 index 0000000000000000000000000000000000000000..bd70c581b8d148880b6a05c8624115e1fa34a0c7 --- /dev/null +++ b/test/jdk/jfr/event/os/TestThreadContextSwitches.java @@ -0,0 +1,56 @@ +/* + * 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 + * 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.event.os; + +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; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.os.TestThreadContextSwitches + */ +public class TestThreadContextSwitches { + private final static String EVENT_NAME = EventNames.ThreadContextSwitchRate; + + public static void main(String[] args) throws Throwable { + Recording recording = new Recording(); + recording.enable(EVENT_NAME); + recording.start(); + recording.stop(); + List events = Events.fromRecording(recording); + Events.hasEvents(events); + for (RecordedEvent event : events) { + System.out.println("Event: " + event); + Events.assertField(event, "switchRate").atLeast(0.0f); + } + } +} diff --git a/test/jdk/jfr/event/profiling/TestFullStackTrace.java b/test/jdk/jfr/event/profiling/TestFullStackTrace.java new file mode 100644 index 0000000000000000000000000000000000000000..7236b5951cec6799b2c92b7bd5f4b7e147e01103 --- /dev/null +++ b/test/jdk/jfr/event/profiling/TestFullStackTrace.java @@ -0,0 +1,171 @@ +/* + * 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 + * 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.event.profiling; + +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedFrame; +import jdk.jfr.consumer.RecordedStackTrace; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.RecurseThread; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.profiling.TestFullStackTrace + */ +public class TestFullStackTrace { + private final static String EVENT_NAME = EventNames.ExecutionSample; + private final static int MAX_DEPTH = 64; // currently hardcoded in jvm + + public static void main(String[] args) throws Throwable { + RecurseThread[] threads = new RecurseThread[3]; + for (int i = 0; i < threads.length; ++i) { + int depth = MAX_DEPTH - 1 + i; + threads[i] = new RecurseThread(depth); + threads[i].setName("recursethread-" + depth); + threads[i].start(); + } + + for (RecurseThread thread : threads) { + while (!thread.isInRunLoop()) { + Thread.sleep(20); + } + } + + assertStackTraces(threads); + + for (RecurseThread thread : threads) { + thread.quit(); + thread.join(); + } + } + + private static void assertStackTraces( RecurseThread[] threads) throws Throwable { + Recording recording= null; + do { + recording = new Recording(); + recording.enable(EVENT_NAME).withPeriod(Duration.ofMillis(50)); + recording.start(); + Thread.sleep(500); + recording.stop(); + } while (!hasValidStackTraces(recording, threads)); + } + + private static boolean hasValidStackTraces(Recording recording, RecurseThread[] threads) throws Throwable { + boolean[] isEventFound = new boolean[threads.length]; + + for (RecordedEvent event : Events.fromRecording(recording)) { + //System.out.println("Event: " + event); + String threadName = Events.assertField(event, "sampledThread.javaName").getValue(); + long threadId = Events.assertField(event, "sampledThread.javaThreadId").getValue(); + + for (int threadIndex = 0; threadIndex < threads.length; ++threadIndex) { + RecurseThread currThread = threads[threadIndex]; + if (threadId == currThread.getId()) { + System.out.println("ThreadName=" + currThread.getName() + ", depth=" + currThread.totalDepth); + Asserts.assertEquals(threadName, currThread.getName(), "Wrong thread name"); + if ("recurseEnd".equals(getTopMethodName(event))) { + isEventFound[threadIndex] = true; + checkEvent(event, currThread.totalDepth); + break; + } + } + } + } + + for (int i = 0; i < threads.length; ++i) { + String msg = "threadIndex=%d, recurseDepth=%d, isEventFound=%b%n"; + System.out.printf(msg, i, threads[i].totalDepth, isEventFound[i]); + } + for (int i = 0; i < threads.length; ++i) { + if(!isEventFound[i]) { + // no assertion, let's retry. + // Could be race condition, i.e safe point during Thread.sleep + System.out.println("Falied to validate all threads, will retry."); + return false; + } + } + return true; + } + + public static String getTopMethodName(RecordedEvent event) { + List frames = event.getStackTrace().getFrames(); + Asserts.assertFalse(frames.isEmpty(), "JavaFrames was empty"); + return frames.get(0).getMethod().getName(); + } + + private static void checkEvent(RecordedEvent event, int expectedDepth) throws Throwable { + RecordedStackTrace stacktrace = null; + try { + stacktrace = event.getStackTrace(); + List frames = stacktrace.getFrames(); + Asserts.assertEquals(Math.min(MAX_DEPTH, expectedDepth), frames.size(), "Wrong stacktrace depth. Expected:" + expectedDepth); + List expectedMethods = getExpectedMethods(expectedDepth); + Asserts.assertEquals(expectedMethods.size(), frames.size(), "Wrong expectedMethods depth. Test error."); + + for (int i = 0; i < frames.size(); ++i) { + String name = frames.get(i).getMethod().getName(); + String expectedName = expectedMethods.get(i); + System.out.printf("method[%d]=%s, expected=%s%n", i, name, expectedName); + Asserts.assertEquals(name, expectedName, "Wrong method name"); + } + + boolean isTruncated = stacktrace.isTruncated(); + boolean isTruncateExpected = expectedDepth > MAX_DEPTH; + Asserts.assertEquals(isTruncated, isTruncateExpected, "Wrong value for isTruncated. Expected:" + isTruncateExpected); + + String firstMethod = frames.get(frames.size() - 1).getMethod().getName(); + boolean isFullTrace = "run".equals(firstMethod); + String msg = String.format("Wrong values for isTruncated=%b, isFullTrace=%b", isTruncated, isFullTrace); + Asserts.assertTrue(isTruncated != isFullTrace, msg); + } catch (Throwable t) { + System.out.println(String.format("stacktrace:%n%s", stacktrace)); + throw t; + } + } + + private static List getExpectedMethods(int depth) { + List methods = new ArrayList<>(); + methods.add("recurseEnd"); + for (int i = 0; i < depth - 2; ++i) { + methods.add((i % 2) == 0 ? "recurseA" : "recurseB"); + } + methods.add("run"); + if (depth > MAX_DEPTH) { + methods = methods.subList(0, MAX_DEPTH); + } + return methods; + } +} diff --git a/test/jdk/jfr/event/runtime/TestActiveRecordingEvent.java b/test/jdk/jfr/event/runtime/TestActiveRecordingEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..7d4b786fa41acaa7f50a7cff23f6e1592b8f1078 --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestActiveRecordingEvent.java @@ -0,0 +1,126 @@ +/* + * 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. 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.event.runtime; + +import static jdk.test.lib.Asserts.assertEquals; +import static jdk.test.lib.Asserts.assertNull; +import static jdk.test.lib.Asserts.assertTrue; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.time.Duration; +import java.time.Instant; +import java.util.List; + +import jdk.jfr.EventType; +import jdk.jfr.Recording; +import jdk.jfr.Timespan; +import jdk.jfr.Timestamp; +import jdk.jfr.ValueDescriptor; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Tests that the recording properties are properly reflected in the ActiveRecording event + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.runtime.TestActiveRecordingEvent + */ +public final class TestActiveRecordingEvent { + + private static final String ACTIVE_RECORDING_EVENT_NAME = EventNames.ActiveRecording; + + private static final Path MY_JFR_FILEPATH = Paths.get("", "my.jfr"); + + private static final long MAX_SIZE = 1000000L; + + private static final Duration MAX_AGE = Duration.ofDays(1); + + private static final Duration REC_DURATION = Duration.ofMinutes(10); + + private static final String REC_NAME = "MYNAME"; + + public static void main(String[] args) throws Throwable { + testWithPath(null); + testWithPath(MY_JFR_FILEPATH); + } + + private static void testWithPath(Path path) throws Throwable { + Recording recording = new Recording(); + recording.enable(ACTIVE_RECORDING_EVENT_NAME); + + recording.setDuration(REC_DURATION); + recording.setMaxSize(MAX_SIZE); + recording.setMaxAge(MAX_AGE); + recording.setName(REC_NAME); + if (path != null) { + recording.setToDisk(true); + recording.setDestination(path); + } + + long tsBeforeStart = Instant.now().toEpochMilli(); + recording.start(); + recording.stop(); + long tsAfterStop = Instant.now().toEpochMilli(); + + List events = Events.fromRecording(recording); + + Events.hasEvents(events); + RecordedEvent ev = events.get(0); + + // Duration must be kept in milliseconds + assertEquals(REC_DURATION.toMillis(), ev.getValue("recordingDuration")); + + assertEquals(MAX_SIZE, ev.getValue("maxSize")); + + // maxAge must be kept in milliseconds + assertEquals(MAX_AGE.toMillis(), ev.getValue("maxAge")); + + EventType evType = ev.getEventType(); + ValueDescriptor durationField = evType.getField("recordingDuration"); + assertEquals(durationField.getAnnotation(Timespan.class).value(), Timespan.MILLISECONDS); + + if (path == null) { + assertNull(ev.getValue("destination")); + } else { + assertEquals(path.toAbsolutePath().toString(), ev.getValue("destination").toString()); + } + + ValueDescriptor recordingStartField = evType.getField("recordingStart"); + assertEquals(recordingStartField.getAnnotation(Timestamp.class).value(), Timestamp.MILLISECONDS_SINCE_EPOCH); + + long tsRecordingStart = ev.getValue("recordingStart"); + assertTrue(tsBeforeStart <= tsRecordingStart); + assertTrue(tsAfterStop >= tsRecordingStart); + + assertEquals(recording.getId(), ev.getValue("id")); + + ValueDescriptor maxAgeField = evType.getField("maxAge"); + assertEquals(maxAgeField.getAnnotation(Timespan.class).value(), Timespan.MILLISECONDS); + } +} diff --git a/test/jdk/jfr/event/runtime/TestActiveSettingEvent.java b/test/jdk/jfr/event/runtime/TestActiveSettingEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..3b3ff9053674d8131c11248f4f1784d2149578b4 --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestActiveSettingEvent.java @@ -0,0 +1,253 @@ +/* + * 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. 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.event.runtime; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jdk.jfr.Configuration; +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; +import jdk.jfr.Registered; +import jdk.jfr.SettingDescriptor; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @summary Tests that active setting are available in the ActiveSettingevent + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.runtime.TestActiveSettingEvent + */ +public final class TestActiveSettingEvent { + + private static class MyEvent extends Event { + } + + @Registered(false) + private static class MyRegistrationEvent extends Event { + } + + private static final String ACTIVE_SETTING_EVENT_NAME = EventNames.ActiveSetting; + + public static void main(String[] args) throws Throwable { + testDefaultSettings();; + testProfileSettings();; + testNewSettings(); + testChangedSetting(); + testUnregistered(); + testRegistration(); + } + + private static void testProfileSettings() throws Exception { + testSettingConfiguration("profile"); + } + + private static void testDefaultSettings() throws Exception { + testSettingConfiguration("default"); + } + + private static void testRegistration() throws Exception { + // Register new + try (Recording recording = new Recording()) { + recording.enable(ACTIVE_SETTING_EVENT_NAME); + recording.start(); + FlightRecorder.register(MyRegistrationEvent.class); + recording.stop(); + List events = Events.fromRecording(recording); + Events.hasEvents(events); + EventType type = EventType.getEventType(MyRegistrationEvent.class); + assertSetting(events, type, "threshold", "0 ns"); + assertSetting(events, type, "enabled", "true"); + assertSetting(events, type, "stackTrace", "true"); + } + // Register unregistered + FlightRecorder.unregister(MyEvent.class); + try (Recording recording = new Recording()) { + recording.enable(ACTIVE_SETTING_EVENT_NAME); + recording.start(); + FlightRecorder.register(MyRegistrationEvent.class); + recording.stop(); + EventType type = EventType.getEventType(MyRegistrationEvent.class); + List events = Events.fromRecording(recording); + Events.hasEvents(events); + type = EventType.getEventType(MyRegistrationEvent.class); + assertSetting(events, type, "threshold", "0 ns"); + assertSetting(events, type, "enabled", "true"); + assertSetting(events, type, "stackTrace", "true"); + } + } + + private static void testUnregistered() throws Exception { + FlightRecorder.register(MyEvent.class); + EventType type = EventType.getEventType(MyEvent.class); + FlightRecorder.unregister(MyEvent.class); + try (Recording recording = new Recording()) { + recording.enable(ACTIVE_SETTING_EVENT_NAME); + recording.start(); + MyEvent m = new MyEvent(); + m.commit(); + recording.stop(); + List events = Events.fromRecording(recording); + Events.hasEvents(events); + assertNotSetting(events, type, "threshold", "0 ns"); + assertNotSetting(events, type, "enabled", "true"); + assertNotSetting(events, type, "stackTrace", "true"); + } + } + + private static void testNewSettings() throws Exception { + try (Recording recording = new Recording()) { + recording.enable(ACTIVE_SETTING_EVENT_NAME); + recording.start(); + MyEvent m = new MyEvent(); + m.commit(); + recording.stop(); + List events = Events.fromRecording(recording); + Events.hasEvents(events); + EventType type = EventType.getEventType(MyEvent.class); + assertSetting(events, type, "threshold", "0 ns"); + assertSetting(events, type, "enabled", "true"); + assertSetting(events, type, "stackTrace", "true"); + assertNotSetting(events, type, "period", "everyChunk"); + } + } + + private static void testChangedSetting() throws Exception { + EventType type = EventType.getEventType(MyEvent.class); + Map base = new HashMap<>(); + base.put(ACTIVE_SETTING_EVENT_NAME + "#enabled", "true"); + try (Recording recording = new Recording()) { + recording.setSettings(base); + recording.start(); + Map newS = new HashMap<>(base); + newS.put(type.getName() + "#enabled", "true"); + newS.put(type.getName() + "#threshold", "11 ns"); + recording.setSettings(newS); + recording.stop(); + List events = Events.fromRecording(recording); + Events.hasEvents(events); + assertSetting(events, type, "threshold", "0 ns"); // initial value + assertSetting(events, type, "enabled", "true"); + assertSetting(events, type, "threshold", "11 ns"); // changed value + } + } + + private static void assertSetting(List events, EventType evenType, String settingName, String settingValue) throws Exception { + if (!hasSetting(events, evenType, settingName, settingValue)) { + throw new Exception("Could not find setting " + settingName + " with value " + settingValue + " for event type " + evenType.getName()); + } + } + + private static void assertNotSetting(List events, EventType evenType, String settingName, String settingValue) throws Exception { + if (hasSetting(events, evenType, settingName, settingValue)) { + throw new Exception("Found unexpected setting " + settingName + " with value " + settingValue + " for event type " + evenType.getName()); + } + } + + private static boolean hasSetting(List events, EventType evenType, String settingName, String settingValue) throws Exception { + for (RecordedEvent e : events) { + if (e.getEventType().getName().equals(ACTIVE_SETTING_EVENT_NAME)) { + String name = e.getValue("name"); + String value = e.getValue("value"); + Long id = e.getValue("id"); + if (evenType.getId() == id && name.equals(settingName) && settingValue.equals(value)) { + return true; + } + } + } + return false; + } + + private static void testSettingConfiguration(String configurationName) throws Exception { + System.out.println("Testing configuration " + configurationName); + Configuration c = Configuration.getConfiguration(configurationName); + Map settingValues = c.getSettings(); + // Don't want to add these settings to the jfc-files we ship since they + // are not useful to configure. They are however needed to make the test + // pass. + settingValues.put(EventNames.ActiveSetting + "#stackTrace", "false"); + settingValues.put(EventNames.ActiveSetting + "#threshold", "0 ns"); + settingValues.put(EventNames.ActiveRecording + "#stackTrace", "false"); + settingValues.put(EventNames.ActiveRecording + "#threshold", "0 ns"); + settingValues.put(EventNames.JavaExceptionThrow + "#threshold", "0 ns"); + settingValues.put(EventNames.JavaErrorThrow + "#threshold", "0 ns"); + + try (Recording recording = new Recording(c)) { + Map eventTypes = new HashMap<>(); + for (EventType et : FlightRecorder.getFlightRecorder().getEventTypes()) { + eventTypes.put(et.getId(), et); + } + recording.start(); + Map expectedSettings = new HashMap<>(); + for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) { + for (SettingDescriptor s : type.getSettingDescriptors()) { + String settingName = type.getName() + "#" + s.getName(); + String value = settingValues.get(settingName); + if (value == null) { + throw new Exception("Could not find setting with name " + settingName); + } + // Prefer to have ms unit in jfc file + if (value.equals("0 ms")) { + value = "0 ns"; + } + expectedSettings.put(settingName, value); + } + } + recording.stop(); + + for (RecordedEvent e : Events.fromRecording(recording)) { + if (e.getEventType().getName().equals(ACTIVE_SETTING_EVENT_NAME)) { + Long id = e.getValue("id"); + EventType et = eventTypes.get(id); + if (et == null) { + throw new Exception("Could not find event type with id " + id); + } + String name = e.getValue("name"); + String settingName = et.getName() + "#" + name; + String value = e.getValue("value"); + String expectedValue = expectedSettings.get(settingName); + if (expectedValue != null) { + if (value.equals("0 ms")) { + value = "0 ns"; + } + Asserts.assertEquals(expectedValue, value, "Incorrect settings value for " + settingName + " was " + value + ", expected " + expectedValue); + expectedSettings.remove(settingName); + } + } + } + if (!expectedSettings.isEmpty()) { + throw new Exception("Not all setting in event. Missing " + expectedSettings.keySet()); + } + } + } +} diff --git a/test/jdk/jfr/event/runtime/TestBiasedLockRevocationEvents.java b/test/jdk/jfr/event/runtime/TestBiasedLockRevocationEvents.java new file mode 100644 index 0000000000000000000000000000000000000000..58eee6c6edcd57e9388f4d4485e816a7fad4db2a --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestBiasedLockRevocationEvents.java @@ -0,0 +1,319 @@ +/* + * 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. 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.event.runtime; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.*; +import jdk.test.lib.Asserts; +import jdk.test.lib.dcmd.PidJcmdExecutor; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.process.OutputAnalyzer; + +import java.util.*; +import java.util.concurrent.FutureTask; +import java.util.stream.Collectors; + +/** + * @test + * @key jfr + * + * @library /lib / + * + * @run main/othervm -XX:BiasedLockingStartupDelay=0 jdk.jfr.event.runtime.TestBiasedLockRevocationEvents + */ +public class TestBiasedLockRevocationEvents { + + public static void main(String[] args) throws Throwable { + testSingleRevocation(); + testBulkRevocation(); + testSelfRevocation(); + testExitedThreadRevocation(); + testBulkRevocationNoRebias(); + testRevocationSafepointIdCorrelation(); + } + + // Default value of BiasedLockingBulkRebiasThreshold is 20, and BiasedLockingBulkRevokeTreshold is 40. + // Using a value that will hit the first threshold once, and the second one the next time. + private static final int BULK_REVOKE_THRESHOLD = 25; + + static void touch(Object lock) { + synchronized(lock) { + } + } + + static Thread triggerRevocation(int numRevokes, Class lockClass) throws Throwable { + Object[] locks = new Object[numRevokes]; + for (int i = 0; i < locks.length; ++i) { + locks[i] = lockClass.getDeclaredConstructor().newInstance(); + touch(locks[i]); + } + + Thread biasBreaker = new Thread("BiasBreaker") { + @Override + public void run() { + for (Object lock : locks) { + touch(lock); + } + } + }; + + biasBreaker.start(); + biasBreaker.join(); + + return biasBreaker; + } + + // Basic stack trace validation, checking the name of the leaf method + static void validateStackTrace(RecordedStackTrace stackTrace, String leafMethodName) { + List frames = stackTrace.getFrames(); + Asserts.assertFalse(frames.isEmpty()); + String name = frames.get(0).getMethod().getName(); + Asserts.assertEquals(name, leafMethodName); + } + + // Validates that the given stack trace refers to lock.touch(); in triggerRevocation + static void validateStackTrace(RecordedStackTrace stackTrace) { + validateStackTrace(stackTrace, "touch"); + } + + // Retrieve all biased lock revocation events related to the provided lock class, sorted by start time + static List getRevocationEvents(Recording recording, String fieldName, Class lockClass) throws Throwable { + return Events.fromRecording(recording).stream() + .filter(e -> ((RecordedClass)e.getValue(fieldName)).getName().equals(lockClass.getName())) + .sorted(Comparator.comparing(RecordedEvent::getStartTime)) + .collect(Collectors.toList()); + } + + static void testSingleRevocation() throws Throwable { + class MyLock {}; + + Recording recording = new Recording(); + + recording.enable(EventNames.BiasedLockRevocation); + recording.start(); + + Thread biasBreaker = triggerRevocation(1, MyLock.class); + + recording.stop(); + List events = getRevocationEvents(recording, "lockClass", MyLock.class); + Asserts.assertEQ(events.size(), 1); + + RecordedEvent event = events.get(0); + Events.assertEventThread(event, biasBreaker); + Events.assertEventThread(event, "previousOwner", Thread.currentThread()); + + RecordedClass lockClass = event.getValue("lockClass"); + Asserts.assertEquals(lockClass.getName(), MyLock.class.getName()); + + validateStackTrace(event.getStackTrace()); + } + + static void testBulkRevocation() throws Throwable { + class MyLock {}; + + Recording recording = new Recording(); + + recording.enable(EventNames.BiasedLockClassRevocation); + recording.start(); + + Thread biasBreaker = triggerRevocation(BULK_REVOKE_THRESHOLD, MyLock.class); + + recording.stop(); + List events = getRevocationEvents(recording, "revokedClass", MyLock.class); + Asserts.assertEQ(events.size(), 1); + + RecordedEvent event = events.get(0); + Events.assertEventThread(event, biasBreaker); + Events.assertField(event, "disableBiasing").equal(false); + + RecordedClass lockClass = event.getValue("revokedClass"); + Asserts.assertEquals(lockClass.getName(), MyLock.class.getName()); + + validateStackTrace(event.getStackTrace()); + } + + static void testSelfRevocation() throws Throwable { + class MyLock {}; + + Recording recording = new Recording(); + + recording.enable(EventNames.BiasedLockSelfRevocation); + recording.start(); + + MyLock l = new MyLock(); + touch(l); + Thread.holdsLock(l); + + recording.stop(); + List events = getRevocationEvents(recording, "lockClass", MyLock.class); + Asserts.assertEQ(events.size(), 1); + + RecordedEvent event = events.get(0); + Events.assertEventThread(event, Thread.currentThread()); + + validateStackTrace(event.getStackTrace(), "holdsLock"); + } + + static void testExitedThreadRevocation() throws Throwable { + class MyLock {}; + + Recording recording = new Recording(); + + recording.enable(EventNames.BiasedLockRevocation); + recording.start(); + + FutureTask lockerTask = new FutureTask<>(() -> { + MyLock l = new MyLock(); + touch(l); + return l; + }); + + Thread locker = new Thread(lockerTask, "BiasLocker"); + locker.start(); + locker.join(); + + // Even after joining, the VM has a bit more work to do before the thread is actually removed + // from the threads list. Ensure that this has happened before proceeding. + while (true) { + PidJcmdExecutor jcmd = new PidJcmdExecutor(); + OutputAnalyzer oa = jcmd.execute("Thread.print", true); + String lockerThreadFound = oa.firstMatch("BiasLocker"); + if (lockerThreadFound == null) { + break; + } + }; + + MyLock l = lockerTask.get(); + touch(l); + + recording.stop(); + List events = getRevocationEvents(recording, "lockClass", MyLock.class); + Asserts.assertEQ(events.size(), 1); + + RecordedEvent event = events.get(0); + Events.assertEventThread(event, Thread.currentThread()); + // Previous owner will usually be null, but can also be a thread that + // was created after the BiasLocker thread exited due to address reuse. + RecordedThread prevOwner = event.getValue("previousOwner"); + if (prevOwner != null) { + Asserts.assertNE(prevOwner.getJavaName(), "BiasLocker"); + } + validateStackTrace(event.getStackTrace()); + } + + static void testBulkRevocationNoRebias() throws Throwable { + class MyLock {}; + + Recording recording = new Recording(); + + recording.enable(EventNames.BiasedLockClassRevocation); + recording.start(); + + Thread biasBreaker0 = triggerRevocation(BULK_REVOKE_THRESHOLD, MyLock.class); + Thread biasBreaker1 = triggerRevocation(BULK_REVOKE_THRESHOLD, MyLock.class); + + recording.stop(); + List events = getRevocationEvents(recording, "revokedClass", MyLock.class); + Asserts.assertEQ(events.size(), 2); + + // The rebias event should occur before the noRebias one + RecordedEvent eventRebias = events.get(0); + RecordedEvent eventNoRebias = events.get(1); + + Events.assertEventThread(eventRebias, biasBreaker0); + Events.assertField(eventRebias, "disableBiasing").equal(false); + + Events.assertEventThread(eventNoRebias, biasBreaker1); + Events.assertField(eventNoRebias, "disableBiasing").equal(true); + + RecordedClass lockClassRebias = eventRebias.getValue("revokedClass"); + Asserts.assertEquals(lockClassRebias.getName(), MyLock.class.getName()); + RecordedClass lockClassNoRebias = eventNoRebias.getValue("revokedClass"); + Asserts.assertEquals(lockClassNoRebias.getName(), MyLock.class.getName()); + + validateStackTrace(eventRebias.getStackTrace()); + validateStackTrace(eventNoRebias.getStackTrace()); + } + + static void testRevocationSafepointIdCorrelation() throws Throwable { + class MyLock {}; + + Recording recording = new Recording(); + + recording.enable(EventNames.BiasedLockRevocation); + recording.enable(EventNames.BiasedLockClassRevocation); + recording.enable(EventNames.ExecuteVMOperation); + recording.start(); + + triggerRevocation(BULK_REVOKE_THRESHOLD, MyLock.class); + + recording.stop(); + List events = Events.fromRecording(recording); + + // Determine which safepoints included single and bulk revocation VM operations + Set vmOperationsSingle = new HashSet<>(); + Set vmOperationsBulk = new HashSet<>(); + + for (RecordedEvent event : events) { + if (event.getEventType().getName().equals(EventNames.ExecuteVMOperation)) { + String operation = event.getValue("operation"); + Integer safepointId = event.getValue("safepointId"); + + if (operation.equals("RevokeBias")) { + vmOperationsSingle.add(safepointId); + } else if (operation.equals("BulkRevokeBias")) { + vmOperationsBulk.add(safepointId); + } + } + } + + int revokeCount = 0; + int bulkRevokeCount = 0; + + // Match all revoke events to a corresponding VMOperation event + for (RecordedEvent event : events) { + if (event.getEventType().getName().equals(EventNames.BiasedLockRevocation)) { + Integer safepointId = event.getValue("safepointId"); + String lockClass = ((RecordedClass)event.getValue("lockClass")).getName(); + if (lockClass.equals(MyLock.class.getName())) { + Asserts.assertTrue(vmOperationsSingle.contains(safepointId)); + revokeCount++; + } + } else if (event.getEventType().getName().equals(EventNames.BiasedLockClassRevocation)) { + Integer safepointId = event.getValue("safepointId"); + String lockClass = ((RecordedClass)event.getValue("revokedClass")).getName(); + if (lockClass.toString().equals(MyLock.class.getName())) { + Asserts.assertTrue(vmOperationsBulk.contains(safepointId)); + bulkRevokeCount++; + } + } + } + + Asserts.assertGT(bulkRevokeCount, 0); + Asserts.assertGT(revokeCount, bulkRevokeCount); + } +} diff --git a/test/jdk/jfr/event/runtime/TestClassDefineEvent.java b/test/jdk/jfr/event/runtime/TestClassDefineEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..30f9320af7ee0a6afd88ec9c2d8983c2a21fda93 --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestClassDefineEvent.java @@ -0,0 +1,80 @@ +/* + * 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. 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.event.runtime; + +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedClass; +import jdk.jfr.consumer.RecordedClassLoader; +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.jfr.TestClassLoader; + +/** + * @test + * @key jfr + * + * @library /lib / + * @build jdk.jfr.event.runtime.TestClasses + * @run main/othervm jdk.jfr.event.runtime.TestClassDefineEvent + * @run main/othervm -XX:+AllowParallelDefineClass jdk.jfr.event.runtime.TestClassDefineEvent + */ +public final class TestClassDefineEvent { + + private final static String TEST_CLASS_NAME = "jdk.jfr.event.runtime.TestClasses"; + private final static String EVENT_NAME = EventNames.ClassDefine; + + public static void main(String[] args) throws Throwable { + Recording recording = new Recording(); + recording.enable(EVENT_NAME); + TestClassLoader cl = new TestClassLoader(); + recording.start(); + cl.loadClass(TEST_CLASS_NAME); + recording.stop(); + + List events = Events.fromRecording(recording); + boolean foundTestClasses = false; + for (RecordedEvent event : events) { + System.out.println(event); + RecordedClass definedClass = event.getValue("definedClass"); + if (TEST_CLASS_NAME.equals(definedClass.getName())) { + RecordedClassLoader definingClassLoader = definedClass.getClassLoader(); + Asserts.assertNotNull(definingClassLoader, "Defining Class Loader should not be null"); + RecordedClass definingClassLoaderType = definingClassLoader.getType(); + Asserts.assertNotNull(definingClassLoaderType, "The defining Class Loader type should not be null"); + Asserts.assertEquals(cl.getClass().getName(), definingClassLoaderType.getName(), + "Expected type " + cl.getClass().getName() + ", got type " + definingClassLoaderType.getName()); + //Asserts.assertEquals(cl.getName(), definingClassLoader.getName(), + // "Defining Class Loader should have the same name as the original class loader"); + foundTestClasses = true; + } + } + Asserts.assertTrue(foundTestClasses, "No class define event found for " + TEST_CLASS_NAME); + } +} diff --git a/test/jdk/jfr/event/runtime/TestClassLoadEvent.java b/test/jdk/jfr/event/runtime/TestClassLoadEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..b0719d20cc6cc3be70d8e9c0ea1bcd8df1a10485 --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestClassLoadEvent.java @@ -0,0 +1,86 @@ +/* + * 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 + * 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.event.runtime; + +import java.time.Duration; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedClass; +import jdk.jfr.consumer.RecordedClassLoader; +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.jfr.TestClassLoader; + +/** + * @test + * @key jfr + * + * @library /lib / + * @build jdk.jfr.event.runtime.TestClasses + * @run main/othervm jdk.jfr.event.runtime.TestClassLoadEvent + */ +public final class TestClassLoadEvent { + + private final static String TEST_CLASS_NAME = "jdk.jfr.event.runtime.TestClasses"; + private final static String BOOT_CLASS_LOADER_NAME = ""; + private final static String SEARCH_CLASS_NAME = "java.lang.Object"; + private final static String SEARCH_PACKAGE_NAME = "java/lang"; + private final static String SEARCH_MODULE_NAME = "java.base"; + private final static String EVENT_NAME = EventNames.ClassLoad; + + public static void main(String[] args) throws Throwable { + Recording recording = new Recording(); + recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(0)); + TestClassLoader cl = new TestClassLoader(); + recording.start(); + cl.loadClass(TEST_CLASS_NAME); + recording.stop(); + + List events = Events.fromRecording(recording); + boolean isLoaded = false; + for (RecordedEvent event : events) { + RecordedClass loadedClass = event.getValue("loadedClass"); + if (SEARCH_CLASS_NAME.equals(loadedClass.getName())) { + System.out.println(event); + Events.assertClassPackage(loadedClass, SEARCH_PACKAGE_NAME); + //module events are not available at 8 + //Events.assertClassModule(loadedClass, SEARCH_MODULE_NAME); + RecordedClassLoader initiatingClassLoader = event.getValue("initiatingClassLoader"); + Asserts.assertEquals(cl.getClass().getName(), initiatingClassLoader.getType().getName(), + "Expected type " + cl.getClass().getName() + ", got type " + initiatingClassLoader.getType().getName()); + RecordedClassLoader definingClassLoader = loadedClass.getClassLoader(); + Asserts.assertEquals(BOOT_CLASS_LOADER_NAME, definingClassLoader.getName(), + "Expected boot loader to be the defining class loader"); + Asserts.assertNull(definingClassLoader.getType(), "boot loader should not have a type"); + isLoaded = true; + } + } + Asserts.assertTrue(isLoaded, "No class load event found for class " + SEARCH_CLASS_NAME); + } +} diff --git a/test/jdk/jfr/event/runtime/TestClassLoaderStatsEvent.java b/test/jdk/jfr/event/runtime/TestClassLoaderStatsEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..debf79f07c2956b111d43dd3ac683e17c9e37fc6 --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestClassLoaderStatsEvent.java @@ -0,0 +1,133 @@ +/* + * 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 + * 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.event.runtime; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedClassLoader; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * @library /lib / + * @build jdk.jfr.event.runtime.TestClasses + * @run main/othervm jdk.jfr.event.runtime.TestClassLoaderStatsEvent + */ +public class TestClassLoaderStatsEvent { + private final static String EVENT_NAME = EventNames.ClassLoaderStatistics; + private final static String CLASS_LOADER_NAME = "jdk/jfr/event/runtime/TestClassLoaderStatsEvent$DummyClassLoader"; // XXX unsupported in JDK8 "MyDummyClassLoader"; + private final static String CLASSLOADER_TYPE_NAME = "jdk.jfr.event.runtime.TestClassLoaderStatsEvent$DummyClassLoader"; + public static DummyClassLoader dummyloader; + + public static void main(String[] args) throws Throwable { + createDummyClassLoader(CLASS_LOADER_NAME); + + Recording recording = new Recording(); + recording.enable(EVENT_NAME); + recording.start(); + recording.stop(); + List consumer = Events.fromRecording(recording); + Events.hasEvents(consumer); + + boolean isAnyFound = false; + for (RecordedEvent event : consumer) { + System.out.println("Event:" + event); + if (Events.assertField(event, "classLoader").getValue() == null) { + continue; + } + RecordedClassLoader recordedClassLoader = event.getValue("classLoader"); + if (CLASSLOADER_TYPE_NAME.equals(recordedClassLoader.getType().getName())) { + Asserts.assertEquals(CLASS_LOADER_NAME, recordedClassLoader.getName(), + "Expected class loader name " + CLASS_LOADER_NAME + ", got name " + recordedClassLoader.getName()); + Events.assertField(event, "classCount").equal(1L); + Events.assertField(event, "chunkSize").above(1L); + Events.assertField(event, "blockSize").above(1L); + Events.assertField(event, "anonymousClassCount").equal(1L); + Events.assertField(event, "anonymousChunkSize").above(1L); + Events.assertField(event, "anonymousBlockSize").above(1L); + isAnyFound = true; + } + } + Asserts.assertTrue(isAnyFound, "No events found"); + } + + private static void createDummyClassLoader(String name) throws Throwable { + dummyloader = new DummyClassLoader(name); + Class c = Class.forName(TestClass.class.getName(), true, dummyloader); + if (c.getClassLoader() != dummyloader) { + throw new RuntimeException("TestClass defined by wrong classloader: " + c.getClassLoader()); + } + } + + public static class DummyClassLoader extends ClassLoader { + + static ByteBuffer readClassFile(String name) { + String testClasses = System.getProperty("test.classes"); + File f = new File(testClasses, name); + try (FileInputStream fin = new FileInputStream(f)) { + FileChannel fc = fin.getChannel(); + return fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size()); + } catch (IOException e) { + throw new RuntimeException("Can't open file: " + f, e); + } + } + + protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { + Class c; + if (TestClass.class.getName().equals(name)) { + c = findClass(name); + if (resolve) { + resolveClass(c); + } + } else { + c = super.loadClass(name, resolve); + } + return c; + } + + protected Class findClass(String name) throws ClassNotFoundException { + if (!TestClass.class.getName().equals(name)) { + throw new ClassNotFoundException("Unexpected class: " + name); + } + return defineClass(name, readClassFile(TestClass.class.getName().replace(".", File.separator) + ".class"), null); + } + + public DummyClassLoader(String name) { + super(ClassLoader.getSystemClassLoader()); + } + } +} diff --git a/test/jdk/jfr/event/runtime/TestClassLoadingStatisticsEvent.java b/test/jdk/jfr/event/runtime/TestClassLoadingStatisticsEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..01777475827ab9521a14f3ca1b914cfbcedd0295 --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestClassLoadingStatisticsEvent.java @@ -0,0 +1,142 @@ +/* + * 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 + * 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.event.runtime; + +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.jfr.TestClassLoader; + +/** + * @test + * @key jfr + * + * @library /lib / + * @build jdk.jfr.event.runtime.TestClasses + * @run main/othervm jdk.jfr.event.runtime.TestClassLoadingStatisticsEvent + */ +/** + * This test will load a number of classes. After each load step we verify that + * the loadedClassCount and unloadedClassCount attributes are correct. + * + * System.gc() will trigger class unloading if -XX:+ExplicitGCInvokesConcurrent + * is NOT set. If this flag is set G1 will never unload classes on System.gc() + * and CMS will not guarantee that all semantically dead classes will be + * unloaded. As far as the "jfr" key guarantees no VM flags are set from the + * outside it should be enough with System.gc(). + */ +public class TestClassLoadingStatisticsEvent { + + private final static String EVENT_PATH = EventNames.ClassLoadingStatistics; + private final static String TESTCLASS_PUBLIC_STATIC = + "jdk.jfr.event.runtime.TestClasses$TestClassPublicStatic"; + private final static String TESTCLASS_PUBLIC_STATIC_INNER = + "jdk.jfr.event.runtime.TestClasses$TestClassPublicStatic$TestClassPublicStaticInner"; + + // Declare unloadableClassLoader as "public static" + // to prevent the compiler to optimize away all unread writes + public static TestClassLoader unloadableClassLoader; + + public static void main(String[] args) throws Throwable { + // Load twice to get more stable result. + RecordedEvent event = getCurrentEvent(); + event = getCurrentEvent(); + + // Declare class ClassLoadingStatisticsHelper. + TestClasses[] helpers = new TestClasses[10]; + event = verifyCountDelta(event, 1, 0); + + // Should load classes TestClassPrivate and TestClassPrivateStatic. + for (int c = 0; c < helpers.length; c++) { + helpers[c] = new TestClasses(); + } + event = verifyCountDelta(event, 2, 0); + + // Load classes TestClassProtected and B2. + helpers[0].new TestClassProtected(); + helpers[1].new TestClassProtected(); // This class is already loaded. + new TestClasses.TestClassProtectedStatic(); + event = verifyCountDelta(event, 2, 0); + + // Load classes TestClassProtected1 and TestClassProtectedStatic1. + for (int c = 0; c < helpers.length; c++) { + helpers[c].loadClasses(); + } + event = verifyCountDelta(event, 2, 0); + + // Load the classes with separate class loader. Will be unloaded later. + unloadableClassLoader = new TestClassLoader(); + + unloadableClassLoader.loadClass(TESTCLASS_PUBLIC_STATIC_INNER); + event = verifyCountDelta(event, 1, 0); + + unloadableClassLoader.loadClass(TESTCLASS_PUBLIC_STATIC); + event = verifyCountDelta(event, 1, 0); + + // This System.gc() should not unload classes, since the + // unloadableClassLoader object is still active. + System.gc(); + event = verifyCountDelta(event, 0, 0); + + // make classes are unloaded. + unloadableClassLoader = null; + System.gc(); + event = verifyCountDelta(event, 0, 2); + } + + private static RecordedEvent getCurrentEvent() throws Throwable { + Recording recording = new Recording(); + recording.enable(EVENT_PATH); + recording.start(); + recording.stop(); + List events = Events.fromRecording(recording); + Asserts.assertFalse(events.isEmpty(), "No events in recording"); + RecordedEvent event = events.get(0); + return event; + } + + private static RecordedEvent verifyCountDelta( + RecordedEvent prevEvent, int loadDelta, int unloadDelta) throws Throwable { + RecordedEvent currEvent = null; + try { + long prevLoad = Events.assertField(prevEvent, "loadedClassCount").getValue(); + long prevUnload = Events.assertField(prevEvent, "unloadedClassCount").getValue(); + + currEvent = getCurrentEvent(); + Events.assertField(currEvent, "loadedClassCount").atLeast(prevLoad + loadDelta); + Events.assertField(currEvent, "unloadedClassCount").atLeast(prevUnload + unloadDelta); + return currEvent; + } catch (Throwable t) { + System.out.println("verifyCountDelta failed. prevEvent=" + prevEvent + ", currEvent=" + currEvent); + throw t; + } + } + +} diff --git a/test/jdk/jfr/event/runtime/TestClassUnloadEvent.java b/test/jdk/jfr/event/runtime/TestClassUnloadEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..4962778b32f9b9f0a028a49506c7caecc93d7ab9 --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestClassUnloadEvent.java @@ -0,0 +1,93 @@ +/* + * 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 + * 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.event.runtime; + +import java.time.Duration; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedClass; +import jdk.jfr.consumer.RecordedClassLoader; +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.jfr.TestClassLoader; + +/** + * @test + * @summary The test verifies that a class unload event is created when class is unloaded + * @key jfr + * + * @library /lib / + * @build jdk.jfr.event.runtime.TestClasses + * @run main/othervm -XX:+PrintGCDetails -XX:+PrintGC -verbose:class -Xmx16m jdk.jfr.event.runtime.TestClassUnloadEvent + */ + +/** + * System.gc() will trigger class unloading if -XX:+ExplicitGCInvokesConcurrent is NOT set. + * If this flag is set G1 will never unload classes on System.gc() and + * CMS will not guarantee that all semantically dead classes will be unloaded. + * As far as the "jfr" key guarantees no VM flags are set from the outside + * it should be enough with System.gc(). + */ +public final class TestClassUnloadEvent { + private final static String TEST_CLASS_NAME = "jdk.jfr.event.runtime.TestClasses"; + private final static String EVENT_PATH = EventNames.ClassUnload; + + // Declare unloadableClassLoader as "public static" + // to prevent the compiler to optimize away all unread writes + public static TestClassLoader unloadableClassLoader; + + public static void main(String[] args) throws Throwable { + Recording recording = new Recording(); + recording.enable(EVENT_PATH).withThreshold(Duration.ofMillis(0)); + unloadableClassLoader = new TestClassLoader(); + recording.start(); + unloadableClassLoader.loadClass(TEST_CLASS_NAME); + unloadableClassLoader = null; + System.gc(); + recording.stop(); + + List events = Events.fromRecording(recording); + Events.hasEvents(events); + boolean isAnyFound = false; + for (RecordedEvent event : events) { + System.out.println("Event:" + event); + RecordedClass unloadedClass = event.getValue("unloadedClass"); + if (TEST_CLASS_NAME.equals(unloadedClass.getName())) { + RecordedClassLoader definingClassLoader = unloadedClass.getClassLoader(); + Asserts.assertEquals(TestClassLoader.class.getName(), definingClassLoader.getType().getName(), + "Expected " + TestClassLoader.class.getName() + ", got " + definingClassLoader.getType().getName()); + //Asserts.assertEquals(TestClassLoader.CLASS_LOADER_NAME, definingClassLoader.getName(), + // "Expected " + TestClassLoader.CLASS_LOADER_NAME + ", got " + definingClassLoader.getName()); + Asserts.assertFalse(isAnyFound, "Found more than 1 event"); + isAnyFound = true; + } + } + Asserts.assertTrue(isAnyFound, "No events found"); + } +} diff --git a/test/jdk/jfr/event/runtime/TestClasses.java b/test/jdk/jfr/event/runtime/TestClasses.java new file mode 100644 index 0000000000000000000000000000000000000000..053cb41aaf670f3241a907532f007e62d04aaec3 --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestClasses.java @@ -0,0 +1,83 @@ +/* + * 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 + * 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.event.runtime; + +public class TestClasses { + + protected TestClassPrivate testClassPrivate; + protected TestClassPrivateStatic testClassPrivateStatic; + + public TestClasses() { + testClassPrivate = new TestClassPrivate(); + testClassPrivateStatic = new TestClassPrivateStatic(); + } + + // Classes TestClassPrivate and TestClassPrivateStatic should be loaded at + // the same time + // as the base class TestClasses + private class TestClassPrivate { + } + + private static class TestClassPrivateStatic { + } + + protected class TestClassProtected { + } + + protected static class TestClassProtectedStatic { + } + + // When loadClasses() is run, 3 new classes should be loaded. + public void loadClasses() throws ClassNotFoundException { + final ClassLoader cl = getClass().getClassLoader(); + cl.loadClass("jdk.jfr.event.runtime.TestClasses$TestClassProtected1"); + cl.loadClass("jdk.jfr.event.runtime.TestClasses$TestClassProtectedStatic1"); + } + + protected class TestClassProtected1 { + } + + protected static class TestClassProtectedStatic1 { + protected TestClassProtectedStaticInner testClassProtectedStaticInner = new TestClassProtectedStaticInner(); + + protected static class TestClassProtectedStaticInner { + } + } + + public static class TestClassPublicStatic { + public static class TestClassPublicStaticInner { + } + } + +} + +class TestClass { + static { + // force creation of anonymous class (for the lambda form) + Runnable r = () -> System.out.println("Hello"); + r.run(); + } +} diff --git a/test/jdk/jfr/event/runtime/TestExceptionEvents.java b/test/jdk/jfr/event/runtime/TestExceptionEvents.java new file mode 100644 index 0000000000000000000000000000000000000000..3d0cc5c39cb5f817501afe5890848749cfa68bd6 --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestExceptionEvents.java @@ -0,0 +1,200 @@ +/* + * 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 + * 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.event.runtime; + +import java.time.Duration; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedClass; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedFrame; +import jdk.jfr.consumer.RecordedStackTrace; +import jdk.jfr.consumer.RecordedThread; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.runtime.TestExceptionEvents + */ +public class TestExceptionEvents { + + private static final String EXCEPTION_EVENT_PATH = EventNames.JavaExceptionThrow; + private static final String ERROR_EVENT_PATH = EventNames.JavaErrorThrow; + private static final String EXCEPTION_STATISTICS_PATH = EventNames.ExceptionStatistics; + + private static final String EXCEPTION_MESSAGE = "exceptiontest"; + private static final String ERROR_MESSAGE = "errortest"; + private static final String THROWABLE_MESSAGE = "throwabletest"; + + private static final int ITERATIONS = 10; + + private static int exceptionCount = 0; + + public static void main(String[] args) throws Throwable { + Recording recording = createRecording(); + + List events = Events.fromRecording(recording); + checkStatisticsEvent(events, exceptionCount); + checkThrowableEvents(events, EXCEPTION_EVENT_PATH, ITERATIONS, MyException.class, EXCEPTION_MESSAGE); + checkThrowableEvents(events, ERROR_EVENT_PATH, ITERATIONS, MyError.class, ERROR_MESSAGE); + checkThrowableEvents(events, EXCEPTION_EVENT_PATH, ITERATIONS, MyThrowable.class, THROWABLE_MESSAGE); + checkExceptionStackTrace(); + } + + private static void checkExceptionStackTrace() throws Exception { + @SuppressWarnings("serial") + class TestError extends Error { + } + @SuppressWarnings("serial") + class TestException extends Exception { + } + + try (Recording r = new Recording()) { + r.enable(EventNames.JavaErrorThrow).withStackTrace(); + r.enable(EventNames.JavaExceptionThrow).withStackTrace(); + r.start(); + try { + throw new TestError(); + } catch (Error e) { + System.out.println(e.getClass() + " thrown!"); + } + try { + throw new TestException(); + } catch (Exception e) { + System.out.println(e.getClass() + " thrown!"); + } + try { + throw new Exception(); + } catch (Exception e) { + System.out.println(e.getClass() + " thrown!"); + } + r.stop(); + List events = Events.fromRecording(r); + Events.hasEvents(events); + for (RecordedEvent e : events) { + RecordedStackTrace rs = e.getStackTrace(); + RecordedClass rc = e.getValue("thrownClass"); + List frames = rs.getFrames(); + RecordedFrame topFrame = frames.get(0); + System.out.println(rc.getName() + " Top frame: " + topFrame.getMethod().getName()); + if (!topFrame.getMethod().getName().equals("")) { + throw new Exception("Expected name of top frame to be "); + } + } + } + } + + private static Recording createRecording() throws Exception { + Recording recording = new Recording(); + recording.enable(EXCEPTION_STATISTICS_PATH); + recording.enable(EXCEPTION_EVENT_PATH).withThreshold(Duration.ofMillis(0)); + recording.enable(ERROR_EVENT_PATH).withThreshold(Duration.ofMillis(0)); + recording.start(); + + for (int i = 0; i < ITERATIONS; i++) { + try { + throw new MyException(EXCEPTION_MESSAGE); + } catch (MyException e) { + exceptionCount++; + } + try { + throw new MyError(ERROR_MESSAGE); + } catch (MyError e) { + exceptionCount++; + } + try { + throw new MyThrowable(THROWABLE_MESSAGE); + } catch (MyThrowable t) { + exceptionCount++; + } + } + recording.stop(); + return recording; + } + + + private static void checkStatisticsEvent(List events, long minCount) throws Exception { + // Events are not guaranteed to be in chronological order, take highest value. + long count = -1; + for(RecordedEvent event : events) { + if (Events.isEventType(event, EXCEPTION_STATISTICS_PATH)) { + System.out.println("Event: " + event); + count = Math.max(count, Events.assertField(event, "throwables").getValue()); + System.out.println("count=" + count); + } + } + Asserts.assertTrue(count != -1, "No events of type " + EXCEPTION_STATISTICS_PATH); + Asserts.assertGreaterThanOrEqual(count, minCount, "Too few exception count in statistics event"); + } + + private static void checkThrowableEvents(List events, String eventName, + int excpectedEvents, Class expectedClass, String expectedMessage) throws Exception { + int count = 0; + for(RecordedEvent event : events) { + if (Events.isEventType(event, eventName)) { + String message = Events.assertField(event, "message").getValue(); + if (expectedMessage.equals(message)) { + RecordedThread t = event.getThread(); + String threadName = t.getJavaName(); + if (threadName != null && threadName.equals(Thread.currentThread().getName())) { + RecordedClass jc = event.getValue("thrownClass"); + if (jc.getName().equals(expectedClass.getName())) { + count++; + } + } + } + } + } + Asserts.assertEquals(count, excpectedEvents, "Wrong event count for type " + eventName); + } + + private static class MyException extends Exception { + private static final long serialVersionUID = -2614309279743448910L; + public MyException(String msg) { + super(msg); + } + } + + private static class MyError extends Error { + private static final long serialVersionUID = -8519872786387358196L; + public MyError(String msg) { + super(msg); + } + } + + private static class MyThrowable extends Throwable { + private static final long serialVersionUID = -7929442863511070361L; + public MyThrowable(String msg) { + super(msg); + } + } +} diff --git a/test/jdk/jfr/event/runtime/TestExceptionSubclass.java b/test/jdk/jfr/event/runtime/TestExceptionSubclass.java new file mode 100644 index 0000000000000000000000000000000000000000..320702ecb4ab99585a7aa17e452f0b1dee4d2851 --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestExceptionSubclass.java @@ -0,0 +1,65 @@ +/* + * 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 + * 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.event.runtime; + +import java.util.concurrent.TimeUnit; + +/** + * @test + * @key jfr + * @bug 8013122 + * + * @library /lib / + * @run main/othervm jdk.jfr.event.runtime.TestExceptionSubclass + */ +public class TestExceptionSubclass { + + public TestExceptionSubclass() { + try { + throw new PerfectlyFineException(TimeUnit.MILLISECONDS); + } catch (PerfectlyFineException e) { + //thats perfectly fine. + } + } + + public static void main(String[] args) throws Throwable { + new TestExceptionSubclass(); + } + + + class PerfectlyFineException extends Error { + private static final long serialVersionUID = 1L; + private final TimeUnit unit; + + PerfectlyFineException(TimeUnit unit) { + this.unit = unit; + } + + public String getMessage() { + return "Failed in " + unit.toNanos(1) + " ns"; + } + } +} diff --git a/test/jdk/jfr/event/runtime/TestJavaBlockedEvent.java b/test/jdk/jfr/event/runtime/TestJavaBlockedEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..9a1160e97cd43b4488c79d24367da527db63827a --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestJavaBlockedEvent.java @@ -0,0 +1,119 @@ +/* + * 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 + * 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.event.runtime; + +import static jdk.test.lib.Asserts.assertFalse; +import static jdk.test.lib.Asserts.assertTrue; + +import java.time.Duration; +import java.util.List; +import java.util.concurrent.CountDownLatch; + +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.management.ThreadMXBeanTool; +import jdk.test.lib.thread.TestThread; +import jdk.test.lib.thread.XRun; + +/** + * @test + * @key jfr + * + * @library /lib / + * + * @run main/othervm jdk.jfr.event.runtime.TestJavaBlockedEvent + */ +public class TestJavaBlockedEvent { + private static final String EVENT_NAME = EventNames.JavaMonitorEnter; + private static final long THRESHOLD_MILLIS = 1; + + static class Lock { + } + + public static void main(String[] args) throws Throwable { + Recording recording = new Recording(); + + recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(THRESHOLD_MILLIS)); + recording.start(); + final Lock lock = new Lock(); + final CountDownLatch blockerInLock = new CountDownLatch(1); + final CountDownLatch blockingFinished = new CountDownLatch(1); + final CountDownLatch blockedFinished = new CountDownLatch(1); + TestThread blockerThread = new TestThread(new XRun() { + @Override + public void xrun() throws Throwable { + synchronized (lock) { + blockerInLock.countDown(); + blockingFinished.await(); + } + blockedFinished.await(); + } + }); + + TestThread blockedThread = new TestThread(new XRun() { + @Override + public void xrun() throws Throwable { + blockerInLock.await(); + synchronized (lock) { + blockedFinished.countDown(); + } + } + }); + blockerThread.start(); + blockedThread.start(); + + blockerInLock.await(); + ThreadMXBeanTool.waitUntilBlockingOnObject(blockedThread, Thread.State.BLOCKED, lock); + Thread.sleep(2 * THRESHOLD_MILLIS); + blockingFinished.countDown(); + blockedFinished.await(); + + blockedThread.join(); + blockerThread.join(); + recording.stop(); + + List events = Events.fromRecording(recording); + boolean isAnyFound = false; + for (RecordedEvent event : events) { + System.out.println("Event:" + event); + if (event.getThread().getJavaThreadId() == blockedThread.getId()) { + if (isMyLock(Events.assertField(event, "monitorClass.name").getValue())) { + Events.assertEventThread(event, "previousOwner", blockerThread); + Events.assertField(event, "address").above(0L); + assertFalse(isAnyFound, "Found multiple events"); + isAnyFound = true; + } + } + } + assertTrue(isAnyFound, "No blocking event from " + blockedThread.getName()); + } + + private static boolean isMyLock(String className) { + return Lock.class.getName().replace('.', '/').equals(className); + } +} diff --git a/test/jdk/jfr/event/runtime/TestJavaMonitorInflateEvent.java b/test/jdk/jfr/event/runtime/TestJavaMonitorInflateEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..d98b4ce21c44500247809ea2ad87684e59d7c9db --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestJavaMonitorInflateEvent.java @@ -0,0 +1,116 @@ +/* + * 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. 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.event.runtime; + +import static jdk.test.lib.Asserts.assertTrue; + +import java.nio.file.Paths; +import java.time.Duration; +import java.util.concurrent.CountDownLatch; + +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.thread.TestThread; +import jdk.test.lib.thread.XRun; + +/** + * @test TestJavaMonitorInflateEvent + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.runtime.TestJavaMonitorInflateEvent + */ +public class TestJavaMonitorInflateEvent { + + private static final String FIELD_KLASS_NAME = "monitorClass.name"; + private static final String FIELD_ADDRESS = "address"; + private static final String FIELD_CAUSE = "cause"; + + private static final String EVENT_NAME = EventNames.JavaMonitorInflate; + private static final long WAIT_TIME = 123456; + + static class Lock { + } + + public static void main(String[] args) throws Exception { + Recording recording = new Recording(); + recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(0)); + final Lock lock = new Lock(); + final CountDownLatch latch = new CountDownLatch(1); + // create a thread that waits + TestThread waitThread = new TestThread(new XRun() { + @Override + public void xrun() throws Throwable { + synchronized (lock) { + latch.countDown(); + lock.wait(WAIT_TIME); + } + } + }); + try { + recording.start(); + waitThread.start(); + latch.await(); + synchronized (lock) { + lock.notifyAll(); + } + } finally { + waitThread.join(); + recording.stop(); + } + final String thisThreadName = Thread.currentThread().getName(); + final String waitThreadName = waitThread.getName(); + final String lockClassName = lock.getClass().getName().replace('.', '/'); + boolean isAnyFound = false; + try { + // Find at least one event with the correct monitor class and check the other fields + for (RecordedEvent event : Events.fromRecording(recording)) { + assertTrue(EVENT_NAME.equals(event.getEventType().getName()), "mismatched event types?"); + // Check recorded inflation event is associated with the Lock class used in the test + final String recordedMonitorClassName = Events.assertField(event, FIELD_KLASS_NAME).getValue(); + if (!lockClassName.equals(recordedMonitorClassName)) { + continue; + } + // Check recorded thread matches one of the threads in the test + final String recordedThreadName = event.getThread().getJavaName(); + if (!(recordedThreadName.equals(waitThreadName) || recordedThreadName.equals(thisThreadName))) { + continue; + } + Events.assertField(event, FIELD_ADDRESS).notEqual(0L); + isAnyFound = true; + break; + } + assertTrue(isAnyFound, "Expected an inflation event from test"); + } catch (Throwable e) { + recording.dump(Paths.get("failed.jfr")); + throw e; + } finally { + recording.close(); + } + } +} diff --git a/test/jdk/jfr/event/runtime/TestJavaMonitorWaitEvent.java b/test/jdk/jfr/event/runtime/TestJavaMonitorWaitEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..ead5e7616c03f477e0d718cb3f86c7c2dd5c73da --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestJavaMonitorWaitEvent.java @@ -0,0 +1,107 @@ +/* + * 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 + * 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.event.runtime; + +import static jdk.test.lib.Asserts.assertFalse; +import static jdk.test.lib.Asserts.assertTrue; + +import java.time.Duration; +import java.util.concurrent.CountDownLatch; + +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.thread.TestThread; +import jdk.test.lib.thread.XRun; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.runtime.TestJavaMonitorWaitEvent + */ +public class TestJavaMonitorWaitEvent { + + private final static String EVENT_NAME = EventNames.JavaMonitorWait; + private static final long WAIT_TIME = 123456; + + static class Lock { + } + + static boolean silenceFindBugsNakedNotify; + + public static void main(String[] args) throws Throwable { + Recording recording = new Recording(); + recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(0)); + + final Lock lock = new Lock(); + final CountDownLatch latch = new CountDownLatch(1); + + TestThread waitThread = new TestThread(new XRun() { + @Override + public void xrun() throws Throwable { + synchronized (lock) { + latch.countDown(); + lock.wait(WAIT_TIME); + silenceFindBugsNakedNotify = false; + } + } + }); + + try { + recording.start(); + waitThread.start(); + latch.await(); + synchronized (lock) { + silenceFindBugsNakedNotify = true; + lock.notifyAll(); + } + } finally { + waitThread.join(); + recording.stop(); + } + + boolean isAnyFound = false; + for (RecordedEvent event : Events.fromRecording(recording)) { + System.out.println("Event:" + event); + if ((long)Events.assertField(event, "timeout").getValue() != WAIT_TIME) { + continue; + } + + assertFalse(isAnyFound, "Found more than 1 event"); + isAnyFound = true; + Events.assertEventThread(event, waitThread); + final String lockClassName = lock.getClass().getName().replace('.', '/'); + Events.assertField(event, "monitorClass.name").equal(lockClassName); + Events.assertField(event, "address").notEqual(0L); + Events.assertField(event, "timedOut").equal(false); + Events.assertEventThread(event, "notifier", Thread.currentThread()); + } + assertTrue(isAnyFound, "Correct event not found"); + } +} diff --git a/test/jdk/jfr/event/runtime/TestJavaMonitorWaitTimeOut.java b/test/jdk/jfr/event/runtime/TestJavaMonitorWaitTimeOut.java new file mode 100644 index 0000000000000000000000000000000000000000..16d69b9fd2b480775967c4bc2713b4d0741dded4 --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestJavaMonitorWaitTimeOut.java @@ -0,0 +1,126 @@ +/* + * 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 + * 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.event.runtime; + +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedClass; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedThread; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.runtime.TestJavaMonitorWaitTimeOut + */ +public class TestJavaMonitorWaitTimeOut { + + static final class Lock { + + } + + private static final String THREAD_NAME = "Notifier"; + + static class Notifierhread extends Thread { + private final Object lock; + + Notifierhread(Object lock) { + super(THREAD_NAME); + this.lock = lock; + } + + public void run() { + synchronized (lock) { + lock.notify(); + } + } + } + + public static void main(String[] args) throws Throwable { + try (Recording recording = new Recording()) { + recording.enable(EventNames.JavaMonitorWait).withoutThreshold().withoutStackTrace(); + recording.start(); + Lock lock = new Lock(); + + synchronized (lock) { + // event without notifier, should be null + lock.wait(10); + } + Notifierhread s = new Notifierhread(lock); + + synchronized (lock) { + s.start(); + // event with a notifier + lock.wait(1_000_000); + s.join(); + } + + synchronized (lock) { + // event without a notifier, should be null + lock.wait(11); + } + recording.stop(); + List events = Events.fromRecording(recording); + for (RecordedEvent e : events) { + if (isWaitEvent(e)) { + System.out.println(e); + } + } + assertTimeOutEvent(events, 10, null); + assertTimeOutEvent(events, 1_000_000, THREAD_NAME); + assertTimeOutEvent(events, 11, null); + } + } + + private static boolean isWaitEvent(RecordedEvent event) { + RecordedClass t = event.getValue("monitorClass"); + return t != null && t.getName().equals(Lock.class.getName()); + } + + private static void assertTimeOutEvent(List events, long timeout, String expectedThreadName) { + for (RecordedEvent e : events) { + if (isWaitEvent(e)) { + Long l = e.getValue("timeout"); + if (l == timeout) { + RecordedThread notifier = e.getValue("notifier"); + String threadName = null; + if (notifier != null) { + threadName = notifier.getJavaName(); + } + Asserts.assertEquals(threadName, expectedThreadName, "Invalid thread"); + return; + } + } + } + Asserts.fail("Could not find event with monitorClass" + Lock.class.getName()); + } +} diff --git a/test/jdk/jfr/event/runtime/TestJavaThreadStatisticsEvent.java b/test/jdk/jfr/event/runtime/TestJavaThreadStatisticsEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..983afed8eb919c080f189659e99899eb586bea27 --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestJavaThreadStatisticsEvent.java @@ -0,0 +1,91 @@ +/* + * 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 + * 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.event.runtime; + +import static jdk.test.lib.Asserts.assertTrue; + +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.runtime.TestJavaThreadStatisticsEvent + */ +public class TestJavaThreadStatisticsEvent { + private static final String EVENT_NAME = EventNames.JavaThreadStatistics; + + private static final int THREAD_COUNT = 10; + private static final Random RAND = new Random(4711); + + // verify thread count: 0 <= daemon <= active <= peak <= accumulated. + public static void main(String[] args) throws Throwable { + Recording recording = new Recording(); + recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(10)); + recording.start(); + + List threads = new ArrayList<>(); + for (int i = 0; i < THREAD_COUNT; i++) { + Thread thread = new Thread(TestJavaThreadStatisticsEvent::sleepRandom); + thread.start(); + threads.add(thread); + } + for (Thread thread : threads) { + thread.join(); + } + + recording.stop(); + List events = Events.fromRecording(recording); + boolean isAnyFound = false; + for (RecordedEvent event : events) { + System.out.println("Event:" + event); + isAnyFound = true; + // verify thread count: 0 <= daemon <= active <= peak <= accumulated. + long daemonCount = Events.assertField(event, "daemonCount").atLeast(0L).getValue(); + long activeCount = Events.assertField(event, "activeCount").atLeast(daemonCount).getValue(); + long peakCount = Events.assertField(event, "peakCount").atLeast(activeCount).atLeast(1L).getValue(); + Events.assertField(event, "accumulatedCount").atLeast(peakCount).getValue(); + } + assertTrue(isAnyFound, "Correct event not found"); + } + + static void sleepRandom() { + try { + Thread.sleep(RAND.nextInt(10)); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } +} diff --git a/test/jdk/jfr/event/runtime/TestJavaThreadStatisticsEventBean.java b/test/jdk/jfr/event/runtime/TestJavaThreadStatisticsEventBean.java new file mode 100644 index 0000000000000000000000000000000000000000..307fae7c60d7462444f12c3bd6cd8260fb476abe --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestJavaThreadStatisticsEventBean.java @@ -0,0 +1,85 @@ +/* + * 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 + * 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.event.runtime; + +import static jdk.test.lib.Asserts.assertTrue; + +import java.lang.management.ManagementFactory; +import java.lang.management.ThreadMXBean; +import java.time.Duration; +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; + +/** + * @test + * @key jfr + * + * @library /lib / + * + * @run main/othervm jdk.jfr.event.runtime.TestJavaThreadStatisticsEventBean + */ +public class TestJavaThreadStatisticsEventBean { + private final static String EVENT_NAME = EventNames.JavaThreadStatistics; + + // Compare JFR thread counts to ThreadMXBean counts + public static void main(String[] args) throws Throwable { + long mxDaemonCount = -1; + long mxActiveCount = -1; + + // Loop until we are sure no threads were started during the recording. + Recording recording = null; + ThreadMXBean mxBean = ManagementFactory.getThreadMXBean(); + long totalCountBefore = -1; + while (totalCountBefore != mxBean.getTotalStartedThreadCount()) { + recording = new Recording(); + recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(10)); + totalCountBefore = mxBean.getTotalStartedThreadCount(); + recording.start(); + mxDaemonCount = mxBean.getDaemonThreadCount(); + mxActiveCount = mxBean.getThreadCount(); + recording.stop(); + final String msg = "testCountByMXBean: threadsBefore=%d, threadsAfter=%d%n"; + System.out.format(msg, totalCountBefore, mxBean.getTotalStartedThreadCount()); + } + + List events= Events.fromRecording(recording); + boolean isAnyFound = false; + for (RecordedEvent event : events) { + System.out.println("Event:" + event); + isAnyFound = true; + Events.assertField(event, "daemonCount").equal(mxDaemonCount); + Events.assertField(event, "activeCount").equal(mxActiveCount); + Events.assertField(event, "accumulatedCount").atLeast(mxActiveCount); + Events.assertField(event, "peakCount").atLeast(mxActiveCount); + } + assertTrue(isAnyFound, "Correct event not found"); + } + +} diff --git a/test/jdk/jfr/event/runtime/TestNativeLibrariesEvent.java b/test/jdk/jfr/event/runtime/TestNativeLibrariesEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..6956f5affa5c351b174bc68fcc9b18f7a0c02446 --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestNativeLibrariesEvent.java @@ -0,0 +1,104 @@ +/* + * 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 + * 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.event.runtime; + +import static jdk.test.lib.Asserts.assertTrue; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Platform; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @bug 8216559 + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.runtime.TestNativeLibrariesEvent + */ +public class TestNativeLibrariesEvent { + + private final static String EVENT_NAME = EventNames.NativeLibrary; + + public static void main(String[] args) throws Throwable { + Recording recording = new Recording(); + recording.enable(EVENT_NAME); + recording.start(); + recording.stop(); + + List expectedLibs = getExpectedLibs(); + for (RecordedEvent event : Events.fromRecording(recording)) { + System.out.println("Event:" + event); + long unsignedTopAddress = event.getValue("topAddress"); + long unsignedBaseAddress = event.getValue("baseAddress"); + assertValidAddresses(unsignedBaseAddress, unsignedTopAddress); + String lib = Events.assertField(event, "name").notEmpty().getValue(); + for (String expectedLib : new ArrayList<>(expectedLibs)) { + if (lib.contains(expectedLib)) { + expectedLibs.remove(expectedLib); + } + } + } + assertTrue(expectedLibs.isEmpty(), "Missing libraries:" + expectedLibs.stream().collect(Collectors.joining(", "))); + } + + private static List getExpectedLibs() throws Throwable { + String libTemplate = null; + if (Platform.isSolaris()) { + libTemplate = "lib%s.so"; + } else if (Platform.isWindows()) { + libTemplate = "%s.dll"; + } else if (Platform.isOSX()) { + libTemplate = "lib%s.dylib"; + } else if (Platform.isLinux()) { + libTemplate = "lib%s.so"; + } + if (libTemplate == null) { + throw new Exception("Unsupported OS"); + } + + List libs = new ArrayList(); + String[] names = { "jvm", "java", "zip" }; + for (String name : names) { + libs.add(String.format(libTemplate, name)); + } + return libs; + } + + private static void assertValidAddresses(long unsignedBaseAddress, long unsignedTopAddress) throws Exception { + if (unsignedTopAddress != 0) { // guard against missing value (0) + if (Long.compareUnsigned(unsignedTopAddress, unsignedBaseAddress) < 0) { + throw new Exception("Top address " + Long.toHexString(unsignedTopAddress) + " is below base addess " + Long.toHexString(unsignedBaseAddress)); + } + } + } +} diff --git a/test/jdk/jfr/event/runtime/TestNetworkUtilizationEvent.java b/test/jdk/jfr/event/runtime/TestNetworkUtilizationEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..eaa43a7bfded3828f8d2978106000ea8eb3f3cd0 --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestNetworkUtilizationEvent.java @@ -0,0 +1,108 @@ +/* + * 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.event.runtime; + +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.Platform; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * @library /lib / + * + * @run main/othervm jdk.jfr.event.runtime.TestNetworkUtilizationEvent + */ +public class TestNetworkUtilizationEvent { + + private static final long packetSendCount = 100; + + public static void main(String[] args) throws Throwable { + + Recording recording = new Recording(); + recording.enable(EventNames.NetworkUtilization).with("period", "endChunk"); + recording.start(); + + DatagramSocket socket = new DatagramSocket(); + String msg = "hello!"; + byte[] buf = msg.getBytes(); + forceEndChunk(); + // Send a few packets both to the loopback address as well to an + // external + DatagramPacket packet = new DatagramPacket(buf, buf.length, InetAddress.getLoopbackAddress(), 12345); + for (int i = 0; i < packetSendCount; ++i) { + socket.send(packet); + } + packet = new DatagramPacket(buf, buf.length, InetAddress.getByName("10.0.0.0"), 12345); + for (int i = 0; i < packetSendCount; ++i) { + socket.send(packet); + } + + forceEndChunk(); + socket.close(); + // Now there should have been traffic on at least two different + // interfaces + recording.stop(); + Set networkInterfaces = new HashSet<>(); + List events = Events.fromRecording(recording); + Events.hasEvents(events); + for (RecordedEvent event : events) { + System.out.println(event); + Events.assertField(event, "writeRate").atLeast(0L).atMost(1000L * Integer.MAX_VALUE); + Events.assertField(event, "readRate").atLeast(0L).atMost(1000L * Integer.MAX_VALUE); + Events.assertField(event, "networkInterface").notNull(); + if (event.getLong("writeRate") > 0) { + networkInterfaces.add(event.getString("networkInterface")); + } + } + + if (Platform.isWindows() || Platform.isSolaris()) { + // Windows and Solaris do not track statistics for the loopback + // interface + Asserts.assertGreaterThanOrEqual(networkInterfaces.size(), 1); + } else { + Asserts.assertGreaterThanOrEqual(networkInterfaces.size(), 2); + } + } + + private static void forceEndChunk() { + try(Recording r = new Recording()) { + r.start(); + r.stop(); + } + } +} diff --git a/test/jdk/jfr/event/runtime/TestSafepointEvents.java b/test/jdk/jfr/event/runtime/TestSafepointEvents.java new file mode 100644 index 0000000000000000000000000000000000000000..8aad064c03249852895bc59dccfb4ba90167920b --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestSafepointEvents.java @@ -0,0 +1,117 @@ +/* + * 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 + * 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.event.runtime; + +import static jdk.test.lib.Asserts.assertTrue; + +import java.nio.file.Paths; +import java.time.Duration; +import java.util.*; + +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 sun.hotspot.WhiteBox; + +/** + * @test TestSafepointEvents + * @key jfr + * + * @library /lib / + * @build sun.hotspot.WhiteBox + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * @run main/othervm -Xbootclasspath/a:. + * -XX:+FlightRecorder -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * jdk.jfr.event.runtime.TestSafepointEvents + */ +public class TestSafepointEvents { + + static final String[] EVENT_NAMES = new String[] { + EventNames.SafepointBegin, + EventNames.SafepointStateSynchronization, + EventNames.SafepointWaitBlocked, + EventNames.SafepointCleanup, + EventNames.SafepointCleanupTask, + EventNames.SafepointEnd + }; + + public static void main(String[] args) throws Exception { + Recording recording = new Recording(); + for (String name : EVENT_NAMES) { + recording.enable(name).withThreshold(Duration.ofMillis(0)); + } + recording.start(); + WhiteBox.getWhiteBox().forceSafepoint(); + recording.stop(); + + try { + // Verify that each event type was seen at least once + for (String name : EVENT_NAMES) { + boolean found = false; + for (RecordedEvent event : Events.fromRecording(recording)) { + found = event.getEventType().getName().equals(name); + if (found) { + break; + } + } + assertTrue(found, "Expected event from test [" + name + "]"); + } + + // Collect all events grouped by safepoint id + SortedMap> safepointIds = new TreeMap<>(); + for (RecordedEvent event : Events.fromRecording(recording)) { + Integer safepointId = event.getValue("safepointId"); + if (!safepointIds.containsKey(safepointId)) { + safepointIds.put(safepointId, new HashSet<>()); + } + safepointIds.get(safepointId).add(event.getEventType().getName()); + } + + // The last safepoint may be related to stopping the recording and can thus be + // incomplete - so if there is more than one, ignore the last one + if (safepointIds.size() > 1) { + safepointIds.remove(safepointIds.lastKey()); + } + Asserts.assertGreaterThanOrEqual(safepointIds.size(), 1, "At least 1 safepoint must have occured"); + + // Verify that each safepoint id has an occurence of every event type, + // this ensures that all events related to a given safepoint had the same id + for (Set safepointEvents : safepointIds.values()) { + for (String name : EVENT_NAMES) { + assertTrue(safepointEvents.contains(name), "Expected event '" + name + "' to be present"); + } + } + } catch (Throwable e) { + recording.dump(Paths.get("failed.jfr")); + throw e; + } finally { + recording.close(); + } + } +} diff --git a/test/jdk/jfr/event/runtime/TestShutdownEvent.java b/test/jdk/jfr/event/runtime/TestShutdownEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..5bbf69cfde52551cd1fec16ac808b4a63a00590c --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestShutdownEvent.java @@ -0,0 +1,253 @@ +/* + * 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. 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.event.runtime; + +import java.io.IOException; +import java.lang.reflect.Field; +import java.nio.file.Paths; +import java.util.Comparator; +import java.util.List; +import java.util.stream.Collectors; + +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedFrame; +import jdk.jfr.consumer.RecordedStackTrace; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.Platform; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; +import sun.misc.Unsafe; + +/** + * @test + * @summary Test Shutdown event + * @key jfr + * @library /lib / + * @run main/othervm jdk.jfr.event.runtime.TestShutdownEvent + */ +public class TestShutdownEvent { + private static ShutdownEventSubTest subTests[] = { + new TestLastNonDaemon(), + new TestSystemExit(), + new TestVMCrash(), + new TestUnhandledException(), + new TestRuntimeHalt(), + new TestSig("TERM"), + new TestSig("HUP"), + new TestSig("INT") + }; + + public static void main(String[] args) throws Throwable { + for (int i = 0; i < subTests.length; ++i) { + if (subTests[i].isApplicable()) { + runSubtest(i); + } else { + System.out.println("Skipping non-applicable test: " + i); + } + } + } + + private static void runSubtest(int subTestIndex) throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, + "-XX:+LogJFR", + "-XX:-CreateMinidumpOnCrash", + "-XX:StartFlightRecording=filename=./dumped.jfr,dumponexit=true,settings=default", + "jdk.jfr.event.runtime.TestShutdownEvent$TestMain", + String.valueOf(subTestIndex)); + OutputAnalyzer output = ProcessTools.executeProcess(pb); + System.out.println(output.getOutput()); + int exitCode = output.getExitValue(); + System.out.println("Exit code: " + exitCode); + + String recordingName = output.firstMatch("emergency jfr file: (.*.jfr)", 1); + if (recordingName == null) { + recordingName = "./dumped.jfr"; + } + + List events = RecordingFile.readAllEvents(Paths.get(recordingName)); + List filteredEvents = events.stream() + .filter(e -> e.getEventType().getName().equals(EventNames.Shutdown)) + .sorted(Comparator.comparing(RecordedEvent::getStartTime)) + .collect(Collectors.toList()); + + Asserts.assertEquals(filteredEvents.size(), 1); + RecordedEvent event = filteredEvents.get(0); + subTests[subTestIndex].verifyEvents(event, exitCode); + } + + @SuppressWarnings("unused") + private static class TestMain { + public static void main(String[] args) throws Exception { + ShutdownEventSubTest subTest = subTests[Integer.parseInt(args[0])]; + System.out.println("Running subtest " + args[0] + " (" + subTest.getClass().getName() + ")"); + subTest.runTest(); + } + } + + private interface ShutdownEventSubTest { + default boolean isApplicable() { + return true; + } + void runTest(); + void verifyEvents(RecordedEvent event, int exitCode); + } + + public static Unsafe getUnsafe() { + try { + Field f = Unsafe.class.getDeclaredField("theUnsafe"); + f.setAccessible(true); + return (Unsafe)f.get(null); + } catch (Exception e) { + Asserts.fail("Could not access Unsafe"); + } + return null; + } + + // Basic stack trace validation, checking that the runTest method is part of the stack + static void validateStackTrace(RecordedStackTrace stackTrace) { + List frames = stackTrace.getFrames(); + Asserts.assertFalse(frames.isEmpty()); + Asserts.assertTrue(frames.stream() + .anyMatch(t -> t.getMethod().getName().equals("runTest"))); + } + + + // ========================================================================= + private static class TestLastNonDaemon implements ShutdownEventSubTest { + @Override + public void runTest() { + // Do nothing - this is the default exit reason + } + + @Override + public void verifyEvents(RecordedEvent event, int exitCode) { + Events.assertField(event, "reason").equal("No remaining non-daemon Java threads"); + } + } + + private static class TestSystemExit implements ShutdownEventSubTest { + @Override + public void runTest() { + System.out.println("Running System.exit"); + System.exit(42); + } + + @Override + public void verifyEvents(RecordedEvent event, int exitCode) { + Events.assertField(event, "reason").equal("Shutdown requested from Java"); + validateStackTrace(event.getStackTrace()); + } + } + + private static class TestVMCrash implements ShutdownEventSubTest { + + @Override + public void runTest() { + System.out.println("Attempting to crash"); + getUnsafe().putInt(0L, 0); + } + + @Override + public void verifyEvents(RecordedEvent event, int exitCode) { + Events.assertField(event, "reason").equal("VM Error"); + validateStackTrace(event.getStackTrace()); + } + } + + private static class TestUnhandledException implements ShutdownEventSubTest { + @Override + public void runTest() { + throw new RuntimeException("Unhandled"); + } + + @Override + public void verifyEvents(RecordedEvent event, int exitCode) { + Events.assertField(event, "reason").equal("No remaining non-daemon Java threads"); + } + } + + private static class TestRuntimeHalt implements ShutdownEventSubTest { + @Override + public void runTest() { + System.out.println("Running Runtime.getRuntime.halt"); + Runtime.getRuntime().halt(17); + } + + @Override + public void verifyEvents(RecordedEvent event, int exitCode) { + Events.assertField(event, "reason").equal("Shutdown requested from Java"); + validateStackTrace(event.getStackTrace()); + } + } + + private static class TestSig implements ShutdownEventSubTest { + + private final String signalName; + + @Override + public boolean isApplicable() { + if (Platform.isWindows()) { + return false; + } + if (signalName.equals("HUP") && Platform.isSolaris()) { + return false; + } + return true; + } + + public TestSig(String signalName) { + this.signalName = signalName; + } + + @Override + public void runTest() { + try { + long pid = ProcessTools.getProcessId(); + System.out.println("Sending SIG" + signalName + " to process " + pid); + Runtime.getRuntime().exec("kill -" + signalName + " " + pid).waitFor(); + Thread.sleep(60_1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println("Process survived the SIG" + signalName + " signal!"); + } + + @Override + public void verifyEvents(RecordedEvent event, int exitCode) { + if (exitCode == 0) { + System.out.println("Process exited normally with exit code 0, skipping the verification"); + return; + } + Events.assertField(event, "reason").equal("Shutdown requested from Java"); + Events.assertEventThread(event); + Asserts.assertEquals(event.getThread().getJavaName(), "SIG" + signalName + " handler"); + } + } +} diff --git a/test/jdk/jfr/event/runtime/TestSizeTFlags.java b/test/jdk/jfr/event/runtime/TestSizeTFlags.java new file mode 100644 index 0000000000000000000000000000000000000000..0650bc3c0e3e106cea7ea0b952e38d6037d56866 --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestSizeTFlags.java @@ -0,0 +1,109 @@ +/* + * 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. 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.event.runtime; + +import static jdk.test.lib.Asserts.assertTrue; + +import java.nio.file.Paths; +import java.time.Duration; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @bug 8058552 + * + * + * @key jfr + * @summary Test checks that flags of type size_t are being sent to the jfr + * @library /lib / + * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -XX:+UseG1GC -XX:+UseTLAB -XX:MinTLABSize=3k -XX:OldSize=30m -XX:YoungPLABSize=3k -XX:MaxDirectMemorySize=5M jdk.jfr.event.runtime.TestSizeTFlags + */ +public class TestSizeTFlags { + private static final String EVENT_NAME = EventNames.UnsignedLongFlag; + private static final int NUMBER_OF_FLAGS_TO_CHECK = 4; + private static final long MIN_TLAB_SIZE_FLAG_VALUE = 3*1024L; + private static final long OLD_SIZE_FLAG_VALUE = 30*1024*1024L; + private static final long YOUNG_PLAB_SIZE_FLAG_VALUE = 3*1024L; + private static final long MAX_DIRECT_MEMORY_SIZE_FLAG_VALUE = 5*1024*1024L; + + // Test run java with some of the flags of type size_t. + // Goals are + // - to check that flags are reported to the jfr; + // - to make sure values are as expected. + public static void main(String[] args) throws Exception { + final boolean[] flagsFoundWithExpectedValue = new boolean[NUMBER_OF_FLAGS_TO_CHECK]; + Recording recording = null; + try { + recording = new Recording(); + recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(0)); + recording.start(); + recording.stop(); + + for (final RecordedEvent event : Events.fromRecording(recording)) { + final String recordedFlagName = Events.assertField(event, "name").getValue(); + final long value = Events.assertField(event, "value").getValue(); + switch (recordedFlagName) { + case "MinTLABSize": { + flagsFoundWithExpectedValue[0] = MIN_TLAB_SIZE_FLAG_VALUE == value; + continue; + } + case "OldSize": { + flagsFoundWithExpectedValue[1] = OLD_SIZE_FLAG_VALUE == value; + continue; + } + case "YoungPLABSize": { + flagsFoundWithExpectedValue[2] = YOUNG_PLAB_SIZE_FLAG_VALUE == value; + continue; + } + case "MaxDirectMemorySize": { + flagsFoundWithExpectedValue[3] = MAX_DIRECT_MEMORY_SIZE_FLAG_VALUE == value; + continue; + } + default: { + continue; + } + } + } + + for (int i = 0; i < flagsFoundWithExpectedValue.length; ++i) { + assertTrue(flagsFoundWithExpectedValue[i], "Flag not found or value error!"); + } + + } catch (Throwable e) { + if (recording != null) { + recording.dump(Paths.get("failed.jfr")); + } + throw e; + } finally { + if (recording != null) { + recording.close(); + } + } + } +} diff --git a/test/jdk/jfr/event/runtime/TestSystemPropertyEvent.java b/test/jdk/jfr/event/runtime/TestSystemPropertyEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..e2c1b17ebdaea0e8d41e1c2022350a3aef745197 --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestSystemPropertyEvent.java @@ -0,0 +1,112 @@ +/* + * 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 + * 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.event.runtime; + +import java.util.HashMap; +import java.util.Map; + +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; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.runtime.TestSystemPropertyEvent + */ +public class TestSystemPropertyEvent { + + private final static String EVENT_NAME = EventNames.InitialSystemProperty; + + public static void main(String[] args) throws Throwable { + Map systemProps = createInitialSystemProperties(); + // Recording should only contain properties defined at JVM start. + // This property should not be included. + System.setProperty("party.pooper", "buh!"); + + Recording recording = new Recording(); + recording.enable(EVENT_NAME); + recording.start(); + recording.stop(); + + Map eventProps = new HashMap<>(); + for (RecordedEvent event : Events.fromRecording(recording)) { + String key = Events.assertField(event, "key").notEmpty().getValue(); + String value = Events.assertField(event, "value").notNull().getValue(); + if (!eventProps.containsKey(key)) { + // Event is received at both start and end of chunk. Only log first. + System.out.println("Event:" + event); + } + eventProps.put(key, value); + } + Asserts.assertGreaterThan(eventProps.size(), 4, "Should have at least 5 events"); + + // Value of System.properties may change. We can not expect all values in + // events and System.getProperties() to be equal. + // To do some verification of property values we require that at least one + // property with non-empty value is equal. + int countEqualAndNonEmpty = 0; + + String missingKeys = ""; + for (String key : eventProps.keySet()) { + if (!systemProps.containsKey(key)) { + missingKeys += key + " "; + continue; + } + if (isEqualAndNonEmpty(key, eventProps.get(key), systemProps.get(key))) { + countEqualAndNonEmpty++; + } + } + + if (!missingKeys.isEmpty()) { + Asserts.fail("Event properties not found in System.properties(): " + missingKeys); + } + Asserts.assertTrue(countEqualAndNonEmpty > 0, "No property had expected value"); + } + + private static boolean isEqualAndNonEmpty(String key, String eventValue, String systemValue) { + if (eventValue == null || systemValue == null || eventValue.isEmpty() || systemValue.isEmpty()) { + return false; + } + boolean isEquals = eventValue.equals(systemValue); + System.out.printf("eq=%b, key='%s', event='%s', system='%s'%n", isEquals, key, eventValue, systemValue); + return isEquals; + } + + private static Map createInitialSystemProperties() { + Map result = new HashMap<>(); + for (Object keyObject : System.getProperties().keySet()) { + String key = (String) keyObject; + result.put(key, System.getProperty(key)); + System.out.println("initialProp: " + key); + } + return result; + } +} diff --git a/test/jdk/jfr/event/runtime/TestThreadAllocationEvent.java b/test/jdk/jfr/event/runtime/TestThreadAllocationEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..c839de8f6103c0b10681e593fac45a3f2933d9cb --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestThreadAllocationEvent.java @@ -0,0 +1,210 @@ +/* + * 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 + * 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.event.runtime; + +import static jdk.test.lib.Asserts.assertGreaterThan; +import static jdk.test.lib.Asserts.assertTrue; + +import java.lang.management.ManagementFactory; +import java.time.Duration; +import java.util.Collections; +import java.util.List; +import java.util.Random; +import java.util.concurrent.CountDownLatch; + +import com.sun.management.ThreadMXBean; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedThread; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * @library /lib / + * + * + * @run main/othervm -XX:-UseTLAB jdk.jfr.event.runtime.TestThreadAllocationEvent + */ + +/** + * The test will create a few threads that will allocate memory for a short time. + * During this time a number of thread_allocation events will be generated. + * The test will verify: + * 1. That number of allocated bytes is not decreasing for a thread. + * - This assumption is only true when not using TLABs. For this reason the + * test is run with -XX:-UseTLAB. When using TLABs, the code calculating the + * allocated bytes is using the current TLAB to do as good of an approximation + * as possible, but this introduces a race which might double count the current + * TLAB when it is full and in the middle of being switched out. + * 2. That sum of allocated bytes approximately matches value in ThreadMXBean. + */ +public class TestThreadAllocationEvent { + private static final String EVENT_NAME = EventNames.ThreadAllocationStatistics; + private static final String testThreadName = "testThread-"; + private static final long eventPeriodMillis = 50; + + // The value in both the JFR event and in the ThreadMXBean is documented as + // an "approximation" of number of bytes allocated. + // To not give any false errors, we allow an error margin of 5 mb. + // The test will typically allocate over 600 mb, so 5 mb is an error of less than 1%. + private static final long allowedTotalAllocatedDiff = 5000000; + + public static void main(String[] args) throws Throwable { + Recording recording = new Recording(); + recording.enable(EVENT_NAME).withPeriod(Duration.ofMillis(eventPeriodMillis)); + recording.start(); + + AllocatorThread[] threads = new AllocatorThread[4]; + CountDownLatch allocationsDoneLatch = new CountDownLatch(threads.length); + for (int i = 0; i < threads.length; i++) { + threads[i] = new AllocatorThread(allocationsDoneLatch, 1000 * (i + 1)); + threads[i].setName(testThreadName + i); + threads[i].setDaemon(true); + threads[i].start(); + } + + // Take regular measurements while the threads are allocating memory. + // Stop measurement when all threads are ready. + try { + allocationsDoneLatch.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + // Verify that number of allocated bytes is not decreasing. + recording.stop(); + verifyAllocationsNotDecreasing(Events.fromRecording(recording), threads); + + // Now allocations are done and threads are waiting to die. + // Make a new instant recording to get total number of allocated bytes. + // The reason for this extra recording is to make sure we get a JFR event + // after all allocations are done so we can compare the JFR value with + // the value reported by ThreadMXBean. + recording = new Recording(); + recording.enable(EVENT_NAME); + recording.start(); + recording.stop(); + verifyTotalAllocated(Events.fromRecording(recording), threads); + } + + /** + * Verify that the allocated value never decreases. + * We only compare our own allocator threads. The reason for that is that other threads + * may start/stop at any time, and we do not know if other thread names are unique. + */ + private static void verifyAllocationsNotDecreasing(List events, AllocatorThread[] threads) { + Collections.sort(events, (u,v) -> u.getEndTime().compareTo(v.getEndTime())); + long[] prevAllocated = new long[threads.length]; + for (RecordedEvent event : events) { + RecordedThread rt = Events.assertField(event, "thread").notNull().getValue(); // Check that we have a thread. + String name = rt.getJavaName(); + for (int i = 0; i < threads.length; i++) { + if (name.equals(threads[i].getName())) { + long curr = Events.assertField(event, "allocated").atLeast(prevAllocated[i]).getValue(); + prevAllocated[i] = curr; + } + } + } + + for (int i = 0; i < threads.length; i++) { + assertGreaterThan(prevAllocated[i], 0L, "No allocations for thread " + threads[i].getName()); + } + } + + /** + * Verify that total allocated bytes in JFR event approximately matches the value in ThreadMXBean. + */ + private static void verifyTotalAllocated(List events, AllocatorThread[] threads) { + boolean[] isEventFound = new boolean[threads.length]; + for (RecordedEvent event : events) { + RecordedThread rt = Events.assertField(event, "thread").notNull().getValue(); + String name = rt.getJavaName(); + for (int i = 0; i < threads.length; ++i) { + if (name.equals(threads[i].getName())) { + System.out.println("Event:" + event); + long maxAllowed = threads[i].totalAllocated + allowedTotalAllocatedDiff; + long minAllowed = Math.max(0, threads[i].totalAllocated - allowedTotalAllocatedDiff); + Events.assertField(event, "allocated").atLeast(minAllowed).atMost(maxAllowed); + isEventFound[i] = true; + } + } + } + for (int i = 0; i < threads.length; ++i) { + assertTrue(isEventFound[i], "No event for thread id " + i); + } + } + + /** + * Thread that does a number of allocations and records total number of + * bytes allocated as reported by ThreadMXBean. + */ + public static class AllocatorThread extends Thread { + private volatile long totalAllocated = -1; + private final int averageAllocationSize; + public byte[] buffer; + private final CountDownLatch allocationsDoneLatch; + + public AllocatorThread(CountDownLatch allocationsDoneLatch, int averageAllocationSize) { + this.allocationsDoneLatch = allocationsDoneLatch; + this.averageAllocationSize = averageAllocationSize; + } + + @Override + public void run() { + Random rand = new Random(); + int allocationSizeBase = averageAllocationSize / 2; + int allocationSizeRandom = averageAllocationSize; + for (int batches=0; batches<100; batches++) { + for (int i=0; i<1500; i++) { + buffer = new byte[rand.nextInt(allocationSizeRandom) + allocationSizeBase]; + } + try { + // No need to allocate too much data between JFR events, so do a short sleep. + Thread.sleep(eventPeriodMillis / 5); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + totalAllocated = getThreadAllocatedBytes(); + allocationsDoneLatch.countDown(); + + // Need to keep thread alive so we can get the final JFR event. + // This is a daemon thread, so it will finish when the main thread finishes. + while (true) { + Thread.yield(); + } + } + + private long getThreadAllocatedBytes() { + ThreadMXBean bean = (ThreadMXBean) ManagementFactory.getThreadMXBean(); + return bean.getThreadAllocatedBytes(Thread.currentThread().getId()); + } + } + +} diff --git a/test/jdk/jfr/event/runtime/TestThreadCpuTimeEvent.java b/test/jdk/jfr/event/runtime/TestThreadCpuTimeEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..bddbb3243c0d414a7362afa236fb9185067f997c --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestThreadCpuTimeEvent.java @@ -0,0 +1,276 @@ +/* + * 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. 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.event.runtime; + +import com.sun.management.ThreadMXBean; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedThread; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +import java.lang.management.ManagementFactory; +import java.time.Duration; +import java.time.Instant; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.BrokenBarrierException; +import java.util.concurrent.CyclicBarrier; +import java.util.stream.Collectors; + +/** + * @test + * @key jfr + * + * @library /lib / + * + * + * @run main/othervm jdk.jfr.event.runtime.TestThreadCpuTimeEvent + */ + +/** + */ +public class TestThreadCpuTimeEvent { + + public static void main(String[] args) throws Throwable { + testSimple(); + testCompareWithMXBean(); + testEventAtThreadExit(); + } + + private static final long eventPeriodMillis = 50; + private static final String cpuConsumerThreadName = "cpuConsumer"; + + // The cpu consumer will run for eventPeriodMillis times this factor to ensure that we see some + // events even if the scheduler isn't cooperating. + private static final long cpuConsumerRunFactor = 10; + + // The cpu consumer will run at least this number of loops, even if it takes longer than + // the requested period of time (in case the thread didn't get scheduled within the allotted time). + private static final long cpuConsumerMinCount = 1000000; + + static class CpuConsumingThread extends Thread { + + Duration runTime; + CyclicBarrier barrier; + volatile long counter; + + CpuConsumingThread(Duration runTime, CyclicBarrier barrier, String threadName) { + super(threadName); + this.runTime = runTime; + this.barrier = barrier; + } + + CpuConsumingThread(Duration runTime, CyclicBarrier barrier) { + this(runTime, barrier, cpuConsumerThreadName); + } + + @Override + public void run() { + try { + while (true) { + barrier.await(); + Instant start = Instant.now(); + counter = 0; + while ((Duration.between(start, Instant.now()).compareTo(runTime) < 0) || + (counter < cpuConsumerMinCount)) { + counter++; + } + barrier.await(); + } + } catch (BrokenBarrierException e) { + // Another thread has been interrupted - wait for us to be interrupted as well + while (!interrupted()) { + yield(); + } + } catch (InterruptedException e) { + // Normal way of stopping the thread + } + } + } + + // For a given thread, check that accumulated processTime >= cpuTime >= userTime. + // This may not hold for a single event instance due to differences in counter resolution + static void verifyPerThreadInvariant(List events, String threadName) { + List filteredEvents = events.stream() + .filter(e -> e.getThread().getJavaName().equals(threadName)) + .sorted(Comparator.comparing(RecordedEvent::getStartTime)) + .collect(Collectors.toList()); + + int numCpus = Runtime.getRuntime().availableProcessors(); + Iterator i = filteredEvents.iterator(); + while (i.hasNext()) { + RecordedEvent event = i.next(); + + Float systemLoad = (Float)event.getValue("system"); + Float userLoad = (Float)event.getValue("user"); + + Asserts.assertLessThan(systemLoad + userLoad, 1.01f / numCpus); // 100% + rounding errors + } + } + + static Duration getAccumulatedTime(List events, String threadName, String fieldName) { + List filteredEvents = events.stream() + .filter(e -> e.getThread().getJavaName().equals(threadName)) + .sorted(Comparator.comparing(RecordedEvent::getStartTime)) + .collect(Collectors.toList()); + + int numCpus = Runtime.getRuntime().availableProcessors(); + Iterator i = filteredEvents.iterator(); + RecordedEvent cur = i.next(); + Duration totalTime = Duration.ZERO; + while (i.hasNext()) { + RecordedEvent prev = cur; + cur = i.next(); + + Duration sampleTime = Duration.between(prev.getStartTime(), cur.getStartTime()); + Float load = (Float)cur.getValue(fieldName); + + // Adjust load to be thread-relative (fully loaded thread would give 100%) + Float totalLoadForThread = load * numCpus; + Duration threadTime = Duration.ofMillis((long) (sampleTime.toMillis() * totalLoadForThread)); + totalTime = totalTime.plus(threadTime); + } + + return totalTime; + } + + static List generateEvents(int minimumEventCount, CyclicBarrier barrier) throws Throwable { + int retryCount = 0; + + while (true) { + Recording recording = new Recording(); + + // Default period is once per chunk + recording.enable(EventNames.ThreadCPULoad).withPeriod(Duration.ofMillis(eventPeriodMillis)); + recording.start(); + + // Run a single pass + barrier.await(); + barrier.await(); + + recording.stop(); + List events = Events.fromRecording(recording); + + long numEvents = events.stream() + .filter(e -> e.getThread().getJavaName().equals(cpuConsumerThreadName)) + .count(); + + // If the JFR periodicals thread is really starved, we may not get enough events. + // In that case, we simply retry the operation. + if (numEvents < minimumEventCount) { + System.out.println("Not enough events recorded, trying again..."); + if (retryCount++ > 10) { + Asserts.fail("Retry count exceeded"); + throw new RuntimeException(); + } + } else { + return events; + } + } + } + + static void testSimple() throws Throwable { + Duration testRunTime = Duration.ofMillis(eventPeriodMillis * cpuConsumerRunFactor); + CyclicBarrier barrier = new CyclicBarrier(2); + CpuConsumingThread thread = new CpuConsumingThread(testRunTime, barrier); + thread.start(); + + List events = generateEvents(1, barrier); + verifyPerThreadInvariant(events, cpuConsumerThreadName); + + thread.interrupt(); + thread.join(); + } + + static void testCompareWithMXBean() throws Throwable { + Duration testRunTime = Duration.ofMillis(eventPeriodMillis * cpuConsumerRunFactor); + CyclicBarrier barrier = new CyclicBarrier(2); + CpuConsumingThread thread = new CpuConsumingThread(testRunTime, barrier); + thread.start(); + + List beforeEvents = generateEvents(2, barrier); + verifyPerThreadInvariant(beforeEvents, cpuConsumerThreadName); + + // Run a second single pass + barrier.await(); + barrier.await(); + + ThreadMXBean bean = (ThreadMXBean) ManagementFactory.getThreadMXBean(); + Duration cpuTime = Duration.ofNanos(bean.getThreadCpuTime(thread.getId())); + Duration userTime = Duration.ofNanos(bean.getThreadUserTime(thread.getId())); + + // Check something that should hold even in the presence of unfortunate scheduling + Asserts.assertGreaterThanOrEqual(cpuTime.toMillis(), eventPeriodMillis); + Asserts.assertGreaterThanOrEqual(userTime.toMillis(), eventPeriodMillis); + + Duration systemTimeBefore = getAccumulatedTime(beforeEvents, cpuConsumerThreadName, "system"); + Duration userTimeBefore = getAccumulatedTime(beforeEvents, cpuConsumerThreadName, "user"); + Duration cpuTimeBefore = userTimeBefore.plus(systemTimeBefore); + + Asserts.assertLessThan(cpuTimeBefore, cpuTime); + Asserts.assertLessThan(userTimeBefore, userTime); + Asserts.assertGreaterThan(cpuTimeBefore, Duration.ZERO); + + thread.interrupt(); + thread.join(); + } + + static void testEventAtThreadExit() throws Throwable { + Recording recording = new Recording(); + + recording.enable(EventNames.ThreadCPULoad).withPeriod(Duration.ofHours(10)); + recording.start(); + + Duration testRunTime = Duration.ofMillis(eventPeriodMillis * cpuConsumerRunFactor); + CyclicBarrier barrier = new CyclicBarrier(2); + CpuConsumingThread thread = new CpuConsumingThread(testRunTime, barrier); + + // Run a single pass + thread.start(); + barrier.await(); + barrier.await(); + + thread.interrupt(); + thread.join(); + + recording.stop(); + + List events = Events.fromRecording(recording); + verifyPerThreadInvariant(events, cpuConsumerThreadName); + + int exitingCount = 0; + for (RecordedEvent event : events) { + RecordedThread eventThread = event.getThread(); + if (eventThread.getJavaName().equals(cpuConsumerThreadName)) { + exitingCount++; + } + } + Asserts.assertEquals(exitingCount, 1); + } +} diff --git a/test/jdk/jfr/event/runtime/TestThreadDumpEvent.java b/test/jdk/jfr/event/runtime/TestThreadDumpEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..971fc974daf61811962bbf04e05af106110eb268 --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestThreadDumpEvent.java @@ -0,0 +1,66 @@ +/* + * 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 + * 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.event.runtime; + +import static jdk.test.lib.Asserts.assertTrue; + +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.EventField; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.runtime.TestThreadDumpEvent + */ +public class TestThreadDumpEvent { + + private final static String EVENT_NAME = EventNames.ThreadDump; + private static final String RESULT_STRING_MATCH = "Full thread dump"; + + public static void main(String[] args) throws Throwable { + Recording recording = new Recording(); + recording.enable(EVENT_NAME); + recording.start(); + recording.stop(); + + List events = Events.fromRecording(recording); + boolean isAnyFound = false; + for (RecordedEvent event : events) { + System.out.println("Event:" + event); + isAnyFound = true; + EventField dumpField = Events.assertField(event, "result"); + dumpField.instring(RESULT_STRING_MATCH).instring("TestThreadDumpEvent.main"); + } + assertTrue(isAnyFound, "Correct event not found"); + } +} diff --git a/test/jdk/jfr/event/runtime/TestThreadParkEvent.java b/test/jdk/jfr/event/runtime/TestThreadParkEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..06c6b78bb56879ab178e02ea42ef9a5e3f6b8999 --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestThreadParkEvent.java @@ -0,0 +1,132 @@ +/* + * 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 + * 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.event.runtime; + +import static jdk.test.lib.Asserts.assertTrue; + +import java.nio.file.Files; +import java.nio.file.Paths; +import java.time.Duration; +import java.time.Instant; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.locks.LockSupport; +import java.util.function.Consumer; + +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.management.ThreadMXBeanTool; +import jdk.test.lib.thread.TestThread; + +/** + * @test + * @key jfr + * + * @library /lib / + * + * @run main/othervm jdk.jfr.event.runtime.TestThreadParkEvent + */ + +public class TestThreadParkEvent { + private static final String EVENT_NAME = EventNames.ThreadPark; + private static final long THRESHOLD_MILLIS = 1; + + static class Blocker { + } + + public static void main(String[] args) throws Throwable { + testParkNoTimeout(); + testParkTimeout(); + testParkUntil(); + } + + private static void testParkNoTimeout() throws Exception { + RecordedEvent event = testPark(x -> LockSupport.park(x), Thread.State.WAITING); + Events.assertMissingValue(event, "timeout"); + Events.assertMissingValue(event, "until"); + } + + private static void testParkTimeout() throws Exception { + Duration expected = Duration.ofNanos(1_234_567_890_123L); + RecordedEvent event = testPark(x -> LockSupport.parkNanos(x, expected.toNanos()), Thread.State.TIMED_WAITING); + Events.assertDuration(event, "timeout", expected); + Events.assertMissingValue(event, "until"); + } + + private static void testParkUntil() throws Exception { + long epochMillis = Instant.now().plusSeconds(1000000).toEpochMilli(); + RecordedEvent event = testPark(x -> LockSupport.parkUntil(x, epochMillis), Thread.State.TIMED_WAITING); + Events.assertMissingValue(event, "timeout"); + Events.assertInstant(event, "until", Instant.ofEpochMilli(epochMillis)); + } + + static RecordedEvent testPark(Consumer parkOperation, Thread.State threadState) throws Exception { + + final CountDownLatch stop = new CountDownLatch(1); + final Blocker blocker = new Blocker(); + TestThread parkThread = new TestThread(new Runnable() { + public void run() { + while (stop.getCount() > 0) { + parkOperation.accept(blocker); + } + } + }); + + Recording recording = new Recording(); + recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(THRESHOLD_MILLIS)); + try { + recording.start(); + parkThread.start(); + ThreadMXBeanTool.waitUntilBlockingOnObject(parkThread, threadState, blocker); + // sleep so we know the event is recorded + Thread.sleep(2 * THRESHOLD_MILLIS); + } finally { + stop.countDown(); + LockSupport.unpark(parkThread); + parkThread.join(); + recording.stop(); + } + List events = Events.fromRecording(recording); + Events.hasEvents(events); + RecordedEvent foundEvent = null; + for (RecordedEvent event : events) { + System.out.println("Event:" + event); + String klassName = Events.assertField(event, "parkedClass.name").notNull().getValue(); + if (klassName.equals(blocker.getClass().getName().replace('.', '/'))) { + Asserts.assertNull(foundEvent , "Found more than 1 event"); + Events.assertField(event, "address").notEqual(0L); + Events.assertEventThread(event, parkThread); + foundEvent = event; + } + } + Asserts.assertNotNull(foundEvent, "Correct event not found"); + return foundEvent; + } + +} diff --git a/test/jdk/jfr/event/runtime/TestThreadSleepEvent.java b/test/jdk/jfr/event/runtime/TestThreadSleepEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..53e97e7ac3dbb8d5029d2a93ef7832c3b4224f54 --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestThreadSleepEvent.java @@ -0,0 +1,72 @@ +/* + * 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 + * 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.event.runtime; + +import static jdk.test.lib.Asserts.assertTrue; + +import java.time.Duration; +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; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.runtime.TestThreadSleepEvent + */ +public class TestThreadSleepEvent { + + private final static String EVENT_NAME = EventNames.ThreadSleep; + // Need to set the sleep time quite high (47 ms) since the sleep + // time on Windows has been proved unreliable. + // See bug 6313903 + private final static Long SLEEP_TIME_MS = new Long(47); + + public static void main(String[] args) throws Throwable { + Recording recording = new Recording(); + recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(0)); + recording.start(); + Thread.sleep(SLEEP_TIME_MS); + recording.stop(); + + List events = Events.fromRecording(recording); + boolean isAnyFound = false; + for (RecordedEvent event : events) { + if (event.getThread().getJavaThreadId() == Thread.currentThread().getId()) { + System.out.println("Event:" + event); + isAnyFound = true; + Events.assertField(event, "time").equal(SLEEP_TIME_MS); + } + } + assertTrue(isAnyFound, "No matching events found"); + } + +} diff --git a/test/jdk/jfr/event/runtime/TestThreadStartEndEvents.java b/test/jdk/jfr/event/runtime/TestThreadStartEndEvents.java new file mode 100644 index 0000000000000000000000000000000000000000..ea0de076e3bebb598e0550bbbc58d6f103cbfa2c --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestThreadStartEndEvents.java @@ -0,0 +1,138 @@ +/* + * 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 + * 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.event.runtime; + +import java.time.Duration; +import java.util.List; +import java.util.concurrent.CountDownLatch; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.event.runtime.TestThreadStartEndEvents + */ + +/** + * Starts and stops a number of threads in order. + * Verifies that events are in the same order. + */ +public class TestThreadStartEndEvents { + private final static String EVENT_NAME_THREAD_START = EventNames.ThreadStart; + private final static String EVENT_NAME_THREAD_END = EventNames.ThreadEnd; + private static final String THREAD_NAME_PREFIX = "TestThread-"; + + public static void main(String[] args) throws Throwable { + // Test Java Thread Start event + Recording recording = new Recording(); + recording.enable(EVENT_NAME_THREAD_START).withThreshold(Duration.ofMillis(0)); + recording.enable(EVENT_NAME_THREAD_END).withThreshold(Duration.ofMillis(0)); + recording.start(); + LatchedThread[] threads = startThreads(); + stopThreads(threads); + recording.stop(); + + int currThreadIndex = 0; + long currentThreadId = Thread.currentThread().getId(); + List events = Events.fromRecording(recording); + Events.hasEvents(events); + for (RecordedEvent event : events) { + System.out.println("Event:" + event); + if (event.getThread().getJavaThreadId() != currentThreadId) { + continue; + } + // Threads should be started and stopped in the correct order. + Events.assertEventThread(event, threads[currThreadIndex % threads.length]); + String eventName = currThreadIndex < threads.length ? EVENT_NAME_THREAD_START : EVENT_NAME_THREAD_END; + if (!eventName.equals(event.getEventType().getName())) { + throw new Exception("Expected event of tyoe " + eventName + " but got " + event.getEventType().getName()); + } + currThreadIndex++; + } + } + + private static LatchedThread[] startThreads() { + LatchedThread threads[] = new LatchedThread[10]; + ThreadGroup threadGroup = new ThreadGroup("TestThreadGroup"); + for (int i = 0; i < threads.length; i++) { + threads[i] = new LatchedThread(threadGroup, THREAD_NAME_PREFIX + i); + threads[i].startThread(); + System.out.println("Started thread id=" + threads[i].getId()); + } + return threads; + } + + private static void stopThreads(LatchedThread[] threads) { + for (LatchedThread thread : threads) { + thread.stopThread(); + while (thread.isAlive()) { + try { + Thread.sleep(5); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + } + + private static class LatchedThread extends Thread { + private final CountDownLatch start = new CountDownLatch(1); + private final CountDownLatch stop = new CountDownLatch(1); + + public LatchedThread(ThreadGroup threadGroup, String name) { + super(threadGroup, name); + } + + public void run() { + start.countDown(); + try { + stop.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + public void startThread() { + this.start(); + try { + start.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + public void stopThread() { + stop.countDown(); + } + } + +} diff --git a/test/jdk/jfr/event/runtime/TestThrowableInstrumentation.java b/test/jdk/jfr/event/runtime/TestThrowableInstrumentation.java new file mode 100644 index 0000000000000000000000000000000000000000..888d19ca68fd5dc58ceae5589dfd7243c9774ff0 --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestThrowableInstrumentation.java @@ -0,0 +1,61 @@ +/* + * 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. 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.event.runtime; + +import sun.hotspot.WhiteBox; +import java.util.Objects; +import jdk.test.lib.Platform; + +/** + * @test + * @bug 8153324 + * @summary Verify instrumented Throwable bytecode by compiling it with C1. + * + * @library /lib / + * + * + * @build sun.hotspot.WhiteBox + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -Xbatch -XX:StartFlightRecording=dumponexit=true jdk.jfr.event.runtime.TestThrowableInstrumentation + */ +public class TestThrowableInstrumentation { + private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); + private static int COMP_LEVEL_SIMPLE = 1; + + private static boolean isTieredCompilationEnabled() { + return Boolean.valueOf(Objects.toString(WHITE_BOX.getVMFlag("TieredCompilation"))); + } + + public static void main(String[] args) { + // Compile Throwable:: with C1 (if available) + if (!WHITE_BOX.enqueueInitializerForCompilation(java.lang.Throwable.class, COMP_LEVEL_SIMPLE)) { + if (!Platform.isServer() || isTieredCompilationEnabled() || Platform.isEmulatedClient()) { + throw new RuntimeException("Unable to compile Throwable:: with C1"); + } + } + } +} diff --git a/test/jdk/jfr/event/runtime/TestVMInfoEvent.flags b/test/jdk/jfr/event/runtime/TestVMInfoEvent.flags new file mode 100644 index 0000000000000000000000000000000000000000..d8ee8312b0237f3e55df10e068af37a4450ade66 --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestVMInfoEvent.flags @@ -0,0 +1 @@ ++FlightRecorder diff --git a/test/jdk/jfr/event/runtime/TestVMInfoEvent.java b/test/jdk/jfr/event/runtime/TestVMInfoEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..175ff603c2af0823227c8f68dba38a33e372775c --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestVMInfoEvent.java @@ -0,0 +1,80 @@ +/* + * 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 + * 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.event.runtime; + + + +import java.lang.management.ManagementFactory; +import java.lang.management.RuntimeMXBean; +import java.util.List; +import java.util.stream.Collectors; + +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.process.ProcessTools; + +/** + * The test will verify that JVM Information event values are delivered + * and compare them with the RuntimeMXBean's values. + */ +public class TestVMInfoEvent { + private final static String EVENT_NAME = EventNames.JVMInformation; + + public static void main(String[] args) throws Exception { + RuntimeMXBean mbean = ManagementFactory.getRuntimeMXBean(); + Recording recording = new Recording(); + recording.enable(EVENT_NAME); + recording.start(); + recording.stop(); + + List events = Events.fromRecording(recording); + Events.hasEvents(events); + for (RecordedEvent event : events) { + System.out.println("Event:" + event); + Events.assertField(event, "jvmName").equal(mbean.getVmName()); + String jvmVersion = Events.assertField(event, "jvmVersion").notEmpty().getValue(); + if (!jvmVersion.contains(mbean.getVmVersion())) { + Asserts.fail(String.format("%s does not contain %s", jvmVersion, mbean.getVmVersion())); + } + + String jvmArgs = Events.assertField(event, "jvmArguments").notNull().getValue(); + String jvmFlags = Events.assertField(event, "jvmFlags").notNull().getValue(); + Long pid = Events.assertField(event, "pid").atLeast(0L).getValue(); + Asserts.assertEquals(pid, ProcessTools.getProcessId()); + String eventArgs = (jvmFlags.trim() + " " + jvmArgs).trim(); + String beanArgs = mbean.getInputArguments().stream().collect(Collectors.joining(" ")); + Asserts.assertEquals(eventArgs, beanArgs, "Wrong inputArgs"); + + final String javaCommand = mbean.getSystemProperties().get("sun.java.command"); + Events.assertField(event, "javaArguments").equal(javaCommand); + Events.assertField(event, "jvmStartTime").equal(mbean.getStartTime()); + } + } + +} diff --git a/test/jdk/jfr/event/runtime/TestVMInfoEvent.sh b/test/jdk/jfr/event/runtime/TestVMInfoEvent.sh new file mode 100644 index 0000000000000000000000000000000000000000..7beae562b01ea6d20249fea78584ee9ca55a4e4c --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestVMInfoEvent.sh @@ -0,0 +1,35 @@ +# +# 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 +# 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 +# @key jfr +# +# @library /lib / +# @build jdk.jfr.event.runtime.TestVMInfoEvent +# @run shell TestVMInfoEvent.sh + +echo ------------------------------------------------------------- +echo Launching test for `basename $0 .sh` +echo ------------------------------------------------------------- + +${TESTJAVA}/bin/java -cp ${TESTCLASSPATH} -XX:Flags=${TESTSRC}/TestVMInfoEvent.flags jdk.jfr.event.runtime.TestVMInfoEvent arg1 arg2 +exit $? diff --git a/test/jdk/jfr/event/runtime/TestVMOperation.java b/test/jdk/jfr/event/runtime/TestVMOperation.java new file mode 100644 index 0000000000000000000000000000000000000000..6dad4f9c14f3420f8145f1881af00f016141faff --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestVMOperation.java @@ -0,0 +1,72 @@ +/* + * 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 + * 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.event.runtime; + +import java.time.Duration; +import java.util.List; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedThread; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test + * + * + * @key jfr + * @library /lib / + * @run main/othervm -XX:+UseParallelGC jdk.jfr.event.runtime.TestVMOperation + */ +public class TestVMOperation { + + private static final String EVENT_NAME = EventNames.ExecuteVMOperation; + private static final String VM_OPERATION = "ParallelGCSystemGC"; + + public static void main(String[] args) throws Throwable { + Recording recording = new Recording(); + recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(0)); + recording.start(); + System.gc(); + recording.stop(); + + List events = Events.fromRecording(recording); + Events.hasEvents(events); + for (RecordedEvent event : Events.fromRecording(recording)) { + String operation = Events.assertField(event, "operation").notEmpty().getValue(); + if (operation.equals(VM_OPERATION)) { + Events.assertField(event, "safepoint").equal(true); + Events.assertField(event, "blocking").equal(true); + RecordedThread jt = event.getValue("caller"); + if (Thread.currentThread().getName().equals(jt.getJavaName())) { + return; + } + } + } + throw new AssertionError("No matching event with VM operation name " + VM_OPERATION + " and current threasd as caller"); + } +} diff --git a/test/jdk/jfr/event/runtime/TestVmFlagChangedEvent.java b/test/jdk/jfr/event/runtime/TestVmFlagChangedEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..e205b3dedd1bbb290286a70ecb919b07fb845e53 --- /dev/null +++ b/test/jdk/jfr/event/runtime/TestVmFlagChangedEvent.java @@ -0,0 +1,118 @@ +/* + * 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 + * 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.event.runtime; + +import static jdk.test.lib.Asserts.assertEquals; +import static jdk.test.lib.Asserts.assertTrue; + +import java.lang.management.ManagementFactory; + +import com.sun.management.HotSpotDiagnosticMXBean; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; + +/** + * @test TestVmFlagChangedEvent + * @key jfr + * + * @library /lib / + * + * + * @run main/othervm jdk.jfr.event.runtime.TestVmFlagChangedEvent + */ +public final class TestVmFlagChangedEvent { + + public static void main(String[] args) throws Throwable { + EventFlag[] eventFlags = { + new EventFlag(EventNames.LongFlagChanged, "CMSWaitDuration", "2500"), + new EventFlag(EventNames.StringFlagChanged, "HeapDumpPath", "/a/sample/path"), + new EventFlag(EventNames.BooleanFlagChanged, "HeapDumpOnOutOfMemoryError", "true") + }; + + Recording recording = new Recording(); + for (EventFlag eventFlag : eventFlags) { + recording.enable(eventFlag.eventName); + } + + recording.start(); + HotSpotDiagnosticMXBean mbean = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class); + for (EventFlag eventFlag : eventFlags) { + eventFlag.update(mbean); + } + recording.stop(); + + for (RecordedEvent event : Events.fromRecording(recording)) { + final String flagName = Events.assertField(event, "name").getValue(); + System.out.println("flag name=" + flagName); + for (EventFlag eventFlag : eventFlags) { + if (flagName.equals(eventFlag.eventLabel)) { + System.out.println("Event:" + event); + Object newValue = Events.assertField(event, "newValue").getValue(); + Object oldValue = Events.assertField(event, "oldValue").getValue(); + System.out.println("newValue:" + asText(newValue)); + System.out.println("oldValue:" + asText(oldValue)); + assertEquals(eventFlag.newValue, asText(newValue), "Wrong new value: expected" + eventFlag.newValue); + assertEquals(eventFlag.oldValue, asText(oldValue), "Wrong old value: expected" + eventFlag.oldValue); + Events.assertField(event, "origin").equal("Management"); + eventFlag.isFound = true; + break; + } + } + } + for (EventFlag eventFlag : eventFlags) { + assertTrue(eventFlag.isFound, "Missing flag change for: " + eventFlag.eventLabel); + } + } + + private static String asText(Object value) { + if (value == null) { + return ""; // HotSpotDiagnosticMXBean interface return "" for unset values + } + return String.valueOf(value); + } + + private static class EventFlag { + final String eventName; + final String eventLabel; + String newValue; + String oldValue; + boolean isFound = false; + + EventFlag(String eventName, String eventLabel, String newValue) { + this.eventName = eventName; + this.eventLabel = eventLabel; + this.newValue = newValue; + } + + void update(HotSpotDiagnosticMXBean mbean) { + this.oldValue = mbean.getVMOption(eventLabel).getValue(); + mbean.setVMOption(eventLabel, newValue); + } + } +} diff --git a/test/jdk/jfr/event/runtime/exception.security.policy b/test/jdk/jfr/event/runtime/exception.security.policy new file mode 100644 index 0000000000000000000000000000000000000000..2e561de2447d5e7022573dc5c2e2194dbcbae162 --- /dev/null +++ b/test/jdk/jfr/event/runtime/exception.security.policy @@ -0,0 +1,20 @@ +grant { + // must allow file reads so that jtreg itself and JFR can run + permission java.io.FilePermission "<>", "read"; + // must allow file delete so that JFR can delete repository + permission java.io.FilePermission "<>", "delete"; + // must allow file write so that the test can create the recording + permission java.io.FilePermission "<>", "write"; + + // need to be able to create temporary files + permission java.util.PropertyPermission "java.io.tmpdir", "read"; + permission java.util.PropertyPermission "user.dir", "read"; + + // need ManagementPermission to control JFR from the test + permission java.lang.management.ManagementPermission "control"; + permission java.lang.management.ManagementPermission "monitor"; + + // JDK-8019403 - access to sun.security.util, which is needed for creation of temp files, + // is not permitted automatically on solaris + permission java.lang.RuntimePermission "accessClassInPackage.sun.security.util"; +}; diff --git a/test/jdk/jfr/event/sampling/TestNative.java b/test/jdk/jfr/event/sampling/TestNative.java new file mode 100644 index 0000000000000000000000000000000000000000..b2227b8a7cde67014c70c739a188ca2141d619e7 --- /dev/null +++ b/test/jdk/jfr/event/sampling/TestNative.java @@ -0,0 +1,94 @@ +/* + * 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. 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.event.sampling; + +import java.io.File; +import java.nio.file.Paths; +import java.time.Duration; + +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +/* + * @test + * @key jfr + * + * @library /lib / + * + * @run main/native jdk.jfr.event.sampling.TestNative + */ +public class TestNative { + + public final static String EVENT_SETTINGS_FILE = System.getProperty("test.src", ".") + File.separator + "sampling.jfc"; + public final static String JFR_DUMP = "samples.jfr"; + public final static String EXCEPTION = "No native samples found"; + public final static String NATIVE_EVENT = EventNames.NativeMethodSample; + public static Recording recording; + + public static native void longTime(); + + public static void main(String[] args) throws Exception { + String lib = System.getProperty("test.nativepath"); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-Djava.library.path=" + lib, "jdk.jfr.event.sampling.TestNative$Test"); + + OutputAnalyzer output = ProcessTools.executeProcess(pb); + output.shouldHaveExitValue(0); + output.stdoutShouldNotContain("No native samples found"); + } + + static class Test { + public static void main(String[] args) throws Exception { + System.loadLibrary("TestNative"); + FlightRecorder.getFlightRecorder(); + recording = new Recording(); + recording.setToDisk(true); + recording.setDestination(Paths.get(JFR_DUMP)); + recording.enable(NATIVE_EVENT).withPeriod(Duration.ofMillis(10)); + recording.start(); + + longTime(); + + recording.stop(); + recording.close(); + + try (RecordingFile rf = new RecordingFile(Paths.get(JFR_DUMP))) { + while (rf.hasMoreEvents()) { + RecordedEvent re = rf.readEvent(); + if (re.getEventType().getName().equals(NATIVE_EVENT)) { + return; + } + } + } + + throw new Exception("No native samples found"); + } + } +} diff --git a/test/jdk/jfr/event/sampling/libTestNative.c b/test/jdk/jfr/event/sampling/libTestNative.c new file mode 100644 index 0000000000000000000000000000000000000000..f64f79fa7babebbe44aec7d17ecd3f8117736b91 --- /dev/null +++ b/test/jdk/jfr/event/sampling/libTestNative.c @@ -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. + * + * 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 + +#ifdef WINDOWS +#include +#else +#include +#endif + +JNIEXPORT void JNICALL Java_jdk_jfr_event_sampling_TestNative_longTime + (JNIEnv *env, jclass jc) +{ +#ifdef WINDOWS + Sleep(2*1000); +#else + usleep(2*1000*1000); +#endif +} diff --git a/test/jdk/jfr/javaagent/EventEmitterAgent.java b/test/jdk/jfr/javaagent/EventEmitterAgent.java new file mode 100644 index 0000000000000000000000000000000000000000..0e19589d65d3a94dea713015f429ccc3efdf95f2 --- /dev/null +++ b/test/jdk/jfr/javaagent/EventEmitterAgent.java @@ -0,0 +1,106 @@ +/* + * 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.jfr.javaagent; + +import java.lang.instrument.Instrumentation; +import java.nio.file.Path; +import java.nio.file.Paths; + +import jdk.jfr.Configuration; +import jdk.jfr.Event; +import jdk.jfr.Name; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; + +// Java agent that emits in multiple threads +public class EventEmitterAgent { + + private static final int THREADS = 5; + private static final int EVENTS_PER_THREAD = 150_000; + private static final int EXPECTED_COUNT = THREADS * EVENTS_PER_THREAD; + private static final Path DUMP_PATH = Paths.get("dump.jfr").toAbsolutePath(); + + // Called when agent is loaded from command line + public static void agentmain(String agentArgs, Instrumentation inst) throws Exception { + agentWork(); + } + + // Called when agent is dynamically loaded + public static void premain(String agentArgs, Instrumentation inst) throws Exception { + agentWork(); + } + + private static void agentWork() throws Exception { + try (Recording r = new Recording(Configuration.getConfiguration("default"))) { + r.enable(EventNames.JavaExceptionThrow); + r.setDestination(DUMP_PATH); + r.start(); + Thread[] threads = new Thread[THREADS]; + for (int i = 0; i < THREADS; i++) { + threads[i] = new Thread(EventEmitterAgent::emitEvents); + threads[i].start(); + } + for (int i = 0; i < THREADS; i++) { + threads[i].join(); + } + r.stop(); + } + } + + public static void emitEvents() { + for (int i = 0; i < EVENTS_PER_THREAD; i++) { + TestEvent e = new TestEvent(); + e.msg = "Long message that puts pressure on the string pool " + i % 100; + e.count = i; + e.thread = Thread.currentThread(); + e.clazz = String.class; + e.commit(); + if (i % 10000 == 0) { + try { + Thread.sleep(1); + } catch (InterruptedException ie) { + // ignore + } + } + } + } + + @Name("Test") + static class TestEvent extends Event { + String msg; + int count; + Thread thread; + Class clazz; + } + + public static void validateRecording() throws Exception { + long testEventCount = RecordingFile.readAllEvents(DUMP_PATH) + .stream() + .filter(e -> e.getEventType().getName().equals("Test")) + .count(); + Asserts.assertTrue(testEventCount == EXPECTED_COUNT, "Mismatch in TestEvent count"); + } +} diff --git a/test/jdk/jfr/javaagent/JavaAgentBuilder.java b/test/jdk/jfr/javaagent/JavaAgentBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..605880f16ec05bae69597dd1f501daac940be679 --- /dev/null +++ b/test/jdk/jfr/javaagent/JavaAgentBuilder.java @@ -0,0 +1,87 @@ +/* + * 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.util; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.jar.Attributes; +import java.util.jar.Manifest; + +import jdk.test.lib.Utils; +import jdk.testlibrary.JarUtils; + +/** + * A builder for a common Java agent. + * Can be used directly from the jtreg test header to + * build a java agent before the test is executed. + * + * E.g.: + * @run driver jdk.test.lib.util.JavaAgentBuilder + * jdk.jfr.javaagent.EventEmitterAgent EventEmitterAgent.jar + * + */ +public class JavaAgentBuilder { + + /** + * Build a java agent jar file with a given agent class. + * + * @param args[0] fully qualified name of an agent class + * @param args[1] file name of the agent jar to be created + * @throws IOException + */ + public static void main(String... args) throws IOException { + String agentClass = args[0]; + String agentJar = args[1]; + System.out.println("Building " + agentJar + " with agent class " + agentClass); + build(agentClass, agentJar); + } + + /** + * Build a java agent jar file with a given agent class. + * The agent class will be added as both premain class and agent class. + * + * @param agentClass fully qualified name of an agent class + * @param agentJar file name of the agent jar to be created + * the file will be placed in a current work directory + * @throws IOException + */ + public static void build(String agentClass, String agentJar) throws IOException { + Manifest mf = new Manifest(); + Attributes attrs = mf.getMainAttributes(); + attrs.put(Attributes.Name.MANIFEST_VERSION, "1.0"); + attrs.putValue("Premain-Class", agentClass); + attrs.putValue("Agent-Class", agentClass); + + Path jarFile = Paths.get(".", agentJar); + String testClasses = Utils.TEST_CLASSES; + String agentPath = agentClass.replace(".", File.separator) + ".class"; + Path agentFile = Paths.get(testClasses, agentPath); + Path dir = Paths.get(testClasses); + JarUtils.createJarFile(jarFile, mf, dir, agentFile); + System.out.println("Agent built:" + jarFile.toAbsolutePath()); + } +} diff --git a/test/jdk/jfr/javaagent/TestLoadedAgent.java b/test/jdk/jfr/javaagent/TestLoadedAgent.java new file mode 100644 index 0000000000000000000000000000000000000000..90d80b2044fe438d1a2cc0387c82002d34b0d426 --- /dev/null +++ b/test/jdk/jfr/javaagent/TestLoadedAgent.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 + * @key jfr + * @summary Tests emitting events in a dynamically loaded Java agent + * + * @library /lib/testlibrary /lib / + * @modules java.instrument + * + * @build jdk.jfr.javaagent.EventEmitterAgent + * + * @run driver jdk.test.lib.util.JavaAgentBuilder + * jdk.jfr.javaagent.EventEmitterAgent EventEmitterAgent.jar + * + * @run main/othervm -Djdk.attach.allowAttachSelf=true jdk.jfr.javaagent.TestLoadedAgent + */ + +package jdk.jfr.javaagent; + +import com.sun.tools.attach.VirtualMachine; +import jdk.jfr.FlightRecorder; +import jdk.jfr.FlightRecorderListener; +import jdk.jfr.Recording; +import jdk.jfr.RecordingState; +import jdk.test.lib.process.ProcessTools; + +public class TestLoadedAgent { + public static void main(String... arg) throws Exception { + long pid = ProcessTools.getProcessId(); + VirtualMachine vm = VirtualMachine.attach(Long.toString(pid)); + vm.loadAgent("EventEmitterAgent.jar"); + vm.detach(); + EventEmitterAgent.validateRecording(); + } +} diff --git a/test/jdk/jfr/javaagent/TestPremainAgent.java b/test/jdk/jfr/javaagent/TestPremainAgent.java new file mode 100644 index 0000000000000000000000000000000000000000..4ebf4293116cd089504df56a6b0209a5f102cea5 --- /dev/null +++ b/test/jdk/jfr/javaagent/TestPremainAgent.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 + * @key jfr + * @summary Tests emitting event before main using a Java agent + * + * @library /lib/testlibrary /lib / + * @modules java.instrument + * + * @build jdk.jfr.javaagent.EventEmitterAgent + * + * @run driver jdk.test.lib.util.JavaAgentBuilder + * jdk.jfr.javaagent.EventEmitterAgent EventEmitterAgent.jar + * + * @run main/othervm -javaagent:EventEmitterAgent.jar -XX:+UseConcMarkSweepGC jdk.jfr.javaagent.TestPremainAgent + */ + +package jdk.jfr.javaagent; + + +public class TestPremainAgent { + public static void main(String... arg) throws Exception { + EventEmitterAgent.validateRecording(); + } +} diff --git a/test/jdk/jfr/jcmd/JcmdAsserts.java b/test/jdk/jfr/jcmd/JcmdAsserts.java new file mode 100644 index 0000000000000000000000000000000000000000..71cd94577a15eb68ab74b279057079ae37778a5e --- /dev/null +++ b/test/jdk/jfr/jcmd/JcmdAsserts.java @@ -0,0 +1,190 @@ +/* + * 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. 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.File; + +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.process.OutputAnalyzer; + + + +public class JcmdAsserts { + + private static final String NEW_LINE = System.getProperty("line.separator"); + + public static void assertJfrNotUsed(OutputAnalyzer output) { + output.shouldMatch("Flight Recorder has not been used"); + } + + public static void assertJfrUsed(OutputAnalyzer output) { + output.shouldMatch("Flight Recorder has been used"); + } + + public static void assertRecordingDumpedToFile(OutputAnalyzer output, File recording) { + output.shouldContain("Dumped recording"); + output.shouldContain(recording.getAbsolutePath()); + } + + public static void assertNotAbleToWriteToFile(OutputAnalyzer output) { + output.shouldContain("Could not start recording, not able to write to file"); + } + + public static void assertFileNotFoundException(OutputAnalyzer output, String name) { + output.shouldMatch("Could not write recording \"" + name + "\" to file.*"); + } + +// public static void assertNotAbleToSetFilename(OutputAnalyzer output) { +// output.shouldContain( +// "Filename can only be set for a recording with a duration, " + +// "or if dumponexit=true"); +// } + + public static void assertNotAbleToFindSettingsFile(OutputAnalyzer output) { + output.shouldContain("Could not parse setting"); + } + + public static void assertNoRecordingsAvailable(OutputAnalyzer output) { + output.shouldContain("No available recordings"); + } + + public static void assertRecordingNotExist(OutputAnalyzer output, String name) { + output.shouldContain("Could not find " + name); + } + + public static void assertRecordingNotRunning(OutputAnalyzer output, String name) { + output.shouldNotMatch(".*" + name + ".*running"); + } + + public static void assertRecordingIsRunning(OutputAnalyzer output, String name) { + output.shouldMatch(".*" + name + ".*running"); + } + + public static void assertRecordingHasStarted(OutputAnalyzer output) { + output.shouldContain("Started recording"); + } + + public static void assertCouldNotStartDefaultRecordingWithName(OutputAnalyzer output) { + output.shouldContain( + "It's not possible to set custom name for the defaultrecording"); + } + + public static void assertCouldNotStartDefaultRecording(OutputAnalyzer output) { + output.shouldContain( + "The only option that can be combined with defaultrecording is settings"); + } + + public static void assertRecordingIsUnstarted(OutputAnalyzer output, + String name, String duration) { + output.stdoutShouldMatch("^Recording \\d+: name=" + name + + " duration=" + duration + " .*\\W{1}unstarted\\W{1}"); + } + + public static void assertRecordingIsStopped(OutputAnalyzer output, String name) { + output.stdoutShouldMatch("^Recording \\d+: name=" + name + + " .*\\W{1}stopped\\W{1}"); + } + + public static void assertRecordingIsStopped(OutputAnalyzer output, String name, String duration) { + output.stdoutShouldMatch("^Recording \\d+: name=" + name + + " duration=" + duration + " .*\\W{1}stopped\\W{1}"); + } + + public static void assertStartTimeGreaterOrEqualThanMBeanValue(String name, + long actualStartTime) throws Exception { + Recording recording = findRecording(name); + Asserts.assertNotNull(recording.getStartTime(), "Start time is not set"); + Asserts.assertGreaterThanOrEqual(actualStartTime, recording.getStartTime().toEpochMilli()); + } + + public static void assertDelayAtLeast1s(OutputAnalyzer output) { + output.shouldContain("Could not start recording, delay must be at least 1 second."); + } + + public static void assertRecordingIsScheduled(OutputAnalyzer output, String name, String delay) { + output.stdoutShouldMatch( + "^\\s*Recording\\s+" + name + "\\s+scheduled to start in " + delay); + } + + public static void assertMaxSizeEqualsMBeanValue(String name, long maxSize) throws Exception { + Recording recording = findRecording(name); + Asserts.assertEquals(maxSize, recording.getMaxSize()); + } + + private static Recording findRecording(String name) { + for(Recording r : FlightRecorder.getFlightRecorder().getRecordings()) { + if (r.getName().equals(name)) { + return r; + } + } + throw new AssertionError("Could not find recording named " + name); + } + + public static void assertMaxAgeEqualsMBeanValue(String name, long maxAge) + throws Exception { + Recording recording = findRecording(name); + Asserts.assertNotNull(recording, "No recording found"); + Asserts.assertEquals(maxAge, recording.getMaxAge().toMillis()); + } + + public static void assertDurationEqualsMBeanValue(String name, + long duration) throws Exception { + Recording recording = findRecording(name); + Asserts.assertNotNull(recording, "No recording found"); + Asserts.assertEquals(duration, recording.getDuration().toMillis()); + } + + public static void assertDurationAtLeast1s(OutputAnalyzer output) { + output.shouldContain("Could not start recording, duration must be at least 1 second."); + } + + public static void assertStoppedRecording(OutputAnalyzer output, String name) { + output.shouldContain("Stopped recording \"" + name + "\""); + } + + public static void assertStoppedAndWrittenTo(OutputAnalyzer output, String name, File file) { + output.shouldMatch("^Stopped recording \"" + name + "\"" + ".*written to:"); + output.shouldContain(file.getAbsolutePath()); + } + + public static void assertStoppedDefaultRecording(OutputAnalyzer output) { + output.shouldContain("Stopped recording 0"); + } + + public static void assertThreadSleepThresholdIsSet(OutputAnalyzer output) throws Exception { + output.stdoutShouldMatch("\\s+\\W{1}" + EventNames.ThreadSleep + "\\W{1}" + + NEW_LINE + ".*threshold=1 ms.*"); + } + + public static void assertMonitorWaitThresholdIsSet(OutputAnalyzer output) throws Exception { + output.stdoutShouldMatch("\\s+\\W{1}" + EventNames.JavaMonitorWait + "\\W{1}" + + NEW_LINE + ".*threshold=1 ms.*"); + } + +} diff --git a/test/jdk/jfr/jcmd/JcmdHelper.java b/test/jdk/jfr/jcmd/JcmdHelper.java new file mode 100644 index 0000000000000000000000000000000000000000..5248fb5e4239a9d2ec1229c8592da91cc4d7d2d8 --- /dev/null +++ b/test/jdk/jfr/jcmd/JcmdHelper.java @@ -0,0 +1,123 @@ +/* + * 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. 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.File; +import java.util.Arrays; +import java.util.stream.Collectors; + +import jdk.test.lib.Asserts; +import jdk.test.lib.dcmd.CommandExecutor; +import jdk.test.lib.dcmd.PidJcmdExecutor; +import jdk.test.lib.process.OutputAnalyzer; + +public class JcmdHelper { + + // Wait until recording's state became running + public static void waitUntilRunning(String name) throws Exception { + long timeoutAt = System.currentTimeMillis() + 10000; + while (true) { + OutputAnalyzer output = jcmdCheck(name, false); + try { + // The expected output can look like this: + // Recording 1: name=1 (running) + output.shouldMatch("^Recording \\d+: name=" + name + + " .*\\W{1}running\\W{1}"); + return; + } catch (RuntimeException e) { + if (System.currentTimeMillis() > timeoutAt) { + Asserts.fail("Recording not started: " + name); + } + Thread.sleep(100); + } + } + } + + public static void stopAndCheck(String name) throws Exception { + jcmd("JFR.stop", "name=\"" + name + "\""); + assertRecordingNotRunning(name); + } + + public static void stopWriteToFileAndCheck(String name, File file) throws Exception { + OutputAnalyzer output = jcmd("JFR.stop", + "name=\"" + name + "\"", + "filename=\"" + file.getAbsolutePath() + "\""); + JcmdAsserts.assertStoppedAndWrittenTo(output, name, file); + assertRecordingNotRunning(name); + } + + public static void stopCompressAndCheck(String name, File file) throws Exception { + OutputAnalyzer output = jcmd("JFR.stop", + "name=\"" + name + "\"", + "compress=true", + "filename=\"" + file.getAbsolutePath() + "\""); + JcmdAsserts.assertStoppedAndWrittenTo(output, name, file); + checkAndAssertNoRecordingsAvailable(); + } + + public static void stopDefaultRecordingAndCheck() throws Exception { + OutputAnalyzer output = jcmd("JFR.stop", "recording=0"); + JcmdAsserts.assertStoppedDefaultRecording(output); + checkAndAssertNoRecordingsAvailable(); + } + + public static void checkAndAssertNoRecordingsAvailable() throws Exception { + OutputAnalyzer output = jcmd("JFR.check"); + JcmdAsserts.assertNoRecordingsAvailable(output); + } + + public static void assertRecordingNotExist(String name) throws Exception { + OutputAnalyzer output = jcmdCheck(name, false); + JcmdAsserts.assertRecordingNotExist(output, name); + } + + public static void assertRecordingNotRunning(String name) throws Exception { + OutputAnalyzer output = jcmdCheck(name, false); + JcmdAsserts.assertRecordingNotRunning(output, name); + } + + public static void assertRecordingIsRunning(String name) throws Exception { + OutputAnalyzer output = jcmdCheck(name, false); + JcmdAsserts.assertRecordingIsRunning(output, name); + } + + public static OutputAnalyzer jcmd(int expectedExitValue, String... args) { + String argsString = Arrays.stream(args).collect(Collectors.joining(" ")); + CommandExecutor executor = new PidJcmdExecutor(); + OutputAnalyzer oa = executor.execute(argsString); + oa.shouldHaveExitValue(expectedExitValue); + return oa; + } + + public static OutputAnalyzer jcmd(String... args) { + return jcmd(0, args); + } + + + public static OutputAnalyzer jcmdCheck(String recordingName, boolean verbose) { + return jcmd("JFR.check", "name=" + recordingName, "verbose=" + verbose); + } +} diff --git a/test/jdk/jfr/jcmd/TEST.properties b/test/jdk/jfr/jcmd/TEST.properties new file mode 100644 index 0000000000000000000000000000000000000000..0bd03a75b925363c14975f88080e9fc36aaced12 --- /dev/null +++ b/test/jdk/jfr/jcmd/TEST.properties @@ -0,0 +1,2 @@ +modules = jdk.jcmd + diff --git a/test/jdk/jfr/jcmd/TestJcmdConfigure.java b/test/jdk/jfr/jcmd/TestJcmdConfigure.java new file mode 100644 index 0000000000000000000000000000000000000000..c77bf2fbc54fc66bc0df205c7d9637e472951bc7 --- /dev/null +++ b/test/jdk/jfr/jcmd/TestJcmdConfigure.java @@ -0,0 +1,120 @@ +/* + * 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. 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.nio.file.Files; +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.internal.Options; +import jdk.test.lib.Asserts; + +/** + * @test + * @summary The test verifies JFR.configure command + * @key jfr + * + * @library /lib / + * + * @run main/othervm jdk.jfr.jcmd.TestJcmdConfigure + */ +public class TestJcmdConfigure { + + private static final String DUMPPATH = "dumppath"; + private static final String STACK_DEPTH = "stackdepth"; + private static final String GLOBAL_BUFFER_COUNT = "globalbuffercount"; + private static final String GLOBAL_BUFFER_SIZE = "globalbuffersize"; + private static final String THREAD_BUFFER_SIZE = "thread_buffer_size"; + private static final String MAX_CHUNK_SIZE = "maxchunksize"; + private static final String SAMPLE_THREADS = "samplethreads"; + private static final String UNSUPPORTED_OPTION = "unsupportedoption"; + + public static void main(String[] args) throws Exception { + // + // Simple sanity tests against what is available in Java, + // before Flight Recorder is loaded. To do: + // + // - set values when JFR is running, check for errors. + // - validate against output from JFR.configure + // - where feasible, check if they are respected + // + + String dumpPath = Files.createTempDirectory("dump-path").toAbsolutePath().toString(); + + test(DUMPPATH, dumpPath); + test(STACK_DEPTH, 15); + test(GLOBAL_BUFFER_COUNT, 7); + test(GLOBAL_BUFFER_SIZE, 6); + test(THREAD_BUFFER_SIZE, 5); + test(MAX_CHUNK_SIZE, 14 * 1000 * 1000); + test(SAMPLE_THREADS, false); + test(SAMPLE_THREADS, true); + testNegative(UNSUPPORTED_OPTION, 100000); + testNegative(MAX_CHUNK_SIZE, -500); + + if (!testExceptions.isEmpty()) { + for (Exception e : testExceptions) { + System.out.println("Error: " + e.getMessage()); + } + throw testExceptions.get(0); + } + } + + private static List testExceptions = new ArrayList<>(); + + private static void test(String configName, Object value) { + JcmdHelper.jcmd("JFR.configure", configName + "=" + value); + Object actualValue = getOption(configName); + System.out.format("Test param='%s', expected='%s', actual='%s'%n", configName, value, actualValue); + try { + // Need convert to string to compare Integer and Long + Asserts.assertEquals(value.toString(), actualValue.toString(), "Wrong JFR.configure " + configName); + } catch (Exception e) { + testExceptions.add(e); + } + } + + private static void testNegative(String configName, Object value) { + try { + JcmdHelper.jcmd(1, "JFR.configure", configName + "=" + value); + } catch(Exception e) { + testExceptions.add(e); + } + } + + private static Object getOption(String name) { + switch (name) { + case DUMPPATH: return Options.getDumpPath().toString(); + case STACK_DEPTH: return Options.getStackDepth(); + case GLOBAL_BUFFER_COUNT: return Options.getGlobalBufferCount(); + case GLOBAL_BUFFER_SIZE: return Options.getGlobalBufferSize(); + case THREAD_BUFFER_SIZE: return Options.getThreadBufferSize(); + case MAX_CHUNK_SIZE: return Options.getMaxChunkSize(); + case SAMPLE_THREADS: return Options.getSampleThreads(); + default: throw new RuntimeException("Unknown option " + name); + } + } +} diff --git a/test/jdk/jfr/jcmd/TestJcmdDump.java b/test/jdk/jfr/jcmd/TestJcmdDump.java new file mode 100644 index 0000000000000000000000000000000000000000..b2f0d8c70574d208cf4b9275b204d89b765371f2 --- /dev/null +++ b/test/jdk/jfr/jcmd/TestJcmdDump.java @@ -0,0 +1,172 @@ +/* + * 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. 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.File; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Predicate; + +import jdk.jfr.Event; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.process.OutputAnalyzer; + +/** + * @test + * @summary The test verifies JFR.dump command + * @key jfr + * + * @library /lib / + * @run main/othervm -XX:FlightRecorderOptions:maxchunksize=1M jdk.jfr.jcmd.TestJcmdDump + */ +public class TestJcmdDump { + + static class StoppedEvent extends Event { + } + static class RunningEvent extends Event { + } + + private static final String[] names = { null, "r1" }; + private static final boolean booleanValues[] = { true, false }; + + public static void main(String[] args) throws Exception { + + // Create a stopped recording in the repository to complicate things + Recording r = new Recording(); + r.start(); + StoppedEvent de = new StoppedEvent(); + de.commit(); + r.stop(); + + // The implementation of JFR.dump touch code that can't be executed using the + // Java API. It is therefore important to try all combinations. The + // implementation is non-trivial and depends on the combination + for (String name : names) { + for (boolean disk : booleanValues) { + try (Recording r1 = new Recording(); Recording r2 = new Recording()) { + System.out.println(); + System.out.println(); + System.out.println("Starting recordings with disk=" + disk); + r1.setToDisk(disk); + // To complicate things, only enable OldObjectSample for one recording + r1.enable(EventNames.OldObjectSample).withoutStackTrace(); + r1.setName("r1"); + r2.setToDisk(disk); + r2.setName("r2"); + r1.start(); + r2.start(); + + // Expect no path to GC roots + jfrDump(Boolean.FALSE, name, disk, rootCount -> rootCount == 0); + // Expect path to GC roots + jfrDump(null, name, disk, rootCount -> rootCount == 0); + // Expect at least one path to a GC root + jfrDump(Boolean.TRUE, name, disk, rootCount -> rootCount > 0); + } + } + } + r.close(); // release recording data from the stopped recording + } + + private static void jfrDump(Boolean pathToGCRoots, String name, boolean disk, Predicate successPredicate) throws Exception { + List leakList = new ArrayList<>(); + leakList.add(new Object[1000_0000]); + System.gc(); + while (true) { + RunningEvent re = new RunningEvent(); + re.commit(); + leakList.add(new Object[1000_0000]); + leakList.add(new Object[1000_0000]); + leakList.add(new Object[1000_0000]); + System.gc(); // This will shorten time for object to be emitted. + File recording = new File("TestJCMdDump.jfr"); + String[] params = buildParameters(pathToGCRoots, name, recording); + OutputAnalyzer output = JcmdHelper.jcmd(params); + JcmdAsserts.assertRecordingDumpedToFile(output, recording); + int rootCount = 0; + int oldObjectCount = 0; + int stoppedEventCount = 0; + int runningEventCount = 0; + for (RecordedEvent e : RecordingFile.readAllEvents(recording.toPath())) { + if (e.getEventType().getName().equals(EventNames.OldObjectSample)) { + if (e.getValue("root") != null) { + rootCount++; + } + oldObjectCount++; + } + if (e.getEventType().getName().equals(StoppedEvent.class.getName())) { + stoppedEventCount++; + } + if (e.getEventType().getName().equals(RunningEvent.class.getName())) { + runningEventCount++; + } + } + System.out.println("Name: " + name); + System.out.println("Disk: " + disk); + System.out.println("Path to GC roots: " + pathToGCRoots); + System.out.println("Old Objects: " + oldObjectCount); + System.out.println("Root objects: "+ rootCount); + System.out.println("Stopped events: "+ stoppedEventCount); + System.out.println("Running events: "+ runningEventCount); + + System.out.println(); + if (runningEventCount == 0) { + throw new Exception("Missing event from running recording"); + } + if (name == null && stoppedEventCount == 0) { + throw new Exception("Missing event from stopped recording"); + } + if (name != null && stoppedEventCount > 0) { + throw new Exception("Stopped event should not be part of dump"); + } + if (oldObjectCount != 0 && successPredicate.test(rootCount)) { + return; + } + System.out.println(); + System.out.println(); + System.out.println(); + System.out.println("************* Retrying! **************"); + Files.delete(recording.toPath()); + } + } + + private static String[] buildParameters(Boolean pathToGCRoots, String name, File recording) { + List params = new ArrayList<>(); + params.add("JFR.dump"); + params.add("filename=" + recording.getAbsolutePath()); + if (pathToGCRoots != null) { // if path-to-gc-roots is omitted, default is used (disabled). + params.add("path-to-gc-roots=" + pathToGCRoots); + } + if (name != null) { // if name is omitted, all recordings will be dumped + params.add("name=" + name); + } + return params.toArray(new String[0]); + } +} diff --git a/test/jdk/jfr/jcmd/TestJcmdDumpGeneratedFilename.java b/test/jdk/jfr/jcmd/TestJcmdDumpGeneratedFilename.java new file mode 100644 index 0000000000000000000000000000000000000000..1ec9abbb16bfb1f4aa0df922c1b502bdb6174afb --- /dev/null +++ b/test/jdk/jfr/jcmd/TestJcmdDumpGeneratedFilename.java @@ -0,0 +1,136 @@ +/* + * 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. 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.File; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Iterator; +import java.lang.management.ManagementFactory; + +import jdk.jfr.Configuration; +import jdk.jfr.Recording; +import jdk.test.lib.jfr.FileHelper; +import jdk.test.lib.process.OutputAnalyzer; + +/** + * @test + * @summary The test verifies JFR.dump command + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jcmd.TestJcmdDumpGeneratedFilename + */ +public class TestJcmdDumpGeneratedFilename { + + public static void main(String[] args) throws Exception { + // Increase the id for a recording + for (int i = 0; i < 300; i++) { + new Recording(); + } + try (Recording r = new Recording(Configuration.getConfiguration("default"))) { + r.start(); + r.stop(); + testDumpFilename(); + testDumpFilename(r); + testDumpDiectory(); + testDumpDiectory(r); + } + } + + private static void testDumpFilename() throws Exception { + OutputAnalyzer output = JcmdHelper.jcmd("JFR.dump"); + verifyFile(readFilename(output), null); + } + + private static void testDumpFilename(Recording r) throws Exception { + OutputAnalyzer output = JcmdHelper.jcmd("JFR.dump", "name=" + r.getId()); + verifyFile(readFilename(output), r.getId()); + } + + private static void testDumpDiectory() throws Exception { + Path directory = Paths.get(".").toAbsolutePath().normalize(); + OutputAnalyzer output = JcmdHelper.jcmd("JFR.dump", "filename=" + directory); + String filename = readFilename(output); + verifyFile(filename, null); + verifyDirectory(filename, directory); + } + + private static void testDumpDiectory(Recording r) throws Exception { + Path directory = Paths.get(".").toAbsolutePath().normalize(); + OutputAnalyzer output = JcmdHelper.jcmd("JFR.dump", "name=" + r.getId(), "filename=" + directory); + String filename = readFilename(output); + verifyFile(filename, r.getId()); + verifyDirectory(filename, directory); + } + + private static void verifyDirectory(String filename, Path directory) throws Exception { + if (!filename.contains(directory.toAbsolutePath().normalize().toString())) { + throw new Exception("Expected dump to be at " + directory); + } + } + + private static long getProcessId() { + + // something like '@', at least in SUN / Oracle JVMs + final String jvmName = ManagementFactory.getRuntimeMXBean().getName(); + + final int index = jvmName.indexOf('@'); + + if (index < 1) { + // part before '@' empty (index = 0) / '@' not found (index = -1) + return 42; + } + + try { + return Long.parseLong(jvmName.substring(0, index)); + } catch (NumberFormatException e) { + // ignore + } + return 42; + } + + private static void verifyFile(String filename, Long id) throws Exception { + String idText = id == null ? "" : "-id-" + Long.toString(id); + String expectedName = "hotspot-pid-" + getProcessId() + idText; + if (!filename.contains(expectedName)) { + throw new Exception("Expected filename to contain " + expectedName); + } + FileHelper.verifyRecording(new File(filename)); + } + + private static String readFilename(OutputAnalyzer output) throws Exception { + Iterator it = output.asLines().iterator(); + while (it.hasNext()) { + String line = it.next(); + if (line.contains("written to")) { + line = it.next(); // blank line + return it.next(); + } + } + throw new Exception("Could not find filename of dumped recording."); + } +} diff --git a/test/jdk/jfr/jcmd/TestJcmdDumpLimited.java b/test/jdk/jfr/jcmd/TestJcmdDumpLimited.java new file mode 100644 index 0000000000000000000000000000000000000000..c49f5c0995d102eff7caca865b2a851439dac930 --- /dev/null +++ b/test/jdk/jfr/jcmd/TestJcmdDumpLimited.java @@ -0,0 +1,294 @@ +/* + * 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. 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.nio.file.Paths; +import java.time.Duration; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneOffset; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import jdk.jfr.Event; +import jdk.jfr.Recording; +import jdk.test.lib.Asserts; +import jdk.test.lib.process.OutputAnalyzer; + +/** + * @test + * @summary The test verifies JFR.dump command + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jcmd.TestJcmdDumpLimited + */ +public class TestJcmdDumpLimited { + + static class TestEvent extends Event { + int id; + int number; + } + + static class TestRecording { + Instant time; + final Recording r; + Path path; + int size; + int total; + int id; + Instant now; + + TestRecording(int id, int events) throws IOException, InterruptedException { + r = new Recording(); + r.start(); + for (int i = 0; i < events; i++) { + TestEvent event = new TestEvent(); + event.id = id; + event.number = i; + event.commit(); + if (i == events / 2) { + time = Instant.now(); + } + } + r.stop(); + Thread.sleep(1); + path = Paths.get("dump-" + id + ".jfr"); + r.dump(path); + size = (int) Files.size(path); + this.id = id; + this.now = Instant.now(); + } + + public void close() { + r.close(); + } + } + + private static long totalSize; + private static long lastFiveSize; + private static long firstFiveSize; + private static long middleSize; + private static long centerSize; + private static long lastSize; + + private static Instant middle; + private static Instant centerLeft; + private static Instant centerRight; + + public static void main(String[] args) throws Exception { + + List recs = new ArrayList<>(); + + for (int i = 0; i < 9; i++) { + recs.add(new TestRecording(i, 100)); + } + int last = 0; + List reversed = new ArrayList<>(recs); + Collections.reverse(reversed); + for (TestRecording r : reversed) { + r.total = r.size + last; + last += r.size; + } + + for (TestRecording r : recs) { + System.out.println("Recording " + r.id + ": size=" + r.size + " (total=" + r.total + ", time=" + r.now + ")"); + } + + centerLeft = recs.get(3).time; + middle = recs.get(4).time; + centerRight = recs.get(5).time; + + totalSize = size(recs, 0, 9); + lastFiveSize = size(recs, 4, 5); + firstFiveSize = size(recs, 0, 5); + middleSize = size(recs, 4, 1); + centerSize = size(recs, 3, 3); + lastSize = size(recs, 8, 1); + + testDump(); + testDumpMaxSize(); + testDumpMaxSizeSmall(); + testDumpBegin(); + testDumpEnd(); + testDumpBeginEndInstant(); + testDumpBeginEndLocalDateTime(); + testDumpBeginEndLocalTime(); + testDumpBeginEndSame(); + testDumpMaxAge(); + testDumpBeginEndRelative(); + testDumpTooEarly(); + testDumpTooLate(); + testDumpBeginMaxAge(); + TestDumpEndMaxage(); + testDumpEndBegin(); + testDumpInvalidTime(); + } + + private static int size(List recs, int skip, int limit) { + return recs.stream().skip(skip).limit(limit).mapToInt(r -> r.size).sum(); + } + + private static void testDumpEndBegin() throws Exception { + Path testEndBegin = Paths.get("testEndBegin.jfr"); + OutputAnalyzer output = JcmdHelper.jcmd("JFR.dump", "filename=" + testEndBegin.toFile().getAbsolutePath(), "begin=" + Instant.now(), "end=" + Instant.now().minusSeconds(200)); + output.shouldContain("Dump failed, begin must preceed end."); + assertMissingFile(testEndBegin); + } + + private static void TestDumpEndMaxage() throws Exception { + Path testEndMaxAge = Paths.get("testEndMaxAge.jfr"); + OutputAnalyzer output = JcmdHelper.jcmd("JFR.dump", "filename=" + testEndMaxAge.toFile().getAbsolutePath(), "end=" + Instant.now(), "maxage=2h"); + output.shouldContain("Dump failed, maxage can't be combined with begin or end."); + assertMissingFile(testEndMaxAge); + } + + private static Path testDumpBeginMaxAge() throws Exception { + Path testBeginMaxAge = Paths.get("testBeginMaxAge.jfr"); + OutputAnalyzer output = JcmdHelper.jcmd("JFR.dump", "filename=" + testBeginMaxAge.toFile().getAbsolutePath(), "begin=" + Instant.now().minusSeconds(100), "maxage=2h"); + output.shouldContain("Dump failed, maxage can't be combined with begin or end."); + assertMissingFile(testBeginMaxAge); + return testBeginMaxAge; + } + + private static void testDumpTooLate() throws Exception { + Path missing = Paths.get("missing2.jfr"); + OutputAnalyzer output = JcmdHelper.jcmd("JFR.dump", "filename=" + missing.toFile().getAbsolutePath(), "begin=" + Instant.now().plus(Duration.ofHours(1)), + "end=" + Instant.now().plus(Duration.ofHours(2))); + output.shouldContain("Dump failed. No data found in the specified interval."); + assertMissingFile(missing); + } + + private static void testDumpTooEarly() throws Exception { + Path missing = Paths.get("missing.jfr"); + OutputAnalyzer output = JcmdHelper.jcmd("JFR.dump", "filename=" + missing.toFile().getAbsolutePath(), "end=" + Instant.now().minus(Duration.ofHours(1))); + output.shouldContain("Dump failed. No data found in the specified interval."); + assertMissingFile(missing); + } + + private static void testDumpBeginEndRelative() throws IOException { + Path testBeginEndRelative = Paths.get("testBeginEndRelative.jfr"); + JcmdHelper.jcmd("JFR.dump", "filename=" + testBeginEndRelative.toFile().getAbsolutePath(), "begin=-3h", "end=-0s"); + Asserts.assertEquals(totalSize, Files.size(testBeginEndRelative), "Expected dump with begin=-3h end=0s to contain data from all recordings"); + Files.delete(testBeginEndRelative); + } + + private static void testDumpMaxAge() throws IOException { + Path testMaxAge = Paths.get("testMaxAge.jfr"); + JcmdHelper.jcmd("JFR.dump", "filename=" + testMaxAge.toFile().getAbsolutePath(), "maxage=2h"); + Asserts.assertEquals(totalSize, Files.size(testMaxAge), "Expected dump with maxage=2h to contain data from all recordings"); + Files.delete(testMaxAge); + } + + private static void testDumpBeginEndSame() throws IOException { + Path testBeginEnd = Paths.get("testBeginEndSame.jfr"); + JcmdHelper.jcmd("JFR.dump", "filename=" + testBeginEnd.toFile().getAbsolutePath(), "begin=" + middle, "end=" + middle); + Asserts.assertEquals(middleSize, Files.size(testBeginEnd), "Expected dump with begin=" + middle + "end=" + middle + " contain data from middle recording"); + Files.delete(testBeginEnd); + } + + private static void testDumpBeginEndInstant() throws IOException { + Path testBeginEnd = Paths.get("testBeginEndInstant.jfr"); + JcmdHelper.jcmd("JFR.dump", "filename=" + testBeginEnd.toFile().getAbsolutePath(), "begin=" + centerLeft, "end=" + centerRight); + Asserts.assertEquals(centerSize, Files.size(testBeginEnd), "Expected dump with begin=" + centerLeft + " end=" + centerRight + " contain data from the 'center'-recordings"); + Files.delete(testBeginEnd); + } + + private static void testDumpBeginEndLocalDateTime() throws IOException { + LocalDateTime centerLeftLocal = LocalDateTime.ofInstant(centerLeft, ZoneOffset.systemDefault()); + LocalDateTime centerRightLocal = LocalDateTime.ofInstant(centerRight, ZoneOffset.systemDefault()); + Path testBeginEnd = Paths.get("testBeginEndLocalDateTime.jfr"); + JcmdHelper.jcmd("JFR.dump", "filename=" + testBeginEnd.toFile().getAbsolutePath(), "begin=" + centerLeftLocal, "end=" + centerRightLocal); + Asserts.assertEquals(centerSize, Files.size(testBeginEnd), "Expected dump with begin=" + centerLeftLocal + " end=" + centerRightLocal + " contain data from the 'center'-recordings"); + Files.delete(testBeginEnd); + } + + private static void testDumpBeginEndLocalTime() throws IOException { + //LocalTime centerLeftLocal = LocalTime.ofInstant(centerLeft, ZoneOffset.systemDefault()); + LocalTime centerLeftLocal = LocalDateTime.ofInstant(centerLeft, ZoneOffset.systemDefault()).toLocalTime(); + //LocalTime centerRightLocal = LocalTime.ofInstant(centerRight, ZoneOffset.systemDefault()); + LocalTime centerRightLocal = LocalDateTime.ofInstant(centerRight, ZoneOffset.systemDefault()).toLocalTime(); + Path testBeginEnd = Paths.get("testBeginEndLocalTime.jfr"); + JcmdHelper.jcmd("JFR.dump", "filename=" + testBeginEnd.toFile().getAbsolutePath(), "begin=" + centerLeftLocal, "end=" + centerRightLocal); + Asserts.assertEquals(centerSize, Files.size(testBeginEnd), "Expected dump with begin=" + centerLeftLocal + " end=" + centerRightLocal + " contain data from the 'center'-recordings"); + Files.delete(testBeginEnd); + } + + private static void testDumpEnd() throws IOException { + Path testEnd = Paths.get("testEnd.jfr"); + JcmdHelper.jcmd("JFR.dump", "filename=" + testEnd.toFile().getAbsolutePath(), "end=" + middle); + Asserts.assertEquals(firstFiveSize, Files.size(testEnd), "Expected dump with end=" + middle + " to contain data from the five first recordings"); + Files.delete(testEnd); + } + + private static void testDumpBegin() throws IOException { + Path testBegin = Paths.get("testBegin.jfr"); + JcmdHelper.jcmd("JFR.dump", "filename=" + testBegin.toFile().getAbsolutePath(), "begin=" + middle); + Asserts.assertEquals(lastFiveSize, Files.size(testBegin), "Expected dump with begin=" + middle + " to contain data from the last five recordings"); + Files.delete(testBegin); + } + + private static void testDumpMaxSize() throws IOException { + Path testMaxSize = Paths.get("testMaxSize.jfr"); + JcmdHelper.jcmd("JFR.dump", "filename=" + testMaxSize.toFile().getAbsolutePath(), "maxsize=" + lastFiveSize); + Asserts.assertEquals(lastFiveSize, Files.size(testMaxSize), "Expected dump with maxsize=" + lastFiveSize + " to contain data from the last five recordings"); + Files.delete(testMaxSize); + } + + private static void testDumpMaxSizeSmall() throws IOException { + Path testMaxSizeSmall = Paths.get("testMaxSizeSmall.jfr"); + JcmdHelper.jcmd("JFR.dump", "filename=" + testMaxSizeSmall.toFile().getAbsolutePath(), "maxsize=1k"); + Asserts.assertEquals(lastSize, Files.size(testMaxSizeSmall), "Expected dump with maxsize=1k to contain data from the last recording"); + Files.delete(testMaxSizeSmall); + } + + private static void testDump() throws IOException { + Path all = Paths.get("all.jfr"); + OutputAnalyzer output = JcmdHelper.jcmd("JFR.dump", "filename=" + all.toFile().getAbsolutePath()); + JcmdAsserts.assertRecordingDumpedToFile(output, all.toFile()); + Asserts.assertEquals(totalSize, Files.size(all), "Expected dump to be sum of all recordings"); + Files.delete(all); + } + + private static void testDumpInvalidTime() throws Exception { + Path invalidTime = Paths.get("invalidTime.jfr"); + OutputAnalyzer output = JcmdHelper.jcmd("JFR.dump", "filename=" + invalidTime.toFile().getAbsolutePath(), "begin=4711"); + output.shouldContain("Dump failed, not a valid begin time."); + assertMissingFile(invalidTime); + } + + private static void assertMissingFile(Path missing) throws Exception { + if (Files.exists(missing)) { + throw new Exception("Unexpected dumpfile found"); + } + } + +} diff --git a/test/jdk/jfr/jcmd/TestJcmdDumpPathToGCRoots.java b/test/jdk/jfr/jcmd/TestJcmdDumpPathToGCRoots.java new file mode 100644 index 0000000000000000000000000000000000000000..5804772219fd75308d915b16de95a0ae3802cfb9 --- /dev/null +++ b/test/jdk/jfr/jcmd/TestJcmdDumpPathToGCRoots.java @@ -0,0 +1,133 @@ +/* + * 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. 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.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jdk.jfr.Enabled; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedObject; +import jdk.jfr.consumer.RecordingFile; +import jdk.jfr.internal.test.WhiteBox; +import jdk.test.lib.jfr.EventNames; + +/** + * @test + * @summary Start a recording with or without path-to-gc-roots + * + * + * @library /lib / + * @key jfr + * + * @run main/othervm -XX:TLABSize=2k jdk.jfr.jcmd.TestJcmdDumpPathToGCRoots + */ +public class TestJcmdDumpPathToGCRoots { + + private static final int OBJECT_COUNT = 100_000; + public static List leak = new ArrayList<>(OBJECT_COUNT); + + public static void main(String[] args) throws Exception { + WhiteBox.setWriteAllObjectSamples(true); + + String settingName = EventNames.OldObjectSample + "#" + "cutoff"; + + // dump parameter trumps previous setting + testDump("path-to-gc-roots=true", Collections.singletonMap(settingName, "infinity"), true); + testDump("path-to-gc-roots=true", Collections.singletonMap(settingName, "0 ns"), true); + testDump("path-to-gc-roots=true", Collections.emptyMap(), true); + + testDump("path-to-gc-roots=false", Collections.singletonMap(settingName, "infinity"), false); + testDump("path-to-gc-roots=false", Collections.singletonMap(settingName, "0 ns"), false); + testDump("path-to-gc-roots=false", Collections.emptyMap(), false); + + testDump("", Collections.singletonMap(settingName, "infinity"), true); + testDump("", Collections.singletonMap(settingName, "0 ns"), false); + testDump("", Collections.emptyMap(), false); + } + + private static void testDump(String pathToGcRoots, Map settings, boolean expectedChains) throws Exception { + try (Recording r = new Recording()) { + Map p = new HashMap<>(settings); + p.put(EventNames.OldObjectSample + "#" + Enabled.NAME, "true"); + r.setName("dodo"); + r.setSettings(p); + r.setToDisk(true); + r.start(); + clearLeak(); + System.out.println("Recording id: " + r.getId()); + System.out.println("Settings: " + settings.toString()); + System.out.println("Command: JFR.dump " + pathToGcRoots); + System.out.println("Chains expected: " + expectedChains); + buildLeak(); + System.gc(); + System.gc(); + File recording = new File("TestJcmdDumpPathToGCRoots" + r.getId() + ".jfr"); + recording.delete(); + JcmdHelper.jcmd("JFR.dump", "name=dodo", pathToGcRoots, "filename=" + recording.getAbsolutePath()); + r.setSettings(Collections.emptyMap()); + List events = RecordingFile.readAllEvents(recording.toPath()); + if (events.isEmpty()) { + throw new Exception("No events found in recoding"); + } + boolean chains = hasChains(events); + if (expectedChains && !chains) { + System.out.println(events); + throw new Exception("Expected chains but found none"); + } + if (!expectedChains && chains) { + System.out.println(events); + throw new Exception("Didn't expect chains but found some"); + } + } + } + + private static void clearLeak() { + leak.clear(); + } + + private static boolean hasChains(List events) throws IOException { + for (RecordedEvent e : events) { + RecordedObject ro = e.getValue("object"); + if (ro.getValue("referrer") != null) { + return true; + } + } + return false; + } + + private static void buildLeak() { + for (int i = 0; i < OBJECT_COUNT;i ++) { + leak.add(new Object[0]); + } + } +} diff --git a/test/jdk/jfr/jcmd/TestJcmdLegacy.java b/test/jdk/jfr/jcmd/TestJcmdLegacy.java new file mode 100644 index 0000000000000000000000000000000000000000..4f86ab28ae71b7a470672f0697af58138d6b2138 --- /dev/null +++ b/test/jdk/jfr/jcmd/TestJcmdLegacy.java @@ -0,0 +1,93 @@ +/* + * 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.jcmd; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; + +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Utils; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.FileHelper; +import jdk.test.lib.process.OutputAnalyzer; + +/** + * @test TestClassId + * @key jfr + * + * @library /lib / + * + * @run main/othervm jdk.jfr.jcmd.TestJcmdLegacy + */ +public class TestJcmdLegacy { + + private static final String DIR = System.getProperty("test.src", "."); + private static final File SETTINGS = new File(DIR, "legacy.jfc"); + + private static final String LEGACY_EVENT = "com.oracle.jdk.JVMInformation"; + + public static void main(String... args) throws Exception { + testAPI(); + testJcmd(); + } + + private static void testJcmd() throws Exception { + String name = "testLegacy"; + Path p = Paths.get(name + ".jfr").toAbsolutePath().normalize(); + OutputAnalyzer output = JcmdHelper.jcmd("JFR.start", "name=" + name, "settings=" + SETTINGS.getCanonicalPath()); + JcmdAsserts.assertRecordingHasStarted(output); + JcmdHelper.waitUntilRunning(name); + JcmdHelper.stopWriteToFileAndCheck(name, p.toFile()); + FileHelper.verifyRecording(p.toFile()); + verify(p); + } + + private static void testAPI() throws IOException, Exception { + Path p = Utils.createTempFile("enable-legacy-event", ".jfr"); + + try (Recording r = new Recording()) { + r.enable(LEGACY_EVENT); + r.start(); + r.stop(); + r.dump(p); + verify(p); + } + } + + private static void verify(Path p) throws IOException, Exception { + for (RecordedEvent e : RecordingFile.readAllEvents(p)) { + System.out.println(e.getEventType().getName()); + if (e.getEventType().getName().equals(EventNames.JVMInformation)) { + return; + } + } + throw new Exception("Could not find legacy event"); + } +} diff --git a/test/jdk/jfr/jcmd/TestJcmdSaveToFile.java b/test/jdk/jfr/jcmd/TestJcmdSaveToFile.java new file mode 100644 index 0000000000000000000000000000000000000000..5d2e91d3d2b91b61e6b7906cfe2db4eaa36aab82 --- /dev/null +++ b/test/jdk/jfr/jcmd/TestJcmdSaveToFile.java @@ -0,0 +1,70 @@ +/* + * 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. 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.File; + +import jdk.test.lib.jfr.FileHelper; +import jdk.test.lib.process.OutputAnalyzer; + +/** + * @test + * @summary The test verifies that recording can be written to a file both with JFR.start and JFR.stop + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jcmd.TestJcmdSaveToFile + */ +public class TestJcmdSaveToFile { + + public static void main(String[] args) throws Exception { + testStartAndSave(); + testStopAndSave(); + } + + private static void testStartAndSave() throws Exception { + String name = "testStartAndSave"; + File recording = new File(name + ".jfr"); + OutputAnalyzer output = JcmdHelper.jcmd("JFR.start", + "name=" + name, + "duration=1h", + "filename=" + recording.getAbsolutePath()); + JcmdAsserts.assertRecordingHasStarted(output); + JcmdHelper.waitUntilRunning(name); + JcmdHelper.stopAndCheck(name); + FileHelper.verifyRecording(recording); + } + + private static void testStopAndSave() throws Exception { + String name = "testStopAndSave"; + File recording = new File(name + ".jfr"); + OutputAnalyzer output = JcmdHelper.jcmd("JFR.start", "name=" + name); + JcmdAsserts.assertRecordingHasStarted(output); + JcmdHelper.waitUntilRunning(name); + JcmdHelper.stopWriteToFileAndCheck(name, recording); + FileHelper.verifyRecording(recording); + } +} diff --git a/test/jdk/jfr/jcmd/TestJcmdStartDirNotExist.java b/test/jdk/jfr/jcmd/TestJcmdStartDirNotExist.java new file mode 100644 index 0000000000000000000000000000000000000000..28318b9d6630b6f24a2e7f73f60efddb2c6f3125 --- /dev/null +++ b/test/jdk/jfr/jcmd/TestJcmdStartDirNotExist.java @@ -0,0 +1,54 @@ +/* + * 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. 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.nio.file.Path; +import java.nio.file.Paths; + +import jdk.test.lib.process.OutputAnalyzer; + +/** + * @test + * @summary Verify error when starting with a dir that does not exist. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jcmd.TestJcmdStartDirNotExist + */ +public class TestJcmdStartDirNotExist { + + public static void main(String[] args) throws Exception { + Path path = Paths.get(".", "dirDoesNotExist", "my.jfr"); + String name = "testStartWithIllegalFilename"; + OutputAnalyzer output = JcmdHelper.jcmd("JFR.start", + "name=" + name, + "duration=10s", + "filename=" + path.toString()); + JcmdAsserts.assertNotAbleToWriteToFile(output); + JcmdHelper.assertRecordingNotExist(name); + } + +} diff --git a/test/jdk/jfr/jcmd/TestJcmdStartInvaldFile.java b/test/jdk/jfr/jcmd/TestJcmdStartInvaldFile.java new file mode 100644 index 0000000000000000000000000000000000000000..068005d411260b1707f34897d079f11b273d942e --- /dev/null +++ b/test/jdk/jfr/jcmd/TestJcmdStartInvaldFile.java @@ -0,0 +1,52 @@ +/* + * 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. 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 jdk.test.lib.process.OutputAnalyzer; + +/** + * @test + * @summary Verify error when starting with invalid file. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jcmd.TestJcmdStartInvaldFile + */ +public class TestJcmdStartInvaldFile { + + private final static String ILLEGAL_FILE_NAME = ":;/\\?"; + + public static void main(String[] args) throws Exception { + String name = "testStartWithIllegalFilename"; + OutputAnalyzer output = JcmdHelper.jcmd("JFR.start", + "name=" + name, + "duration=10s", + "filename=" + ILLEGAL_FILE_NAME); + JcmdAsserts.assertNotAbleToWriteToFile(output); + JcmdHelper.assertRecordingNotExist(name); + } + +} diff --git a/test/jdk/jfr/jcmd/TestJcmdStartPathToGCRoots.java b/test/jdk/jfr/jcmd/TestJcmdStartPathToGCRoots.java new file mode 100644 index 0000000000000000000000000000000000000000..5d93f16fba0923aa04067170ebb7293adefb99aa --- /dev/null +++ b/test/jdk/jfr/jcmd/TestJcmdStartPathToGCRoots.java @@ -0,0 +1,86 @@ +/* + * 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. 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.util.List; + +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; +import jdk.test.lib.jfr.EventNames; + + +/** + * @test + * @summary Start a recording with or without path-to-gc-roots + * + * @library /lib / + * @key jfr + * + * @run main/othervm jdk.jfr.jcmd.TestJcmdStartPathToGCRoots + */ +public class TestJcmdStartPathToGCRoots { + + public static void main(String[] args) throws Exception { + + JcmdHelper.jcmd("JFR.start", "path-to-gc-roots=true"); + assertCutoff("infinity", "Expected cutoff to be '0 ns' wuth -XX:StartFlightRecording=path-to-gc-roots=true"); + closeRecording(); + + JcmdHelper.jcmd("JFR.start", "path-to-gc-roots=false"); + assertCutoff("0 ns", "Expected cutoff to be '0 ns' with -XX:StartFlightRecording=path-to-gc-roots=false"); + closeRecording(); + + JcmdHelper.jcmd("JFR.start"); + assertCutoff("0 ns", "Expected cutoff to be '0 ns' with -XX:StartFlightRecording="); + closeRecording(); + } + + private static void assertCutoff(String expected, String errorMessage) throws Exception { + List recordings = FlightRecorder.getFlightRecorder().getRecordings(); + if (recordings.isEmpty()) { + throw new Exception("Expected recording to be started"); + } + if (recordings.size() != 1) { + throw new Exception("Expected only one recording"); + } + + String settingName = EventNames.OldObjectSample + "#" + "cutoff"; + Recording r = recordings.get(0); + String cutoff = r.getSettings().get(settingName); + System.out.println(settingName + "=" + cutoff); + if (!expected.equals(cutoff)) { + throw new Exception(errorMessage); + } + r.close(); + } + + private static void closeRecording() { + for (Recording r : FlightRecorder.getFlightRecorder().getRecordings()) { + r.close(); + } + } + +} diff --git a/test/jdk/jfr/jcmd/TestJcmdStartReadOnlyFile.java b/test/jdk/jfr/jcmd/TestJcmdStartReadOnlyFile.java new file mode 100644 index 0000000000000000000000000000000000000000..3a339d8ae39a9820e1eeb2f96248c4403afd2ee1 --- /dev/null +++ b/test/jdk/jfr/jcmd/TestJcmdStartReadOnlyFile.java @@ -0,0 +1,60 @@ +/* + * 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. 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.nio.file.Path; +import java.nio.file.Paths; + +import jdk.test.lib.jfr.FileHelper; +import jdk.test.lib.process.OutputAnalyzer; + +/** + * @test + * @summary Verify error when starting with read-only file. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jcmd.TestJcmdStartReadOnlyFile + */ +public class TestJcmdStartReadOnlyFile { + + public static void main(String[] args) throws Exception { + String name = "TestJcmdStartReadOnlyFile"; + Path readonlyFile = FileHelper.createReadOnlyFile(Paths.get(".", name + ".jfr")); + if (!FileHelper.isReadOnlyPath(readonlyFile)) { + System.out.println("Could not create read-only file. Ignoring test."); + return; + } + + OutputAnalyzer output = JcmdHelper.jcmd("JFR.start", + "name=" + name, + "duration=10s", + "filename=" + readonlyFile.toAbsolutePath()); + JcmdAsserts.assertNotAbleToWriteToFile(output); + JcmdHelper.assertRecordingNotExist(name); + } + +} diff --git a/test/jdk/jfr/jcmd/TestJcmdStartStopDefault.java b/test/jdk/jfr/jcmd/TestJcmdStartStopDefault.java new file mode 100644 index 0000000000000000000000000000000000000000..d8ca538535a964bad563bb5c551d2eb2d4bba6ff --- /dev/null +++ b/test/jdk/jfr/jcmd/TestJcmdStartStopDefault.java @@ -0,0 +1,77 @@ +/* + * 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. 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.nio.file.Path; +import java.nio.file.Paths; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.FileHelper; +import jdk.test.lib.process.OutputAnalyzer; + +/** + * @test + * @summary Start a recording without name. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jcmd.TestJcmdStartStopDefault + */ +public class TestJcmdStartStopDefault { + + public static void main(String[] args) throws Exception { + Path recording = Paths.get(".","TestJcmdStartStopDefault.jfr").toAbsolutePath().normalize(); + + OutputAnalyzer output = JcmdHelper.jcmd("JFR.start"); + JcmdAsserts.assertRecordingHasStarted(output); + + String name = parseRecordingName(output); + JcmdHelper.waitUntilRunning(name); + + output = JcmdHelper.jcmd("JFR.dump", + "name=" + name, + "filename=" + recording); + JcmdAsserts.assertRecordingDumpedToFile(output, recording.toFile()); + JcmdHelper.stopAndCheck(name); + FileHelper.verifyRecording(recording.toFile()); + } + + private static String parseRecordingName(OutputAnalyzer output) { + // Expected output: + // Started recording recording-1. No limit (duration/maxsize/maxage) in use. + // Use JFR.dump name=recording-1 filename=FILEPATH to copy recording data to file. + + String stdout = output.getStdout(); + Pattern p = Pattern.compile(".*Use jcmd \\d+ JFR.dump name=(\\S+).*", Pattern.DOTALL); + Matcher m = p.matcher(stdout); + Asserts.assertTrue(m.matches(), "Could not parse recording name"); + String name = m.group(1); + System.out.println("Recording name=" + name); + return name; + } +} diff --git a/test/jdk/jfr/jcmd/TestJcmdStartWithOptions.java b/test/jdk/jfr/jcmd/TestJcmdStartWithOptions.java new file mode 100644 index 0000000000000000000000000000000000000000..f80cfeff33934dbabfda1dbefe30fc2c3d279e5d --- /dev/null +++ b/test/jdk/jfr/jcmd/TestJcmdStartWithOptions.java @@ -0,0 +1,143 @@ +/* + * 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 + * 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.File; + +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; +import jdk.jfr.RecordingState; +import jdk.test.lib.process.OutputAnalyzer; + +/** + * @test + * @summary The test verifies that recording can be started with options delay|duration|maxage|maxsize + * @key jfr + * + * @library /lib / + * @run main/othervm -XX:+FlightRecorder -XX:FlightRecorderOptions=maxchunksize=2097152 jdk.jfr.jcmd.TestJcmdStartWithOptions + */ +public class TestJcmdStartWithOptions { + + private static final String DIR = System.getProperty("test.src", "."); + private static final File SETTINGS = new File(DIR, "jcmd-testsettings3.jfc"); + + public static void main(String[] args) throws Exception { + testRecordingNotStartedTooEarly(); + testDelayLessThan1s(); + testDuration(); + testDurationLessThan1s(); + testMaxAge(); + testMaxSize(); + } + + static void testRecordingNotStartedTooEarly() throws Exception { + String name = "testRecordingNotStartedTooEarly"; + long delay = 2 * 1000; + OutputAnalyzer output = JcmdHelper.jcmd("JFR.start", + "name=" + name, + "delay=" + delay + "ms"); + JcmdAsserts.assertRecordingIsScheduled(output, "1", "2 s"); + for (Recording r : FlightRecorder.getFlightRecorder().getRecordings()) { + if (name.equals(r.getName())) { + while(r.getState() != RecordingState.RUNNING) { + Thread.sleep(10); + } + long currentTime = System.currentTimeMillis(); + long afterActualStart = currentTime + delay; + JcmdAsserts.assertStartTimeGreaterOrEqualThanMBeanValue(name, afterActualStart); + JcmdHelper.stopAndCheck(name); + return; + } + } + throw new Exception("Could not find recording with name " + name); + } + + private static void testDelayLessThan1s() throws Exception { + String name = "testDelayLessThan1s"; + OutputAnalyzer output = JcmdHelper.jcmd("JFR.start", + "name=" + name, + "delay=10ms"); + JcmdAsserts.assertDelayAtLeast1s(output); + output = JcmdHelper.jcmd("JFR.check"); + JcmdAsserts.assertNoRecordingsAvailable(output); + } + + private static void testDuration() throws Exception { + String name = "testDuration"; + long duration = 3600 * 1000; + String durationS = String.valueOf(duration / 1000) + "s" ; + OutputAnalyzer output = JcmdHelper.jcmd("JFR.start", + "name=" + name, + "duration=" + durationS); + JcmdAsserts.assertRecordingHasStarted(output); + JcmdHelper.waitUntilRunning(name); + JcmdAsserts.assertDurationEqualsMBeanValue(name, duration); + JcmdHelper.stopAndCheck(name); + } + + private static void testDurationLessThan1s() throws Exception { + String name = "testDurationLessThan1s"; + OutputAnalyzer output = JcmdHelper.jcmd("JFR.start", + "name=" + name, + "duration=10ms"); + JcmdAsserts.assertDurationAtLeast1s(output); + JcmdHelper.checkAndAssertNoRecordingsAvailable(); + } + + /** + * Check the maxage is the same as MBean value + */ + private static void testMaxAge() throws Exception { + String name = "testMaxAge"; + long maxAge = 2 * 1000; + OutputAnalyzer output = JcmdHelper.jcmd("JFR.start", + "name=" + name, + "settings=" + SETTINGS.getAbsolutePath(), + "maxage=2s"); + JcmdAsserts.assertRecordingHasStarted(output); + JcmdHelper.waitUntilRunning(name); + JcmdAsserts.assertMaxAgeEqualsMBeanValue(name, maxAge); + JcmdHelper.stopAndCheck(name); + } + + /** + * Check the maxsize is the same as MBean value + */ + private static void testMaxSize() throws Exception { + String name = "testMaxSize"; + long maxSize = 2 * 1024 * 1024; + OutputAnalyzer output = JcmdHelper.jcmd("JFR.start", + "name=" + name, + "settings=" + SETTINGS.getAbsolutePath(), + "maxsize=" + maxSize); + JcmdAsserts.assertRecordingHasStarted(output); + JcmdHelper.waitUntilRunning(name); + JcmdAsserts.assertMaxSizeEqualsMBeanValue(name, maxSize); + JcmdHelper.stopAndCheck(name); + } + +} diff --git a/test/jdk/jfr/jcmd/TestJcmdStartWithSettings.java b/test/jdk/jfr/jcmd/TestJcmdStartWithSettings.java new file mode 100644 index 0000000000000000000000000000000000000000..976cde8104581e3e1ffdc6af4fd53864701a03af --- /dev/null +++ b/test/jdk/jfr/jcmd/TestJcmdStartWithSettings.java @@ -0,0 +1,178 @@ +/* + * 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. 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.File; + +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedThread; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.process.OutputAnalyzer; + +/** + * @test + * @summary The test verifies that recording can be started with setting file(s) + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jcmd.TestJcmdStartWithSettings + */ +public class TestJcmdStartWithSettings { + + private static final String DIR = System.getProperty("test.src", "."); + private static final File SETTINGS = new File(DIR, "jcmd-testsettings.jfc"); + private static final File SETTINGS2 = new File(DIR, "jcmd-testsettings.2.jfc"); + + public static void main(String[] args) throws Exception { + testSingleSettingFile(); + testManySettingFiles(); + testPresetSettings(); + testNonExistingSettingFile(); + } + + private static void testSingleSettingFile() throws Exception { + String name = "testSingleSettingFile"; + File recording = new File(name + ".jfr"); + + OutputAnalyzer output = JcmdHelper.jcmd("JFR.start", + "name=" + name, + "duration=1h", + "settings=" + SETTINGS.getCanonicalPath(), + "filename=" + recording.getCanonicalPath()); + JcmdAsserts.assertRecordingHasStarted(output); + JcmdHelper.waitUntilRunning(name); + output = JcmdHelper.jcmdCheck(name, true); + JcmdAsserts.assertThreadSleepThresholdIsSet(output); + + Thread.sleep(100); + JcmdHelper.stopAndCheck(name); + assertHasEvent(recording, EventNames.ThreadSleep, Thread.currentThread().getName()); + } + + /** + * Start a recording with two setting files and + * verify Java Thread Sleep and Java Monitor Wait events have been recorded. + */ + private static void testManySettingFiles() throws Exception { + String name = "testManySettingFiles"; + File recording = new File(name + ".jfr"); + + OutputAnalyzer output = JcmdHelper.jcmd("JFR.start", + "name=" + name, + "duration=1h", + "settings=" + SETTINGS.getCanonicalPath(), + "settings=" + SETTINGS2.getCanonicalPath(), + "filename=" + recording.getCanonicalPath()); + JcmdAsserts.assertRecordingHasStarted(output); + JcmdHelper.waitUntilRunning(name); + output = JcmdHelper.jcmdCheck(name, true); + JcmdAsserts.assertThreadSleepThresholdIsSet(output); + JcmdAsserts.assertMonitorWaitThresholdIsSet(output); + + // Generate Monitor Wait event + ThreadWait threadWait = new ThreadWait(); + threadWait.start(); + Thread.sleep(300); + threadWait.join(); + + JcmdHelper.stopAndCheck(name); + assertHasEvent(recording, EventNames.ThreadSleep, Thread.currentThread().getName()); + assertHasEvent(recording, EventNames.JavaMonitorWait, threadWait.getName()); + } + + /** + * It should be possible to use "profile" as non-path preset, + * both with and without '.jfc' + */ + private static void testPresetSettings() throws Exception { + String name = "testPresetSettingsJfc"; + OutputAnalyzer output = JcmdHelper.jcmd("JFR.start", + "name=" + name, + "settings=profile.jfc"); + JcmdAsserts.assertRecordingHasStarted(output); + JcmdHelper.waitUntilRunning(name); + JcmdHelper.stopAndCheck(name); + + name = "testPresetSettingsNoJfc"; + output = JcmdHelper.jcmd("JFR.start", + "name=" + name, + "settings=profile"); + JcmdAsserts.assertRecordingHasStarted(output); + JcmdHelper.waitUntilRunning(name); + JcmdHelper.stopAndCheck(name); + } + + /** + * It should not be possible to start a recording + * with a non-existing setting file + */ + private static void testNonExistingSettingFile() throws Exception { + String name = "testNonExistingSettingFile"; + OutputAnalyzer output = JcmdHelper.jcmd("JFR.start", + "name=" + name, + "settings=nonexisting.jfc"); + JcmdAsserts.assertNotAbleToFindSettingsFile(output); + JcmdHelper.assertRecordingNotExist(name); + } + + private static void assertHasEvent(File file, String eventType, String threadName) throws Exception { + for (RecordedEvent event : RecordingFile.readAllEvents(file.toPath())) { + if (Events.isEventType(event, eventType)) { + System.out.println(event); + RecordedThread t = event.getThread(); + if (t == null) { + throw new Exception("Thread null for event " + eventType); + } + if (threadName.equals(t.getJavaName())) { + System.out.println("Found event: " + event); + return; + } + } + } + Asserts.fail("No events of type " + eventType); + } + + static class ThreadWait extends Thread { + + public ThreadWait() { + setName("ThreadWait"); + } + + @Override + public void run() { + try { + synchronized (this) { + wait(100); + } + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } +} diff --git a/test/jdk/jfr/jcmd/TestJcmdStopInvalidFile.java b/test/jdk/jfr/jcmd/TestJcmdStopInvalidFile.java new file mode 100644 index 0000000000000000000000000000000000000000..e3212d35b67ce198ba524d9a147d2ad05f705d1b --- /dev/null +++ b/test/jdk/jfr/jcmd/TestJcmdStopInvalidFile.java @@ -0,0 +1,58 @@ +/* + * 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. 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 jdk.test.lib.process.OutputAnalyzer; + +/** + * @test + * @summary Verify error when stopping with invalid file. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jcmd.TestJcmdStopInvalidFile + */ +public class TestJcmdStopInvalidFile { + + private final static String ILLEGAL_FILE_NAME = ":;/\\?"; + + public static void main(String[] args) throws Exception { + String name = "testStopWithIllegalFilename"; + OutputAnalyzer output = JcmdHelper.jcmd("JFR.start", "name=" + name); + JcmdAsserts.assertRecordingHasStarted(output); + JcmdHelper.waitUntilRunning(name); + + output = JcmdHelper.jcmd("JFR.stop", + "name=" + name, + "filename=" + ILLEGAL_FILE_NAME); + JcmdAsserts.assertFileNotFoundException(output, name); + + output = JcmdHelper.jcmd("JFR.check"); + JcmdHelper.assertRecordingIsRunning(name); + JcmdHelper.stopAndCheck(name); + } + +} diff --git a/test/jdk/jfr/jcmd/TestJcmdStopReadOnlyFile.java b/test/jdk/jfr/jcmd/TestJcmdStopReadOnlyFile.java new file mode 100644 index 0000000000000000000000000000000000000000..2ede1ef33ae221c136f2f30e1d3778cef00cbe3f --- /dev/null +++ b/test/jdk/jfr/jcmd/TestJcmdStopReadOnlyFile.java @@ -0,0 +1,65 @@ +/* + * 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 + * 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.nio.file.Path; +import java.nio.file.Paths; + +import jdk.test.lib.jfr.FileHelper; +import jdk.test.lib.process.OutputAnalyzer; + +/** + * @test + * @summary Verify error when stopping with read-only file. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jcmd.TestJcmdStopReadOnlyFile + */ +public class TestJcmdStopReadOnlyFile { + + + public static void main(String[] args) throws Exception { + String name = "TestJcmdStopReadOnlyFile"; + Path readonlyFile = FileHelper.createReadOnlyFile(Paths.get(".", name + ".jfr")); + if (!FileHelper.isReadOnlyPath(readonlyFile)) { + System.out.println("Could not create read-only file. Ignoring test."); + return; + } + + OutputAnalyzer output = JcmdHelper.jcmd("JFR.start", "name=" + name); + JcmdAsserts.assertRecordingHasStarted(output); + JcmdHelper.waitUntilRunning(name); + + output = JcmdHelper.jcmd("JFR.stop", + "name=" + name, + "filename=" + readonlyFile.toAbsolutePath()); + JcmdAsserts.assertFileNotFoundException(output, name); + JcmdHelper.assertRecordingIsRunning(name); + JcmdHelper.stopAndCheck(name); + } + +} diff --git a/test/jdk/jfr/jcmd/jcmd-testsettings.2.jfc b/test/jdk/jfr/jcmd/jcmd-testsettings.2.jfc new file mode 100644 index 0000000000000000000000000000000000000000..2214e3b4683b633f64324f71760239d8d2ef111b --- /dev/null +++ b/test/jdk/jfr/jcmd/jcmd-testsettings.2.jfc @@ -0,0 +1,10 @@ + + + + + true + true + 1 ms + + + diff --git a/test/jdk/jfr/jcmd/jcmd-testsettings.jfc b/test/jdk/jfr/jcmd/jcmd-testsettings.jfc new file mode 100644 index 0000000000000000000000000000000000000000..a6fb83c86fb4b3313dc81617556b36846b788186 --- /dev/null +++ b/test/jdk/jfr/jcmd/jcmd-testsettings.jfc @@ -0,0 +1,10 @@ + + + + + true + true + 1 ms + + + diff --git a/test/jdk/jfr/jcmd/jcmd-testsettings3.jfc b/test/jdk/jfr/jcmd/jcmd-testsettings3.jfc new file mode 100644 index 0000000000000000000000000000000000000000..adf7188b094ce2915561bc4fb7e57b2747e46d09 --- /dev/null +++ b/test/jdk/jfr/jcmd/jcmd-testsettings3.jfc @@ -0,0 +1,8 @@ + + + + + true + + + diff --git a/test/jdk/jfr/jcmd/legacy.jfc b/test/jdk/jfr/jcmd/legacy.jfc new file mode 100644 index 0000000000000000000000000000000000000000..67cdadbe9132287102063fe47acb96105124e4c8 --- /dev/null +++ b/test/jdk/jfr/jcmd/legacy.jfc @@ -0,0 +1,7 @@ + + + + true + everyChunk + + diff --git a/test/jdk/jfr/jmx/JmxHelper.java b/test/jdk/jfr/jmx/JmxHelper.java new file mode 100644 index 0000000000000000000000000000000000000000..d6ca8641ff30ca3f5c0edfc67a06630811d46c2a --- /dev/null +++ b/test/jdk/jfr/jmx/JmxHelper.java @@ -0,0 +1,281 @@ +/* + * 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 + * 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.jmx; + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.lang.management.ManagementFactory; +import java.time.Instant; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; +import jdk.jfr.RecordingState; +import jdk.jfr.SettingDescriptor; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.management.jfr.EventTypeInfo; +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.management.jfr.RecordingInfo; +import jdk.management.jfr.SettingDescriptorInfo; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.CommonHelper; +import jdk.test.lib.jfr.Events; + +public class JmxHelper { + + public static RecordingInfo getJmxRecording(long recId) { + for (RecordingInfo r : getFlighteRecorderMXBean().getRecordings()) { + if (r.getId() == recId) { + return r; + } + } + Asserts.fail("No RecordingInfo with id " + recId); + return null; + } + + public static Recording getJavaRecording(long recId) { + for (Recording r : FlightRecorder.getFlightRecorder().getRecordings()) { + if (r.getId() == recId) { + return r; + } + } + Asserts.fail("No Recording with id " + recId); + return null; + } + + public static void verifyState(long recId, RecordingState state, List recordings) { + RecordingInfo r = verifyExists(recId, recordings); + verifyState(r, state); + } + + public static void verifyState(RecordingInfo recording, RecordingState state) { + final String actual = recording.getState().toString(); + final String expected = state.toString(); + Asserts.assertEquals(actual, expected, "Wrong state"); + } + + public static void verifyState(long recId, RecordingState state, FlightRecorderMXBean bean) throws Exception { + FlightRecorder jfr = FlightRecorder.getFlightRecorder(); + Recording recording = CommonHelper.verifyExists(recId, jfr.getRecordings()); + CommonHelper.verifyRecordingState(recording, state); + verifyState(recId, state, bean.getRecordings()); + } + + public static void verifyNotExists(long recId, List recordings) { + for (RecordingInfo r : recordings) { + if (recId == r.getId()) { + logRecordingInfos(recordings); + Asserts.fail("Recording should not exist, id=" + recId); + } + } + } + + public static RecordingInfo verifyExists(long recId, List recordings) { + for (RecordingInfo r : recordings) { + if (recId == r.getId()) { + return r; + } + } + logRecordingInfos(recordings); + Asserts.fail("Recording not found, id=" + recId); + return null; + } + + + public static void logRecordingInfos(List recordings) { + System.out.println("RecordingInfos:"); + for (RecordingInfo r : recordings) { + System.out.println(asString(r)); + } + } + + public static void logRecordings(List recordings) { + System.out.println("Recordings:"); + for (Recording r : recordings) { + System.out.println(asString(r)); + } + } + + static File dump(long streamId, FlightRecorderMXBean bean) throws IOException { + File f = File.createTempFile("stream_" + streamId + "_", ".jfr", new File(".")); + try (FileOutputStream fos = new FileOutputStream(f); BufferedOutputStream bos = new BufferedOutputStream(fos)) { + while (true) { + byte[] data = bean.readStream(streamId); + if (data == null) { + bos.flush(); + return f; + } + bos.write(data); + } + } + } + + public static List parseStream(long streamId, FlightRecorderMXBean bean) throws Exception { + File dumpFile = dump(streamId, bean); + System.out.println("data.length=" + dumpFile.length()); + List events = new ArrayList<>(); + for (RecordedEvent event : RecordingFile.readAllEvents(dumpFile.toPath())) { + System.out.println("EVENT:" + event); + events.add(event); + } + return events; + } + + public static void verifyEquals(RecordingInfo ri, Recording r) { + String destination = r.getDestination() != null ? r.getDestination().toString() : null; + long maxAge = r.getMaxAge() != null ? r.getMaxAge().getSeconds() : 0; + long duration = r.getDuration() != null ? r.getDuration().getSeconds() : 0; + + Asserts.assertEquals(destination, ri.getDestination(), "Wrong destination"); + Asserts.assertEquals(r.getDumpOnExit(), ri.getDumpOnExit(), "Wrong dumpOnExit"); + Asserts.assertEquals(duration, ri.getDuration(), "Wrong duration"); + Asserts.assertEquals(r.getId(), ri.getId(), "Wrong id"); + Asserts.assertEquals(maxAge, ri.getMaxAge(), "Wrong maxAge"); + Asserts.assertEquals(r.getMaxSize(), ri.getMaxSize(), "Wrong maxSize"); + Asserts.assertEquals(r.getName(), ri.getName(), "Wrong name"); + Asserts.assertEquals(r.getSize(), ri.getSize(), "Wrong size"); + Asserts.assertEquals(toEpochMillis(r.getStartTime()), ri.getStartTime(), "Wrong startTime"); + Asserts.assertEquals(r.getState().toString(), ri.getState(), "Wrong state"); + Asserts.assertEquals(toEpochMillis(r.getStopTime()), ri.getStopTime(), "Wrong stopTime"); + + verifyMapEquals(r.getSettings(), ri.getSettings()); + } + + public static String asString(RecordingInfo r) { + StringBuffer sb = new StringBuffer(); + sb.append(String.format("RecordingInfo:%n")); + sb.append(String.format("destination=%s%n", r.getDestination())); + sb.append(String.format("dumpOnExit=%b%n", r.getDumpOnExit())); + sb.append(String.format("duration=%d%n", r.getDuration())); + sb.append(String.format("id=%d%n", r.getId())); + sb.append(String.format("maxAge=%d%n", r.getMaxAge())); + sb.append(String.format("maxSize=%d%n", r.getMaxSize())); + sb.append(String.format("getName=%s%n", r.getName())); + sb.append(String.format("size=%d%n", r.getSize())); + sb.append(String.format("startTime=%d%n", r.getStartTime())); + sb.append(String.format("state=%s%n", r.getState())); + sb.append(String.format("stopTime=%d%n", r.getStopTime())); + return sb.toString(); + } + + public static String asString(Recording r) { + StringBuffer sb = new StringBuffer(); + sb.append(String.format("Recording:%n")); + sb.append(String.format("destination=%s%n", r.getDestination())); + sb.append(String.format("dumpOnExit=%b%n", r.getDumpOnExit())); + sb.append(String.format("duration=%d%n", r.getDuration().getSeconds())); + sb.append(String.format("id=%d%n", r.getId())); + sb.append(String.format("maxAge=%d%n", r.getMaxAge().getSeconds())); + sb.append(String.format("maxSize=%d%n", r.getMaxSize())); + sb.append(String.format("getName=%s%n", r.getName())); + sb.append(String.format("size=%d%n", r.getSize())); + sb.append(String.format("startTime=%d%n", toEpochMillis(r.getStartTime()))); + sb.append(String.format("state=%s%n", r.getState())); + sb.append(String.format("stopTime=%d%n", toEpochMillis(r.getStopTime()))); + return sb.toString(); + } + + public static void verifyMapEquals(Map a, Map b) { + try { + Asserts.assertEquals(a.size(), b.size(), "Wrong number of keys"); + for (String key : a.keySet()) { + Asserts.assertTrue(a.containsKey(key), "Missing key " + key); + Asserts.assertEquals(a.get(key), b.get(key), "Wrong values for key " + key); + //System.out.printf("equal: %s=%s%n", key, a.get(key)); + } + } catch (Exception e) { + System.out.println("Error: " + e.getMessage()); + logMap("a", a); + logMap("b", b); + throw e; + } + } + + public static void logMap(String name, Map map) { + for (String key : map.keySet()) { + System.out.printf("map %s: %s=%s%n", name, key, map.get(key)); + } + } + + private static long toEpochMillis(Instant instant) { + return instant != null ? instant.toEpochMilli() : 0; + } + + public static void verifyEventSettingsEqual(EventType javaType, EventTypeInfo jmxType) { + Map javaSettings = new HashMap<>(); + for (SettingDescriptor settingDescriptor : javaType.getSettingDescriptors()) { + javaSettings.put(settingDescriptor.getName(), settingDescriptor); + } + Asserts.assertFalse(javaSettings.isEmpty(), "No ValueDescriptor for EventType " + javaType.getName()); + + for (SettingDescriptorInfo jmxSetting : jmxType.getSettingDescriptors()) { + final String name = jmxSetting.getName(); + System.out.printf("SettingDescriptorInfo: %s#%s=%s%n", jmxType.getName(), name, jmxSetting.getDefaultValue()); + SettingDescriptor javaSetting = javaSettings.remove(name); + Asserts.assertNotNull(javaSetting, "No Setting for name " + name); + Asserts.assertEquals(jmxSetting.getDefaultValue(), Events.getSetting(javaType, name).getDefaultValue(), "Wrong default value"); + Asserts.assertEquals(jmxSetting.getDescription(), javaSetting.getDescription(), "Wrong description"); + Asserts.assertEquals(jmxSetting.getLabel(), javaSetting.getLabel(), "Wrong label"); + Asserts.assertEquals(jmxSetting.getName(), javaSetting.getName(), "Wrong name"); + Asserts.assertEquals(jmxSetting.getTypeName(), javaSetting.getTypeName(), "Wrong type name"); + Asserts.assertEquals(jmxSetting.getContentType(), javaSetting.getContentType()); + } + + // Verify that all Settings have been matched. + if (!javaSettings.isEmpty()) { + for (String name : javaSettings.keySet()) { + System.out.println("Missing setting" + name + " in EventTypeInfo for " + javaType.getName()); + } + System.out.println(); + System.out.println(javaType.getName() + " Java API"); + System.out.println("==============="); + for (SettingDescriptor v : javaType.getSettingDescriptors()) { + System.out.println(" - " + v.getName()); + } + System.out.println(); + System.out.println(jmxType.getName() + " JMX API"); + System.out.println("==============="); + for (SettingDescriptorInfo v : jmxType.getSettingDescriptors()) { + System.out.println(" - " + v.getName()); + } + + Asserts.fail("Missing setting"); + } + } + + + public static FlightRecorderMXBean getFlighteRecorderMXBean() { + return ManagementFactory.getPlatformMXBean(FlightRecorderMXBean.class); + } + +} diff --git a/test/jdk/jfr/jmx/TEST.properties b/test/jdk/jfr/jmx/TEST.properties new file mode 100644 index 0000000000000000000000000000000000000000..008169be025a786ee5e74df40009e05d9c3a2132 --- /dev/null +++ b/test/jdk/jfr/jmx/TEST.properties @@ -0,0 +1,2 @@ +modules = jdk.management.jfr + diff --git a/test/jdk/jfr/jmx/TestClone.java b/test/jdk/jfr/jmx/TestClone.java new file mode 100644 index 0000000000000000000000000000000000000000..d50b679fd478462b79fdedba29a1a5c77c2dafc1 --- /dev/null +++ b/test/jdk/jfr/jmx/TestClone.java @@ -0,0 +1,102 @@ +/* + * 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 + * 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.jmx; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Iterator; +import java.util.List; + +import jdk.jfr.RecordingState; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.management.jfr.RecordingInfo; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventField; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.SimpleEventHelper; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.TestClone + */ +public class TestClone { + public static void main(String[] args) throws Exception { + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + + long orgId = bean.newRecording(); + bean.startRecording(orgId); + SimpleEventHelper.createEvent(1); // Should be in both org and clone + + long cloneId = bean.cloneRecording(orgId, false); + Asserts.assertNotEquals(orgId, cloneId, "clone id should not be same as org id"); + + List recordings = bean.getRecordings(); + JmxHelper.verifyState(orgId, RecordingState.RUNNING, recordings); + JmxHelper.verifyState(cloneId, RecordingState.RUNNING, recordings); + + bean.stopRecording(orgId); + recordings = bean.getRecordings(); + JmxHelper.verifyState(orgId, RecordingState.STOPPED, recordings); + JmxHelper.verifyState(cloneId, RecordingState.RUNNING, recordings); + + SimpleEventHelper.createEvent(2); // Should only be in clone + + bean.stopRecording(cloneId); + recordings = bean.getRecordings(); + JmxHelper.verifyState(orgId, RecordingState.STOPPED, recordings); + JmxHelper.verifyState(cloneId, RecordingState.STOPPED, recordings); + + Path orgPath = Paths.get(".", "org.jfr"); + Path clonePath = Paths.get(".", "clone.jfr"); + bean.copyTo(orgId, orgPath.toString()); + bean.copyTo(cloneId, clonePath.toString()); + + verifyEvents(orgPath, 1); + verifyEvents(clonePath, 1, 2); + + bean.closeRecording(orgId); + bean.closeRecording(cloneId); + } + + private static void verifyEvents(Path path, int... ids) throws Exception { + List events = RecordingFile.readAllEvents(path); + Iterator iterator = events.iterator(); + for (int i=0; i ids = new ArrayList<>(); + for (int i=0; i<5; i++) { + long cloneId = bean.cloneRecording(orgId, false); + SimpleEventHelper.createEvent(i); + bean.stopRecording(cloneId); + Path path = Paths.get(".", i + "-org.jfr"); + bean.copyTo(cloneId, path.toString()); + bean.closeRecording(cloneId); + ids.add(i); + verifyEvents(path, ids); + } + + bean.closeRecording(orgId); + } + + private static void verifyEvents(Path path, List ids) throws Exception { + List events = RecordingFile.readAllEvents(path); + Iterator iterator = events.iterator(); + for (int i=0; i cc = new HashMap<>(); + for (Configuration c : Configuration.getConfigurations()) { + cc.put(c.getName(), c); + } + Asserts.assertTrue(!cc.isEmpty(), "Mising configurations, can't verify ConfigurationInfo"); + for (ConfigurationInfo ci : JmxHelper.getFlighteRecorderMXBean().getConfigurations()) { + Configuration c = cc.remove(ci.getName()); + Asserts.assertNotNull(c, "Superfluous configuration " + ci.getName()); + Asserts.assertEquals(c.getDescription(), ci.getDescription(), "Descriptions don't match"); + Asserts.assertEquals(c.getLabel(), ci.getLabel(), "Labels don't match"); + Asserts.assertEquals(c.getProvider(), ci.getProvider(), "Providers don't match"); + Asserts.assertEquals(c.getContents(), ci.getContents(), "Contents don't match"); + Asserts.assertEquals(c.getSettings(), ci.getSettings(), "Settings don't match"); + } + Asserts.assertTrue(cc.isEmpty(), "Missing configuration in FlightRecorderMXBean, " + cc.keySet()); + } +} diff --git a/test/jdk/jfr/jmx/TestCopyTo.java b/test/jdk/jfr/jmx/TestCopyTo.java new file mode 100644 index 0000000000000000000000000000000000000000..54bc791a6d1554bc34b8c2aeacf930bf89df509f --- /dev/null +++ b/test/jdk/jfr/jmx/TestCopyTo.java @@ -0,0 +1,65 @@ +/* + * 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 + * 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.jmx; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.SimpleEventHelper; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.TestCopyTo + */ +public class TestCopyTo { + public static void main(String[] args) throws Exception { + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + + long recId = bean.newRecording(); + bean.startRecording(recId); + SimpleEventHelper.createEvent(1); + bean.stopRecording(recId); + + Path path = Paths.get(".", "my.jfr"); + bean.copyTo(recId, path.toString()); + + List events = RecordingFile.readAllEvents(path); + Asserts.assertTrue(events.iterator().hasNext(), "No events found"); + for (RecordedEvent event : events) { + System.out.println("Event:" + event); + } + + bean.closeRecording(recId); + } +} diff --git a/test/jdk/jfr/jmx/TestCopyToInvalidPath.java b/test/jdk/jfr/jmx/TestCopyToInvalidPath.java new file mode 100644 index 0000000000000000000000000000000000000000..7d8e4f37aeff73b0e47104d0812529ea8da8a2e4 --- /dev/null +++ b/test/jdk/jfr/jmx/TestCopyToInvalidPath.java @@ -0,0 +1,59 @@ +/* + * 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 + * 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.jmx; + +import java.io.IOException; +import java.nio.file.Paths; + +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.test.lib.jfr.CommonHelper; +import jdk.test.lib.jfr.SimpleEventHelper; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.TestCopyToInvalidPath + */ +public class TestCopyToInvalidPath { + public static void main(String[] args) throws Throwable { + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + + long recId = bean.newRecording(); + bean.startRecording(recId); + SimpleEventHelper.createEvent(1); + bean.stopRecording(recId); + + CommonHelper.verifyException(()->{bean.copyTo(recId, null);}, "copyTo(null)", NullPointerException.class); + CommonHelper.verifyException(()->{bean.copyTo(recId, "");}, "copyTo('')", IOException.class); + + String p = Paths.get(".", "thisdir", "doesnot", "exists").toString(); + CommonHelper.verifyException(()->{bean.copyTo(recId, p);}, "copyTo(dirNotExist)", IOException.class); + + bean.closeRecording(recId); + } +} diff --git a/test/jdk/jfr/jmx/TestCopyToReadOnlyDir.java b/test/jdk/jfr/jmx/TestCopyToReadOnlyDir.java new file mode 100644 index 0000000000000000000000000000000000000000..51efe66e9d2c36a342d2f7263078b1aa904635fb --- /dev/null +++ b/test/jdk/jfr/jmx/TestCopyToReadOnlyDir.java @@ -0,0 +1,72 @@ +/* + * 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 + * 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.jmx; + +import java.nio.file.AccessDeniedException; +import java.nio.file.Path; +import java.nio.file.Paths; + +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.FileHelper; +import jdk.test.lib.jfr.SimpleEventHelper; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.TestCopyToReadOnlyDir + */ +public class TestCopyToReadOnlyDir { + public static void main(String[] args) throws Throwable { + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + + long recId = bean.newRecording(); + bean.startRecording(recId); + SimpleEventHelper.createEvent(1); + bean.stopRecording(recId); + + Path readOnlyDir = FileHelper.createReadOnlyDir(Paths.get(".", "readOnlyDir")); + System.out.println("readOnlyDir=" + readOnlyDir.toString()); + Asserts.assertTrue(readOnlyDir.toFile().isDirectory(), "Could not create directory. Test error"); + if (!FileHelper.isReadOnlyPath(readOnlyDir)) { + System.out.println("Failed to create read-only dir. Maybe running as root? Skipping test"); + return; + } + + Path file = Paths.get(readOnlyDir.toString(), "my.jfr"); + System.out.println("file=" + file.toString()); + try { + bean.copyTo(recId, file.toString()); + Asserts.fail("Should be able to dump to read only file"); + } catch (AccessDeniedException e) { + // ok as expected + } + + bean.closeRecording(recId); + } +} diff --git a/test/jdk/jfr/jmx/TestCopyToRunning.java b/test/jdk/jfr/jmx/TestCopyToRunning.java new file mode 100644 index 0000000000000000000000000000000000000000..df41634c42b0b1f2610e91f4151c4b62166fbf96 --- /dev/null +++ b/test/jdk/jfr/jmx/TestCopyToRunning.java @@ -0,0 +1,83 @@ +/* + * 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 + * 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.jmx; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; +import jdk.jfr.RecordingState; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.SimpleEventHelper; + +/** + * @test + * @key jfr + * @summary Copy a recording to file while it is running. + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.TestCopyToRunning + */ +public class TestCopyToRunning { + public static void main(String[] args) throws Exception { + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + + long recId = bean.newRecording(); + bean.startRecording(recId); + SimpleEventHelper.createEvent(1); + + Path path = Paths.get(".", "my.jfr"); + bean.copyTo(recId, path.toString()); + + List events = RecordingFile.readAllEvents(path); + Asserts.assertTrue(events.iterator().hasNext(), "No events found"); + for (RecordedEvent event : events) { + System.out.println("Event:" + event); + } + + Recording recording = getRecording(recId); + Asserts.assertEquals(recording.getState(), RecordingState.RUNNING, "Recording not in state running"); + bean.stopRecording(recId); + Asserts.assertEquals(recording.getState(), RecordingState.STOPPED, "Recording not in state stopped"); + bean.closeRecording(recId); + Asserts.assertEquals(recording.getState(), RecordingState.CLOSED, "Recording not in state closed"); + } + + private static Recording getRecording(long recId) { + for (Recording r : FlightRecorder.getFlightRecorder().getRecordings()) { + if (r.getId() == recId) { + return r; + } + } + Asserts.fail("Could not find recording with id " + recId); + return null; + } +} diff --git a/test/jdk/jfr/jmx/TestEventTypes.java b/test/jdk/jfr/jmx/TestEventTypes.java new file mode 100644 index 0000000000000000000000000000000000000000..2a20c43a4e4749695fac5b27962a270d43dc9e95 --- /dev/null +++ b/test/jdk/jfr/jmx/TestEventTypes.java @@ -0,0 +1,156 @@ +/* + * 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 + * 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.jmx; + +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Description; +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorder; +import jdk.jfr.Label; +import jdk.jfr.Name; +import jdk.jfr.Recording; +import jdk.jfr.SettingDescriptor; +import jdk.management.jfr.EventTypeInfo; +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.management.jfr.SettingDescriptorInfo; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * @summary Verifies that EventTypes from jmx and FlightRecorder are the same. + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.TestEventTypes + */ +public class TestEventTypes { + public static void main(String[] args) throws Exception { + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + FlightRecorder jfr = FlightRecorder.getFlightRecorder(); + + Recording r = new Recording(); + r.enable(MyEvent.class); + new MyEvent(); // triggers + List infos = bean.getEventTypes(); + List types = jfr.getEventTypes(); + Asserts.assertFalse(infos.isEmpty(), "No EventTypeInfos found"); + verifyMyEventType(infos); + assertSame(infos, types); + r.close(); + } + + @Name("MyEvent.name") + @Label("MyEvent.label") + @Description("MyEvent.description") + private static class MyEvent extends Event { + @Label("MyEvent.message") + public String message; + } + + private static void verifyMyEventType(List infos) { + for (EventTypeInfo info : infos) { + if ("MyEvent.name".equals(info.getName())) { + System.out.println("EventTypeInfo for MyEvent: " + info); + Asserts.assertEquals("MyEvent.label", info.getLabel()); + Asserts.assertEquals("MyEvent.description", info.getDescription()); + for (SettingDescriptorInfo si : info.getSettingDescriptors()) { + System.out.println("si=" + si); + } + return; + } + } + Asserts.fail("Missing EventTypeInfo for MyEvent"); + } + + private static void assertSame(List infos, List types) { + List ids = new ArrayList<>(); + for (EventTypeInfo info : infos) { + long id = info.getId(); + Asserts.assertFalse(ids.contains(id), "EventTypeInfo.id not unique:" + id); + ids.add(id); + boolean isFound = false; + for (EventType type : types) { + if (type.getId() == id) { + assertSame(info, type); + isFound = true; + break; + } + } + if (!isFound) { + String msg = "No EventType for EventTypeInfo"; + System.out.println(msg + ": " + info); + Asserts.fail(msg); + } + } + Asserts.assertEquals(infos.size(), types.size(), "Number of EventTypeInfos != EventTypes"); + } + + private static void assertSame(EventTypeInfo ti, EventType t) { + try { + Asserts.assertEquals(ti.getId(), t.getId(), "Wrong id"); + Asserts.assertEquals(ti.getName(), t.getName(), "Wrong name"); + Asserts.assertEquals(ti.getLabel(), t.getLabel(), "Wrong label"); + Asserts.assertEquals(ti.getDescription(), t.getDescription(), "Wrong description"); + Asserts.assertEquals(ti.getCategoryNames(), t.getCategoryNames(), "Wrong category names"); + + for (SettingDescriptorInfo si : ti.getSettingDescriptors()) { + String settingName = si.getName(); + boolean isFound = false; + for (SettingDescriptor d : t.getSettingDescriptors()) { + if (settingName.equals(d.getName())) { + assertSame(si, d, t); + isFound = true; + break; + } + } + if (!isFound) { + Asserts.fail("No ValueDescriptor for SettingDescriptorInfo: " + si); + } + } + } catch (Exception e) { + System.out.printf("EventTypeInfo != EventType%nEventTypeInfo=%s%nEventType=%s%n", ti, t); + throw e; + } + } + + private static void assertSame(SettingDescriptorInfo si, SettingDescriptor d, EventType type) { + try { + Asserts.assertEquals(si.getName(), d.getName(), "Wrong name"); + Asserts.assertEquals(si.getLabel(), d.getLabel(), "Wrong label"); + Asserts.assertEquals(si.getTypeName(), d.getTypeName(), "Wrong typeName"); + Asserts.assertEquals(si.getDescription(), d.getDescription(), "Wrong description"); + String typeDefaultValue = Events.getSetting(type, si.getName()).getDefaultValue(); + Asserts.assertEquals(si.getDefaultValue(), typeDefaultValue, "Wrong defaultValue"); + } catch (Exception e) { + System.out.printf("SettingDescriptorInfo != SettingDescriptor=%s%nValueDescriptor=%s%n", si, d); + throw e; + } + } +} diff --git a/test/jdk/jfr/jmx/TestGetRecordings.java b/test/jdk/jfr/jmx/TestGetRecordings.java new file mode 100644 index 0000000000000000000000000000000000000000..71083690bc9d8dfb0de0f9ebb395d7fb716d9e0f --- /dev/null +++ b/test/jdk/jfr/jmx/TestGetRecordings.java @@ -0,0 +1,50 @@ +/* + * 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 + * 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.jmx; + +import java.util.List; + +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.management.jfr.RecordingInfo; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.TestGetRecordings + */ +public class TestGetRecordings { + public static void main(String[] args) throws Throwable { + FlightRecorderMXBean bean =JmxHelper.getFlighteRecorderMXBean(); + + List preCreateRecordings = bean.getRecordings(); + long recId = bean.newRecording(); + JmxHelper.verifyNotExists(recId, preCreateRecordings); + bean.closeRecording(recId); + JmxHelper.verifyNotExists(recId, bean.getRecordings()); + } +} diff --git a/test/jdk/jfr/jmx/TestGetRecordingsMultiple.java b/test/jdk/jfr/jmx/TestGetRecordingsMultiple.java new file mode 100644 index 0000000000000000000000000000000000000000..4817a1fe06d3008b2c414c155e8ea2506044cb5e --- /dev/null +++ b/test/jdk/jfr/jmx/TestGetRecordingsMultiple.java @@ -0,0 +1,122 @@ +/* + * 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 + * 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.jmx; + +import java.util.ArrayList; +import java.util.List; + +import jdk.management.jfr.RecordingInfo; +import jdk.test.lib.Asserts; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.TestGetRecordingsMultiple + */ +public class TestGetRecordingsMultiple { + + private static class TestRecording { + long id; + boolean isClosed; + public TestRecording(long id) { + this.id = id; + isClosed = false; + } + } + + public static void main(String[] args) throws Throwable { + List testRecordings = new ArrayList<>(); + for (int i = 0; i < 5; ++i) { + verifyExistingRecordings(testRecordings); + testRecordings.add(createRecording()); + if (i >= 1) { + startRecording(testRecordings.get(i-1)); + } + if (i >= 2) { + stopRecording(testRecordings.get(i-2)); + } + if (i >= 3) { + closeRecording(testRecordings.get(i-3)); + } + } + verifyExistingRecordings(testRecordings); + + for (TestRecording r : testRecordings) { + if (!r.isClosed) { + closeRecording(r); + } + } + verifyExistingRecordings(testRecordings); + } + + // Verify that all active recordings are found, but no closed recordings. + private static void verifyExistingRecordings(List testRecordings) { + for (TestRecording testRecording : testRecordings) { + RecordingInfo r = findRecording(testRecording); + if (r != null) { + Asserts.assertFalse(testRecording.isClosed, "Found closed recording with id " + testRecording.id); + System.out.printf("Recording %d: %s%n", r.getId(), r.getState()); + } else { + Asserts.assertTrue(testRecording.isClosed, "Missing recording with id " + testRecording.id); + System.out.printf("Recording %d: CLOSED%n", testRecording.id); + } + } + } + + private static RecordingInfo findRecording(TestRecording testRecording) { + for (RecordingInfo r : JmxHelper.getFlighteRecorderMXBean().getRecordings()) { + if (r.getId() == testRecording.id) { + return r; + } + } + return null; + } + + private static TestRecording createRecording() { + long id = JmxHelper.getFlighteRecorderMXBean().newRecording(); + System.out.println("created recording " + id); + return new TestRecording(id); + } + + private static void startRecording(TestRecording rec) { + System.out.println("starting recording " + rec.id); + JmxHelper.getFlighteRecorderMXBean().startRecording(rec.id); + } + + private static void stopRecording(TestRecording rec) { + System.out.println("stopping recording " + rec.id); + JmxHelper.getFlighteRecorderMXBean().stopRecording(rec.id); + } + + private static void closeRecording(TestRecording rec) throws Exception { + System.out.println("closing recording " + rec.id); + JmxHelper.getFlighteRecorderMXBean().closeRecording(rec.id); + rec.isClosed = true; + + } +} diff --git a/test/jdk/jfr/jmx/TestMultipleRecordings.java b/test/jdk/jfr/jmx/TestMultipleRecordings.java new file mode 100644 index 0000000000000000000000000000000000000000..dd05232d47c6fb6b6fa6fc1780eed207aade8507 --- /dev/null +++ b/test/jdk/jfr/jmx/TestMultipleRecordings.java @@ -0,0 +1,95 @@ +/* + * 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 + * 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.jmx; + +import java.util.List; + +import jdk.jfr.RecordingState; +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.management.jfr.RecordingInfo; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.TestMultipleRecordings + */ +public class TestMultipleRecordings { + public static void main(String[] args) throws Throwable { + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + System.out.println("bean.class=" + bean.getClass().getName()); + + // Start recA + long recIdA = createRecording(bean); + startRecording(recIdA, bean); + + // Start recB + long recIdB = createRecording(bean); + startRecording(recIdB, bean); + + // Stop and destroy recA + stopRecording(recIdA, bean); + destroyRecording(recIdA, bean); + + // Start, stop and destroy recC + long recIdC = createRecording(bean); + startRecording(recIdC, bean); + stopRecording(recIdC, bean); + destroyRecording(recIdC, bean); + + // Stop and destroy recB + stopRecording(recIdB, bean); + destroyRecording(recIdB, bean); + } + + private static long createRecording(FlightRecorderMXBean bean) throws Exception { + List preCreateRecordings = bean.getRecordings(); + long recId = bean.newRecording(); + JmxHelper.verifyNotExists(recId, preCreateRecordings); + JmxHelper.verifyState(recId, RecordingState.NEW, bean); + return recId; + } + + private static void startRecording(long recId, FlightRecorderMXBean bean) throws Exception { + JmxHelper.verifyState(recId, RecordingState.NEW, bean); + bean.startRecording(recId); + JmxHelper.verifyState(recId, RecordingState.RUNNING, bean); + } + + private static void stopRecording(long recId, FlightRecorderMXBean bean) throws Exception { + JmxHelper.verifyState(recId, RecordingState.RUNNING, bean); + bean.stopRecording(recId); + JmxHelper.verifyState(recId, RecordingState.STOPPED, bean); + } + + private static void destroyRecording(long recId, FlightRecorderMXBean bean) throws Exception { + JmxHelper.verifyState(recId, RecordingState.STOPPED, bean); + bean.closeRecording(recId); + JmxHelper.verifyNotExists(recId, bean.getRecordings()); + } + +} diff --git a/test/jdk/jfr/jmx/TestNotificationListener.java b/test/jdk/jfr/jmx/TestNotificationListener.java new file mode 100644 index 0000000000000000000000000000000000000000..09b6cbd39292e9a57391d0cbd9016160216c29e3 --- /dev/null +++ b/test/jdk/jfr/jmx/TestNotificationListener.java @@ -0,0 +1,65 @@ +/* + * 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. 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.jmx; + +import java.lang.management.ManagementFactory; +import java.util.concurrent.CountDownLatch; + +import javax.management.Notification; +import javax.management.NotificationListener; +import javax.management.ObjectName; + +import jdk.management.jfr.FlightRecorderMXBean; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.TestNotificationListener + */ +public class TestNotificationListener { + + private final static CountDownLatch latch = new CountDownLatch(1); + + private final static NotificationListener listener = new NotificationListener() { + public void handleNotification(Notification notification, Object handback) { + System.out.println("Got notification: " + notification); + latch.countDown(); + } + }; + + public static void main(String[] args) throws Throwable { + ObjectName objectName = new ObjectName(FlightRecorderMXBean.MXBEAN_NAME); + ManagementFactory.getPlatformMBeanServer().addNotificationListener(objectName, listener, null, null); + FlightRecorderMXBean bean = ManagementFactory.getPlatformMXBean(FlightRecorderMXBean.class); + + long recId = bean.newRecording(); + bean.startRecording(recId); + + latch.await(); + System.out.println("Completed successfully"); + } +} diff --git a/test/jdk/jfr/jmx/TestPredefinedConfiguration.java b/test/jdk/jfr/jmx/TestPredefinedConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..2d7d6f21c1061327d4a578b63a5afea296e2f889 --- /dev/null +++ b/test/jdk/jfr/jmx/TestPredefinedConfiguration.java @@ -0,0 +1,61 @@ +/* + * 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 + * 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.jmx; + +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.Configuration; +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.management.jfr.RecordingInfo; +import jdk.test.lib.Asserts; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.TestPredefinedConfiguration + */ +public class TestPredefinedConfiguration { + public static void main(String[] args) throws Exception { + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + + long recId = bean.newRecording(); + List configNames = new ArrayList<>(); + for (Configuration config : Configuration.getConfigurations()) { + System.out.println("name=" + config.getName()); + configNames.add(config.getName()); + bean.setPredefinedConfiguration(recId, config.getName()); + + RecordingInfo jmxRecording = JmxHelper.getJmxRecording(recId); + JmxHelper.verifyMapEquals(jmxRecording.getSettings(), config.getSettings()); + JmxHelper.verifyMapEquals(bean.getRecordingSettings(recId), config.getSettings()); + } + Asserts.assertTrue(configNames.contains("default"), "Missing config 'default'"); + Asserts.assertTrue(configNames.contains("profile"), "Missing config 'profile'"); + } +} diff --git a/test/jdk/jfr/jmx/TestPredefinedConfigurationInvalid.java b/test/jdk/jfr/jmx/TestPredefinedConfigurationInvalid.java new file mode 100644 index 0000000000000000000000000000000000000000..f1a462e537b77ede3b062a2204d0696a5fe3033e --- /dev/null +++ b/test/jdk/jfr/jmx/TestPredefinedConfigurationInvalid.java @@ -0,0 +1,75 @@ +/* + * 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 + * 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.jmx; + +import jdk.jfr.Configuration; +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.CommonHelper; +import jdk.test.lib.jfr.VoidFunction; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.TestPredefinedConfigurationInvalid + */ +public class TestPredefinedConfigurationInvalid { + public static void main(String[] args) throws Throwable { + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + + long recId = bean.newRecording(); + + // Test invalid named configs. + verifyNullPointer(()->{ bean.setPredefinedConfiguration(recId, null); }, "setNamedConfig(null)"); + setInvalidConfigName(recId, ""); + setInvalidConfigName(recId, "invalidname"); + + // Verify we can set named config after failed attempts. + Configuration config = Configuration.getConfigurations().get(0); + bean.setPredefinedConfiguration(recId, config.getName()); + JmxHelper.verifyMapEquals(bean.getRecordingSettings(recId), config.getSettings()); + } + + private static void setInvalidConfigName(long recId, String name) { + try { + JmxHelper.getFlighteRecorderMXBean().setPredefinedConfiguration(recId, name); + Asserts.fail("Missing Exception when setNamedConfig('" + name + "')"); + } catch (IllegalArgumentException e) { + // Expected exception. + String msg = e.getMessage().toLowerCase(); + System.out.println("Got expected exception: " + msg); + String expectMsg = "not find configuration"; + Asserts.assertTrue(msg.contains(expectMsg), String.format("No '%s' in '%s'", expectMsg, msg)); + } + } + + private static void verifyNullPointer(VoidFunction f, String msg) throws Throwable { + CommonHelper.verifyException(f, msg, NullPointerException.class); + } + +} diff --git a/test/jdk/jfr/jmx/TestRecordingOptions.java b/test/jdk/jfr/jmx/TestRecordingOptions.java new file mode 100644 index 0000000000000000000000000000000000000000..37e09111c79a9638b38c691ea197a2d3364e5586 --- /dev/null +++ b/test/jdk/jfr/jmx/TestRecordingOptions.java @@ -0,0 +1,130 @@ +/* + * 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 + * 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.jmx; + +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; + +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.test.lib.Asserts; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.TestRecordingOptions + */ +public class TestRecordingOptions { + @SuppressWarnings({ "rawtypes", "unchecked" }) + public static void main(String[] args) throws Exception { + Map options = new HashMap<>(); + options.put("name", "myName"); + options.put("maxAge", "2 h"); + options.put("maxSize", "1234567890"); + options.put("dumpOnExit", "false"); + options.put("disk", "false"); + options.put("duration", "1 h"); // don't want recording to stop + + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + long recId = bean.newRecording(); + Map defaults = bean.getRecordingOptions(recId); + bean.setRecordingOptions(recId, options); + + // Verify that all options have been set. We only check the option we + // have set. Unknown options are ignored. + Map outOptions = bean.getRecordingOptions(recId); + logMap("set options", options); + logMap("get options", outOptions); + for (String key : options.keySet()) { + Asserts.assertTrue(outOptions.containsKey(key), "Missing key " + key); + Asserts.assertEquals(options.get(key), outOptions.get(key), "Wrong value for key " + key); + } + + // Verify options in RecordingInfo + Asserts.assertEquals(outOptions.get("name"), "myName", "Wrong name"); + Asserts.assertEquals(outOptions.get("maxAge"), "2 h", "Wrong maxAge"); + Asserts.assertEquals(outOptions.get("maxSize"), "1234567890", "Wrong maxSize"); + Asserts.assertEquals(outOptions.get("dumpOnExit"), "false", "Wrong dumpOnExit"); + Asserts.assertEquals(outOptions.get("disk"), "false", "Wrong disk"); + Asserts.assertEquals(outOptions.get("duration"), "1 h", "Wrong duration"); + + // try empty map + bean.setRecordingOptions(recId, new HashMap<>()); + + // try map that does not have string keys + Map invalidKeys = new HashMap<>(); + invalidKeys.put(4711, "value"); + try { + bean.setRecordingOptions(recId, (Map) invalidKeys); + throw new Error("Expected IllagalStateException for non String key"); + } catch (IllegalArgumentException iae) { + // OK, as expected + } + // try map that does not have string values + Map invalidValues = new HashMap<>(); + invalidValues.put("duration", 4711); + try { + bean.setRecordingOptions(recId, (Map) invalidKeys); + throw new Error("Expected IllagalStateException for non String value"); + } catch (IllegalArgumentException iae) { + // OK, as expected + } + + // Try one incorrect value, and make sure non + // of the other values are set. + Map lastIncorrect = new LinkedHashMap<>(); + lastIncorrect.put("duration", "10 h"); + lastIncorrect.put("whatever", "4711"); + try { + bean.setRecordingOptions(recId, lastIncorrect); + throw new Error("Expected IllagalStateException for incorrect key"); + } catch (IllegalArgumentException iae) { + // ok + Asserts.assertEquals("1 h", bean.getRecordingOptions(recId).get("duration")); + } + + // verify that defaults are set back, if we use null + Map nullMap = new HashMap<>(); + nullMap.put("name", null); + nullMap.put("maxAge", null); + nullMap.put("maxSize", null); + nullMap.put("dumpOnExit", null); + nullMap.put("disk", null); + nullMap.put("duration", null); + bean.setRecordingOptions(recId, nullMap); + Asserts.assertEquals(bean.getRecordingOptions(recId), defaults); + + bean.closeRecording(recId); + } + + private static void logMap(String name, Map map) { + for (String key : map.keySet()) { + System.out.printf("%s: %s=%s%n", name, key, map.get(key)); + } + } +} diff --git a/test/jdk/jfr/jmx/TestRecordingSettings.java b/test/jdk/jfr/jmx/TestRecordingSettings.java new file mode 100644 index 0000000000000000000000000000000000000000..9365964592c2fd48e93d98b9297af4e02fc6fa1e --- /dev/null +++ b/test/jdk/jfr/jmx/TestRecordingSettings.java @@ -0,0 +1,76 @@ +/* + * 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 + * 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.jmx; + +import java.util.HashMap; +import java.util.Map; + +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.test.lib.Asserts; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.TestRecordingSettings + */ +public class TestRecordingSettings { + public static void main(String[] args) throws Exception { + Map settings = new HashMap<>(); + settings.put("java.exception_throw#enabled", "false"); + settings.put("java.exception_throw#threshold", "2 s"); + settings.put("java.exception_throw#thread", "true"); + settings.put("java.exception_throw#stackTrace", "false"); + settings.put("os.information#enabled", "true"); + settings.put("os.information#period", "400 ms"); + + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + long recId = bean.newRecording(); + bean.setRecordingSettings(recId, settings); + + // Verify that JMX input and output settings are equal. + JmxHelper.verifyMapEquals(settings, JmxHelper.getFlighteRecorderMXBean().getRecordingSettings(recId)); + + // Verify that settings from Java API is correct. + Recording recording = null; + for (Recording r : FlightRecorder.getFlightRecorder().getRecordings()) { + if (r.getId() == recId) { + recording = r; + break; + } + } + Asserts.assertNotNull(recording, "No Recording with id " + recId); + JmxHelper.verifyMapEquals(settings, recording.getSettings()); + + bean.startRecording(recId); + bean.stopRecording(recId); + bean.closeRecording(recId); + } + +} diff --git a/test/jdk/jfr/jmx/TestRecordingSettingsInvalid.java b/test/jdk/jfr/jmx/TestRecordingSettingsInvalid.java new file mode 100644 index 0000000000000000000000000000000000000000..af787c883a5a0d9f58d3e406b05159ad3f0ea7be --- /dev/null +++ b/test/jdk/jfr/jmx/TestRecordingSettingsInvalid.java @@ -0,0 +1,81 @@ +/* + * 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 + * 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.jmx; + +import java.util.HashMap; +import java.util.Map; + +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.test.lib.Asserts; + +/** + * @test + * @key jfr + * @summary Verify exception when setting invalid settings. + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.TestRecordingSettingsInvalid + */ +public class TestRecordingSettingsInvalid { + public static void main(String[] args) throws Exception { + Map settings = new HashMap<>(); + settings.put(null, "true"); + settings.put("java.exception_throw#stackTrace", null); + settings.put("java.exception_throw#threshold", "not-a-number"); + settings.put("os.information#period", "4 x"); + + // TODO: No exception for these settings. Not sure how much validation can be done on settings. + //settings.put("java.exception_throw#enabled", "maybe"); + //settings.put("os.information#period", "-4 s"); + //settings.put("java.exception_throw#thread", ""); + //settings.put("", "true"); + //settings.put("os.information#what", "4 ms"); + //settings.put("#", "4 what"); + //settings.put("java.exception_throw#", "true"); + //settings.put("java.exception_throwenabled", "false"); + + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + + for (String key : settings.keySet()) { + System.out.printf("settings: %s=%s%n", key, settings.get(key)); + Map temp = new HashMap(); + temp.put(key, settings.get(key)); + long recId = -1; + try { + recId = bean.newRecording(); + bean.setRecordingSettings(recId, temp); + bean.startRecording(recId); + bean.stopRecording(recId); + Asserts.fail("Missing exception"); + } catch (Exception e) { + System.out.println("Got expected exception: " + e.getMessage()); + } finally { + bean.closeRecording(recId); + } + } + } + +} diff --git a/test/jdk/jfr/jmx/TestRecordingSettingsMultiple.java b/test/jdk/jfr/jmx/TestRecordingSettingsMultiple.java new file mode 100644 index 0000000000000000000000000000000000000000..2f5838d2b775e6a8219a423462a7525d73f0d31e --- /dev/null +++ b/test/jdk/jfr/jmx/TestRecordingSettingsMultiple.java @@ -0,0 +1,87 @@ +/* + * 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 + * 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.jmx; + +import java.util.HashMap; +import java.util.Map; + +import jdk.management.jfr.FlightRecorderMXBean; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.TestRecordingSettingsMultiple + */ +public class TestRecordingSettingsMultiple { + public static void main(String[] args) throws Exception { + Map settingsA = new HashMap<>(); + settingsA.put("java.exception_throw#enabled", "false"); + settingsA.put("java.exception_throw#threshold", "2 s"); + settingsA.put("java.exception_throw#thread", "true"); + settingsA.put("java.exception_throw#stackTrace", "false"); + settingsA.put("os.information#enabled", "true"); + settingsA.put("os.information#period", "400 ms"); + + Map settingsB = new HashMap<>(); + settingsB.put("vm/code_sweeper/config#enabled", "true"); + settingsB.put("vm/code_sweeper/config#period", "everyChunk"); + settingsA.put("java.exception_throw#enabled", "true"); + settingsA.put("java.exception_throw#threshold", "6 m"); + settingsB.put("os.information#enabled", "true"); + settingsB.put("os.information#period", "0 ms"); + + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + long recIdA = bean.newRecording(); + long recIdB = bean.newRecording(); + bean.setRecordingSettings(recIdA, settingsA); + bean.setRecordingSettings(recIdB, settingsB); + + JmxHelper.verifyMapEquals(settingsA, bean.getRecordingSettings(recIdA)); + JmxHelper.verifyMapEquals(settingsB, bean.getRecordingSettings(recIdB)); + JmxHelper.verifyMapEquals(settingsA, JmxHelper.getJavaRecording(recIdA).getSettings()); + JmxHelper.verifyMapEquals(settingsB, JmxHelper.getJavaRecording(recIdB).getSettings()); + + bean.startRecording(recIdA); + bean.startRecording(recIdB); + JmxHelper.verifyMapEquals(settingsA, bean.getRecordingSettings(recIdA)); + JmxHelper.verifyMapEquals(settingsB, bean.getRecordingSettings(recIdB)); + JmxHelper.verifyMapEquals(settingsA, JmxHelper.getJavaRecording(recIdA).getSettings()); + JmxHelper.verifyMapEquals(settingsB, JmxHelper.getJavaRecording(recIdB).getSettings()); + + bean.stopRecording(recIdA); + bean.stopRecording(recIdB); + JmxHelper.verifyMapEquals(settingsA, bean.getRecordingSettings(recIdA)); + JmxHelper.verifyMapEquals(settingsB, bean.getRecordingSettings(recIdB)); + JmxHelper.verifyMapEquals(settingsA, JmxHelper.getJavaRecording(recIdA).getSettings()); + JmxHelper.verifyMapEquals(settingsB, JmxHelper.getJavaRecording(recIdB).getSettings()); + + bean.closeRecording(recIdA); + bean.closeRecording(recIdB); + } + +} diff --git a/test/jdk/jfr/jmx/TestRecordingState.java b/test/jdk/jfr/jmx/TestRecordingState.java new file mode 100644 index 0000000000000000000000000000000000000000..603cb6be357aaa8a7d15e4f641b97deb3b6cd8d5 --- /dev/null +++ b/test/jdk/jfr/jmx/TestRecordingState.java @@ -0,0 +1,59 @@ +/* + * 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 + * 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.jmx; + +import java.util.List; + +import jdk.jfr.RecordingState; +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.management.jfr.RecordingInfo; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.TestRecordingState + */ +public class TestRecordingState { + public static void main(String[] args) throws Throwable { + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + + List preCreateRecordings = bean.getRecordings(); + long recId = bean.newRecording(); + JmxHelper.verifyNotExists(recId, preCreateRecordings); + JmxHelper.verifyState(recId, RecordingState.NEW, bean); + + bean.startRecording(recId); + JmxHelper.verifyState(recId, RecordingState.RUNNING, bean); + + bean.stopRecording(recId); + JmxHelper.verifyState(recId, RecordingState.STOPPED, bean); + + bean.closeRecording(recId); + JmxHelper.verifyNotExists(recId, bean.getRecordings()); + } +} diff --git a/test/jdk/jfr/jmx/TestRecordingStateInvalid.java b/test/jdk/jfr/jmx/TestRecordingStateInvalid.java new file mode 100644 index 0000000000000000000000000000000000000000..d1d2bbae9d13d9e539dba45abeff96dcf9fd0e1a --- /dev/null +++ b/test/jdk/jfr/jmx/TestRecordingStateInvalid.java @@ -0,0 +1,97 @@ +/* + * 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 + * 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.jmx; + +import java.util.List; + +import jdk.jfr.RecordingState; +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.management.jfr.RecordingInfo; +import jdk.test.lib.jfr.CommonHelper; +import jdk.test.lib.jfr.VoidFunction; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.TestRecordingStateInvalid + */ +public class TestRecordingStateInvalid { + public static void main(String[] args) throws Throwable { + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + + long recId = createRecording(bean); + verifyIllegalState(()->{ bean.stopRecording(recId); }, "Stop not started"); + + startRecording(recId, bean); + verifyIllegalState(()->{ bean.startRecording(recId); }, "Start already started"); + + stopRecording(recId, bean); + verifyIllegalState(()->{ bean.startRecording(recId); }, "Start already stopped"); + verifyIllegalState(()->{ bean.stopRecording(recId); }, "Stop already stopped"); + + destroyRecording(recId, bean); + verifyIllegalArg(()->{ bean.startRecording(recId); }, "Start already destroyed"); + verifyIllegalArg(()->{ bean.stopRecording(recId); }, "Stop already destroyed"); + + } + + private static long createRecording(FlightRecorderMXBean bean) throws Exception { + List preCreateRecordings = bean.getRecordings(); + long recId = bean.newRecording(); + JmxHelper.verifyNotExists(recId, preCreateRecordings); + JmxHelper.verifyState(recId, RecordingState.NEW, bean); + return recId; + } + + private static void startRecording(long recId, FlightRecorderMXBean bean) throws Exception { + JmxHelper.verifyState(recId, RecordingState.NEW, bean); + bean.startRecording(recId); + JmxHelper.verifyState(recId, RecordingState.RUNNING, bean); + } + + private static void stopRecording(long recId, FlightRecorderMXBean bean) throws Exception { + JmxHelper.verifyState(recId, RecordingState.RUNNING, bean); + bean.stopRecording(recId); + JmxHelper.verifyState(recId, RecordingState.STOPPED, bean); + } + + private static void destroyRecording(long recId, FlightRecorderMXBean bean) throws Exception { + JmxHelper.verifyState(recId, RecordingState.STOPPED, bean); + bean.closeRecording(recId); + JmxHelper.verifyNotExists(recId, bean.getRecordings()); + } + + private static void verifyIllegalState(VoidFunction f, String msg) throws Throwable { + CommonHelper.verifyException(f, msg, IllegalStateException.class); + } + + private static void verifyIllegalArg(VoidFunction f, String msg) throws Throwable { + CommonHelper.verifyException(f, msg, IllegalArgumentException.class); + } + +} diff --git a/test/jdk/jfr/jmx/TestSetConfiguration.java b/test/jdk/jfr/jmx/TestSetConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..013cfe8d4e6e2abe80a4fb96708e4776e2966b26 --- /dev/null +++ b/test/jdk/jfr/jmx/TestSetConfiguration.java @@ -0,0 +1,80 @@ +/* + * 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 + * 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.jmx; + +import java.util.HashMap; +import java.util.Map; + +import jdk.jfr.Recording; +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.management.jfr.RecordingInfo; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.TestSetConfiguration + */ +public class TestSetConfiguration { + public static void main(String[] args) throws Exception { + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + long recId = bean.newRecording(); + + final String configContents = + " \n" + + "\n" + + " \r" + + " \t false\r\n" + + " true\t\r\n" + + " 5 ms \n" + + " " + + " " + + " false\n" + + " " + + ""; + + Map expectedSetting = new HashMap<>(); + expectedSetting.put(EventNames.ClassLoad + "#enabled", "false"); + expectedSetting.put(EventNames.ClassLoad + "#stackTrace", "true"); + expectedSetting.put(EventNames.ClassLoad + "#threshold", "5 ms"); + + bean.setConfiguration(recId, configContents); + RecordingInfo jmxRecording = JmxHelper.getJmxRecording(recId); + Recording javaRecording = JmxHelper.getJavaRecording(recId); + JmxHelper.verifyEquals(jmxRecording, javaRecording); + + Map settings = jmxRecording.getSettings(); + for (String name : expectedSetting.keySet()) { + String value = settings.remove(name); + Asserts.assertNotNull(value, "No setting with name " + name); + Asserts.assertEquals(value, expectedSetting.get(name), "Wrong setting value"); + } + Asserts.assertTrue(settings.isEmpty(), "Extra settings found " + settings.keySet()); + } +} diff --git a/test/jdk/jfr/jmx/TestSetConfigurationInvalid.java b/test/jdk/jfr/jmx/TestSetConfigurationInvalid.java new file mode 100644 index 0000000000000000000000000000000000000000..89f92ab682dfe2c6b91bbe581e234144a726f234 --- /dev/null +++ b/test/jdk/jfr/jmx/TestSetConfigurationInvalid.java @@ -0,0 +1,108 @@ +/* + * 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 + * 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.jmx; + +import java.util.HashMap; +import java.util.Map; + +import jdk.jfr.Recording; +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.management.jfr.RecordingInfo; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventNames; + +/** + * @test + * @key jfr + * @summary Verify Exception when setting invalid config. + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.TestSetConfigurationInvalid + */ +public class TestSetConfigurationInvalid { + public static void main(String[] args) throws Exception { + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + long recId = bean.newRecording(); + + final String correctConfig = + " \n" + + "\n" + + " \r" + + " \t false\r\n" + + " true\t\r\n" + + " 5 ms \n" + + " " + + " " + + " false\n" + + " " + + ""; + + Map expectedSetting = new HashMap<>(); + expectedSetting.put(EventNames.ClassLoad + "#enabled", "false"); + expectedSetting.put(EventNames.ClassLoad + "#stackTrace", "true"); + expectedSetting.put(EventNames.ClassLoad + "#threshold", "5 ms"); + + // First set a few invalid configs. Should get Exceptions. + try { + bean.setConfiguration(recId, null); + Asserts.fail("Expected NullPointerException"); + } catch (NullPointerException e) { + // Expected exception + } + + setInvalidConfig(recId, "Dummy text"); + setInvalidConfig(recId, correctConfig.replace("/event", "event")); + setInvalidConfig(recId, correctConfig.replace("", "")); + + // Verify that we can set a correct setting after the failed attempts. + bean.setConfiguration(recId, correctConfig); + RecordingInfo jmxRecording = JmxHelper.getJmxRecording(recId); + Recording javaRecording = JmxHelper.getJavaRecording(recId); + JmxHelper.verifyEquals(jmxRecording, javaRecording); + + Map settings = jmxRecording.getSettings(); + for (String name : expectedSetting.keySet()) { + String value = settings.remove(name); + Asserts.assertNotNull(value, "No setting with name " + name); + Asserts.assertEquals(value, expectedSetting.get(name), "Wrong setting value"); + } + Asserts.assertTrue(settings.isEmpty(), "Extra settings found " + settings.keySet()); + } + + private static void setInvalidConfig(long recId, String config) { + try { + JmxHelper.getFlighteRecorderMXBean().setConfiguration(recId, config); + System.out.printf("Invalid config:%n%s", config); + Asserts.fail("No exception when setting invalid configuration"); + } catch (IllegalArgumentException e) { + // Expected exception + // Simple check if error message is about parse error. + String msg = e.getMessage().toLowerCase(); + Asserts.assertTrue(msg.contains("parse"), String.format("Missing 'parse' in msg '%s'", msg)); + } + } + +} diff --git a/test/jdk/jfr/jmx/TestSnapshot.java b/test/jdk/jfr/jmx/TestSnapshot.java new file mode 100644 index 0000000000000000000000000000000000000000..21ca15c34f58c5531ece24c0921a46b202dc164a --- /dev/null +++ b/test/jdk/jfr/jmx/TestSnapshot.java @@ -0,0 +1,75 @@ +/* + * 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 + * 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.jmx; + +import java.io.IOException; +import java.util.List; + +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.management.jfr.RecordingInfo; +import jdk.test.lib.jfr.SimpleEvent; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.TestSnapshot + */ +public class TestSnapshot { + + public static void main(String[] args) throws Exception { + testEmpty(); + testStopped(); + } + + private static void testStopped() throws IOException { + try (Recording r = new Recording()) { + r.enable(SimpleEvent.class); + r.start(); + SimpleEvent se = new SimpleEvent(); + se.commit(); + r.stop(); + + try (Recording snapshot = FlightRecorder.getFlightRecorder().takeSnapshot()) { + r.close(); + FlightRecorderMXBean mxBean = JmxHelper.getFlighteRecorderMXBean(); + List recs = mxBean.getRecordings(); + JmxHelper.verifyEquals(recs.get(0), snapshot); + } + } + } + + private static void testEmpty() throws IOException { + try (Recording snapshot = FlightRecorder.getFlightRecorder().takeSnapshot()) { + FlightRecorderMXBean mxBean = JmxHelper.getFlighteRecorderMXBean(); + List recs = mxBean.getRecordings(); + JmxHelper.verifyEquals(recs.get(0), snapshot); + } + } +} diff --git a/test/jdk/jfr/jmx/TestStartRecording.java b/test/jdk/jfr/jmx/TestStartRecording.java new file mode 100644 index 0000000000000000000000000000000000000000..4a3b19e4d1546ee6f5e02829ade0f50ee6a7fdcb --- /dev/null +++ b/test/jdk/jfr/jmx/TestStartRecording.java @@ -0,0 +1,66 @@ +/* + * 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 + * 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.jmx; + +import java.util.List; +import java.util.Map; + +import jdk.management.jfr.ConfigurationInfo; +import jdk.management.jfr.EventTypeInfo; +import jdk.management.jfr.FlightRecorderMXBean; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.TestStartRecording + */ +public class TestStartRecording { + public static void main(String[] args) throws Throwable { + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + long recId = bean.newRecording(); + bean.startRecording(recId); + + // TODO: Remove debug logs + List configs = bean.getConfigurations(); + for (ConfigurationInfo config : configs) { + System.out.println("config=" + config.toString()); + } + Map settings = bean.getRecordingSettings(recId); + for (String key : settings.keySet()) { + System.out.println("setting: " + key + "=" + settings.get(key)); + } + List types = bean.getEventTypes(); + for (EventTypeInfo type : types) { + System.out.println("type=" + type.getName()); + } + ////////////////////// + + bean.stopRecording(recId); + bean.closeRecording(recId); + } +} diff --git a/test/jdk/jfr/jmx/TestStream.java b/test/jdk/jfr/jmx/TestStream.java new file mode 100644 index 0000000000000000000000000000000000000000..f2c8ec5887af50a9980f9a1629b9a2e6ae7b4630 --- /dev/null +++ b/test/jdk/jfr/jmx/TestStream.java @@ -0,0 +1,83 @@ +/* + * 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 + * 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.jmx; + +import java.io.IOException; +import java.time.Instant; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jdk.jfr.consumer.RecordedEvent; +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.test.lib.jfr.SimpleEventHelper; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.TestStream + */ +public class TestStream { + public static void main(String[] args) throws Exception { + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + + Instant startTime = Instant.now(); + SimpleEventHelper.createEvent(0); + + long recId = bean.newRecording(); + bean.startRecording(recId); + SimpleEventHelper.createEvent(1); + + bean.stopRecording(recId); + SimpleEventHelper.createEvent(2); + + Instant endTime = Instant.now(); + // Test with ISO-8601 + Map options = new HashMap<>(); + options.put("startTime", startTime.toString()); + options.put("endTime", endTime.toString()); + options.put("blockSize", String.valueOf(50_000)); + verifyStream(bean, recId, options); + // Test with milliseconds since epoch + options.put("startTime", Long.toString(startTime.toEpochMilli())); + options.put("endTime", Long.toString(endTime.toEpochMilli())); + options.put("blockSize", String.valueOf(150_000)); + verifyStream(bean, recId, options); + + bean.closeRecording(recId); + } + + private static void verifyStream(FlightRecorderMXBean bean, long recId, Map options) throws IOException, Exception { + long streamId = bean.openStream(recId, options); + + List events = JmxHelper.parseStream(streamId, bean); + SimpleEventHelper.verifyContains(events, 1); + SimpleEventHelper.verifyNotContains(events, 0, 2); + bean.closeStream(streamId); + } +} diff --git a/test/jdk/jfr/jmx/TestStreamClosed.java b/test/jdk/jfr/jmx/TestStreamClosed.java new file mode 100644 index 0000000000000000000000000000000000000000..f9df6c6b988a8a821ced695f5d9a9ce46aaa8aae --- /dev/null +++ b/test/jdk/jfr/jmx/TestStreamClosed.java @@ -0,0 +1,63 @@ +/* + * 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 + * 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.jmx; + +import java.io.IOException; + +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.SimpleEventHelper; + +/** + * @test + * @key jfr + * @summary Call readStream() after closeStream() + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.TestStreamClosed + */ +public class TestStreamClosed { + public static void main(String[] args) throws Exception { + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + + long recId = bean.newRecording(); + bean.startRecording(recId); + SimpleEventHelper.createEvent(1); + bean.stopRecording(recId); + + long streamId = bean.openStream(recId, null); + bean.closeStream(streamId); + try { + bean.readStream(streamId); + Asserts.fail("No exception whean reading closed stream"); + } catch (IOException e) { + // Expected exception. + String msg = e.getMessage().toLowerCase(); + Asserts.assertTrue(msg.contains("stream") && msg.contains("closed"), "No 'stream closed' in " + msg); + } + bean.closeRecording(recId); + } +} diff --git a/test/jdk/jfr/jmx/TestStreamMultiple.java b/test/jdk/jfr/jmx/TestStreamMultiple.java new file mode 100644 index 0000000000000000000000000000000000000000..7a04ab77185a68996c4aa2eb5524d3412bcd8750 --- /dev/null +++ b/test/jdk/jfr/jmx/TestStreamMultiple.java @@ -0,0 +1,81 @@ +/* + * 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 + * 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.jmx; + +import java.util.List; + +import jdk.jfr.consumer.RecordedEvent; +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.SimpleEventHelper; + +/** + * @test + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.TestStreamMultiple + */ +public class TestStreamMultiple { + + public static void main(String[] args) throws Exception { + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + + SimpleEventHelper.createEvent(0); // No recordings + + long recIdA = bean.newRecording(); + + bean.startRecording(recIdA); + SimpleEventHelper.createEvent(1); // recA + + long recIdB = bean.newRecording(); + Asserts.assertNotEquals(recIdA, recIdB, "Recording Ids should be unique"); + bean.startRecording(recIdB); + SimpleEventHelper.createEvent(2); // recA and recB + + bean.stopRecording(recIdA); + SimpleEventHelper.createEvent(3); // recB + + bean.stopRecording(recIdB); + SimpleEventHelper.createEvent(4); // No recordings + + // Check recA + long streamIdA = bean.openStream(recIdA, null); + List events = JmxHelper.parseStream(streamIdA, bean); + SimpleEventHelper.verifyContains(events, 1, 2); + SimpleEventHelper.verifyNotContains(events, 0, 3, 4); + bean.closeStream(streamIdA); + // check recB + long streamIdB = bean.openStream(recIdB, null); + events = JmxHelper.parseStream(streamIdB, bean); + SimpleEventHelper.verifyContains(events, 2, 3); + SimpleEventHelper.verifyNotContains(events, 0, 1, 4); + bean.closeStream(streamIdB); + + bean.closeRecording(recIdA); + bean.closeRecording(recIdB); + } +} diff --git a/test/jdk/jfr/jmx/TestWrongId.java b/test/jdk/jfr/jmx/TestWrongId.java new file mode 100644 index 0000000000000000000000000000000000000000..ccfd6c38aa0dca5555bb41a05a734fa89494214d --- /dev/null +++ b/test/jdk/jfr/jmx/TestWrongId.java @@ -0,0 +1,64 @@ +/* + * 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 + * 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.jmx; + +import java.util.HashMap; + +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.test.lib.jfr.CommonHelper; +import jdk.test.lib.jfr.VoidFunction; + + +/** + * @test + * @key jfr + * @summary Call functions with invalid argument id. Verify Exception. + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.TestWrongId + */ +public class TestWrongId { + public static void main(String[] args) throws Throwable { + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + final int id = 123456; + verifyIllegalArg(() -> bean.startRecording(id), "startRecording(invalidId)"); + verifyIllegalArg(() -> bean.stopRecording(id), "stopRecording(invalidId)"); + verifyIllegalArg(() -> bean.closeRecording(id), "destroyRecording(invalidId)"); + verifyIllegalArg(() -> bean.openStream(id, null), "openStream(invalidId)"); + verifyIllegalArg(() -> bean.closeStream(id), "closeStream(invalidId)"); + verifyIllegalArg(() -> bean.readStream(id), "readStream(invalidId)"); + verifyIllegalArg(() -> bean.getRecordingSettings(id), "getRecordingSettings(invalidId)"); + verifyIllegalArg(() -> bean.setConfiguration(id, "dummy"), "setConfiguration(invalidId)"); + verifyIllegalArg(() -> bean.setPredefinedConfiguration(id, "dummy"), "setNamedConfiguration(invalidId)"); + verifyIllegalArg(() -> bean.setRecordingSettings(id, new HashMap()), "setRecordingSettings(invalidId)"); + verifyIllegalArg(() -> bean.copyTo(id, "./dummy.jfr"), "dumpRecording(invalidId)"); + } + + private static void verifyIllegalArg(VoidFunction f, String msg) throws Throwable { + CommonHelper.verifyException(f, msg, IllegalArgumentException.class); + } + +} diff --git a/test/jdk/jfr/jmx/info/TestConfigurationInfo.java b/test/jdk/jfr/jmx/info/TestConfigurationInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..cd98e6e720cf9862f6e7672e84731a0d577525f6 --- /dev/null +++ b/test/jdk/jfr/jmx/info/TestConfigurationInfo.java @@ -0,0 +1,109 @@ +/* + * 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 + * 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.jmx.info; + + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jdk.jfr.jmx.JmxHelper; + +import jdk.jfr.Configuration; +import jdk.management.jfr.ConfigurationInfo; +import jdk.test.lib.Asserts; + +/** + * @test + * @key jfr + * @summary Test for ConfigurationInfo. Compare infos from java API and jmx API. + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.info.TestConfigurationInfo + */ +public class TestConfigurationInfo { + public static void main(String[] args) throws Throwable { + List configInfos = JmxHelper.getFlighteRecorderMXBean().getConfigurations(); + Asserts.assertFalse(configInfos.isEmpty(), "No ConfigurationInfos found"); + + Map configs = new HashMap<>(); + for (Configuration config : Configuration.getConfigurations()) { + configs.put(config.getName(), config); + } + Asserts.assertFalse(configs.isEmpty(), "No Configurations found"); + + for (ConfigurationInfo configInfo : configInfos) { + final String key = configInfo.getName(); + Configuration config = configs.remove(key); + Asserts.assertNotNull(config, "No Configuration for name " + key); + + System.out.println("getDescription:" + configInfo.getDescription()); + System.out.println("getLabel:" + configInfo.getLabel()); + System.out.println("getName:" + configInfo.getName()); + System.out.println("getProvider:" + configInfo.getProvider()); + + Asserts.assertEquals(configInfo.getContents(), config.getContents(), "Wrong contents"); + Asserts.assertEquals(configInfo.getDescription(), config.getDescription(), "Wrong description"); + Asserts.assertEquals(configInfo.getLabel(), config.getLabel(), "Wrong label"); + Asserts.assertEquals(configInfo.getName(), config.getName(), "Wrong name"); + Asserts.assertEquals(configInfo.getProvider(), config.getProvider(), "Wrong provider"); + + verifySettingsEqual(config, configInfo); + } + + // Verify that all EventTypes have been matched. + if (!configs.isEmpty()) { + for (String name : configs.keySet()) { + System.out.println("Found extra Configuration with name " + name); + } + Asserts.fail("Found extra Configuration"); + } + } + + private static void verifySettingsEqual(Configuration config, ConfigurationInfo configInfo) { + Map javaSettings = config.getSettings(); + Map jmxSettings = configInfo.getSettings(); + + Asserts.assertFalse(javaSettings.isEmpty(), "No Settings found in java apa"); + Asserts.assertFalse(jmxSettings.isEmpty(), "No Settings found in jmx api"); + + for (String name : jmxSettings.keySet().toArray(new String[0])) { + System.out.printf("%s: jmx=%s, java=%s%n", name, jmxSettings.get(name), javaSettings.get(name)); + Asserts.assertNotNull(javaSettings.get(name), "No java setting for " + name); + Asserts.assertEquals(jmxSettings.get(name), javaSettings.get(name), "Wrong value for setting"); + javaSettings.remove(name); + } + + // Verify that all Settings have been matched. + if (!javaSettings.isEmpty()) { + for (String name : javaSettings.keySet()) { + System.out.println("Found extra Settings name " + name); + } + Asserts.fail("Found extra Setting in java api"); + } + } + +} diff --git a/test/jdk/jfr/jmx/info/TestEventTypeInfo.java b/test/jdk/jfr/jmx/info/TestEventTypeInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..c5a26c50a36bb450828d7dc51721caf98b6e007a --- /dev/null +++ b/test/jdk/jfr/jmx/info/TestEventTypeInfo.java @@ -0,0 +1,89 @@ +/* + * 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 + * 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.jmx.info; + + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jdk.jfr.jmx.JmxHelper; + +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorder; +import jdk.management.jfr.EventTypeInfo; +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.test.lib.Asserts; + +/** + * @test + * @key jfr + * @summary Test for EventTypeInfo + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.info.TestEventTypeInfo + */ +public class TestEventTypeInfo { + public static void main(String[] args) throws Throwable { + FlightRecorder jfr = FlightRecorder.getFlightRecorder(); + + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + List typeInfos = bean.getEventTypes(); + + Map types = new HashMap<>(); + for (EventType type : jfr.getEventTypes()) { + types.put(type.getName(), type); + } + + Asserts.assertFalse(typeInfos.isEmpty(), "No EventTypeInfos found"); + Asserts.assertFalse(types.isEmpty(), "No EventTypes found"); + + for (EventTypeInfo typeInfo : typeInfos) { + final String key = typeInfo.getName(); + System.out.println("EventType name = " + key); + EventType type = types.get(key); + Asserts.assertNotNull(type, "No EventType for name " + key); + types.remove(key); + + Asserts.assertEquals(typeInfo.getCategoryNames(), type.getCategoryNames(), "Wrong category"); + Asserts.assertEquals(typeInfo.getDescription(), type.getDescription(), "Wrong description"); + Asserts.assertEquals(typeInfo.getId(), type.getId(), "Wrong id"); + Asserts.assertEquals(typeInfo.getLabel(), type.getLabel(), "Wrong label"); + Asserts.assertEquals(typeInfo.getName(), type.getName(), "Wrong name"); + + JmxHelper.verifyEventSettingsEqual(type, typeInfo); + } + + // Verify that all EventTypes have been matched. + if (!types.isEmpty()) { + for (String name : types.keySet()) { + System.out.println("Found extra EventType with name " + name); + } + Asserts.fail("Found extra EventTypes"); + } + } + +} diff --git a/test/jdk/jfr/jmx/info/TestRecordingInfo.java b/test/jdk/jfr/jmx/info/TestRecordingInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..f119d03b283be7d2e184d2be7d9521404aa10f53 --- /dev/null +++ b/test/jdk/jfr/jmx/info/TestRecordingInfo.java @@ -0,0 +1,75 @@ +/* + * 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 + * 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.jmx.info; + + +import java.nio.file.Paths; +import java.time.Duration; + +import jdk.jfr.jmx.JmxHelper; + +import jdk.jfr.Configuration; +import jdk.jfr.Recording; +import jdk.jfr.RecordingState; +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.management.jfr.RecordingInfo; +import jdk.test.lib.jfr.CommonHelper; + +/** + * @test + * @key jfr + * @summary Test for RecordingInfo + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.info.TestRecordingInfo + */ +public class TestRecordingInfo { + public static void main(String[] args) throws Throwable { + Recording recording = new Recording(Configuration.getConfiguration("profile")); + recording.setDestination(Paths.get(".", "my.jfr")); + recording.setDumpOnExit(true); + recording.setDuration(Duration.ofSeconds(60)); + recording.setMaxAge(Duration.ofHours(1)); + recording.setMaxSize(123456789); + recording.setName("myName"); + recording.enable("java.exception_throw").with("threashold", "2 s"); + recording.setToDisk(true); + + recording.start(); + CommonHelper.verifyRecordingState(recording, RecordingState.RUNNING); // Wait until running + + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + RecordingInfo info = JmxHelper.verifyExists(recording.getId(), bean.getRecordings()); + + System.out.println(JmxHelper.asString(recording)); + System.out.println(JmxHelper.asString(info)); + JmxHelper.verifyEquals(info, recording); + + recording.stop(); + recording.close(); + } + +} diff --git a/test/jdk/jfr/jmx/info/TestSettingDescriptorInfo.java b/test/jdk/jfr/jmx/info/TestSettingDescriptorInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..b68c2c89eb4a877bd622c89556f3b7a0a976dd1b --- /dev/null +++ b/test/jdk/jfr/jmx/info/TestSettingDescriptorInfo.java @@ -0,0 +1,75 @@ +/* + * 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 + * 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.jmx.info; + + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jdk.jfr.jmx.JmxHelper; + +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorder; +import jdk.management.jfr.EventTypeInfo; +import jdk.test.lib.Asserts; + +/** + * @test + * @key jfr + * @summary Test for SettingDescriptorInfo. Compare infos from java API and jmx API. + * + * @library /lib / + * @run main/othervm jdk.jfr.jmx.info.TestSettingDescriptorInfo + */ +public class TestSettingDescriptorInfo { + public static void main(String[] args) throws Throwable { + + Map javaTypes = new HashMap(); + for (EventType t : FlightRecorder.getFlightRecorder().getEventTypes()) { + javaTypes.put(t.getName(), t); + } + + List jmxTypes =JmxHelper.getFlighteRecorderMXBean().getEventTypes(); + Asserts.assertFalse(jmxTypes.isEmpty(), "No EventTypes found in jmx api"); + + for (EventTypeInfo jmxType : jmxTypes) { + final String name = jmxType.getName(); + EventType javaType = javaTypes.remove(name); + Asserts.assertNotNull(javaType, "No EventType for name " + name); + JmxHelper.verifyEventSettingsEqual(javaType, jmxType); + } + + // Verify that all EventTypes have been matched. + if (!javaTypes.isEmpty()) { + for (String name : javaTypes.keySet()) { + System.out.println("Found extra EventType that is not available using JMX " + name); + } + Asserts.fail("Found extra EventType"); + } + } + +} diff --git a/test/jdk/jfr/jmx/security/TestEnoughPermission.java b/test/jdk/jfr/jmx/security/TestEnoughPermission.java new file mode 100644 index 0000000000000000000000000000000000000000..5fc80b5454391f3850904b93abd23b3ec61eb195 --- /dev/null +++ b/test/jdk/jfr/jmx/security/TestEnoughPermission.java @@ -0,0 +1,105 @@ +/* + * 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 + * 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.jmx.security; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + +import jdk.jfr.jmx.JmxHelper; + +import jdk.management.jfr.ConfigurationInfo; +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.test.lib.Asserts; + +/** + * @test + * @key jfr + * @summary Test with minimal needed permissions. All functions should work. + * + * @library /lib / + * @run main/othervm/secure=java.lang.SecurityManager/java.security.policy=enough.policy jdk.jfr.jmx.security.TestEnoughPermission + */ +public class TestEnoughPermission { + + public static void main(String[] args) throws Throwable { + try { + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + + System.out.println("AAAAAAAAAAAAAAAAAA"); + Asserts.assertFalse(bean.getEventTypes().isEmpty(), "No EventTypes"); + System.out.println("BBBBBBBBBBBBBBB"); + List configs = bean.getConfigurations(); + System.out.println("CCCCCCCCCCCCCCCCC"); + for (ConfigurationInfo config : configs) { + System.out.println("config.name=" + config.getName() + ": " + config.getContents()); + } + + long recId = testRecording(bean); + testStream(bean, recId); + bean.closeRecording(recId); + + //*************** verifySecurityException(() -> bean.getRecordingOptions(dummyId), "getRecordingOptions()"); + //*************** verifySecurityException(() -> bean.getRecordingSettings(dummyId), "getRecordingSettings()"); + //*********** verifySecurityException(() -> bean.setConfiguration(dummyId, "<>"), "setConfiguration()"); + //************* verifySecurityException(() -> bean.setRecordingSettings(dummyId, dummyMap), "setRecordingSettings()"); + //************* verifySecurityException(() -> bean.setRecordingOptions(dummyId, dummyMap), "setRecordingOptions()"); + } catch (Throwable t) { + t.printStackTrace(); + throw t; + } + } + + private static long testRecording(FlightRecorderMXBean bean) throws Exception { + System.out.println("A"); + long recId = bean.newRecording(); + System.out.println("B"); + bean.setPredefinedConfiguration(recId, "profile"); + System.out.println("C"); + bean.startRecording(recId); + System.out.println("D"); + Asserts.assertTrue(bean.getRecordings().stream().anyMatch(r -> { return r.getId() == recId; }), "recId not found"); + System.out.println("E"); + bean.stopRecording(recId); + + final Path path = Paths.get(".", "rec" + recId + ".jfr"); + bean.copyTo(recId, path.toString()); + //EventSet events = EventSet.fromFile(path); + return recId; + } + + private static void testStream(FlightRecorderMXBean bean, long recId) throws Exception { + long streamId = bean.openStream(recId, null); + byte[] buff = bean.readStream(streamId); + Asserts.assertNotNull(buff, "Stream data was empty"); + while (buff != null) { + // TODO: write to file and parse. + System.out.println("buff.length=" + buff.length); + buff = bean.readStream(streamId); + } + bean.closeStream(streamId); + } +} diff --git a/test/jdk/jfr/jmx/security/TestNoControlPermission.java b/test/jdk/jfr/jmx/security/TestNoControlPermission.java new file mode 100644 index 0000000000000000000000000000000000000000..a6f0f4f7436a8f9ac31ea4eeef840b0c45538cdf --- /dev/null +++ b/test/jdk/jfr/jmx/security/TestNoControlPermission.java @@ -0,0 +1,73 @@ +/* + * 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 + * 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.jmx.security; + +import jdk.jfr.jmx.JmxHelper; + +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.test.lib.jfr.CommonHelper; +import jdk.test.lib.jfr.VoidFunction; + +/** + * @test + * @key jfr + * @summary Verify we get SecurityExceptions when missing management permission "control". + * + * @library /lib / + * @run main/othervm/secure=java.lang.SecurityManager/java.security.policy=nocontrol.policy jdk.jfr.jmx.security.TestNoControlPermission + */ +public class TestNoControlPermission { + + public static void main(String[] args) throws Throwable { + try { + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + + int dummyId = 1; + java.util.Map dummyMap = new java.util.HashMap<>(); + + verifySecurityException(() -> bean.takeSnapshot(), "takeSnapshot()"); + verifySecurityException(() -> bean.newRecording(), "newRecording()"); + verifySecurityException(() -> bean.startRecording(dummyId), "startRecording()"); + verifySecurityException(() -> bean.stopRecording(dummyId), "stopRecording()"); + verifySecurityException(() -> bean.closeRecording(dummyId), "closeRecording()"); + verifySecurityException(() -> bean.openStream(dummyId, null), "openStream()"); + verifySecurityException(() -> bean.closeStream(dummyId), "closeStream()"); + verifySecurityException(() -> bean.setConfiguration(dummyId, "dummy"), "setConfiguration()"); + verifySecurityException(() -> bean.setPredefinedConfiguration(dummyId, "dummy"), "setPredefinedConfiguration()"); + verifySecurityException(() -> bean.setRecordingSettings(dummyId, dummyMap), "setRecordingSettings()"); + verifySecurityException(() -> bean.setRecordingOptions(dummyId, dummyMap), "setRecordingOptions()"); + verifySecurityException(() -> bean.copyTo(dummyId, "."), "dumpRecording()"); + } catch (Throwable t) { + t.printStackTrace(); + throw t; + } + } + + + private static void verifySecurityException(VoidFunction f, String msg) throws Throwable { + CommonHelper.verifyException(f, msg, java.lang.SecurityException.class); + } +} diff --git a/test/jdk/jfr/jmx/security/TestNoMonitorPermission.java b/test/jdk/jfr/jmx/security/TestNoMonitorPermission.java new file mode 100644 index 0000000000000000000000000000000000000000..91eaedd70f3bd4abc2b4eb357fb841cbc893a05f --- /dev/null +++ b/test/jdk/jfr/jmx/security/TestNoMonitorPermission.java @@ -0,0 +1,65 @@ +/* + * 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 + * 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.jmx.security; + +import jdk.jfr.jmx.JmxHelper; + +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.test.lib.jfr.CommonHelper; +import jdk.test.lib.jfr.VoidFunction; + +/** + * @test + * @key jfr + * @summary Verify we get SecurityExceptions when missing management permission "monitor". + * + * @library /lib / + * @run main/othervm/secure=java.lang.SecurityManager/java.security.policy=nomonitor.policy jdk.jfr.jmx.security.TestNoMonitorPermission + */ +public class TestNoMonitorPermission { + + public static void main(String[] args) throws Throwable { + try { + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + + int dummyId = 1; + verifySecurityException(() -> bean.getRecordings(), "getRecordings()"); + verifySecurityException(() -> bean.getConfigurations(), "getConfigurations()"); + verifySecurityException(() -> bean.getEventTypes(), "getEventTypes()"); + verifySecurityException(() -> bean.getRecordingOptions(dummyId), "getRecordingOptions()"); + verifySecurityException(() -> bean.getRecordingSettings(dummyId), "getRecordingSettings()"); + verifySecurityException(() -> bean.readStream(dummyId), "readStream()"); + } catch (Throwable t) { + t.printStackTrace(); + throw t; + } + } + + + private static void verifySecurityException(VoidFunction f, String msg) throws Throwable { + CommonHelper.verifyException(f, msg, java.lang.SecurityException.class); + } +} diff --git a/test/jdk/jfr/jmx/security/TestNotificationListenerPermission.java b/test/jdk/jfr/jmx/security/TestNotificationListenerPermission.java new file mode 100644 index 0000000000000000000000000000000000000000..11f32f41c7e112fb7594d1d9cc428d87eedf4833 --- /dev/null +++ b/test/jdk/jfr/jmx/security/TestNotificationListenerPermission.java @@ -0,0 +1,87 @@ +/* + * 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 + * 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.jmx.security; + +import java.lang.management.ManagementFactory; +import java.util.concurrent.CountDownLatch; + +import javax.management.Notification; +import javax.management.NotificationListener; +import javax.management.ObjectName; + +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.test.lib.Asserts; + +import jdk.jfr.jmx.JmxHelper; + +/** + * @test + * @key jfr + * @summary Test with minimal needed permissions. All functions should work. + * + * @library /lib / + * @run main/othervm/secure=java.lang.SecurityManager/java.security.policy=listener.policy jdk.jfr.jmx.security.TestNotificationListenerPermission + */ +public class TestNotificationListenerPermission { + private static boolean gotSecurityException; + + static class TestListener implements NotificationListener { + private final CountDownLatch latch = new CountDownLatch(1); + + @Override + public void handleNotification(Notification arg0, Object arg1) { + try { + System.getProperty("user.name"); + } catch (SecurityException se) { + se.printStackTrace(); + gotSecurityException = true; + } + latch.countDown(); + } + + public void awaitNotication() throws InterruptedException { + latch.await(); + } + } + + public static void main(String[] args) throws Throwable { + try { + System.getProperty("user.name"); + Asserts.fail("Didn't get security exception. Test not configured propertly?"); + } catch (SecurityException se) { + // as expected + } + FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean(); + TestListener testListener = new TestListener(); + ManagementFactory.getPlatformMBeanServer().addNotificationListener(new ObjectName(FlightRecorderMXBean.MXBEAN_NAME), testListener, null, null); + long id = bean.newRecording(); + bean.startRecording(id); + testListener.awaitNotication(); + Asserts.assertTrue(gotSecurityException, "Should not get elevated privileges in notification handler!"); + bean.stopRecording(id); + bean.closeRecording(id); + } +} diff --git a/test/jdk/jfr/jmx/security/enough.policy b/test/jdk/jfr/jmx/security/enough.policy new file mode 100644 index 0000000000000000000000000000000000000000..85c31cd16cd20255759f6e15c1b484abb3455dec --- /dev/null +++ b/test/jdk/jfr/jmx/security/enough.policy @@ -0,0 +1,19 @@ +// Minimum policy for JMX to activate JFR and create a recording. + +grant { + +permission java.lang.management.ManagementPermission "control"; +permission java.lang.management.ManagementPermission "monitor"; + +// in order for the test to accomplish dump/copyto on a user defined recording +permission "java.io.FilePermission" "<>", "read,write,delete"; +permission "java.util.PropertyPermission" "user.dir", "read"; +permission "javax.management.MBeanPermission" "jdk.management.jfr.FlightRecorderMXBeanImpl#-[jdk.jfr.management:type=FlightRecorder]", "addNotificationListener"; + +permission "javax.management.MBeanServerPermission" "createMBeanServer"; +permission "javax.management.MBeanPermission" "jdk.management.jfr.FlightRecorderMXBeanImpl#Recordings[jdk.jfr:type=FlightRecorder]", "getAttribute"; +permission "javax.management.MBeanPermission" "jdk.management.jfr.FlightRecorderMXBeanImpl#EventTypes[jdk.jfr:type=FlightRecorder]", "getAttribute"; +permission "javax.management.MBeanPermission" "jdk.management.jfr.FlightRecorderMXBeanImpl#Configurations[jdk.jfr:type=FlightRecorder]", "getAttribute"; +permission "javax.management.MBeanPermission" "jdk.management.jfr.FlightRecorderMXBeanImpl#newRecording[jdk.jfr:type=FlightRecorder]", "invoke"; + +}; diff --git a/test/jdk/jfr/jmx/security/listener.policy b/test/jdk/jfr/jmx/security/listener.policy new file mode 100644 index 0000000000000000000000000000000000000000..48496c1785dae6b5924a6c5105652574a6568042 --- /dev/null +++ b/test/jdk/jfr/jmx/security/listener.policy @@ -0,0 +1,11 @@ +// Minimum policy for JMX to activate JFR and create a recording. + +grant { + +permission java.lang.management.ManagementPermission "control"; +permission java.lang.management.ManagementPermission "monitor"; +permission "javax.management.MBeanPermission" "*", "addNotificationListener"; +permission "javax.management.MBeanPermission" "*", "invoke"; +permission "javax.management.MBeanServerPermission" "createMBeanServer"; + +}; diff --git a/test/jdk/jfr/jmx/security/nocontrol.policy b/test/jdk/jfr/jmx/security/nocontrol.policy new file mode 100644 index 0000000000000000000000000000000000000000..dd080c6f89285b77b4dfc13d0dfddedf68914e10 --- /dev/null +++ b/test/jdk/jfr/jmx/security/nocontrol.policy @@ -0,0 +1,11 @@ +// Removed security "ManagementPermission control". Should cause SecurityExceptions. + +grant { + +// Removed permission: permission java.lang.management.ManagementPermission "control"; +permission java.lang.management.ManagementPermission "monitor"; + +permission javax.management.MBeanServerPermission "createMBeanServer"; +permission "javax.management.MBeanPermission" "jdk.management.jfr.FlightRecorderMXBeanImpl#Recordings[jdk.jfr:type=FlightRecorder]", "getAttribute"; + +}; diff --git a/test/jdk/jfr/jmx/security/nomonitor.policy b/test/jdk/jfr/jmx/security/nomonitor.policy new file mode 100644 index 0000000000000000000000000000000000000000..52eedde40ffd0de725f3868c82f6dec1f73ef574 --- /dev/null +++ b/test/jdk/jfr/jmx/security/nomonitor.policy @@ -0,0 +1,11 @@ +// Removed security "ManagementPermission monitor". Should cause SecurityExceptions. + +grant { + +permission java.lang.management.ManagementPermission "control"; +// Removed permission: permission java.lang.management.ManagementPermission "monitor"; + +permission javax.management.MBeanServerPermission "createMBeanServer"; +permission "javax.management.MBeanPermission" "jdk.management.jfr.FlightRecorderMXBeanImpl#Recordings[jdk.jfr:type=FlightRecorder]", "getAttribute"; + +}; diff --git a/test/jdk/jfr/jvm/HelloWorldEvent1.java b/test/jdk/jfr/jvm/HelloWorldEvent1.java new file mode 100644 index 0000000000000000000000000000000000000000..d34c5665f33b35b0f494413f3ce3734c9c1ddeb2 --- /dev/null +++ b/test/jdk/jfr/jvm/HelloWorldEvent1.java @@ -0,0 +1,40 @@ +/* + * 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.jvm; + +import jdk.jfr.Description; +import jdk.jfr.Enabled; +import jdk.jfr.Event; +import jdk.jfr.Label; + +@Label("Hello World") +@Description("My first event") +@Enabled +public class HelloWorldEvent1 extends Event { + + @Label("Message") + public String message; +} diff --git a/test/jdk/jfr/jvm/HelloWorldEvent2.java b/test/jdk/jfr/jvm/HelloWorldEvent2.java new file mode 100644 index 0000000000000000000000000000000000000000..e3275398f5f9c5b0c58fa428d22c2cf4a7b89151 --- /dev/null +++ b/test/jdk/jfr/jvm/HelloWorldEvent2.java @@ -0,0 +1,40 @@ +/* + * 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.jvm; + +import jdk.jfr.Description; +import jdk.jfr.Enabled; +import jdk.jfr.Event; +import jdk.jfr.Label; + +@Label("Hello World") +@Description("My second event") +@Enabled +public class HelloWorldEvent2 extends Event { + + @Label("Message") + public String message; +} diff --git a/test/jdk/jfr/jvm/TestBeginAndEnd.java b/test/jdk/jfr/jvm/TestBeginAndEnd.java new file mode 100644 index 0000000000000000000000000000000000000000..abec5939aee128532cf92f27a59f0e078b2d0eac --- /dev/null +++ b/test/jdk/jfr/jvm/TestBeginAndEnd.java @@ -0,0 +1,49 @@ +/* + * 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.jvm; + +import jdk.jfr.internal.JVM; + +/** + * @test TestBeginAndEnd + * @key jfr + * + * + * @run main/othervm jdk.jfr.jvm.TestBeginAndEnd + */ +public class TestBeginAndEnd { + + private final static long MAX_CHUNK_SIZE = 12 * 1024 * 1024; + + public static void main(String... args) { + JVM jvm = JVM.getJVM(); + jvm.createNativeJFR(); + jvm.setFileNotification(MAX_CHUNK_SIZE); + jvm.beginRecording(); + jvm.endRecording(); + jvm.destroyNativeJFR(); + } +} diff --git a/test/jdk/jfr/jvm/TestClassId.java b/test/jdk/jfr/jvm/TestClassId.java new file mode 100644 index 0000000000000000000000000000000000000000..2dd4a3d0f49f6148a98715d7ab65158102e0cdc9 --- /dev/null +++ b/test/jdk/jfr/jvm/TestClassId.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. 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.jvm; + +import static jdk.test.lib.Asserts.assertGreaterThan; +import static jdk.test.lib.Asserts.assertNE; + +import jdk.jfr.internal.JVM; +import jdk.jfr.internal.Type; + +/** + * @test TestClassId + * @key jfr + * + * @library /lib / + * + * @run main/othervm jdk.jfr.jvm.TestClassId + */ +public class TestClassId { + + public static void main(String... args) { + assertClassIds(); + JVM jvm = JVM.getJVM(); + jvm.createNativeJFR(); + assertClassIds(); + jvm.destroyNativeJFR(); + assertClassIds(); + } + + private static void assertClassIds() { + long doubleClassId = Type.getTypeId(Double.class); + assertGreaterThan(doubleClassId, 0L, "Class id must be greater than 0"); + + long floatClassId = Type.getTypeId(Float.class); + assertNE(doubleClassId, floatClassId, "Different classes must have different class ids"); + } +} diff --git a/test/jdk/jfr/jvm/TestCounterTime.java b/test/jdk/jfr/jvm/TestCounterTime.java new file mode 100644 index 0000000000000000000000000000000000000000..0962a00230f4bbf3d03a19921fab6d3f8c6eac54 --- /dev/null +++ b/test/jdk/jfr/jvm/TestCounterTime.java @@ -0,0 +1,62 @@ +/* + * 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.jvm; + +import static jdk.test.lib.Asserts.assertGreaterThan; + +import jdk.jfr.internal.JVM; + +/** + * @test TestCounterTime + * @key jfr + * + * @library /lib / + * + * @run main/othervm jdk.jfr.jvm.TestCounterTime + */ +public class TestCounterTime { + + public static void main(String... args) throws InterruptedException { + // Not enabled + assertCounterTime(); + + JVM jvm = JVM.getJVM(); + jvm.createNativeJFR(); + assertCounterTime(); + // Enabled + jvm.destroyNativeJFR(); + } + + private static void assertCounterTime() throws InterruptedException { + long time1 = JVM.counterTime(); + assertGreaterThan(time1, 0L, "Counter time can't be negative."); + + Thread.sleep(1); + + long time2 = JVM.counterTime(); + assertGreaterThan(time2, time1, "Counter time must be increasing."); + } +} diff --git a/test/jdk/jfr/jvm/TestCreateNative.java b/test/jdk/jfr/jvm/TestCreateNative.java new file mode 100644 index 0000000000000000000000000000000000000000..f9a3f5157ee1062d6d38cdda6c5198962c678f85 --- /dev/null +++ b/test/jdk/jfr/jvm/TestCreateNative.java @@ -0,0 +1,76 @@ +/* + * 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. 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.jvm; + +import java.nio.file.Paths; + +import jdk.jfr.Configuration; +import jdk.jfr.Recording; +import jdk.jfr.internal.JVM; + +/** + * @test + * @summary Checks that the JVM can rollback on native initialization failures. + * @key jfr + * + * @library /lib / + * + * @run main/othervm jdk.jfr.jvm.TestCreateNative + */ +public class TestCreateNative { + + // This is a white-box test where we fabricate a native initialization + // error by calling JMV#createNative(false), which will tear down + // all native structures after they are setup, as if something went wrong + // at the last step. + public static void main(String... args) throws Exception { + JVM jvm = JVM.getJVM(); + // Ensure that repeated failures can be handled + for (int i = 1; i < 4; i++) { + System.out.println("About to try failed initialization, attempt " + i + " out of 3"); + assertFailedInitialization(jvm); + System.out.println("As expected, initialization failed."); + } + // Ensure that Flight Recorder can be initialized properly after failures + Configuration defConfig = Configuration.getConfiguration("default"); + Recording r = new Recording(defConfig); + r.start(); + r.stop(); + r.dump(Paths.get("recording.jfr")); + r.close(); + } + + private static void assertFailedInitialization(JVM jvm) throws Exception { + try { + jvm.createFailedNativeJFR(); + throw new Exception("Expected failure when creating native JFR"); + } catch (IllegalStateException ise) { + String message = ise.getMessage(); + if (!message.equals("Unable to start Jfr")) { + throw new Exception("Expected failure on initialization of native JFR"); + } + } + } +} diff --git a/test/jdk/jfr/jvm/TestDumpOnCrash.java b/test/jdk/jfr/jvm/TestDumpOnCrash.java new file mode 100644 index 0000000000000000000000000000000000000000..03aef77602a1828922447f167cc33723a129f8af --- /dev/null +++ b/test/jdk/jfr/jvm/TestDumpOnCrash.java @@ -0,0 +1,110 @@ +/* + * 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. 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.jvm; + +import java.lang.reflect.Field; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; + +import sun.misc.Unsafe; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +/** + * @test + * @key jfr + * @summary Verifies that data associated with a running recording can be evacuated to an hs_err_pidXXX.jfr when the VM crashes + * + * + * @library /lib / + * + + * + * @run main/othervm jdk.jfr.jvm.TestDumpOnCrash + */ +public class TestDumpOnCrash { + + private static final CharSequence LOG_FILE_EXTENSION = ".log"; + private static final CharSequence JFR_FILE_EXTENSION = ".jfr"; + + static class Crasher { + public static void main(String[] args) { + try { + Field theUnsafeRefLocation = Unsafe.class.getDeclaredField("theUnsafe"); + theUnsafeRefLocation.setAccessible(true); + ((Unsafe)theUnsafeRefLocation.get(null)).putInt(0L, 0); + } + catch(Exception ex) { + Asserts.fail("cannot execute"); + } + } + } + + public static void main(String[] args) throws Exception { + processOutput(runProcess()); + } + + private static OutputAnalyzer runProcess() throws Exception { + return new OutputAnalyzer( + ProcessTools.createJavaProcessBuilder(true, + "-Xmx64m", + "-Xint", + "-XX:-TransmitErrorReport", + "-XX:-CreateMinidumpOnCrash", + /*"--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED",*/ + "-XX:StartFlightRecording=dumponexit=true", + Crasher.class.getName()).start()); + } + + private static void processOutput(OutputAnalyzer output) throws Exception { + //output.shouldContain("CreateCoredumpOnCrash turned off, no core file dumped"); + + final Path jfrEmergencyFilePath = getHsErrJfrPath(output); + Asserts.assertTrue(Files.exists(jfrEmergencyFilePath), "No emergency jfr recording file " + jfrEmergencyFilePath + " exists"); + Asserts.assertNotEquals(Files.size(jfrEmergencyFilePath), 0L, "File length 0. Should at least be some bytes"); + System.out.printf("File size=%d%n", Files.size(jfrEmergencyFilePath)); + + List events = RecordingFile.readAllEvents(jfrEmergencyFilePath); + Asserts.assertFalse(events.isEmpty(), "No event found"); + System.out.printf("Found event %s%n", events.get(0).getEventType().getName()); + } + + private static Path getHsErrJfrPath(OutputAnalyzer output) throws Exception { + // extract to find hs-err_pid log file location + final String hs_err_pid_log_file = output.firstMatch("# *(\\S*hs_err_pid\\d+\\.log)", 1); + if (hs_err_pid_log_file == null) { + throw new RuntimeException("Did not find hs_err_pid.log file in output.\n"); + } + // the dumped out jfr file should have the same name and location but with a .jfr extension + final String hs_err_pid_jfr_file = hs_err_pid_log_file.replace(LOG_FILE_EXTENSION, JFR_FILE_EXTENSION); + return Paths.get(hs_err_pid_jfr_file); + } +} + diff --git a/test/jdk/jfr/jvm/TestGetAllEventClasses.java b/test/jdk/jfr/jvm/TestGetAllEventClasses.java new file mode 100644 index 0000000000000000000000000000000000000000..0d6e20f2b81eb2bbe128d7c6000797d8cf4aa4e9 --- /dev/null +++ b/test/jdk/jfr/jvm/TestGetAllEventClasses.java @@ -0,0 +1,125 @@ +/* + * 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.jvm; + +import jdk.jfr.Event; +import jdk.jfr.internal.JVM; + +import java.util.List; + +/** + * @test TestGetAllEventClasses + * @key jfr + * + * @library /lib / + * + * + * @build jdk.jfr.jvm.HelloWorldEvent1 + * @build jdk.jfr.jvm.HelloWorldEvent2 + * @run main/othervm jdk.jfr.jvm.TestGetAllEventClasses + */ +public class TestGetAllEventClasses { + + public static void main(String... args) throws ClassNotFoundException { + JVM jvm = JVM.getJVM(); + // before creating native + assertEmptyEventList(jvm); + jvm.createNativeJFR(); + // after creating native + assertEmptyEventList(jvm); + + // Test event class load is triggered and only once + Class clazz = initialize("jdk.jfr.jvm.HelloWorldEvent1"); + // check that the event class is registered + assertEventsIncluded(jvm, clazz); + // second active use of the same event class should not add another class + // to the list - it would already be loaded + clazz = initialize(clazz); + assertEventsIncluded(jvm, clazz); + + // second event class + Class clazz2 = initialize("jdk.jfr.jvm.HelloWorldEvent2"); + // the list of event classes should now have two classes registered + assertEventsIncluded(jvm, clazz, clazz2); + + // verify that an abstract event class is not included + Class abstractClass = initialize(MyAbstractEvent.class); // to run + assertEventsExcluded(jvm, abstractClass); + + // verify that a class that is yet to run its is not included in the list of event classes + assertEventsExcluded(jvm, MyUnInitializedEvent.class); + + // ensure old classes are not lost + assertEventsIncluded(jvm, clazz, clazz2); + + jvm.destroyNativeJFR(); + } + + private static Class initialize(String name) throws ClassNotFoundException { + // Class.forName() will force the class to run its method + return Class.forName(name).asSubclass(Event.class); + } + + private static Class initialize(Class event) throws ClassNotFoundException { + return initialize(event.getName()); + } + + private static void assertEmptyEventList(JVM jvm) { + if (!jvm.getAllEventClasses().isEmpty()) { + throw new AssertionError("should not have any event classes registered!"); + } + } + + @SafeVarargs + private static void assertEventsExcluded(JVM jvm, Class... targetEvents) { + assertEvents(jvm, false, targetEvents); + } + + @SafeVarargs + private static void assertEventsIncluded(JVM jvm, Class... targetEvents) { + assertEvents(jvm, true, targetEvents); + } + + @SafeVarargs + private static void assertEvents(JVM jvm, boolean inclusion, Class... targetEvents) { + final List> list = jvm.getAllEventClasses(); + for (Class ev : targetEvents) { + if (list.contains(ev)) { + if (inclusion) { + continue; + } + throw new AssertionError(ev.getName() + " in list but should not be!"); + } + if (!inclusion) { + continue; + } + throw new AssertionError(ev.getName() + " in not in list but should be!"); + } + } + + private static abstract class MyAbstractEvent extends Event {} + private static class MyUnInitializedEvent extends Event {} +} diff --git a/test/jdk/jfr/jvm/TestGetEventWriter.java b/test/jdk/jfr/jvm/TestGetEventWriter.java new file mode 100644 index 0000000000000000000000000000000000000000..03293623584e7b1b98231ab66f891a28f1f245ba --- /dev/null +++ b/test/jdk/jfr/jvm/TestGetEventWriter.java @@ -0,0 +1,51 @@ +/* + * 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.jvm; + +import static jdk.test.lib.Asserts.assertNotNull; + +import jdk.jfr.internal.EventWriter; +import jdk.jfr.internal.JVM; + +/** + * @test TestGetEventWriter + * @key jfr + * + * @library /lib / + * + * + * @run main/othervm jdk.jfr.jvm.TestGetEventWriter + */ +public class TestGetEventWriter { + + public static void main(String... args) { + JVM jvm = JVM.getJVM(); + jvm.createNativeJFR(); + EventWriter writer = EventWriter.getEventWriter(); + assertNotNull(writer, "EventWriter should not be null"); + jvm.destroyNativeJFR(); + } +} diff --git a/test/jdk/jfr/jvm/TestGetStackTraceId.java b/test/jdk/jfr/jvm/TestGetStackTraceId.java new file mode 100644 index 0000000000000000000000000000000000000000..30aae4b78517ae0cb668ff9d0318035dfef781d2 --- /dev/null +++ b/test/jdk/jfr/jvm/TestGetStackTraceId.java @@ -0,0 +1,71 @@ +/* + * 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.jvm; + +import jdk.jfr.FlightRecorder; +import jdk.jfr.internal.JVM; +import jdk.test.lib.Asserts; + +/** + * @test TestGetStackTraceId + * @key jfr + * + * @library /lib / + * + * @run main/othervm jdk.jfr.jvm.TestGetStackTraceId + */ +public class TestGetStackTraceId { + + public static void main(String... args) { + FlightRecorder.getFlightRecorder(); + JVM jvm = JVM.getJVM(); + + long id10 = getStackIdOfDepth(10); + assertValid(id10); + + long id5 = getStackIdOfDepth(5); + assertValid(id5); + + Asserts.assertNotEquals(id5, id10, "Different stack depth must return different stack trace ids"); + + assertMaxSkip(jvm); + } + + private static void assertMaxSkip(JVM jvm) { + assertValid(jvm.getStackTraceId(Integer.MAX_VALUE)); + } + + private static void assertValid(long value) { + Asserts.assertGreaterThan(value, 0L, "Stack trace id must be greater than 0, was " + value); + } + + public static long getStackIdOfDepth(int depth) { + if (depth > 0) { + return getStackIdOfDepth(depth - 1); + } + return JVM.getJVM().getStackTraceId(0); + } +} diff --git a/test/jdk/jfr/jvm/TestJFRIntrinsic.java b/test/jdk/jfr/jvm/TestJFRIntrinsic.java new file mode 100644 index 0000000000000000000000000000000000000000..be41df51ecaa80ac9080d1817907fbb1402cf871 --- /dev/null +++ b/test/jdk/jfr/jvm/TestJFRIntrinsic.java @@ -0,0 +1,154 @@ +/* + * 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. 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. + */ + +/** + * @test + * @summary Intrinsic for JFR + * @key jfr + * + * @library /lib / + * + * + * + * @build sun.hotspot.WhiteBox + * @build ClassFileInstaller + * + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * + * @run main/othervm -Xbootclasspath/a:. -ea -Xmixed -Xbatch -XX:TieredStopAtLevel=4 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * jdk.jfr.jvm.TestJFRIntrinsic + * + * @run main/othervm -Xbootclasspath/a:. -ea -Xmixed -Xbatch -XX:TieredStopAtLevel=1 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * jdk.jfr.jvm.TestJFRIntrinsic + */ + +package jdk.jfr.jvm; + +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.stream.IntStream; +import jdk.jfr.internal.JVM; +import jdk.test.lib.Platform; +import sun.hotspot.WhiteBox; +import sun.hotspot.code.NMethod; + +public class TestJFRIntrinsic { + + private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); + public Object eventWriter; + + public static void main(String... args) throws Exception { + /* + Temporarily excluded until getClassId is reworked to accommodate epoch shift tagging + Method classid = TestJFRIntrinsic.class.getDeclaredMethod("getClassIdIntrinsic", Class.class); + ti.runIntrinsicTest(classid); + */ + TestJFRIntrinsic ti = new TestJFRIntrinsic(); + Method eventWriterMethod = TestJFRIntrinsic.class.getDeclaredMethod("getEventWriterIntrinsic", Class.class); + ti.runIntrinsicTest(eventWriterMethod); + } + + /* + public void getClassIdIntrinsic(Class cls) { + long exp = JVM.getClassId(cls); + if (exp == 0) { + throw new RuntimeException("Class id is zero"); + } + } + */ + + public void getEventWriterIntrinsic(Class cls) { + Object o = JVM.getEventWriter(); + if (o != null) { + eventWriter = o; + } + } + + void runIntrinsicTest(Method method) throws Exception { + if (getMaxCompilationLevel() < 1) { + /* no compiler */ + return; + } + /* load it */ + try { + method.invoke(this, TestJFRIntrinsic.class); + } catch(Exception e) { + throw new RuntimeException(e); + } + + int[] lvls = getAvailableCompilationLevels(); + for (int i : lvls) { + //if (!WHITE_BOX.enqueueMethodForCompilation(method, i)) { + // throw new RuntimeException("Failed to enqueue method on level: " + i); + //} + + //if (WHITE_BOX.isMethodCompiled(method)) { + // NMethod nm = NMethod.get(method, false); + // if (nm.comp_level != i) { + // throw new RuntimeException("Failed to compile on correct level: " + i); + // } + // System.out.println("Compiled " + method + " on level " + i); + //} + } + } + + /* below is copied from CompilerUtil in hotspot test lib, removed this when it's moved */ + + /** + * Returns available compilation levels + * + * @return int array with compilation levels + */ + public static int[] getAvailableCompilationLevels() { + if (!WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompiler")) { + return new int[0]; + } + if (WhiteBox.getWhiteBox().getBooleanVMFlag("TieredCompilation")) { + Long flagValue = WhiteBox.getWhiteBox() + .getIntxVMFlag("TieredStopAtLevel"); + int maxLevel = flagValue.intValue(); + return IntStream.rangeClosed(1, maxLevel).toArray(); + } else { + if (Platform.isServer() && !Platform.isEmulatedClient()) { + return new int[]{4}; + } + if (Platform.isClient() || Platform.isMinimal() || Platform.isEmulatedClient()) { + return new int[]{1}; + } + } + return new int[0]; + } + + /** + * Returns maximum compilation level available + * @return an int value representing maximum compilation level available + */ + public static int getMaxCompilationLevel() { + return Arrays.stream(getAvailableCompilationLevels()) + .max() + .getAsInt(); + } +} diff --git a/test/jdk/jfr/jvm/TestJavaEvent.java b/test/jdk/jfr/jvm/TestJavaEvent.java new file mode 100644 index 0000000000000000000000000000000000000000..bc6619daca99634965766b46b894a149428f15b9 --- /dev/null +++ b/test/jdk/jfr/jvm/TestJavaEvent.java @@ -0,0 +1,213 @@ +/* + * 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.jvm; + +import java.io.File; +import java.io.IOException; +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.Event; +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; +import jdk.jfr.ValueDescriptor; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; + +/** + * @test TestGetThreadId + * @key jfr + * + * @library /lib / + * + * @run main/othervm jdk.jfr.jvm.TestJavaEvent + */ +public class TestJavaEvent { + + private static final int EVENTS_PER_THREAD = 50; + private static final int THREAD_COUNT = 100; + + public static class MyEvent extends Event { + float floatValue; + double doubleValue; + int intValue; + long longValue; + char charValue; + byte byteValue; + String stringValue; + Thread threadValue; + Class classValue; + + public void setFloatValue(float value) { + floatValue = value; + } + + public void setDoubleValue(double value) { + doubleValue = value; + } + + public void setIntValue(int value) { + intValue = value; + } + + public void setLongValue(long value) { + longValue = value; + } + + public void setCharValue(char value) { + charValue = value; + } + + public void setByteValue(byte value) { + byteValue = value; + } + + public void setStringValue(String value) { + stringValue = value; + } + + public void setThreadValue(Thread value) { + threadValue = value; + } + + public void setClassValue(Class value) { + classValue = value; + } + } + + public static void main(String... args) throws IOException, InterruptedException { + Recording r = new Recording(); + r.enable(MyEvent.class).withThreshold(Duration.ofNanos(0)).withoutStackTrace(); + r.start(); + List threads = new ArrayList<>(); + for (int n = 0; n < THREAD_COUNT; n++) { + Thread t = new Thread(TestJavaEvent::emitEvents); + threads.add(t); + t.start(); + } + for (Thread t : threads) { + t.join(); + } + + r.stop(); + // prettyPrint(); + File file = File.createTempFile("test", ".jfr"); + r.dump(file.toPath()); + int eventCount = 0; + for (RecordedEvent e : RecordingFile.readAllEvents(file.toPath())) { + if (e.getEventType().getName().equals(MyEvent.class.getName())) { + eventCount++; + } + System.out.println(e); + } + System.out.println("Event count was " + eventCount + ", expected " + THREAD_COUNT * EVENTS_PER_THREAD); + r.close(); + } + + private static void emitEvents() { + for (int n = 0; n < EVENTS_PER_THREAD; n++) { + MyEvent event = new MyEvent(); + event.begin(); + event.end(); + event.setFloatValue(1.12345f); + event.setDoubleValue(1.234567890); + event.setIntValue(123456); + event.setLongValue(1234567890); + event.setCharValue('c'); + event.setByteValue((byte) 12); + event.setStringValue("1234567890"); + event.setThreadValue(Thread.currentThread()); + event.setClassValue(Class.class); + event.commit(); + try { + Thread.sleep(1); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + static void prettyPrint() { + for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) { + for (AnnotationElement a : type.getAnnotationElements()) { + printAnnotation("", a); + } + System.out.print("class " + removePackage(type.getName())); + System.out.print(" extends Event"); + + System.out.println(" {"); + List values = type.getFields(); + for (int i = 0; i < values.size(); i++) { + ValueDescriptor v = values.get(i); + for (AnnotationElement a : v.getAnnotationElements()) { + printAnnotation(" ", a); + } + System.out.println(" " + removePackage(v.getTypeName() + brackets(v.isArray())) + " " + v.getName()); + if (i != values.size() - 1) { + System.out.println(); + } + } + System.out.println("}"); + System.out.println(); + } + } + + private static String brackets(boolean isArray) { + return isArray ? "[]" : ""; + } + + private static String removePackage(String s) { + + int index = s.lastIndexOf("."); + return s.substring(index + 1); + } + + private static void printAnnotation(String indent, AnnotationElement a) { + String name = removePackage(a.getTypeName()); + if (a.getValues().isEmpty()) { + System.out.println(indent + "@" + name); + return; + } + System.out.print(indent + "@" + name + "("); + for (Object o : a.getValues()) { + printAnnotationValue(o); + } + System.out.println(")"); + } + + private static void printAnnotationValue(Object o) { + if (o instanceof String) { + System.out.print("\"" + o + "\""); + } else { + System.out.print(String.valueOf(o)); + } + } + +} diff --git a/test/jdk/jfr/jvm/TestLargeJavaEvent512k.java b/test/jdk/jfr/jvm/TestLargeJavaEvent512k.java new file mode 100644 index 0000000000000000000000000000000000000000..bd86c87a47aa69ca8315a59fadfd278424197b24 --- /dev/null +++ b/test/jdk/jfr/jvm/TestLargeJavaEvent512k.java @@ -0,0 +1,148 @@ +/* + * 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.jvm; + +import java.io.IOException; +import java.time.Duration; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jdk.jfr.Event; +import jdk.jfr.EventFactory; +import jdk.jfr.Recording; +import jdk.jfr.ValueDescriptor; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventTypePrototype; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.Stressor; + +/** + * @test TestLargeJavaEvent512k + * @key jfr + * + * @library /lib / + * + * @run main/othervm jdk.jfr.jvm.TestLargeJavaEvent512k + */ +public class TestLargeJavaEvent512k { + static boolean error; + static void setError() { + error = true; + } + static boolean hasError() { + return error; + } + + public static void main(String... args) throws Exception { + final String name = "MyLargeJavaEvent512k"; // name of synthetically generated event + final String fieldNamePrefix = "myfield"; + final int numberOfFields = 64; // 64*8k = 512k event size + final Map eventMap = new HashMap<>(); + final int numberOfThreads = 10; // 10 threads will run the test + final int numberOfEventsPerThread = 50; // each thread will generate 50 events + + List fields = new ArrayList<>(); + for (int i = 0; i < numberOfFields; ++i) { + String fieldName = fieldNamePrefix + i; + eventMap.put(fieldName, largeString()); + fields.add(new ValueDescriptor(String.class, fieldName)); + } + + EventTypePrototype prototype = new EventTypePrototype(name,Collections.emptyList(), fields); + + EventFactory ef = EventFactory.create(prototype.getAnnotations(), prototype.getFields()); + + Recording r = new Recording(); + r.enable(prototype.getName()).withThreshold(Duration.ofNanos(0)).withoutStackTrace(); + r.start(); + + Thread.UncaughtExceptionHandler eh = (t, e) -> TestLargeJavaEvent512k.setError(); + + Stressor.execute(numberOfThreads, eh, () -> { + for (int n = 0; n < numberOfEventsPerThread; ++n) { + try { + Event event = ef.newEvent(); + setEventValues(event, ef, prototype, eventMap); + event.commit(); + Thread.sleep(1); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + }); + r.stop(); + try { + if (hasError()) { + throw new RuntimeException("One (or several) of the threads had an exception/error, test failed"); + } + verifyEvents(r, numberOfThreads, numberOfEventsPerThread, eventMap); + } finally { + r.close(); + } + } + + private static void verifyEvents(Recording r, int numberOfThreads, int iterations, Map fields) throws IOException { + List recordedEvents = Events.fromRecording(r); + Events.hasEvents(recordedEvents); + int eventCount = 0; + for (RecordedEvent re : recordedEvents) { + verify(re, fields); + eventCount++; + } + System.out.println("Number of expected events: " + numberOfThreads * iterations); + System.out.println("Number of events found: " + eventCount); + Asserts.assertEquals(numberOfThreads * iterations, eventCount, "Unexpected number of events"); + } + + // each row is 64 chars for 128 rows == 8192 chars + private static String largeString() { + StringBuilder builder = new StringBuilder(); + for (int i = 0; i < 128; ++i) { + builder.append("cygwinapacygwinapacygwinapacygwinapacygwinapacygwinapacygwinapa "); + } + return builder.toString(); + } + + private static void setEventValues(Event event, EventFactory f, EventTypePrototype prototype, Map fields) { + for (Map.Entry entry : fields.entrySet()) { + int index = prototype.getFieldIndex(entry.getKey()); + event.set(index, entry.getValue()); + } + } + + private static void verify(RecordedEvent event, Map fields) { + for (Map.Entry entry : fields.entrySet()) { + String fieldName = entry.getKey(); + Object value = event.getValue(fieldName); + Object expected = fields.get(fieldName); + Asserts.assertEQ(value, expected); + } + } +} diff --git a/test/jdk/jfr/jvm/TestLargeJavaEvent64k.java b/test/jdk/jfr/jvm/TestLargeJavaEvent64k.java new file mode 100644 index 0000000000000000000000000000000000000000..c48762ac28a123f492b2d1e41ad2dfe3afd2764e --- /dev/null +++ b/test/jdk/jfr/jvm/TestLargeJavaEvent64k.java @@ -0,0 +1,148 @@ +/* + * 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.jvm; + +import java.io.IOException; +import java.time.Duration; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jdk.jfr.Event; +import jdk.jfr.EventFactory; +import jdk.jfr.Recording; +import jdk.jfr.ValueDescriptor; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.EventTypePrototype; +import jdk.test.lib.jfr.Events; +import jdk.test.lib.jfr.Stressor; + +/** + * @test TestLargeJavaEvent64k + * @key jfr + * + * @library /lib / + * + * @run main/othervm jdk.jfr.jvm.TestLargeJavaEvent64k + */ +public class TestLargeJavaEvent64k { + static boolean error; + static void setError() { + error = true; + } + static boolean hasError() { + return error; + } + + public static void main(String... args) throws Exception { + final String name = "MyLargeJavaEvent64k"; // name of synthetically generated event + final String fieldNamePrefix = "myfield"; + final int numberOfFields = 8; // 8*8k = ~64k event size + final Map eventMap = new HashMap<>(); + final int numberOfThreads = 100; // 50 threads will run the test + final int numberOfEventsPerThread = 50; // each thread will generate 50 events + + List fields = new ArrayList<>(); + for (int i = 0; i < numberOfFields; ++i) { + String fieldName = fieldNamePrefix + i; + eventMap.put(fieldName, largeString()); + fields.add(new ValueDescriptor(String.class, fieldName)); + } + + EventTypePrototype prototype = new EventTypePrototype(name,Collections.emptyList(), fields); + + EventFactory ef = EventFactory.create(prototype.getAnnotations(), prototype.getFields()); + + Recording r = new Recording(); + r.enable(prototype.getName()).withThreshold(Duration.ofNanos(0)).withoutStackTrace(); + r.start(); + + Thread.UncaughtExceptionHandler eh = (t, e) -> TestLargeJavaEvent64k.setError(); + + Stressor.execute(numberOfThreads, eh, () -> { + for (int n = 0; n < numberOfEventsPerThread; ++n) { + try { + Event event = ef.newEvent(); + setEventValues(event, ef, prototype, eventMap); + event.commit(); + Thread.sleep(1); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + }); + r.stop(); + try { + if (hasError()) { + throw new RuntimeException("One (or several) of the threads had an exception/error, test failed"); + } + verifyEvents(r, numberOfThreads, numberOfEventsPerThread, eventMap); + } finally { + r.close(); + } + } + + private static void verifyEvents(Recording r, int numberOfThreads, int iterations, Map fields) throws IOException { + List recordedEvents = Events.fromRecording(r); + Events.hasEvents(recordedEvents); + int eventCount = 0; + for (RecordedEvent re : recordedEvents) { + verify(re, fields); + eventCount++; + } + System.out.println("Number of expected events: " + numberOfThreads * iterations); + System.out.println("Number of events found: " + eventCount); + Asserts.assertEquals(numberOfThreads * iterations, eventCount, "Unexpected number of events"); + } + + // each row is 64 chars for 128 rows == 8192 chars + private static String largeString() { + StringBuilder builder = new StringBuilder(); + for (int i = 0; i < 128; ++i) { + builder.append("cygwinapacygwinapacygwinapacygwinapacygwinapacygwinapacygwinapa "); + } + return builder.toString(); + } + + private static void setEventValues(Event event, EventFactory f, EventTypePrototype prototype, Map fields) { + for (Map.Entry entry : fields.entrySet()) { + int index = prototype.getFieldIndex(entry.getKey()); + event.set(index, entry.getValue()); + } + } + + private static void verify(RecordedEvent event, Map fields) { + for (Map.Entry entry : fields.entrySet()) { + String fieldName = entry.getKey(); + Object value = event.getValue(fieldName); + Object expected = fields.get(fieldName); + Asserts.assertEQ(value, expected); + } + } +} diff --git a/test/jdk/jfr/jvm/TestLogImplementation.java b/test/jdk/jfr/jvm/TestLogImplementation.java new file mode 100644 index 0000000000000000000000000000000000000000..3a928adcb2d593f011da83574b971b0530e445a5 --- /dev/null +++ b/test/jdk/jfr/jvm/TestLogImplementation.java @@ -0,0 +1,144 @@ +/* + * 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.jvm; + +import jdk.jfr.internal.JVM; +import jdk.jfr.internal.Logger; +import jdk.jfr.internal.LogTag; +import jdk.jfr.internal.LogLevel; + +/** + * @test TestLogImplementation + * @key jfr + * + * @library /lib / + * + * @run main/othervm jdk.jfr.jvm.TestLogImplementation + */ +public class TestLogImplementation { + private static LogLevel DEFAULT_TEST_LOG_LEVEL = LogLevel.ERROR; + private static LogTag JFR_LOG_TAG = LogTag.JFR; + + private static void assertAllLevelsForTag(LogTag tag, String message) { + for (LogLevel level : LogLevel.values()) { + Logger.log(tag, level, message); + } + } + + private static void assertAllTagsForLevel(LogLevel level, String message) { + for (LogTag tag : LogTag.values()) { + Logger.log(tag, level, message); + } + } + + public static void main(String... args) { + assertEmptyMessageOK(); + assertNullMessageOK(); + assertAllCharsOK(); + assertLargeMessageOK(); + assertFormatSpecifierOK(); + assertAllLevelOK(); + assertLogLevelUnderflow(); + assertLogLevelOverflow(); + assertLogTagUnderflow(); + assertLogTagOverflow(); + } + + private static void assertAllLevelOK() { + assertAllLevelsForTag(JFR_LOG_TAG, ""); + assertAllTagsForLevel(DEFAULT_TEST_LOG_LEVEL, ""); + } + + private static void assertFormatSpecifierOK() { + assertAllTagsForLevel(DEFAULT_TEST_LOG_LEVEL, "%s"); + assertAllTagsForLevel(DEFAULT_TEST_LOG_LEVEL, "%n"); + assertAllTagsForLevel(DEFAULT_TEST_LOG_LEVEL, "%h"); + } + + private static void assertLargeMessageOK() { + StringBuilder large = new StringBuilder(); + for (int i = 0; i < 1000 * 1000; i++) { + large.append('o'); + } + Logger.log(JFR_LOG_TAG, DEFAULT_TEST_LOG_LEVEL, large.toString()); + } + + private static void assertAllCharsOK() { + char c = Character.MIN_VALUE; + StringBuilder large = new StringBuilder(); + int logSize = 0; + for(int i = Character.MIN_VALUE; i< (int)Character.MAX_VALUE; i++, c++) { + large.append(c); + logSize++; + if (logSize == 80) { + Logger.log(JFR_LOG_TAG, DEFAULT_TEST_LOG_LEVEL, large.toString()); + large = new StringBuilder(); + } + } + } + + private static void assertEmptyMessageOK() { + assertAllLevelsForTag(JFR_LOG_TAG, ""); + } + + private static void assertNullMessageOK() { + assertAllLevelsForTag(JFR_LOG_TAG, (String)null); + } + + private static void assertLogLevelUnderflow() { + try { + JVM.log(JFR_LOG_TAG.ordinal(), 0, (String)null); + } catch (IllegalArgumentException ex) { + // Expected + } + } + + private static void assertLogLevelOverflow() { + try { + JVM.log(JFR_LOG_TAG.ordinal(), LogLevel.ERROR.ordinal() + 1, (String)null); + } catch (IllegalArgumentException ex) { + // Expected + } + } + + private static void assertLogTagUnderflow() { + try { + JVM.log(JFR_LOG_TAG.ordinal() - 1, DEFAULT_TEST_LOG_LEVEL.ordinal(), (String)null); + } catch (IllegalArgumentException ex) { + // Expected + } + } + + // since the enum will grow with new entries, provoking an overflow is problematic + // is there a built-in "current max" in a Java enum + private static void assertLogTagOverflow() { + try { + JVM.log(10000, DEFAULT_TEST_LOG_LEVEL.ordinal(), (String)null); + } catch (IllegalArgumentException ex) { + // Expected + } + } +} diff --git a/test/jdk/jfr/jvm/TestPid.java b/test/jdk/jfr/jvm/TestPid.java new file mode 100644 index 0000000000000000000000000000000000000000..5cd83cda0d05da9e30d8230cd59a19cda6b763bd --- /dev/null +++ b/test/jdk/jfr/jvm/TestPid.java @@ -0,0 +1,76 @@ +/* + * 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.jvm; + +import static jdk.test.lib.Asserts.assertEquals; +import java.lang.management.ManagementFactory; + +import jdk.jfr.internal.JVM; + +/** + * @test TestPid + * @key jfr + * + * @library /lib / + * + * @run main/othervm jdk.jfr.jvm.TestPid + */ +public class TestPid { + + private static long getProcessId() { + + // something like '@', at least in SUN / Oracle JVMs + final String jvmName = ManagementFactory.getRuntimeMXBean().getName(); + + final int index = jvmName.indexOf('@'); + + if (index < 1) { + // part before '@' empty (index = 0) / '@' not found (index = -1) + return 42; + } + + try { + return Long.parseLong(jvmName.substring(0, index)); + } catch (NumberFormatException e) { + // ignore + } + return 42; + } + + public static void main(String... args) throws InterruptedException { + + JVM jvm = JVM.getJVM(); + String pid = jvm.getPid(); + + try { + String managementPid = String.valueOf(getProcessId()); + assertEquals(pid, managementPid, "Pid doesn't match value returned by RuntimeMXBean"); + } catch (NumberFormatException nfe) { + throw new AssertionError("Pid must be numeric, but was '" + pid + "'"); + } + } + +} diff --git a/test/jdk/jfr/jvm/TestUnloadEventClassCount.java b/test/jdk/jfr/jvm/TestUnloadEventClassCount.java new file mode 100644 index 0000000000000000000000000000000000000000..c5987fc79b06752208e5b70fdf72f498447fce17 --- /dev/null +++ b/test/jdk/jfr/jvm/TestUnloadEventClassCount.java @@ -0,0 +1,111 @@ +/* + * 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.jvm; + +import java.io.ByteArrayOutputStream; +import java.io.InputStream; + +import jdk.jfr.Event; +import jdk.jfr.FlightRecorder; +import jdk.jfr.internal.JVM; + +/** + * @test + * @key jfr + * @summary Unit test for JVM#getUnloadedEventClassCount + * + * + * @library /lib / + * + * + * @run main/othervm -XX:+PrintGCDetails -XX:+PrintGC -verbose:class -Xmx16m jdk.jfr.jvm.TestUnloadEventClassCount + */ +public class TestUnloadEventClassCount { + + private static final String EVENT_NAME = "jdk.jfr.jvm.TestUnloadEventClassCount$ToBeUnloaded"; + + public static class ToBeUnloaded extends Event { + } + + static public class MyClassLoader extends ClassLoader { + public MyClassLoader() { + super(null); + } + + public final Class defineClass(String name, byte[] b) { + return super.defineClass(name, b, 0, b.length); + } + } + + public static MyClassLoader myClassLoader; + + public static void main(String[] args) throws Throwable { + FlightRecorder.getFlightRecorder(); + myClassLoader = createClassLoaderWithEventClass(); + System.out.println("MyClassLoader instance created"); + long initialCount = JVM.getJVM().getUnloadedEventClassCount(); + System.out.println("Initiali unloaded count is " + initialCount); + myClassLoader = null; + System.out.println("Reference to class loader cleared"); + long count = 0; + do { + System.gc(); + System.out.println("GC triggered"); + count = JVM.getJVM().getUnloadedEventClassCount(); + System.out.println("Unloaded count was " + count); + Thread.sleep(1000); // sleep to reduce log + } while (count != initialCount + 1); + } + + private static MyClassLoader createClassLoaderWithEventClass() throws Exception { + String resourceName = EVENT_NAME.replace('.', '/') + ".class"; + try (InputStream is = TestUnloadEventClassCount.class.getClassLoader().getResourceAsStream(resourceName)) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + byte[] buffer = new byte[4096]; + int byteValue = 0; + while ((byteValue = is.read(buffer, 0, buffer.length)) != -1) { + baos.write(buffer, 0, byteValue); + } + baos.flush(); + MyClassLoader myClassLoader = new MyClassLoader(); + Class eventClass = myClassLoader.defineClass(EVENT_NAME, baos.toByteArray()); + if (eventClass == null) { + throw new Exception("Could not define test class"); + } + if (eventClass.getSuperclass() != Event.class) { + throw new Exception("Superclass should be jdk.jfr.Event"); + } + if (eventClass.getSuperclass().getClassLoader() != null) { + throw new Exception("Class loader of jdk.jfr.Event should be null"); + } + if (eventClass.getClassLoader() != myClassLoader) { + throw new Exception("Incorrect class loader for event class"); + } + eventClass.newInstance(); // force + return myClassLoader; + } + } +} diff --git a/test/jdk/jfr/jvm/TestUnsupportedVM.java b/test/jdk/jfr/jvm/TestUnsupportedVM.java new file mode 100644 index 0000000000000000000000000000000000000000..c2485d74689c2fb81f39930de86b7b1f40afac9d --- /dev/null +++ b/test/jdk/jfr/jvm/TestUnsupportedVM.java @@ -0,0 +1,228 @@ +/* + * 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 + * 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.jvm; + + +import java.io.FileReader; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.concurrent.Callable; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.Configuration; +import jdk.jfr.Description; +import jdk.jfr.Event; +import jdk.jfr.EventFactory; +import jdk.jfr.EventSettings; +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorder; +import jdk.jfr.FlightRecorderListener; +import jdk.jfr.FlightRecorderPermission; +import jdk.jfr.Label; +import jdk.jfr.Recording; +import jdk.jfr.RecordingState; +import jdk.jfr.SettingControl; +import jdk.jfr.ValueDescriptor; +import jdk.jfr.consumer.RecordedClass; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedFrame; +import jdk.jfr.consumer.RecordedMethod; +import jdk.jfr.consumer.RecordedObject; +import jdk.jfr.consumer.RecordedStackTrace; +import jdk.jfr.consumer.RecordedThread; +import jdk.jfr.consumer.RecordedThreadGroup; +import jdk.jfr.consumer.RecordingFile; +import jdk.management.jfr.ConfigurationInfo; +import jdk.management.jfr.EventTypeInfo; +import jdk.management.jfr.FlightRecorderMXBean; +import jdk.management.jfr.RecordingInfo; +import jdk.management.jfr.SettingDescriptorInfo; +import jdk.test.lib.Utils; + +/** + * @test TestUnsupportedVM + * @key jfr + * + * + * + * + * @library /lib / + * @run main/othervm -Dprepare-recording=true jdk.jfr.jvm.TestUnsupportedVM + * @run main/othervm -Djfr.unsupported.vm=true jdk.jfr.jvm.TestUnsupportedVM + */ +public class TestUnsupportedVM { + + private static Path RECORDING_FILE = Paths.get("recording.jfr"); + private static Class [] APIClasses = { + AnnotationElement.class, + Configuration.class, + ConfigurationInfo.class, + Event.class, + EventFactory.class, + EventSettings.class, + EventType.class, + EventTypeInfo.class, + FlightRecorder.class, + FlightRecorderPermission.class, + FlightRecorderListener.class, + FlightRecorderMXBean.class, + RecordedClass.class, + RecordedEvent.class, + RecordedFrame.class, + RecordedMethod.class, + RecordedObject.class, + RecordedStackTrace.class, + RecordedThread.class, + RecordedThreadGroup.class, + Recording.class, + RecordingFile.class, + RecordingInfo.class, + RecordingState.class, + SettingControl.class, + SettingDescriptorInfo.class, + ValueDescriptor.class + }; + // * @run main/othervm -Dprepare-recording=true jdk.jfr.jvm.TestUnsupportedVM + @Label("My Event") + @Description("My fine event") + static class MyEvent extends Event { + int myValue; + } + + public static void main(String... args) throws Exception { + if (Boolean.getBoolean("prepare-recording")) { + Recording r = new Recording(Configuration.getConfiguration("default")); + r.start(); + r.stop(); + r.dump(RECORDING_FILE); + r.close(); + return; + } + + System.out.println("jdk.jfr.unsupportedvm=" + System.getProperty("jdk.jfr.unsupportedvm")); + // Class FlightRecorder + if (FlightRecorder.isAvailable()) { + throw new AssertionError("JFR should not be available on an unsupported VM"); + } + + if (FlightRecorder.isInitialized()) { + throw new AssertionError("JFR should not be initialized on an unsupported VM"); + } + + assertIllegalStateException(() -> FlightRecorder.getFlightRecorder()); + assertSwallow(() -> FlightRecorder.addListener(new FlightRecorderListener() {})); + assertSwallow(() -> FlightRecorder.removeListener(new FlightRecorderListener() {})); + assertSwallow(() -> FlightRecorder.register(MyEvent.class)); + assertSwallow(() -> FlightRecorder.unregister(MyEvent.class)); + assertSwallow(() -> FlightRecorder.addPeriodicEvent(MyEvent.class, new Runnable() { public void run() {} })); + assertSwallow(() -> FlightRecorder.removePeriodicEvent(new Runnable() { public void run() {} })); + + // Class Configuration + if (!Configuration.getConfigurations().isEmpty()) { + throw new AssertionError("Configuration files should not exist on an unsupported VM"); + } + Path jfcFile = Utils.createTempFile("empty", ".jfr"); + assertIOException(() -> Configuration.getConfiguration("default")); + assertIOException(() -> Configuration.create(jfcFile)); + assertIOException(() -> Configuration.create(new FileReader(jfcFile.toFile()))); + + // Class EventType + assertInternalError(() -> EventType.getEventType(MyEvent.class)); + + // Class EventFactory + assertInternalError(() -> EventFactory.create(new ArrayList<>(), new ArrayList<>())); + + // Create a static event + MyEvent myEvent = new MyEvent(); + myEvent.begin(); + myEvent.end(); + myEvent.shouldCommit(); + myEvent.commit(); + + // Trigger class initialization failure + for (Class c : APIClasses) { + assertNoClassInitFailure(c); + } + + // jdk.jfr.consumer.* + // Only run this part of tests if we are on VM + // that can produce a recording file + if (Files.exists(RECORDING_FILE)) { + for(RecordedEvent re : RecordingFile.readAllEvents(RECORDING_FILE)) { + System.out.println(re); + } + } + } + + private static void assertNoClassInitFailure(Class clazz) { + try { + Class.forName(clazz.getName(), true, clazz.getClassLoader()); + } catch (ClassNotFoundException e) { + throw new AssertionError("Could not find public API class on unsupported VM"); + } + } + + private static void assertInternalError(Runnable r) { + try { + r.run(); + } catch (InternalError e) { + // OK, as expected + return; + } + throw new AssertionError("Expected InternalError on an unsupported JVM"); + } + + private static void assertIOException(Callable c) { + try { + c.call(); + } catch (Exception e) { + if (e.getClass() == IOException.class) { + return; + } + } + throw new AssertionError("Expected IOException on an unsupported JVM"); + } + + private static void assertIllegalStateException(Runnable r) throws Exception { + try { + r.run(); + } catch (IllegalStateException ise) { + if (!ise.getMessage().equals("Flight Recorder is not supported on this VM")) { + throw new AssertionError("Expected 'Flight Recorder is not supported on this VM'"); + } + } + } + + private static void assertSwallow(Runnable r) throws Exception { + try { + r.run(); + } catch (Exception e) { + throw new AssertionError("Unexpected exception '" + e.getMessage() + " on an unspported VM"); + } + } +} diff --git a/test/jdk/jfr/security/JFRSecurityTestSuite.java b/test/jdk/jfr/security/JFRSecurityTestSuite.java new file mode 100644 index 0000000000000000000000000000000000000000..0c5eb4f7e994a6b96db5e087ecc5d284c4ba9de4 --- /dev/null +++ b/test/jdk/jfr/security/JFRSecurityTestSuite.java @@ -0,0 +1,442 @@ +/* + * Copyright (c) 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 + * 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.io.FilePermission; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; + +import java.security.AccessControlContext; +import java.security.AccessControlException; +import java.security.AccessController; +import java.security.AllPermission; +import java.security.CodeSource; +import java.security.Permission; +import java.security.PermissionCollection; +import java.security.Permissions; +import java.security.Policy; +import java.security.PrivilegedAction; +import java.security.ProtectionDomain; + +import java.time.Duration; + +import java.util.ArrayList; +import java.util.Comparator; + +import jdk.jfr.AnnotationElement; +import jdk.jfr.Configuration; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordingFile; +import jdk.jfr.Event; +import jdk.jfr.EventFactory; +import jdk.jfr.EventType; +import jdk.jfr.FlightRecorder; +import jdk.jfr.FlightRecorderListener; +import jdk.jfr.FlightRecorderPermission; +import jdk.jfr.internal.JVM; +import jdk.jfr.Label; +import jdk.jfr.Name; +import jdk.jfr.Recording; +import jdk.jfr.ValueDescriptor; + +import jdk.test.lib.Platform; + +/* + * @test + * @requires (jdk.version.major >= 8) + * @library /lib / + * @key jfr + * @run main/othervm/timeout=30 -XX:+FlightRecorder -XX:StartFlightRecording JFRSecurityTestSuite + * @author Martin Balao (mbalao@redhat.com) + */ + +public class JFRSecurityTestSuite { + + private static boolean DEBUG = true; + private static SecurityManager sm; + private static String failureMessage = null; + private static Path jfrTmpDirPath = null; + private static Path recFilePath = null; + private static String protectedLocationPath; + + interface F { + void call() throws Exception; + } + + @Label("MyEvent") + static class MyEvent extends Event { + } + + @Label("MyEvent2") + static class MyEvent2 extends Event { + } + + @Label("MyEvent3") + static class MyEvent3 extends Event { + } + + public static class MyPolicy extends Policy { + public MyPolicy() { + super(); + } + @Override + public PermissionCollection getPermissions(ProtectionDomain domain) { + PermissionCollection perms = new Permissions(); + perms.add(new AllPermission()); + return perms; + } + } + + private static class MyProtectionDomain extends ProtectionDomain { + MyProtectionDomain(CodeSource source, Permissions permissions) { + super(source, permissions); + } + + public boolean implies(Permission permission) { + if (DEBUG) { + System.out.println("Permission checked: " + permission); + } + return super.implies(permission); + } + } + + private static final Runnable periodicEvent = new Runnable() { + @Override + public void run() { + if (DEBUG) { + System.out.println("Periodic event"); + } + } + }; + private static final FlightRecorderListener frl = + new FlightRecorderListener() { }; + + public static void main(String[] args) throws Throwable { + + // Temporary directory for JFR files + jfrTmpDirPath = Files.createTempDirectory("jfr_test"); + + try { + setProtectedLocation(); + + File recFile = new File(jfrTmpDirPath.toString(), "rec"); + recFile.createNewFile(); + recFilePath = recFile.toPath(); + if (DEBUG) { + System.out.println("Test JFR tmp directory: " + jfrTmpDirPath); + } + + // Create a SecurityManager with all permissions enabled + Policy.setPolicy(new MyPolicy()); + sm = new SecurityManager(); + System.setSecurityManager(sm); + + CodeSource source = + Thread.currentThread().getClass(). + getProtectionDomain().getCodeSource(); + + // Create a constrained execution environment + Permissions noPermissions = new Permissions(); + ProtectionDomain constrainedPD = new MyProtectionDomain(source, + noPermissions); + AccessControlContext constrainedContext = + new AccessControlContext(new ProtectionDomain[] { + constrainedPD }); + + AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Void run() { + try { + doInConstrainedEnvironment(); + } catch (Throwable t) { + if (DEBUG) { + t.printStackTrace(); + } + failureMessage = t.toString(); + } + return null; + } + }, constrainedContext); + + // Create a JFR execution environment + Permissions JFRPermissions = new Permissions(); + JFRPermissions.add(new FilePermission(recFilePath.toString(), + "read,write")); + JFRPermissions.add(new FlightRecorderPermission( + "accessFlightRecorder")); + JFRPermissions.add(new FlightRecorderPermission( + "registerEvent")); + JFRPermissions.add(new RuntimePermission( + "accessDeclaredMembers")); + ProtectionDomain JFRPD = new MyProtectionDomain(source, + JFRPermissions); + AccessControlContext JFRContext = + new AccessControlContext(new ProtectionDomain[] { JFRPD }); + + AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Void run() { + try { + doInJFREnvironment(); + } catch (Throwable t) { + if (DEBUG) { + t.printStackTrace(); + } + failureMessage = t.toString(); + } + return null; + } + }, JFRContext); + + if (failureMessage != null) { + throw new Exception("TEST FAILED" + System.lineSeparator() + + failureMessage); + } + System.out.println("TEST PASS - OK"); + + } finally { + Files.walk(jfrTmpDirPath) + .sorted(Comparator.reverseOrder()) + .map(Path::toFile) + .forEach(File::delete); + } + } + + private static void setProtectedLocation() { + if (Platform.isWindows()) { + protectedLocationPath = System.getenv("%WINDIR%"); + if (protectedLocationPath == null) { + // fallback + protectedLocationPath = "c:\\windows"; + } + } else { + protectedLocationPath = "/etc"; + } + } + + private static void doInConstrainedEnvironment() throws Throwable { + checkNoDirectAccess(); + + assertPermission(() -> { + FlightRecorder.getFlightRecorder(); + }, FlightRecorderPermission.class, "accessFlightRecorder", false); + + assertPermission(() -> { + FlightRecorder.register(MyEvent.class); + }, FlightRecorderPermission.class, "registerEvent", false); + + assertPermission(() -> { + FlightRecorder.unregister(MyEvent.class); + }, FlightRecorderPermission.class, "registerEvent", false); + + assertPermission(() -> { + FlightRecorder.addPeriodicEvent(MyEvent.class, periodicEvent); + }, FlightRecorderPermission.class, "registerEvent", false); + + assertPermission(() -> { + FlightRecorder.removePeriodicEvent(periodicEvent); + }, FlightRecorderPermission.class, "registerEvent", false); + + assertPermission(() -> { + FlightRecorder.addListener(frl); + }, FlightRecorderPermission.class, "accessFlightRecorder", false); + + assertPermission(() -> { + FlightRecorder.removeListener(frl); + }, FlightRecorderPermission.class, "accessFlightRecorder", false); + + assertPermission(() -> { + new MyEvent().commit(); + }, FlightRecorderPermission.class, "registerEvent", true); + + assertPermission(() -> { + Configuration.create(Paths.get(protectedLocationPath)); + }, FilePermission.class, protectedLocationPath, false); + + assertPermission(() -> { + EventFactory.create(new ArrayList(), + new ArrayList()); + }, FlightRecorderPermission.class, "registerEvent", false); + + assertPermission(() -> { + new AnnotationElement(Name.class, "com.example.HelloWorld"); + }, FlightRecorderPermission.class, "registerEvent", false); + + assertPermission(() -> { + new ValueDescriptor(MyEvent.class, "", + new ArrayList()); + }, FlightRecorderPermission.class, "registerEvent", false); + + assertPermission(() -> { + new Recording(); + }, FlightRecorderPermission.class, "accessFlightRecorder", false); + + assertPermission(() -> { + new RecordingFile(Paths.get(protectedLocationPath)); + }, FilePermission.class, protectedLocationPath, false); + + assertPermission(() -> { + RecordingFile.readAllEvents(Paths.get(protectedLocationPath)); + }, FilePermission.class, protectedLocationPath, false); + + assertPermission(() -> { + EventType.getEventType(MyEvent2.class); + }, FlightRecorderPermission.class, "registerEvent", true); + } + + private static void doInJFREnvironment() throws Throwable { + + checkNoDirectAccess(); + + FlightRecorder fr = FlightRecorder.getFlightRecorder(); + + Configuration c = Configuration.getConfiguration("default"); + + Recording recordingDefault = new Recording(c); + + recordingDefault.start(); + + FlightRecorder.addListener(frl); + + FlightRecorder.register(MyEvent3.class); + + FlightRecorder.addPeriodicEvent(MyEvent3.class, periodicEvent); + + new MyEvent3().commit(); + + FlightRecorder.removePeriodicEvent(periodicEvent); + + FlightRecorder.unregister(MyEvent3.class); + + FlightRecorder.removeListener(frl); + + recordingDefault.stop(); + + try (Recording snapshot = fr.takeSnapshot()) { + if (snapshot.getSize() > 0) { + snapshot.setMaxSize(100_000_000); + snapshot.setMaxAge(Duration.ofMinutes(5)); + snapshot.dump(recFilePath); + } + } + checkRecording(); + + Files.write(recFilePath, new byte[0], + StandardOpenOption.TRUNCATE_EXISTING); + recordingDefault.dump(recFilePath); + checkRecording(); + + try { + class MyEventHandler extends jdk.jfr.internal.handlers.EventHandler { + MyEventHandler() { + super(true, null, null); + } + } + MyEventHandler myEv = new MyEventHandler(); + throw new Exception("EventHandler must not be subclassable"); + } catch (SecurityException e) {} + } + + private static void checkRecording() throws Throwable { + boolean myEvent3Found = false; + try (RecordingFile rf = new RecordingFile(recFilePath)) { + while (rf.hasMoreEvents()) { + RecordedEvent event = rf.readEvent(); + if (event.getEventType().getName().equals( + "JFRSecurityTestSuite$MyEvent3")) { + if (DEBUG) { + System.out.println("Recording of MyEvent3 event:"); + System.out.println(event); + } + myEvent3Found = true; + break; + } + } + } + if (!myEvent3Found) { + throw new Exception("MyEvent3 event was expected in JFR recording"); + } + } + + private static void checkNoDirectAccess() throws Throwable { + assertPermission(() -> { + sm.checkPackageAccess("jdk.jfr.internal"); + }, RuntimePermission.class, null, false); + + assertPermission(() -> { + Class.forName("jdk.jfr.internal.JVM"); + }, RuntimePermission.class, null, false); + + assertPermission(() -> { + JVM.getJVM(); + }, RuntimePermission.class, null, false); + + assertPermission(() -> { + sm.checkPackageAccess("jdk.jfr.events"); + }, RuntimePermission.class, null, false); + + assertPermission(() -> { + Class.forName("jdk.jfr.events.AbstractJDKEvent"); + }, RuntimePermission.class, null, false); + + assertPermission(() -> { + sm.checkPackageAccess("jdk.management.jfr.internal"); + }, RuntimePermission.class, null, false); + } + + private static void assertPermission(F f, Class expectedPermClass, + String expectedPermName, boolean expectedIsCause) + throws Throwable { + String exceptionMessage = expectedPermClass.toString() + + (expectedPermName != null && !expectedPermName.isEmpty() ? + " " + expectedPermName : "") + + " permission check expected."; + try { + f.call(); + throw new Exception(exceptionMessage); + } catch (Throwable t) { + Throwable t2 = null; + if (expectedIsCause) { + t2 = t.getCause(); + } else { + t2 = t; + } + if (t2 instanceof AccessControlException) { + AccessControlException ace = (AccessControlException)t2; + Permission p = ace.getPermission(); + if (!p.getClass().equals(expectedPermClass) || + (expectedPermName != null && !expectedPermName.isEmpty() && + !p.getName().equals(expectedPermName))) { + throw new Exception(exceptionMessage, ace); + } + } else { + throw t; + } + } + } +} + diff --git a/test/jdk/jfr/startupargs/StartupHelper.java b/test/jdk/jfr/startupargs/StartupHelper.java new file mode 100644 index 0000000000000000000000000000000000000000..7e632cb7157fcb0f7050d2d5787b5240e253a987 --- /dev/null +++ b/test/jdk/jfr/startupargs/StartupHelper.java @@ -0,0 +1,106 @@ +/* + * 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 + * 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.startupargs; + +import java.io.IOException; +import java.nio.file.DirectoryStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import jdk.jfr.FlightRecorder; +import jdk.jfr.Recording; +import jdk.test.lib.Asserts; +import jdk.test.lib.dcmd.CommandExecutor; +import jdk.test.lib.dcmd.PidJcmdExecutor; +import jdk.test.lib.process.OutputAnalyzer; + + + +public class StartupHelper { + + public static Recording getRecording(String name) { + for (Recording r : FlightRecorder.getFlightRecorder().getRecordings()) { + System.out.println("Recording=" + r.getName()); + if (name.equals(r.getName())) { + return r; + } + } + Asserts.fail("No recording with name " + name); + return null; + } + + public static List listFilesInDir(Path root) throws IOException { + List paths = new ArrayList<>(); + List searchPaths = new ArrayList<>(); + searchPaths.add(root); + + while (!searchPaths.isEmpty()) { + Path currRoot = searchPaths.remove(searchPaths.size() - 1); + DirectoryStream contents = Files.newDirectoryStream(currRoot); + for (Path path : contents) { + paths.add(path); + if (Files.isDirectory(path)) { + searchPaths.add(path); + } + } + } + + System.out.println("Files in '" + root + "':"); + for (Path path : paths) { + System.out.println(" path: " + path); + } + return paths; + } + + public static Path findRecordingFileInRepo(Path baseLocation) throws IOException { + // Check that repo contains a file ending in "jfr" or "part" + for (Path path : listFilesInDir(baseLocation)) { + if (Files.isRegularFile(path)) { + String filename = path.toString(); + if (filename.endsWith("jfr") || filename.endsWith("part")) { + return path; + } + } + } + return null; + } + + public static OutputAnalyzer jcmd(String... args) { + String argsString = Arrays.stream(args).collect(Collectors.joining(" ")); + CommandExecutor executor = new PidJcmdExecutor(); + OutputAnalyzer oa = executor.execute(argsString); + oa.shouldHaveExitValue(0); + return oa; + } + + public static OutputAnalyzer jcmdCheck(String recordingName) { + return jcmd("JFR.check", "name=" + recordingName, "verbose=true"); + } +} diff --git a/test/jdk/jfr/startupargs/TestBadOptionValues.java b/test/jdk/jfr/startupargs/TestBadOptionValues.java new file mode 100644 index 0000000000000000000000000000000000000000..93398c5d8a797c53924b77050390a45f3b6d52d8 --- /dev/null +++ b/test/jdk/jfr/startupargs/TestBadOptionValues.java @@ -0,0 +1,151 @@ +/* + * 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. 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.startupargs; + +import jdk.test.lib.Asserts; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +/** + * @test + * @key jfr + * + * + * @library /lib / + * + + * + * @run main jdk.jfr.startupargs.TestBadOptionValues + */ +public class TestBadOptionValues { + + private static final String START_FLIGHT_RECORDING = "-XX:StartFlightRecording="; + private static final String FLIGHT_RECORDER_OPTIONS = "-XX:FlightRecorderOptions="; + + private static void test(String prepend, String expectedOutput, String... options) throws Exception { + ProcessBuilder pb; + OutputAnalyzer output; + + Asserts.assertGreaterThan(options.length, 0); + + for (String option : options) { + pb = ProcessTools.createJavaProcessBuilder(prepend + option, "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain(expectedOutput); + } + } + + private static void testBoolean(String prepend, String... options) throws Exception { + String[] splitOption; + + Asserts.assertGreaterThan(options.length, 0); + + for (String option : options) { + splitOption = option.split("=", 2); + test(prepend, String.format("Boolean parsing error in command argument '%s'. Could not parse: %s.", splitOption[0], splitOption[1]), option); + } + } + + private static void testJlong(String prepend, String... options) throws Exception { + String[] splitOption; + + Asserts.assertGreaterThan(options.length, 0); + + for (String option : options) { + splitOption = option.split("=", 2); + test(prepend, String.format("Integer parsing error in command argument '%s'. Could not parse: %s.", + splitOption[0], splitOption.length > 1 ? splitOption[1]: ""), option); + } + } + + public static void main(String[] args) throws Exception { + // Nanotime options + test(START_FLIGHT_RECORDING, "Integer parsing error nanotime value: syntax error", + "delay=ms", + "duration=", + "maxage=q"); + test(START_FLIGHT_RECORDING, "Integer parsing error nanotime value: syntax error, value is null", + "duration"); + test(START_FLIGHT_RECORDING, "Integer parsing error nanotime value: illegal unit", + "delay=1000mq", + "duration=2000mss", + "maxage=-1000"); + test(START_FLIGHT_RECORDING, "Integer parsing error nanotime value: unit required", + "delay=3037", + "maxage=1"); + + // Memory size options + test(START_FLIGHT_RECORDING, "Parsing error memory size value: negative values not allowed", + "maxsize=-1", + "maxsize=-10k"); + + test(FLIGHT_RECORDER_OPTIONS, "Parsing error memory size value: negative values not allowed", + "threadbuffersize=-1M", + "memorysize=-1g", + "globalbuffersize=-0", + "maxchunksize=-"); + + test(START_FLIGHT_RECORDING, "Parsing error memory size value: syntax error, value is null", + "maxsize"); + + test(FLIGHT_RECORDER_OPTIONS, "Parsing error memory size value: syntax error, value is null", + "threadbuffersize", + "memorysize", + "globalbuffersize", + "maxchunksize"); + + test(START_FLIGHT_RECORDING, "Parsing error memory size value: invalid value", + "maxsize="); + + test(FLIGHT_RECORDER_OPTIONS, "Parsing error memory size value: invalid value", + "threadbuffersize=a", + "globalbuffersize=G", + "maxchunksize=M10"); + + // Jlong options + testJlong(FLIGHT_RECORDER_OPTIONS, + "stackdepth=q", + "stackdepth=", + "numglobalbuffers=10m", + "numglobalbuffers", + "numglobalbuffers=0x15"); + + // Boolean options + testBoolean(START_FLIGHT_RECORDING, + "disk=on", + "dumponexit=truee"); + + testBoolean(FLIGHT_RECORDER_OPTIONS, + "samplethreads=falseq", + "retransform=0"); + + // Not existing options + test(START_FLIGHT_RECORDING, "Unknown argument 'dumponexitt' in diagnostic command.", + "dumponexitt=true"); + test(FLIGHT_RECORDER_OPTIONS, "Unknown argument 'notexistoption' in diagnostic command.", + "notexistoption"); + } +} diff --git a/test/jdk/jfr/startupargs/TestDumpOnExit.java b/test/jdk/jfr/startupargs/TestDumpOnExit.java new file mode 100644 index 0000000000000000000000000000000000000000..312c70d41eb7dc718269c3adf5cf5979d4b648b1 --- /dev/null +++ b/test/jdk/jfr/startupargs/TestDumpOnExit.java @@ -0,0 +1,114 @@ +/* + * 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 + * 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.startupargs; + +import java.io.IOException; +import java.nio.file.DirectoryStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Iterator; +import java.util.function.Supplier; + +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + +/** + * @test + * @summary Start a FlightRecording with dumponexit. Verify dump exists. + * @key jfr + * + * @library /lib / + * @run main/othervm jdk.jfr.startupargs.TestDumpOnExit + */ +public class TestDumpOnExit { + + public static void main(String[] args) throws Exception { + Path dumpPath = Paths.get(".", "dumped.jfr"); + + // Test without security manager and a file name relative to current directory + testDumponExit(() -> dumpPath, + "-XX:+LogJFR", + "-XX:StartFlightRecording=filename=./dumped.jfr,dumponexit=true,settings=profile", + "jdk.jfr.startupargs.TestDumpOnExit$TestMain" + ); + // Test a memory recording without a security manager + testDumponExit(() -> findJFRFileInCurrentDirectory(), + "-XX:+LogJFR", + "-XX:StartFlightRecording=dumponexit=true,disk=false", + "jdk.jfr.startupargs.TestDumpOnExit$TestMain" + ); + + // Test with security manager and a file name relative to current directory + testDumponExit(() -> dumpPath, + "-XX:+LogJFR", + "-XX:StartFlightRecording=filename=./dumped.jfr,dumponexit=true,settings=profile", + "-Djava.security.manager", + "jdk.jfr.startupargs.TestDumpOnExit$TestMain" + ); + // Test with security manager but without a name + testDumponExit(() -> findJFRFileInCurrentDirectory(), + "-XX:+LogJFR", + "-XX:StartFlightRecording=dumponexit=true,settings=profile", + "-Djava.security.manager", + "jdk.jfr.startupargs.TestDumpOnExit$TestMain" + ); + } + + private static Path findJFRFileInCurrentDirectory() { + try { + DirectoryStream ds = Files.newDirectoryStream(Paths.get("."), "*pid-*.jfr"); + Iterator pathIterator = ds.iterator(); + if (!pathIterator.hasNext()) { + throw new RuntimeException("Could not find jfr file in current directory"); + } + return pathIterator.next(); + } catch (IOException e) { + throw new RuntimeException("Could not list jfr file in current directory"); + } + } + + private static void testDumponExit(Supplier p,String... args) throws Exception, IOException { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, args); + OutputAnalyzer output = ProcessTools.executeProcess(pb); + System.out.println(output.getOutput()); + output.shouldHaveExitValue(0); + Path dump = p.get(); + Asserts.assertTrue(Files.isRegularFile(dump), "No recording dumped " + dump); + System.out.println("Dumped recording size=" + Files.size(dump)); + Asserts.assertFalse(RecordingFile.readAllEvents(dump).isEmpty(), "No events in dump"); + } + + @SuppressWarnings("unused") + private static class TestMain { + public static void main(String[] args) throws Exception { + System.out.println("Hello from test main"); + } + } + +} diff --git a/test/jdk/jfr/startupargs/TestMemoryOptions.java b/test/jdk/jfr/startupargs/TestMemoryOptions.java new file mode 100644 index 0000000000000000000000000000000000000000..529bd7736bf51b488a6d2228c3bd87bb2250859d --- /dev/null +++ b/test/jdk/jfr/startupargs/TestMemoryOptions.java @@ -0,0 +1,656 @@ +/* + * 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. 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.startupargs; + +import java.util.List; +import java.util.ArrayList; +import java.lang.reflect.Field; + +import jdk.jfr.internal.Options; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import sun.misc.Unsafe; + +/** + * @test + * @key jfr + * + * @library /lib / + * + * @run main/timeout=900 jdk.jfr.startupargs.TestMemoryOptions + */ +public class TestMemoryOptions { + + public enum Unit { + b('b'), k('k'), m('m'), g('g'); + + private char unit; + + Unit(char unit) { + this.unit = unit; + } + + char getUnit() { + return unit; + } + }; + + static class Option implements Comparable