# HG changeset patch # User mfang # Date 1329934677 28800 # Node ID 09f5d262e32952360fc40149583c0ac886e98b2b # Parent eab1e4be8495dae49e9fc6e07a7a1496063b9a5c# Parent c51754cddc037b9609e202b9ed38363d8683e7a8 Merge diff -r eab1e4be8495 -r 09f5d262e329 .hgtags --- a/.hgtags Fri Feb 17 10:18:50 2012 -0800 +++ b/.hgtags Wed Feb 22 10:17:57 2012 -0800 @@ -147,3 +147,4 @@ 498124337041ad53cbaa7eb110f3d7acd6d4eac4 jdk8-b23 7d3720d8c595d1519c31e9ff7366203fc2c61350 jdk8-b24 0071a6d64113a35ba345bb1580c256de5ce17d3e jdk8-b25 +6c805d8ed4e5449ea5e4d158c7bdbd7b0b70efd1 jdk8-b26 diff -r eab1e4be8495 -r 09f5d262e329 .hgtags-top-repo --- a/.hgtags-top-repo Fri Feb 17 10:18:50 2012 -0800 +++ b/.hgtags-top-repo Wed Feb 22 10:17:57 2012 -0800 @@ -147,3 +147,4 @@ 60d6f64a86b1e511169d264727f6d51415978df0 jdk8-b23 1a5f1d6b98d6827cdb529a4abe6e52a886d944f4 jdk8-b24 221a378e06a326f45e5d89e2123cd6323e0181d1 jdk8-b25 +2accafff224ae39caf5f532c305251ba624bf2c0 jdk8-b26 diff -r eab1e4be8495 -r 09f5d262e329 corba/.hgtags --- a/corba/.hgtags Fri Feb 17 10:18:50 2012 -0800 +++ b/corba/.hgtags Wed Feb 22 10:17:57 2012 -0800 @@ -147,3 +147,4 @@ 5218eb256658442b62b05295aafa5b5f35252972 jdk8-b23 b98f0e6dddf987df565029a1f58417fc1844c3f3 jdk8-b24 e45d6b406d5f91ff5256a5c82456ab1e7eb8becd jdk8-b25 +79f709a099f40c08f76567fa6d813f9009a69826 jdk8-b26 diff -r eab1e4be8495 -r 09f5d262e329 hotspot/.hgtags --- a/hotspot/.hgtags Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/.hgtags Wed Feb 22 10:17:57 2012 -0800 @@ -220,3 +220,7 @@ 64b46f975ab82948c1e021e17775ff4fab8bc40e hs23-b14 9ad8feb5afbddec46d3cfe29fb5f73c2e99d5a43 jdk8-b25 d71e662fe03741b6de498ca2077220148405a978 hs23-b15 +fd3060701216a11c0df6dcd053c6fd7c2b17a42c jdk8-b26 +f92a171cf0071ca6c3fa8231d7d570377f8b2f4d hs23-b16 +f92a171cf0071ca6c3fa8231d7d570377f8b2f4d hs23-b16 +931e5f39e365a0d550d79148ff87a7f9e864d2e1 hs23-b16 diff -r eab1e4be8495 -r 09f5d262e329 hotspot/agent/src/os/linux/Makefile --- a/hotspot/agent/src/os/linux/Makefile Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/agent/src/os/linux/Makefile Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ # -# Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2002, 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 @@ -40,7 +40,7 @@ LIBS = -lthread_db -CFLAGS = -c -fPIC -g -D_GNU_SOURCE -D$(ARCH) $(INCLUDES) +CFLAGS = -c -fPIC -g -D_GNU_SOURCE -D$(ARCH) $(INCLUDES) -D_FILE_OFFSET_BITS=64 LIBSA = $(ARCH)/libsaproc.so diff -r eab1e4be8495 -r 09f5d262e329 hotspot/agent/src/os/linux/libproc_impl.c --- a/hotspot/agent/src/os/linux/libproc_impl.c Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/agent/src/os/linux/libproc_impl.c Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -50,10 +50,6 @@ char alt_path[PATH_MAX + 1]; init_alt_root(); - fd = open(name, O_RDONLY); - if (fd >= 0) { - return fd; - } if (alt_root_len > 0) { strcpy(alt_path, alt_root); @@ -73,6 +69,11 @@ return fd; } } + } else { + fd = open(name, O_RDONLY); + if (fd >= 0) { + return fd; + } } return -1; diff -r eab1e4be8495 -r 09f5d262e329 hotspot/make/Makefile --- a/hotspot/make/Makefile Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/make/Makefile Wed Feb 22 10:17:57 2012 -0800 @@ -402,7 +402,6 @@ $(install-file) else $(EXPORT_INCLUDE_DIR)/jfr.h: - endif # Doc files (jvmti.html) @@ -448,12 +447,18 @@ ($(CD) $(JDK_IMAGE_DIR) && $(TAR) -xf -) test_jdk: - ifneq ($(ZERO_BUILD), true) ifeq ($(ARCH_DATA_MODEL), 32) - $(JDK_IMAGE_DIR)/bin/java -client -version + ifneq ($(ZERO_BUILD), true) + $(JDK_IMAGE_DIR)/bin/java -d32 -client -Xinternalversion + $(JDK_IMAGE_DIR)/bin/java -d32 -client -version + endif + $(JDK_IMAGE_DIR)/bin/java -d32 -server -Xinternalversion + $(JDK_IMAGE_DIR)/bin/java -d32 -server -version endif - endif - $(JDK_IMAGE_DIR)/bin/java -server -version + ifeq ($(ARCH_DATA_MODEL), 64) + $(JDK_IMAGE_DIR)/bin/java -d64 -server -Xinternalversion + $(JDK_IMAGE_DIR)/bin/java -d64 -server -version + endif copy_product_jdk:: $(RM) -r $(JDK_IMAGE_DIR) @@ -545,6 +550,7 @@ OUTPUTDIR.desc = Output directory, default is build/ BOOTDIR.desc = JDK used to compile agent java source and test with JDK_IMPORT_PATH.desc = Promoted JDK to copy for 'create_jdk' +JDK_IMAGE_DIR.desc = Directory to place JDK to copy EXPORT_PATH.desc = Directory to place files to export for JDK build # Make variables to print out (description and value) @@ -553,6 +559,7 @@ OUTPUTDIR \ BOOTDIR \ JDK_IMPORT_PATH \ + JDK_IMAGE_DIR \ EXPORT_PATH # Make variables that should refer to directories that exist diff -r eab1e4be8495 -r 09f5d262e329 hotspot/make/bsd/makefiles/defs.make --- a/hotspot/make/bsd/makefiles/defs.make Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/make/bsd/makefiles/defs.make Wed Feb 22 10:17:57 2012 -0800 @@ -191,6 +191,9 @@ # Set universal image dir JDK_IMAGE_DIR=$(OUTPUTDIR)/jdk-universal$(EXPORT_SUBDIR) + ifneq ($(ALT_JDK_IMAGE_DIR),) + JDK_IMAGE_DIR=$(ALT_JDK_IMAGE_DIR) + endif # Binaries to 'universalize' if built UNIVERSAL_LIPO_LIST += $(EXPORT_JRE_LIB_DIR)/libjsig.$(LIBRARY_SUFFIX) diff -r eab1e4be8495 -r 09f5d262e329 hotspot/make/bsd/makefiles/top.make --- a/hotspot/make/bsd/makefiles/top.make Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/make/bsd/makefiles/top.make Wed Feb 22 10:17:57 2012 -0800 @@ -124,8 +124,8 @@ @$(UpdatePCH) @$(MAKE) -f vm.make $(MFLAGS-adjusted) -install: the_vm - @$(MAKE) -f vm.make install +install gamma: the_vm + @$(MAKE) -f vm.make $@ # next rules support "make foo.[ois]" diff -r eab1e4be8495 -r 09f5d262e329 hotspot/make/defs.make --- a/hotspot/make/defs.make Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/make/defs.make Wed Feb 22 10:17:57 2012 -0800 @@ -193,6 +193,9 @@ # Default jdk image if one is created for you with create_jdk JDK_IMAGE_DIR=$(OUTPUTDIR)/jdk-$(PLATFORM) +ifneq ($(ALT_JDK_IMAGE_DIR),) + JDK_IMAGE_DIR=$(ALT_JDK_IMAGE_DIR) +endif # The platform dependent defs.make defines platform specific variable such # as ARCH, EXPORT_LIST etc. We must place the include here after BOOTDIR is defined. diff -r eab1e4be8495 -r 09f5d262e329 hotspot/make/hotspot_version --- a/hotspot/make/hotspot_version Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/make/hotspot_version Wed Feb 22 10:17:57 2012 -0800 @@ -35,7 +35,7 @@ HS_MAJOR_VER=23 HS_MINOR_VER=0 -HS_BUILD_NUMBER=15 +HS_BUILD_NUMBER=16 JDK_MAJOR_VER=1 JDK_MINOR_VER=8 diff -r eab1e4be8495 -r 09f5d262e329 hotspot/make/jprt.properties --- a/hotspot/make/jprt.properties Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/make/jprt.properties Wed Feb 22 10:17:57 2012 -0800 @@ -38,7 +38,9 @@ # This tells jprt what default release we want to build -jprt.tools.default.release=${jprt.submit.release} +jprt.hotspot.default.release=jdk7 + +jprt.tools.default.release=${jprt.submit.option.release?${jprt.submit.option.release}:${jprt.hotspot.default.release}} # Disable syncing the source after builds and tests are done. @@ -52,126 +54,46 @@ # Define the Solaris platforms we want for the various releases jprt.my.solaris.sparc.jdk8=solaris_sparc_5.10 jprt.my.solaris.sparc.jdk7=solaris_sparc_5.10 -jprt.my.solaris.sparc.jdk7b107=solaris_sparc_5.10 -jprt.my.solaris.sparc.jdk7temp=solaris_sparc_5.10 -jprt.my.solaris.sparc.jdk6=solaris_sparc_5.8 -jprt.my.solaris.sparc.jdk6perf=solaris_sparc_5.8 -jprt.my.solaris.sparc.jdk6u10=solaris_sparc_5.8 -jprt.my.solaris.sparc.jdk6u14=solaris_sparc_5.8 -jprt.my.solaris.sparc.jdk6u18=solaris_sparc_5.8 -jprt.my.solaris.sparc.jdk6u20=solaris_sparc_5.8 -jprt.my.solaris.sparc.ejdk7=${jprt.my.solaris.sparc.jdk7} -jprt.my.solaris.sparc.ejdk6=${jprt.my.solaris.sparc.jdk6} jprt.my.solaris.sparc=${jprt.my.solaris.sparc.${jprt.tools.default.release}} jprt.my.solaris.sparcv9.jdk8=solaris_sparcv9_5.10 jprt.my.solaris.sparcv9.jdk7=solaris_sparcv9_5.10 -jprt.my.solaris.sparcv9.jdk7b107=solaris_sparcv9_5.10 -jprt.my.solaris.sparcv9.jdk7temp=solaris_sparcv9_5.10 -jprt.my.solaris.sparcv9.jdk6=solaris_sparcv9_5.8 -jprt.my.solaris.sparcv9.jdk6perf=solaris_sparcv9_5.8 -jprt.my.solaris.sparcv9.jdk6u10=solaris_sparcv9_5.8 -jprt.my.solaris.sparcv9.jdk6u14=solaris_sparcv9_5.8 -jprt.my.solaris.sparcv9.jdk6u18=solaris_sparcv9_5.8 -jprt.my.solaris.sparcv9.jdk6u20=solaris_sparcv9_5.8 -jprt.my.solaris.sparcv9.ejdk7=${jprt.my.solaris.sparcv9.jdk7} -jprt.my.solaris.sparcv9.ejdk6=${jprt.my.solaris.sparcv9.jdk6} jprt.my.solaris.sparcv9=${jprt.my.solaris.sparcv9.${jprt.tools.default.release}} jprt.my.solaris.i586.jdk8=solaris_i586_5.10 jprt.my.solaris.i586.jdk7=solaris_i586_5.10 -jprt.my.solaris.i586.jdk7b107=solaris_i586_5.10 -jprt.my.solaris.i586.jdk7temp=solaris_i586_5.10 -jprt.my.solaris.i586.jdk6=solaris_i586_5.8 -jprt.my.solaris.i586.jdk6perf=solaris_i586_5.8 -jprt.my.solaris.i586.jdk6u10=solaris_i586_5.8 -jprt.my.solaris.i586.jdk6u14=solaris_i586_5.8 -jprt.my.solaris.i586.jdk6u18=solaris_i586_5.8 -jprt.my.solaris.i586.jdk6u20=solaris_i586_5.8 -jprt.my.solaris.i586.ejdk7=${jprt.my.solaris.i586.jdk7} -jprt.my.solaris.i586.ejdk6=${jprt.my.solaris.i586.jdk6} jprt.my.solaris.i586=${jprt.my.solaris.i586.${jprt.tools.default.release}} jprt.my.solaris.x64.jdk8=solaris_x64_5.10 jprt.my.solaris.x64.jdk7=solaris_x64_5.10 -jprt.my.solaris.x64.jdk7b107=solaris_x64_5.10 -jprt.my.solaris.x64.jdk7temp=solaris_x64_5.10 -jprt.my.solaris.x64.jdk6=solaris_x64_5.10 -jprt.my.solaris.x64.jdk6perf=solaris_x64_5.10 -jprt.my.solaris.x64.jdk6u10=solaris_x64_5.10 -jprt.my.solaris.x64.jdk6u14=solaris_x64_5.10 -jprt.my.solaris.x64.jdk6u18=solaris_x64_5.10 -jprt.my.solaris.x64.jdk6u20=solaris_x64_5.10 -jprt.my.solaris.x64.ejdk7=${jprt.my.solaris.x64.jdk7} -jprt.my.solaris.x64.ejdk6=${jprt.my.solaris.x64.jdk6} jprt.my.solaris.x64=${jprt.my.solaris.x64.${jprt.tools.default.release}} jprt.my.linux.i586.jdk8=linux_i586_2.6 jprt.my.linux.i586.jdk7=linux_i586_2.6 -jprt.my.linux.i586.jdk7b107=linux_i586_2.6 -jprt.my.linux.i586.jdk7temp=linux_i586_2.6 -jprt.my.linux.i586.jdk6=linux_i586_2.4 -jprt.my.linux.i586.jdk6perf=linux_i586_2.4 -jprt.my.linux.i586.jdk6u10=linux_i586_2.4 -jprt.my.linux.i586.jdk6u14=linux_i586_2.4 -jprt.my.linux.i586.jdk6u18=linux_i586_2.4 -jprt.my.linux.i586.jdk6u20=linux_i586_2.4 -jprt.my.linux.i586.ejdk7=linux_i586_2.6 -jprt.my.linux.i586.ejdk6=linux_i586_2.6 jprt.my.linux.i586=${jprt.my.linux.i586.${jprt.tools.default.release}} jprt.my.linux.x64.jdk8=linux_x64_2.6 jprt.my.linux.x64.jdk7=linux_x64_2.6 -jprt.my.linux.x64.jdk7b107=linux_x64_2.6 -jprt.my.linux.x64.jdk7temp=linux_x64_2.6 -jprt.my.linux.x64.jdk6=linux_x64_2.4 -jprt.my.linux.x64.jdk6perf=linux_x64_2.4 -jprt.my.linux.x64.jdk6u10=linux_x64_2.4 -jprt.my.linux.x64.jdk6u14=linux_x64_2.4 -jprt.my.linux.x64.jdk6u18=linux_x64_2.4 -jprt.my.linux.x64.jdk6u20=linux_x64_2.4 -jprt.my.linux.x64.ejdk7=${jprt.my.linux.x64.jdk7} -jprt.my.linux.x64.ejdk6=${jprt.my.linux.x64.jdk6} jprt.my.linux.x64=${jprt.my.linux.x64.${jprt.tools.default.release}} jprt.my.linux.ppc.jdk8=linux_ppc_2.6 jprt.my.linux.ppc.jdk7=linux_ppc_2.6 -jprt.my.linux.ppc.jdk7b107=linux_ppc_2.6 -jprt.my.linux.ppc.jdk7temp=linux_ppc_2.6 -jprt.my.linux.ppc.ejdk6=linux_ppc_2.6 -jprt.my.linux.ppc.ejdk7=linux_ppc_2.6 jprt.my.linux.ppc=${jprt.my.linux.ppc.${jprt.tools.default.release}} jprt.my.linux.ppcv2.jdk8=linux_ppcv2_2.6 jprt.my.linux.ppcv2.jdk7=linux_ppcv2_2.6 -jprt.my.linux.ppcv2.jdk7b107=linux_ppcv2_2.6 -jprt.my.linux.ppcv2.jdk7temp=linux_ppcv2_2.6 -jprt.my.linux.ppcv2.ejdk6=linux_ppcv2_2.6 -jprt.my.linux.ppcv2.ejdk7=linux_ppcv2_2.6 jprt.my.linux.ppcv2=${jprt.my.linux.ppcv2.${jprt.tools.default.release}} jprt.my.linux.ppcsflt.jdk8=linux_ppcsflt_2.6 jprt.my.linux.ppcsflt.jdk7=linux_ppcsflt_2.6 -jprt.my.linux.ppcsflt.jdk7b107=linux_ppcsflt_2.6 -jprt.my.linux.ppcsflt.jdk7temp=linux_ppcsflt_2.6 -jprt.my.linux.ppcsflt.ejdk6=linux_ppcsflt_2.6 -jprt.my.linux.ppcsflt.ejdk7=linux_ppcsflt_2.6 jprt.my.linux.ppcsflt=${jprt.my.linux.ppcsflt.${jprt.tools.default.release}} jprt.my.linux.armvfp.jdk8=linux_armvfp_2.6 jprt.my.linux.armvfp.jdk7=linux_armvfp_2.6 -jprt.my.linux.armvfp.jdk7b107=linux_armvfp_2.6 -jprt.my.linux.armvfp.jdk7temp=linux_armvfp_2.6 -jprt.my.linux.armvfp.ejdk6=linux_armvfp_2.6 -jprt.my.linux.armvfp.ejdk7=linux_armvfp_2.6 jprt.my.linux.armvfp=${jprt.my.linux.armvfp.${jprt.tools.default.release}} jprt.my.linux.armsflt.jdk8=linux_armsflt_2.6 jprt.my.linux.armsflt.jdk7=linux_armsflt_2.6 -jprt.my.linux.armsflt.jdk7b107=linux_armsflt_2.6 -jprt.my.linux.armsflt.jdk7temp=linux_armsflt_2.6 -jprt.my.linux.armsflt.ejdk6=linux_armsflt_2.6 -jprt.my.linux.armsflt.ejdk7=linux_armsflt_2.6 jprt.my.linux.armsflt=${jprt.my.linux.armsflt.${jprt.tools.default.release}} jprt.my.macosx.x64.jdk8=macosx_x64_10.7 @@ -180,30 +102,10 @@ jprt.my.windows.i586.jdk8=windows_i586_5.1 jprt.my.windows.i586.jdk7=windows_i586_5.1 -jprt.my.windows.i586.jdk7b107=windows_i586_5.0 -jprt.my.windows.i586.jdk7temp=windows_i586_5.0 -jprt.my.windows.i586.jdk6=windows_i586_5.0 -jprt.my.windows.i586.jdk6perf=windows_i586_5.0 -jprt.my.windows.i586.jdk6u10=windows_i586_5.0 -jprt.my.windows.i586.jdk6u14=windows_i586_5.0 -jprt.my.windows.i586.jdk6u18=windows_i586_5.0 -jprt.my.windows.i586.jdk6u20=windows_i586_5.0 -jprt.my.windows.i586.ejdk7=${jprt.my.windows.i586.jdk7} -jprt.my.windows.i586.ejdk6=${jprt.my.windows.i586.jdk6} jprt.my.windows.i586=${jprt.my.windows.i586.${jprt.tools.default.release}} jprt.my.windows.x64.jdk8=windows_x64_5.2 jprt.my.windows.x64.jdk7=windows_x64_5.2 -jprt.my.windows.x64.jdk7b107=windows_x64_5.2 -jprt.my.windows.x64.jdk7temp=windows_x64_5.2 -jprt.my.windows.x64.jdk6=windows_x64_5.2 -jprt.my.windows.x64.jdk6perf=windows_x64_5.2 -jprt.my.windows.x64.jdk6u10=windows_x64_5.2 -jprt.my.windows.x64.jdk6u14=windows_x64_5.2 -jprt.my.windows.x64.jdk6u18=windows_x64_5.2 -jprt.my.windows.x64.jdk6u20=windows_x64_5.2 -jprt.my.windows.x64.ejdk7=${jprt.my.windows.x64.jdk7} -jprt.my.windows.x64.ejdk6=${jprt.my.windows.x64.jdk6} jprt.my.windows.x64=${jprt.my.windows.x64.${jprt.tools.default.release}} # Standard list of jprt build targets for this source tree @@ -539,16 +441,6 @@ jprt.test.targets.jdk8=${jprt.test.targets.standard} jprt.test.targets.jdk7=${jprt.test.targets.standard} -jprt.test.targets.jdk7temp=${jprt.test.targets.standard} -jprt.test.targets.jdk7b105=${jprt.test.targets.standard} -jprt.test.targets.jdk6=${jprt.test.targets.standard} -jprt.test.targets.jdk6perf=${jprt.test.targets.standard} -jprt.test.targets.jdk6u10=${jprt.test.targets.standard} -jprt.test.targets.jdk6u14=${jprt.test.targets.standard} -jprt.test.targets.jdk6u18=${jprt.test.targets.standard} -jprt.test.targets.jdk6u20=${jprt.test.targets.standard} -jprt.test.targets.ejdk6=${jprt.test.targets.embedded} -jprt.test.targets.ejdk7=${jprt.test.targets.embedded} jprt.test.targets=${jprt.test.targets.${jprt.tools.default.release}} # The default test/Makefile targets that should be run @@ -593,15 +485,5 @@ jprt.make.rule.test.targets.jdk8=${jprt.make.rule.test.targets.standard} jprt.make.rule.test.targets.jdk7=${jprt.make.rule.test.targets.standard} -jprt.make.rule.test.targets.jdk7temp=${jprt.make.rule.test.targets.standard} -jprt.make.rule.test.targets.jdk7b107=${jprt.make.rule.test.targets.standard} -jprt.make.rule.test.targets.jdk6=${jprt.make.rule.test.targets.standard} -jprt.make.rule.test.targets.jdk6perf=${jprt.make.rule.test.targets.standard} -jprt.make.rule.test.targets.jdk6u10=${jprt.make.rule.test.targets.standard} -jprt.make.rule.test.targets.jdk6u14=${jprt.make.rule.test.targets.standard} -jprt.make.rule.test.targets.jdk6u18=${jprt.make.rule.test.targets.standard} -jprt.make.rule.test.targets.jdk6u20=${jprt.make.rule.test.targets.standard} -jprt.make.rule.test.targets.ejdk6=${jprt.make.rule.test.targets.embedded} -jprt.make.rule.test.targets.ejdk7=${jprt.make.rule.test.targets.embedded} jprt.make.rule.test.targets=${jprt.make.rule.test.targets.${jprt.tools.default.release}} diff -r eab1e4be8495 -r 09f5d262e329 hotspot/make/linux/makefiles/saproc.make --- a/hotspot/make/linux/makefiles/saproc.make Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/make/linux/makefiles/saproc.make Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 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 @@ -75,6 +75,7 @@ fi @echo Making SA debugger back-end... $(QUIETLY) $(CC) -D$(BUILDARCH) -D_GNU_SOURCE \ + -D_FILE_OFFSET_BITS=64 \ $(SYMFLAG) $(ARCHFLAG) $(SHARED_FLAG) $(PICFLAG) \ -I$(SASRCDIR) \ -I$(GENERATED) \ diff -r eab1e4be8495 -r 09f5d262e329 hotspot/make/linux/makefiles/top.make --- a/hotspot/make/linux/makefiles/top.make Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/make/linux/makefiles/top.make Wed Feb 22 10:17:57 2012 -0800 @@ -115,8 +115,8 @@ @$(UpdatePCH) @$(MAKE) -f vm.make $(MFLAGS-adjusted) -install: the_vm - @$(MAKE) -f vm.make install +install gamma: the_vm + @$(MAKE) -f vm.make $@ # next rules support "make foo.[ois]" diff -r eab1e4be8495 -r 09f5d262e329 hotspot/make/solaris/makefiles/top.make --- a/hotspot/make/solaris/makefiles/top.make Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/make/solaris/makefiles/top.make Wed Feb 22 10:17:57 2012 -0800 @@ -107,8 +107,8 @@ the_vm: vm_build_preliminaries $(adjust-mflags) @$(MAKE) -f vm.make $(MFLAGS-adjusted) -install: the_vm - @$(MAKE) -f vm.make install +install gamma: the_vm + @$(MAKE) -f vm.make $@ # next rules support "make foo.[oi]" diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/cpu/sparc/vm/globals_sparc.hpp --- a/hotspot/src/cpu/sparc/vm/globals_sparc.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/cpu/sparc/vm/globals_sparc.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -56,14 +56,15 @@ // Stack slots are 2X larger in LP64 than in the 32 bit VM. define_pd_global(intx, ThreadStackSize, 1024); define_pd_global(intx, VMThreadStackSize, 1024); +define_pd_global(intx, StackShadowPages, 10 DEBUG_ONLY(+1)); #else define_pd_global(intx, ThreadStackSize, 512); define_pd_global(intx, VMThreadStackSize, 512); +define_pd_global(intx, StackShadowPages, 3 DEBUG_ONLY(+1)); #endif define_pd_global(intx, StackYellowPages, 2); define_pd_global(intx, StackRedPages, 1); -define_pd_global(intx, StackShadowPages, 3 DEBUG_ONLY(+1)); define_pd_global(intx, PreInflateSpin, 40); // Determined by running design center diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp --- a/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -3431,6 +3431,9 @@ ResourceMark rm; // setup code generation tools int pad = VerifyThread ? 512 : 0;// Extra slop space for more verify code + if (UseStackBanging) { + pad += StackShadowPages*16 + 32; + } #ifdef _LP64 CodeBuffer buffer("deopt_blob", 2100+pad, 512); #else @@ -3650,6 +3653,9 @@ ResourceMark rm; // setup code generation tools int pad = VerifyThread ? 512 : 0; + if (UseStackBanging) { + pad += StackShadowPages*16 + 32; + } #ifdef _LP64 CodeBuffer buffer("uncommon_trap_blob", 2700+pad, 512); #else diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/cpu/x86/vm/assembler_x86.cpp --- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -236,6 +236,16 @@ } } +// Force generation of a 4 byte immediate value even if it fits into 8bit +void Assembler::emit_arith_imm32(int op1, int op2, Register dst, int32_t imm32) { + assert(isByte(op1) && isByte(op2), "wrong opcode"); + assert((op1 & 0x01) == 1, "should be 32bit operation"); + assert((op1 & 0x02) == 0, "sign-extension bit should not be set"); + emit_byte(op1); + emit_byte(op2 | encode(dst)); + emit_long(imm32); +} + // immediate-to-memory forms void Assembler::emit_arith_operand(int op1, Register rm, Address adr, int32_t imm32) { assert((op1 & 0x01) == 1, "should be 32bit operation"); @@ -939,6 +949,7 @@ } void Assembler::addr_nop_4() { + assert(UseAddressNop, "no CPU support"); // 4 bytes: NOP DWORD PTR [EAX+0] emit_byte(0x0F); emit_byte(0x1F); @@ -947,6 +958,7 @@ } void Assembler::addr_nop_5() { + assert(UseAddressNop, "no CPU support"); // 5 bytes: NOP DWORD PTR [EAX+EAX*0+0] 8-bits offset emit_byte(0x0F); emit_byte(0x1F); @@ -956,6 +968,7 @@ } void Assembler::addr_nop_7() { + assert(UseAddressNop, "no CPU support"); // 7 bytes: NOP DWORD PTR [EAX+0] 32-bits offset emit_byte(0x0F); emit_byte(0x1F); @@ -964,6 +977,7 @@ } void Assembler::addr_nop_8() { + assert(UseAddressNop, "no CPU support"); // 8 bytes: NOP DWORD PTR [EAX+EAX*0+0] 32-bits offset emit_byte(0x0F); emit_byte(0x1F); @@ -2769,6 +2783,12 @@ emit_arith(0x81, 0xE8, dst, imm32); } +// Force generation of a 4 byte immediate value even if it fits into 8bit +void Assembler::subl_imm32(Register dst, int32_t imm32) { + prefix(dst); + emit_arith_imm32(0x81, 0xE8, dst, imm32); +} + void Assembler::subl(Register dst, Address src) { InstructionMark im(this); prefix(src, dst); @@ -4760,6 +4780,12 @@ emit_arith(0x81, 0xE8, dst, imm32); } +// Force generation of a 4 byte immediate value even if it fits into 8bit +void Assembler::subq_imm32(Register dst, int32_t imm32) { + (void) prefixq_and_encode(dst->encoding()); + emit_arith_imm32(0x81, 0xE8, dst, imm32); +} + void Assembler::subq(Register dst, Address src) { InstructionMark im(this); prefixq(src, dst); @@ -5101,15 +5127,6 @@ } } -void MacroAssembler::fat_nop() { - // A 5 byte nop that is safe for patching (see patch_verified_entry) - emit_byte(0x26); // es: - emit_byte(0x2e); // cs: - emit_byte(0x64); // fs: - emit_byte(0x65); // gs: - emit_byte(0x90); -} - void MacroAssembler::jC2(Register tmp, Label& L) { // set parity bit if FPU flag C2 is set (via rax) save_rax(tmp); @@ -5704,17 +5721,6 @@ /* else */ { subq(dst, value) ; return; } } -void MacroAssembler::fat_nop() { - // A 5 byte nop that is safe for patching (see patch_verified_entry) - // Recommened sequence from 'Software Optimization Guide for the AMD - // Hammer Processor' - emit_byte(0x66); - emit_byte(0x66); - emit_byte(0x90); - emit_byte(0x66); - emit_byte(0x90); -} - void MacroAssembler::incrementq(Register reg, int value) { if (value == min_jint) { addq(reg, value); return; } if (value < 0) { decrementq(reg, -value); return; } @@ -6766,6 +6772,19 @@ mov(rbp, rsp); } +// A 5 byte nop that is safe for patching (see patch_verified_entry) +void MacroAssembler::fat_nop() { + if (UseAddressNop) { + addr_nop_5(); + } else { + emit_byte(0x26); // es: + emit_byte(0x2e); // cs: + emit_byte(0x64); // fs: + emit_byte(0x65); // gs: + emit_byte(0x90); + } +} + void MacroAssembler::fcmp(Register tmp) { fcmp(tmp, 1, true, true); } @@ -7825,6 +7844,11 @@ LP64_ONLY(subq(dst, imm32)) NOT_LP64(subl(dst, imm32)); } +// Force generation of a 4 byte immediate value even if it fits into 8bit +void MacroAssembler::subptr_imm32(Register dst, int32_t imm32) { + LP64_ONLY(subq_imm32(dst, imm32)) NOT_LP64(subl_imm32(dst, imm32)); +} + void MacroAssembler::subptr(Register dst, Register src) { LP64_ONLY(subq(dst, src)) NOT_LP64(subl(dst, src)); } @@ -9292,6 +9316,80 @@ } #endif // _LP64 + +// C2 compiled method's prolog code. +void MacroAssembler::verified_entry(int framesize, bool stack_bang, bool fp_mode_24b) { + + // WARNING: Initial instruction MUST be 5 bytes or longer so that + // NativeJump::patch_verified_entry will be able to patch out the entry + // code safely. The push to verify stack depth is ok at 5 bytes, + // the frame allocation can be either 3 or 6 bytes. So if we don't do + // stack bang then we must use the 6 byte frame allocation even if + // we have no frame. :-( + + assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned"); + // Remove word for return addr + framesize -= wordSize; + + // Calls to C2R adapters often do not accept exceptional returns. + // We require that their callers must bang for them. But be careful, because + // some VM calls (such as call site linkage) can use several kilobytes of + // stack. But the stack safety zone should account for that. + // See bugs 4446381, 4468289, 4497237. + if (stack_bang) { + generate_stack_overflow_check(framesize); + + // We always push rbp, so that on return to interpreter rbp, will be + // restored correctly and we can correct the stack. + push(rbp); + // Remove word for ebp + framesize -= wordSize; + + // Create frame + if (framesize) { + subptr(rsp, framesize); + } + } else { + // Create frame (force generation of a 4 byte immediate value) + subptr_imm32(rsp, framesize); + + // Save RBP register now. + framesize -= wordSize; + movptr(Address(rsp, framesize), rbp); + } + + if (VerifyStackAtCalls) { // Majik cookie to verify stack depth + framesize -= wordSize; + movptr(Address(rsp, framesize), (int32_t)0xbadb100d); + } + +#ifndef _LP64 + // If method sets FPU control word do it now + if (fp_mode_24b) { + fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_24())); + } + if (UseSSE >= 2 && VerifyFPU) { + verify_FPU(0, "FPU stack must be clean on entry"); + } +#endif + +#ifdef ASSERT + if (VerifyStackAtCalls) { + Label L; + push(rax); + mov(rax, rsp); + andptr(rax, StackAlignmentInBytes-1); + cmpptr(rax, StackAlignmentInBytes-wordSize); + pop(rax); + jcc(Assembler::equal, L); + stop("Stack is not properly aligned!"); + bind(L); + } +#endif + +} + + // IndexOf for constant substrings with size >= 8 chars // which don't need to be loaded through stack. void MacroAssembler::string_indexofC8(Register str1, Register str2, diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/cpu/x86/vm/assembler_x86.hpp --- a/hotspot/src/cpu/x86/vm/assembler_x86.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/cpu/x86/vm/assembler_x86.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -667,6 +667,8 @@ void emit_arith_b(int op1, int op2, Register dst, int imm8); void emit_arith(int op1, int op2, Register dst, int32_t imm32); + // Force generation of a 4 byte immediate value even if it fits into 8bit + void emit_arith_imm32(int op1, int op2, Register dst, int32_t imm32); // only 32bit?? void emit_arith(int op1, int op2, Register dst, jobject obj); void emit_arith(int op1, int op2, Register dst, Register src); @@ -1526,6 +1528,9 @@ void subq(Register dst, Address src); void subq(Register dst, Register src); + // Force generation of a 4 byte immediate value even if it fits into 8bit + void subl_imm32(Register dst, int32_t imm32); + void subq_imm32(Register dst, int32_t imm32); // Subtract Scalar Double-Precision Floating-Point Values void subsd(XMMRegister dst, Address src); @@ -1763,8 +1768,8 @@ // Alignment void align(int modulus); - // Misc - void fat_nop(); // 5 byte nop + // A 5 byte nop that is safe for patching (see patch_verified_entry) + void fat_nop(); // Stack frame creation/removal void enter(); @@ -2275,6 +2280,8 @@ void subptr(Register dst, Address src) { LP64_ONLY(subq(dst, src)) NOT_LP64(subl(dst, src)); } void subptr(Register dst, int32_t src); + // Force generation of a 4 byte immediate value even if it fits into 8bit + void subptr_imm32(Register dst, int32_t src); void subptr(Register dst, Register src); void subptr(Register dst, RegisterOrConstant src) { if (src.is_constant()) subptr(dst, (int) src.as_constant()); @@ -2566,6 +2573,9 @@ void movl2ptr(Register dst, Address src) { LP64_ONLY(movslq(dst, src)) NOT_LP64(movl(dst, src)); } void movl2ptr(Register dst, Register src) { LP64_ONLY(movslq(dst, src)) NOT_LP64(if (dst != src) movl(dst, src)); } + // C2 compiled method's prolog code. + void verified_entry(int framesize, bool stack_bang, bool fp_mode_24b); + // IndexOf strings. // Small strings are loaded through stack if they cross page boundary. void string_indexof(Register str1, Register str2, diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/cpu/x86/vm/c1_MacroAssembler_x86.cpp --- a/hotspot/src/cpu/x86/vm/c1_MacroAssembler_x86.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/cpu/x86/vm/c1_MacroAssembler_x86.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -381,6 +381,16 @@ void C1_MacroAssembler::verified_entry() { + if (C1Breakpoint || VerifyFPU || !UseStackBanging) { + // Verified Entry first instruction should be 5 bytes long for correct + // patching by patch_verified_entry(). + // + // C1Breakpoint and VerifyFPU have one byte first instruction. + // Also first instruction will be one byte "push(rbp)" if stack banging + // code is not generated (see build_frame() above). + // For all these cases generate long instruction first. + fat_nop(); + } if (C1Breakpoint)int3(); // build frame verify_FPU(0, "method_entry"); diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/cpu/x86/vm/globals_x86.hpp --- a/hotspot/src/cpu/x86/vm/globals_x86.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/cpu/x86/vm/globals_x86.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -60,9 +60,9 @@ #ifdef AMD64 // Very large C++ stack frames using solaris-amd64 optimized builds // due to lack of optimization caused by C++ compiler bugs -define_pd_global(intx, StackShadowPages, SOLARIS_ONLY(20) NOT_SOLARIS(6) DEBUG_ONLY(+2)); +define_pd_global(intx, StackShadowPages, NOT_WIN64(20) WIN64_ONLY(6) DEBUG_ONLY(+2)); #else -define_pd_global(intx, StackShadowPages, 3 DEBUG_ONLY(+5)); +define_pd_global(intx, StackShadowPages, 4 DEBUG_ONLY(+5)); #endif // AMD64 define_pd_global(intx, PreInflateSpin, 10); diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/cpu/x86/vm/methodHandles_x86.cpp --- a/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -1018,41 +1018,26 @@ void trace_method_handle_stub(const char* adaptername, oop mh, intptr_t* saved_regs, - intptr_t* entry_sp, - intptr_t* saved_sp, - intptr_t* saved_bp) { + intptr_t* entry_sp) { // called as a leaf from native code: do not block the JVM! bool has_mh = (strstr(adaptername, "return/") == NULL); // return adapters don't have rcx_mh + const char* mh_reg_name = has_mh ? "rcx_mh" : "rcx"; + tty->print_cr("MH %s %s="PTR_FORMAT" sp="PTR_FORMAT, adaptername, mh_reg_name, mh, entry_sp); - intptr_t* last_sp = (intptr_t*) saved_bp[frame::interpreter_frame_last_sp_offset]; - intptr_t* base_sp = last_sp; - typedef MethodHandles::RicochetFrame RicochetFrame; - RicochetFrame* rfp = (RicochetFrame*)((address)saved_bp - RicochetFrame::sender_link_offset_in_bytes()); - if (Universe::heap()->is_in((address) rfp->saved_args_base())) { - // Probably an interpreter frame. - base_sp = (intptr_t*) saved_bp[frame::interpreter_frame_monitor_block_top_offset]; - } - intptr_t mh_reg = (intptr_t)mh; - const char* mh_reg_name = "rcx_mh"; - if (!has_mh) mh_reg_name = "rcx"; - tty->print_cr("MH %s %s="PTR_FORMAT" sp=("PTR_FORMAT"+"INTX_FORMAT") stack_size="INTX_FORMAT" bp="PTR_FORMAT, - adaptername, mh_reg_name, mh_reg, - (intptr_t)entry_sp, (intptr_t)(saved_sp - entry_sp), (intptr_t)(base_sp - last_sp), (intptr_t)saved_bp); if (Verbose) { - tty->print(" reg dump: "); - int saved_regs_count = (entry_sp-1) - saved_regs; - // 32 bit: rdi rsi rbp rsp; rbx rdx rcx (*) rax - int i; - for (i = 0; i <= saved_regs_count; i++) { - if (i > 0 && i % 4 == 0 && i != saved_regs_count) { + tty->print_cr("Registers:"); + const int saved_regs_count = RegisterImpl::number_of_registers; + for (int i = 0; i < saved_regs_count; i++) { + Register r = as_Register(i); + // The registers are stored in reverse order on the stack (by pusha). + tty->print("%3s=" PTR_FORMAT, r->name(), saved_regs[((saved_regs_count - 1) - i)]); + if ((i + 1) % 4 == 0) { tty->cr(); - tty->print(" + dump: "); + } else { + tty->print(", "); } - tty->print(" %d: "PTR_FORMAT, i, saved_regs[i]); } tty->cr(); - if (last_sp != saved_sp && last_sp != NULL) - tty->print_cr("*** last_sp="PTR_FORMAT, (intptr_t)last_sp); { // dumping last frame with frame::describe @@ -1102,14 +1087,7 @@ values.describe(-1, dump_sp, "sp for #1"); } - // mark saved_sp if seems valid - if (has_mh) { - if ((saved_sp >= dump_sp - UNREASONABLE_STACK_MOVE) && (saved_sp < dump_fp)) { - values.describe(-1, saved_sp, "*saved_sp"); - } - } - - tty->print_cr(" stack layout:"); + tty->print_cr("Stack layout:"); values.print(p); } if (has_mh) @@ -1125,16 +1103,12 @@ oopDesc* mh; intptr_t* saved_regs; intptr_t* entry_sp; - intptr_t* saved_sp; - intptr_t* saved_bp; }; void trace_method_handle_stub_wrapper(MethodHandleStubArguments* args) { trace_method_handle_stub(args->adaptername, args->mh, args->saved_regs, - args->entry_sp, - args->saved_sp, - args->saved_bp); + args->entry_sp); } void MethodHandles::trace_method_handle(MacroAssembler* _masm, const char* adaptername) { @@ -1157,20 +1131,18 @@ __ fst_d(Address(rsp, 0)); } - // incoming state: + // Incoming state: // rcx: method handle - // r13 or rsi: saved sp - // To avoid calling convention issues, build a record on the stack and pass the pointer to that instead. - // Note: fix the increment below if pushing more arguments - __ push(rbp); // saved_bp - __ push(saved_last_sp_register()); // saved_sp + // + // To avoid calling convention issues, build a record on the stack + // and pass the pointer to that instead. __ push(rbp); // entry_sp (with extra align space) __ push(rbx); // pusha saved_regs __ push(rcx); // mh __ push(rcx); // slot for adaptername __ movptr(Address(rsp, 0), (intptr_t) adaptername); __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, trace_method_handle_stub_wrapper), rsp); - __ increment(rsp, 6 * wordSize); // MethodHandleStubArguments + __ increment(rsp, sizeof(MethodHandleStubArguments)); if (UseSSE >= 2) { __ movdbl(xmm0, Address(rsp, 0)); diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp --- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -2997,7 +2997,7 @@ // Generate oop map OopMap* map = new OopMap(framesize, 0); - oop_maps->add_gc_map(__ pc() - start, map); + oop_maps->add_gc_map(the_pc - start, map); __ reset_last_Java_frame(true, true); diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/cpu/x86/vm/vm_version_x86.hpp --- a/hotspot/src/cpu/x86/vm/vm_version_x86.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/cpu/x86/vm/vm_version_x86.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -249,13 +249,18 @@ enum { // AMD - CPU_FAMILY_AMD_11H = 17, + CPU_FAMILY_AMD_11H = 0x11, // Intel CPU_FAMILY_INTEL_CORE = 6, - CPU_MODEL_NEHALEM_EP = 26, - CPU_MODEL_WESTMERE_EP = 44, -// CPU_MODEL_IVYBRIDGE_EP = ??, TODO - get real value - CPU_MODEL_SANDYBRIDGE_EP = 45 + CPU_MODEL_NEHALEM = 0x1e, + CPU_MODEL_NEHALEM_EP = 0x1a, + CPU_MODEL_NEHALEM_EX = 0x2e, + CPU_MODEL_WESTMERE = 0x25, + CPU_MODEL_WESTMERE_EP = 0x2c, + CPU_MODEL_WESTMERE_EX = 0x2f, + CPU_MODEL_SANDYBRIDGE = 0x2a, + CPU_MODEL_SANDYBRIDGE_EP = 0x2d, + CPU_MODEL_IVYBRIDGE_EP = 0x3a } cpuExtendedFamily; // cpuid information block. All info derived from executing cpuid with @@ -325,7 +330,7 @@ uint32_t proc_name_4, proc_name_5, proc_name_6, proc_name_7; uint32_t proc_name_8, proc_name_9, proc_name_10,proc_name_11; - // cpuid function 0x80000005 //AMD L1, Intel reserved + // cpuid function 0x80000005 // AMD L1, Intel reserved uint32_t ext_cpuid5_eax; // unused currently uint32_t ext_cpuid5_ebx; // reserved ExtCpuid5Ex ext_cpuid5_ecx; // L1 data cache info (AMD) @@ -547,15 +552,15 @@ static bool is_intel_tsc_synched_at_init() { if (is_intel_family_core()) { uint32_t ext_model = extended_cpu_model(); - if (ext_model == CPU_MODEL_NEHALEM_EP || - ext_model == CPU_MODEL_WESTMERE_EP || -// TODO ext_model == CPU_MODEL_IVYBRIDGE_EP || - ext_model == CPU_MODEL_SANDYBRIDGE_EP) { - // 2-socket invtsc support. EX versions with 4 sockets are not - // guaranteed to synchronize tscs at initialization via a double - // handshake. The tscs can be explicitly set in software. Code - // that uses tsc values must be prepared for them to arbitrarily - // jump backward or forward. + if (ext_model == CPU_MODEL_NEHALEM_EP || + ext_model == CPU_MODEL_WESTMERE_EP || + ext_model == CPU_MODEL_SANDYBRIDGE_EP || + ext_model == CPU_MODEL_IVYBRIDGE_EP) { + // <= 2-socket invariant tsc support. EX versions are usually used + // in > 2-socket systems and likely don't synchronize tscs at + // initialization. + // Code that uses tsc values must be prepared for them to arbitrarily + // jump forward or backward. return true; } } diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/cpu/x86/vm/x86.ad --- a/hotspot/src/cpu/x86/vm/x86.ad Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/cpu/x86/vm/x86.ad Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ // -// Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2011, 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 @@ -37,10 +37,87 @@ static address double_signmask() { return (address)double_signmask_pool; } static address double_signflip() { return (address)double_signflip_pool; } #endif + +#ifndef PRODUCT + void MachNopNode::format(PhaseRegAlloc*, outputStream* st) const { + st->print("nop \t# %d bytes pad for loops and calls", _count); + } +#endif + + void MachNopNode::emit(CodeBuffer &cbuf, PhaseRegAlloc*) const { + MacroAssembler _masm(&cbuf); + __ nop(_count); + } + + uint MachNopNode::size(PhaseRegAlloc*) const { + return _count; + } + +#ifndef PRODUCT + void MachBreakpointNode::format(PhaseRegAlloc*, outputStream* st) const { + st->print("# breakpoint"); + } +#endif + + void MachBreakpointNode::emit(CodeBuffer &cbuf, PhaseRegAlloc* ra_) const { + MacroAssembler _masm(&cbuf); + __ int3(); + } + + uint MachBreakpointNode::size(PhaseRegAlloc* ra_) const { + return MachNode::size(ra_); + } + +%} + +encode %{ + + enc_class preserve_SP %{ + debug_only(int off0 = cbuf.insts_size()); + MacroAssembler _masm(&cbuf); + // RBP is preserved across all calls, even compiled calls. + // Use it to preserve RSP in places where the callee might change the SP. + __ movptr(rbp_mh_SP_save, rsp); + debug_only(int off1 = cbuf.insts_size()); + assert(off1 - off0 == preserve_SP_size(), "correct size prediction"); + %} + + enc_class restore_SP %{ + MacroAssembler _masm(&cbuf); + __ movptr(rsp, rbp_mh_SP_save); + %} + + enc_class call_epilog %{ + if (VerifyStackAtCalls) { + // Check that stack depth is unchanged: find majik cookie on stack + int framesize = ra_->reg2offset_unchecked(OptoReg::add(ra_->_matcher._old_SP, -3*VMRegImpl::slots_per_word)); + MacroAssembler _masm(&cbuf); + Label L; + __ cmpptr(Address(rsp, framesize), (int32_t)0xbadb100d); + __ jccb(Assembler::equal, L); + // Die if stack mismatch + __ int3(); + __ bind(L); + } + %} + %} // INSTRUCTIONS -- Platform independent definitions (same for 32- and 64-bit) +// ============================================================================ + +instruct ShouldNotReachHere() %{ + match(Halt); + format %{ "int3\t# ShouldNotReachHere" %} + ins_encode %{ + __ int3(); + %} + ins_pipe(pipe_slow); +%} + +// ============================================================================ + instruct addF_reg(regF dst, regF src) %{ predicate((UseSSE>=1) && (UseAVX == 0)); match(Set dst (AddF dst src)); diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/cpu/x86/vm/x86_32.ad --- a/hotspot/src/cpu/x86/vm/x86_32.ad Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/cpu/x86/vm/x86_32.ad Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ // -// Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 1997, 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 @@ -341,12 +341,6 @@ return round_to(current_offset, alignment_required()) - current_offset; } -#ifndef PRODUCT -void MachBreakpointNode::format( PhaseRegAlloc *, outputStream* st ) const { - st->print("INT3"); -} -#endif - // EMIT_RM() void emit_rm(CodeBuffer &cbuf, int f1, int f2, int f3) { unsigned char c = (unsigned char)((f1 << 6) | (f2 << 3) | f3); @@ -550,118 +544,66 @@ //============================================================================= #ifndef PRODUCT -void MachPrologNode::format( PhaseRegAlloc *ra_, outputStream* st ) const { +void MachPrologNode::format(PhaseRegAlloc* ra_, outputStream* st) const { Compile* C = ra_->C; - if( C->in_24_bit_fp_mode() ) { - st->print("FLDCW 24 bit fpu control word"); - st->print_cr(""); st->print("\t"); - } int framesize = C->frame_slots() << LogBytesPerInt; assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned"); - // Remove two words for return addr and rbp, - framesize -= 2*wordSize; - - // Calls to C2R adapters often do not accept exceptional returns. - // We require that their callers must bang for them. But be careful, because - // some VM calls (such as call site linkage) can use several kilobytes of - // stack. But the stack safety zone should account for that. - // See bugs 4446381, 4468289, 4497237. + // Remove wordSize for return addr which is already pushed. + framesize -= wordSize; + if (C->need_stack_bang(framesize)) { - st->print_cr("# stack bang"); st->print("\t"); - } - st->print_cr("PUSHL EBP"); st->print("\t"); - - if( VerifyStackAtCalls ) { // Majik cookie to verify stack depth - st->print("PUSH 0xBADB100D\t# Majik cookie for stack depth check"); - st->print_cr(""); st->print("\t"); framesize -= wordSize; - } - - if ((C->in_24_bit_fp_mode() || VerifyStackAtCalls ) && framesize < 128 ) { + st->print("# stack bang"); + st->print("\n\t"); + st->print("PUSH EBP\t# Save EBP"); if (framesize) { - st->print("SUB ESP,%d\t# Create frame",framesize); + st->print("\n\t"); + st->print("SUB ESP, #%d\t# Create frame",framesize); } } else { - st->print("SUB ESP,%d\t# Create frame",framesize); + st->print("SUB ESP, #%d\t# Create frame",framesize); + st->print("\n\t"); + framesize -= wordSize; + st->print("MOV [ESP + #%d], EBP\t# Save EBP",framesize); + } + + if (VerifyStackAtCalls) { + st->print("\n\t"); + framesize -= wordSize; + st->print("MOV [ESP + #%d], 0xBADB100D\t# Majik cookie for stack depth check",framesize); } + + if( C->in_24_bit_fp_mode() ) { + st->print("\n\t"); + st->print("FLDCW \t# load 24 bit fpu control word"); + } + if (UseSSE >= 2 && VerifyFPU) { + st->print("\n\t"); + st->print("# verify FPU stack (must be clean on entry)"); + } + +#ifdef ASSERT + if (VerifyStackAtCalls) { + st->print("\n\t"); + st->print("# stack alignment check"); + } +#endif + st->cr(); } #endif void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { Compile* C = ra_->C; - - if (UseSSE >= 2 && VerifyFPU) { - MacroAssembler masm(&cbuf); - masm.verify_FPU(0, "FPU stack must be clean on entry"); - } - - // WARNING: Initial instruction MUST be 5 bytes or longer so that - // NativeJump::patch_verified_entry will be able to patch out the entry - // code safely. The fldcw is ok at 6 bytes, the push to verify stack - // depth is ok at 5 bytes, the frame allocation can be either 3 or - // 6 bytes. So if we don't do the fldcw or the push then we must - // use the 6 byte frame allocation even if we have no frame. :-( - // If method sets FPU control word do it now - if( C->in_24_bit_fp_mode() ) { - MacroAssembler masm(&cbuf); - masm.fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_24())); - } + MacroAssembler _masm(&cbuf); int framesize = C->frame_slots() << LogBytesPerInt; - assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned"); - // Remove two words for return addr and rbp, - framesize -= 2*wordSize; - - // Calls to C2R adapters often do not accept exceptional returns. - // We require that their callers must bang for them. But be careful, because - // some VM calls (such as call site linkage) can use several kilobytes of - // stack. But the stack safety zone should account for that. - // See bugs 4446381, 4468289, 4497237. - if (C->need_stack_bang(framesize)) { - MacroAssembler masm(&cbuf); - masm.generate_stack_overflow_check(framesize); - } - - // We always push rbp, so that on return to interpreter rbp, will be - // restored correctly and we can correct the stack. - emit_opcode(cbuf, 0x50 | EBP_enc); - - if( VerifyStackAtCalls ) { // Majik cookie to verify stack depth - emit_opcode(cbuf, 0x68); // push 0xbadb100d - emit_d32(cbuf, 0xbadb100d); - framesize -= wordSize; - } - - if ((C->in_24_bit_fp_mode() || VerifyStackAtCalls ) && framesize < 128 ) { - if (framesize) { - emit_opcode(cbuf, 0x83); // sub SP,#framesize - emit_rm(cbuf, 0x3, 0x05, ESP_enc); - emit_d8(cbuf, framesize); - } - } else { - emit_opcode(cbuf, 0x81); // sub SP,#framesize - emit_rm(cbuf, 0x3, 0x05, ESP_enc); - emit_d32(cbuf, framesize); - } + + __ verified_entry(framesize, C->need_stack_bang(framesize), C->in_24_bit_fp_mode()); + C->set_frame_complete(cbuf.insts_size()); -#ifdef ASSERT - if (VerifyStackAtCalls) { - Label L; - MacroAssembler masm(&cbuf); - masm.push(rax); - masm.mov(rax, rsp); - masm.andptr(rax, StackAlignmentInBytes-1); - masm.cmpptr(rax, StackAlignmentInBytes-wordSize); - masm.pop(rax); - masm.jcc(Assembler::equal, L); - masm.stop("Stack is not properly aligned!"); - masm.bind(L); - } -#endif - if (C->has_mach_constant_base_node()) { // NOTE: We set the table base offset here because users might be // emitted before MachConstantBaseNode. @@ -1169,7 +1111,7 @@ } #ifndef PRODUCT -void MachSpillCopyNode::format( PhaseRegAlloc *ra_, outputStream* st ) const { +void MachSpillCopyNode::format(PhaseRegAlloc *ra_, outputStream* st) const { implementation( NULL, ra_, false, st ); } #endif @@ -1182,22 +1124,6 @@ return implementation( NULL, ra_, true, NULL ); } -//============================================================================= -#ifndef PRODUCT -void MachNopNode::format( PhaseRegAlloc *, outputStream* st ) const { - st->print("NOP \t# %d bytes pad for loops and calls", _count); -} -#endif - -void MachNopNode::emit(CodeBuffer &cbuf, PhaseRegAlloc * ) const { - MacroAssembler _masm(&cbuf); - __ nop(_count); -} - -uint MachNopNode::size(PhaseRegAlloc *) const { - return _count; -} - //============================================================================= #ifndef PRODUCT @@ -1883,21 +1809,6 @@ } %} - enc_class preserve_SP %{ - debug_only(int off0 = cbuf.insts_size()); - MacroAssembler _masm(&cbuf); - // RBP is preserved across all calls, even compiled calls. - // Use it to preserve RSP in places where the callee might change the SP. - __ movptr(rbp_mh_SP_save, rsp); - debug_only(int off1 = cbuf.insts_size()); - assert(off1 - off0 == preserve_SP_size(), "correct size prediction"); - %} - - enc_class restore_SP %{ - MacroAssembler _masm(&cbuf); - __ movptr(rsp, rbp_mh_SP_save); - %} - enc_class Java_Static_Call (method meth) %{ // JAVA STATIC CALL // CALL to fixup routine. Fixup routine uses ScopeDesc info to determine // who we intended to call. @@ -3846,9 +3757,9 @@ // Ret Addr is on stack in slot 0 if no locks or verification or alignment. // Otherwise, it is above the locks and verification slot and alignment word return_addr(STACK - 1 + - round_to(1+VerifyStackAtCalls+ - Compile::current()->fixed_slots(), - (StackAlignmentInBytes/wordSize))); + round_to((Compile::current()->in_preserve_stack_slots() + + Compile::current()->fixed_slots()), + stack_alignment_in_slots())); // Body of function which returns an integer array locating // arguments either in registers or in stack slots. Passed an array @@ -13476,6 +13387,25 @@ ins_pipe( ialu_reg_mem ); %} + +// ============================================================================ +// This name is KNOWN by the ADLC and cannot be changed. +// The ADLC forces a 'TypeRawPtr::BOTTOM' output type +// for this guy. +instruct tlsLoadP(eRegP dst, eFlagsReg cr) %{ + match(Set dst (ThreadLocal)); + effect(DEF dst, KILL cr); + + format %{ "MOV $dst, Thread::current()" %} + ins_encode %{ + Register dstReg = as_Register($dst$$reg); + __ get_thread(dstReg); + %} + ins_pipe( ialu_reg_fat ); +%} + + + //----------PEEPHOLE RULES----------------------------------------------------- // These must follow all instruction definitions as they use the names // defined in the instructions definitions. diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/cpu/x86/vm/x86_64.ad --- a/hotspot/src/cpu/x86/vm/x86_64.ad Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/cpu/x86/vm/x86_64.ad Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ // -// Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2003, 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 @@ -610,13 +610,6 @@ return round_to(current_offset, alignment_required()) - current_offset; } -#ifndef PRODUCT -void MachBreakpointNode::format(PhaseRegAlloc*, outputStream* st) const -{ - st->print("INT3"); -} -#endif - // EMIT_RM() void emit_rm(CodeBuffer &cbuf, int f1, int f2, int f3) { unsigned char c = (unsigned char) ((f1 << 6) | (f2 << 3) | f3); @@ -853,121 +846,53 @@ //============================================================================= #ifndef PRODUCT -void MachPrologNode::format(PhaseRegAlloc* ra_, outputStream* st) const -{ +void MachPrologNode::format(PhaseRegAlloc* ra_, outputStream* st) const { Compile* C = ra_->C; int framesize = C->frame_slots() << LogBytesPerInt; assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned"); - // Remove wordSize for return adr already pushed - // and another for the RBP we are going to save - framesize -= 2*wordSize; - bool need_nop = true; - - // Calls to C2R adapters often do not accept exceptional returns. - // We require that their callers must bang for them. But be - // careful, because some VM calls (such as call site linkage) can - // use several kilobytes of stack. But the stack safety zone should - // account for that. See bugs 4446381, 4468289, 4497237. + // Remove wordSize for return addr which is already pushed. + framesize -= wordSize; + if (C->need_stack_bang(framesize)) { - st->print_cr("# stack bang"); st->print("\t"); - need_nop = false; + framesize -= wordSize; + st->print("# stack bang"); + st->print("\n\t"); + st->print("pushq rbp\t# Save rbp"); + if (framesize) { + st->print("\n\t"); + st->print("subq rsp, #%d\t# Create frame",framesize); + } + } else { + st->print("subq rsp, #%d\t# Create frame",framesize); + st->print("\n\t"); + framesize -= wordSize; + st->print("movq [rsp + #%d], rbp\t# Save rbp",framesize); } - st->print_cr("pushq rbp"); st->print("\t"); if (VerifyStackAtCalls) { - // Majik cookie to verify stack depth - st->print_cr("pushq 0xffffffffbadb100d" - "\t# Majik cookie for stack depth check"); - st->print("\t"); - framesize -= wordSize; // Remove 2 for cookie - need_nop = false; + st->print("\n\t"); + framesize -= wordSize; + st->print("movq [rsp + #%d], 0xbadb100d\t# Majik cookie for stack depth check",framesize); +#ifdef ASSERT + st->print("\n\t"); + st->print("# stack alignment check"); +#endif } - - if (framesize) { - st->print("subq rsp, #%d\t# Create frame", framesize); - if (framesize < 0x80 && need_nop) { - st->print("\n\tnop\t# nop for patch_verified_entry"); - } - } + st->cr(); } #endif -void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const -{ +void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { Compile* C = ra_->C; - - // WARNING: Initial instruction MUST be 5 bytes or longer so that - // NativeJump::patch_verified_entry will be able to patch out the entry - // code safely. The fldcw is ok at 6 bytes, the push to verify stack - // depth is ok at 5 bytes, the frame allocation can be either 3 or - // 6 bytes. So if we don't do the fldcw or the push then we must - // use the 6 byte frame allocation even if we have no frame. :-( - // If method sets FPU control word do it now + MacroAssembler _masm(&cbuf); int framesize = C->frame_slots() << LogBytesPerInt; - assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned"); - // Remove wordSize for return adr already pushed - // and another for the RBP we are going to save - framesize -= 2*wordSize; - bool need_nop = true; - - // Calls to C2R adapters often do not accept exceptional returns. - // We require that their callers must bang for them. But be - // careful, because some VM calls (such as call site linkage) can - // use several kilobytes of stack. But the stack safety zone should - // account for that. See bugs 4446381, 4468289, 4497237. - if (C->need_stack_bang(framesize)) { - MacroAssembler masm(&cbuf); - masm.generate_stack_overflow_check(framesize); - need_nop = false; - } - - // We always push rbp so that on return to interpreter rbp will be - // restored correctly and we can correct the stack. - emit_opcode(cbuf, 0x50 | RBP_enc); - - if (VerifyStackAtCalls) { - // Majik cookie to verify stack depth - emit_opcode(cbuf, 0x68); // pushq (sign-extended) 0xbadb100d - emit_d32(cbuf, 0xbadb100d); - framesize -= wordSize; // Remove 2 for cookie - need_nop = false; - } - - if (framesize) { - emit_opcode(cbuf, Assembler::REX_W); - if (framesize < 0x80) { - emit_opcode(cbuf, 0x83); // sub SP,#framesize - emit_rm(cbuf, 0x3, 0x05, RSP_enc); - emit_d8(cbuf, framesize); - if (need_nop) { - emit_opcode(cbuf, 0x90); // nop - } - } else { - emit_opcode(cbuf, 0x81); // sub SP,#framesize - emit_rm(cbuf, 0x3, 0x05, RSP_enc); - emit_d32(cbuf, framesize); - } - } + + __ verified_entry(framesize, C->need_stack_bang(framesize), false); C->set_frame_complete(cbuf.insts_size()); -#ifdef ASSERT - if (VerifyStackAtCalls) { - Label L; - MacroAssembler masm(&cbuf); - masm.push(rax); - masm.mov(rax, rsp); - masm.andptr(rax, StackAlignmentInBytes-1); - masm.cmpptr(rax, StackAlignmentInBytes-wordSize); - masm.pop(rax); - masm.jcc(Assembler::equal, L); - masm.stop("Stack is not properly aligned!"); - masm.bind(L); - } -#endif - if (C->has_mach_constant_base_node()) { // NOTE: We set the table base offset here because users might be // emitted before MachConstantBaseNode. @@ -1598,26 +1523,6 @@ //============================================================================= #ifndef PRODUCT -void MachNopNode::format(PhaseRegAlloc*, outputStream* st) const -{ - st->print("nop \t# %d bytes pad for loops and calls", _count); -} -#endif - -void MachNopNode::emit(CodeBuffer &cbuf, PhaseRegAlloc*) const -{ - MacroAssembler _masm(&cbuf); - __ nop(_count); -} - -uint MachNopNode::size(PhaseRegAlloc*) const -{ - return _count; -} - - -//============================================================================= -#ifndef PRODUCT void BoxLockNode::format(PhaseRegAlloc* ra_, outputStream* st) const { int offset = ra_->reg2offset(in_RegMask(0).find_first_elem()); @@ -2323,21 +2228,6 @@ RELOC_DISP32); %} - enc_class preserve_SP %{ - debug_only(int off0 = cbuf.insts_size()); - MacroAssembler _masm(&cbuf); - // RBP is preserved across all calls, even compiled calls. - // Use it to preserve RSP in places where the callee might change the SP. - __ movptr(rbp_mh_SP_save, rsp); - debug_only(int off1 = cbuf.insts_size()); - assert(off1 - off0 == preserve_SP_size(), "correct size prediction"); - %} - - enc_class restore_SP %{ - MacroAssembler _masm(&cbuf); - __ movptr(rsp, rbp_mh_SP_save); - %} - enc_class Java_Static_Call(method meth) %{ // JAVA STATIC CALL @@ -3276,9 +3166,9 @@ // Ret Addr is on stack in slot 0 if no locks or verification or alignment. // Otherwise, it is above the locks and verification slot and alignment word return_addr(STACK - 2 + - round_to(2 + 2 * VerifyStackAtCalls + - Compile::current()->fixed_slots(), - WordsPerLong * 2)); + round_to((Compile::current()->in_preserve_stack_slots() + + Compile::current()->fixed_slots()), + stack_alignment_in_slots())); // Body of function which returns an integer array locating // arguments either in registers or in stack slots. Passed an array @@ -11736,6 +11626,21 @@ %} +// ============================================================================ +// This name is KNOWN by the ADLC and cannot be changed. +// The ADLC forces a 'TypeRawPtr::BOTTOM' output type +// for this guy. +instruct tlsLoadP(r15_RegP dst) %{ + match(Set dst (ThreadLocal)); + effect(DEF dst); + + size(0); + format %{ "# TLS is in R15" %} + ins_encode( /*empty encoding*/ ); + ins_pipe(ialu_reg_reg); +%} + + //----------PEEPHOLE RULES----------------------------------------------------- // These must follow all instruction definitions as they use the names // defined in the instructions definitions. diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/os/bsd/vm/decoder_machO.hpp --- a/hotspot/src/os/bsd/vm/decoder_machO.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/os/bsd/vm/decoder_machO.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -29,8 +29,9 @@ #include "utilities/decoder.hpp" -// Just a placehold for now -class MachODecoder: public NullDecoder { +// Just a placehold for now, a real implementation should derive +// from AbstractDecoder +class MachODecoder : public NullDecoder { public: MachODecoder() { } ~MachODecoder() { } diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/os/windows/vm/decoder_windows.hpp --- a/hotspot/src/os/windows/vm/decoder_windows.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/os/windows/vm/decoder_windows.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -36,7 +36,7 @@ typedef BOOL (WINAPI *pfn_SymGetSymFromAddr64)(HANDLE, DWORD64, PDWORD64, PIMAGEHLP_SYMBOL64); typedef DWORD (WINAPI *pfn_UndecorateSymbolName)(const char*, char*, DWORD, DWORD); -class WindowsDecoder: public NullDecoder { +class WindowsDecoder : public AbstractDecoder { public: WindowsDecoder(); diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_32.ad --- a/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_32.ad Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_32.ad Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ // -// Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. +// 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 @@ -24,137 +24,3 @@ // X86 Bsd Architecture Description File -//----------OS-DEPENDENT ENCODING BLOCK----------------------------------------------------- -// This block specifies the encoding classes used by the compiler to output -// byte streams. Encoding classes generate functions which are called by -// Machine Instruction Nodes in order to generate the bit encoding of the -// instruction. Operands specify their base encoding interface with the -// interface keyword. There are currently supported four interfaces, -// REG_INTER, CONST_INTER, MEMORY_INTER, & COND_INTER. REG_INTER causes an -// operand to generate a function which returns its register number when -// queried. CONST_INTER causes an operand to generate a function which -// returns the value of the constant when queried. MEMORY_INTER causes an -// operand to generate four functions which return the Base Register, the -// Index Register, the Scale Value, and the Offset Value of the operand when -// queried. COND_INTER causes an operand to generate six functions which -// return the encoding code (ie - encoding bits for the instruction) -// associated with each basic boolean condition for a conditional instruction. -// Instructions specify two basic values for encoding. They use the -// ins_encode keyword to specify their encoding class (which must be one of -// the class names specified in the encoding block), and they use the -// opcode keyword to specify, in order, their primary, secondary, and -// tertiary opcode. Only the opcode sections which a particular instruction -// needs for encoding need to be specified. -encode %{ - // Build emit functions for each basic byte or larger field in the intel - // encoding scheme (opcode, rm, sib, immediate), and call them from C++ - // code in the enc_class source block. Emit functions will live in the - // main source block for now. In future, we can generalize this by - // adding a syntax that specifies the sizes of fields in an order, - // so that the adlc can build the emit functions automagically - - enc_class bsd_tlsencode (eRegP dst) %{ - Register dstReg = as_Register($dst$$reg); - MacroAssembler* masm = new MacroAssembler(&cbuf); - masm->get_thread(dstReg); - %} - - enc_class bsd_breakpoint %{ - MacroAssembler* masm = new MacroAssembler(&cbuf); - masm->call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint))); - %} - - enc_class call_epilog %{ - if( VerifyStackAtCalls ) { - // Check that stack depth is unchanged: find majik cookie on stack - int framesize = ra_->reg2offset_unchecked(OptoReg::add(ra_->_matcher._old_SP,-3*VMRegImpl::slots_per_word)); - if(framesize >= 128) { - emit_opcode(cbuf, 0x81); // cmp [esp+0],0xbadb1ood - emit_d8(cbuf,0xBC); - emit_d8(cbuf,0x24); - emit_d32(cbuf,framesize); // Find majik cookie from ESP - emit_d32(cbuf, 0xbadb100d); - } - else { - emit_opcode(cbuf, 0x81); // cmp [esp+0],0xbadb1ood - emit_d8(cbuf,0x7C); - emit_d8(cbuf,0x24); - emit_d8(cbuf,framesize); // Find majik cookie from ESP - emit_d32(cbuf, 0xbadb100d); - } - // jmp EQ around INT3 - // QQQ TODO - const int jump_around = 5; // size of call to breakpoint, 1 for CC - emit_opcode(cbuf,0x74); - emit_d8(cbuf, jump_around); - // QQQ temporary - emit_break(cbuf); - // Die if stack mismatch - // emit_opcode(cbuf,0xCC); - } - %} - -%} - -// INSTRUCTIONS -- Platform dependent - -//----------OS and Locking Instructions---------------------------------------- - -// This name is KNOWN by the ADLC and cannot be changed. -// The ADLC forces a 'TypeRawPtr::BOTTOM' output type -// for this guy. -instruct tlsLoadP(eRegP dst, eFlagsReg cr) %{ - match(Set dst (ThreadLocal)); - effect(DEF dst, KILL cr); - - format %{ "MOV $dst, Thread::current()" %} - ins_encode( bsd_tlsencode(dst) ); - ins_pipe( ialu_reg_fat ); -%} - -instruct TLS(eRegP dst) %{ - match(Set dst (ThreadLocal)); - - expand %{ - tlsLoadP(dst); - %} -%} - -// Die now -instruct ShouldNotReachHere( ) -%{ - match(Halt); - - // Use the following format syntax - format %{ "INT3 ; ShouldNotReachHere" %} - // QQQ TODO for now call breakpoint - // opcode(0xCC); - // ins_encode(Opc); - ins_encode(bsd_breakpoint); - ins_pipe( pipe_slow ); -%} - - - -// Platform dependent source - -source %{ - -// emit an interrupt that is caught by the debugger -void emit_break(CodeBuffer &cbuf) { - - // Debugger doesn't really catch this but best we can do so far QQQ - MacroAssembler* masm = new MacroAssembler(&cbuf); - masm->call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint))); -} - -void MachBreakpointNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { - emit_break(cbuf); -} - - -uint MachBreakpointNode::size(PhaseRegAlloc *ra_) const { - return 5; -} - -%} diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_64.ad --- a/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_64.ad Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_64.ad Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ // -// Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2003, 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 @@ -55,8 +55,7 @@ // adding a syntax that specifies the sizes of fields in an order, // so that the adlc can build the emit functions automagically - enc_class Java_To_Runtime(method meth) - %{ + enc_class Java_To_Runtime(method meth) %{ // No relocation needed // movq r10, @@ -70,104 +69,15 @@ emit_opcode(cbuf, 0xD0 | (R10_enc - 8)); %} - enc_class bsd_breakpoint - %{ - MacroAssembler* masm = new MacroAssembler(&cbuf); - masm->call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint))); - %} - - enc_class call_epilog - %{ - if (VerifyStackAtCalls) { - // Check that stack depth is unchanged: find majik cookie on stack - int framesize = - ra_->reg2offset_unchecked(OptoReg::add(ra_->_matcher._old_SP, -3*VMRegImpl::slots_per_word)); - if (framesize) { - if (framesize < 0x80) { - emit_opcode(cbuf, Assembler::REX_W); - emit_opcode(cbuf, 0x81); // cmpq [rsp+0],0xbadb1ood - emit_d8(cbuf, 0x7C); - emit_d8(cbuf, 0x24); - emit_d8(cbuf, framesize); // Find majik cookie from ESP - emit_d32(cbuf, 0xbadb100d); - } else { - emit_opcode(cbuf, Assembler::REX_W); - emit_opcode(cbuf, 0x81); // cmpq [rsp+0],0xbadb1ood - emit_d8(cbuf, 0xBC); - emit_d8(cbuf, 0x24); - emit_d32(cbuf, framesize); // Find majik cookie from ESP - emit_d32(cbuf, 0xbadb100d); - } - } - // jmp EQ around INT3 - // QQQ TODO - const int jump_around = 5; // size of call to breakpoint, 1 for CC - emit_opcode(cbuf, 0x74); - emit_d8(cbuf, jump_around); - // QQQ temporary - emit_break(cbuf); - // Die if stack mismatch - // emit_opcode(cbuf,0xCC); - } - %} - -%} - -// INSTRUCTIONS -- Platform dependent - -//----------OS and Locking Instructions---------------------------------------- - -// This name is KNOWN by the ADLC and cannot be changed. -// The ADLC forces a 'TypeRawPtr::BOTTOM' output type -// for this guy. -instruct tlsLoadP(r15_RegP dst) -%{ - match(Set dst (ThreadLocal)); - effect(DEF dst); - - size(0); - format %{ "# TLS is in R15" %} - ins_encode( /*empty encoding*/ ); - ins_pipe(ialu_reg_reg); -%} - -// Die now -instruct ShouldNotReachHere() -%{ - match(Halt); - - // Use the following format syntax - format %{ "int3\t# ShouldNotReachHere" %} - // QQQ TODO for now call breakpoint - // opcode(0xCC); - // ins_encode(Opc); - ins_encode(bsd_breakpoint); - ins_pipe(pipe_slow); %} // Platform dependent source -source -%{ +source %{ int MachCallRuntimeNode::ret_addr_offset() { return 13; // movq r10,#addr; callq (r10) } -// emit an interrupt that is caught by the debugger -void emit_break(CodeBuffer& cbuf) { - // Debugger doesn't really catch this but best we can do so far QQQ - MacroAssembler* masm = new MacroAssembler(&cbuf); - masm->call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint))); -} - -void MachBreakpointNode::emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const { - emit_break(cbuf); -} - -uint MachBreakpointNode::size(PhaseRegAlloc* ra_) const { - return 5; -} - %} diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/os_cpu/linux_x86/vm/linux_x86_32.ad --- a/hotspot/src/os_cpu/linux_x86/vm/linux_x86_32.ad Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/os_cpu/linux_x86/vm/linux_x86_32.ad Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ // -// Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. +// 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 @@ -24,137 +24,3 @@ // X86 Linux Architecture Description File -//----------OS-DEPENDENT ENCODING BLOCK----------------------------------------------------- -// This block specifies the encoding classes used by the compiler to output -// byte streams. Encoding classes generate functions which are called by -// Machine Instruction Nodes in order to generate the bit encoding of the -// instruction. Operands specify their base encoding interface with the -// interface keyword. There are currently supported four interfaces, -// REG_INTER, CONST_INTER, MEMORY_INTER, & COND_INTER. REG_INTER causes an -// operand to generate a function which returns its register number when -// queried. CONST_INTER causes an operand to generate a function which -// returns the value of the constant when queried. MEMORY_INTER causes an -// operand to generate four functions which return the Base Register, the -// Index Register, the Scale Value, and the Offset Value of the operand when -// queried. COND_INTER causes an operand to generate six functions which -// return the encoding code (ie - encoding bits for the instruction) -// associated with each basic boolean condition for a conditional instruction. -// Instructions specify two basic values for encoding. They use the -// ins_encode keyword to specify their encoding class (which must be one of -// the class names specified in the encoding block), and they use the -// opcode keyword to specify, in order, their primary, secondary, and -// tertiary opcode. Only the opcode sections which a particular instruction -// needs for encoding need to be specified. -encode %{ - // Build emit functions for each basic byte or larger field in the intel - // encoding scheme (opcode, rm, sib, immediate), and call them from C++ - // code in the enc_class source block. Emit functions will live in the - // main source block for now. In future, we can generalize this by - // adding a syntax that specifies the sizes of fields in an order, - // so that the adlc can build the emit functions automagically - - enc_class linux_tlsencode (eRegP dst) %{ - Register dstReg = as_Register($dst$$reg); - MacroAssembler* masm = new MacroAssembler(&cbuf); - masm->get_thread(dstReg); - %} - - enc_class linux_breakpoint %{ - MacroAssembler* masm = new MacroAssembler(&cbuf); - masm->call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint))); - %} - - enc_class call_epilog %{ - if( VerifyStackAtCalls ) { - // Check that stack depth is unchanged: find majik cookie on stack - int framesize = ra_->reg2offset_unchecked(OptoReg::add(ra_->_matcher._old_SP,-3*VMRegImpl::slots_per_word)); - if(framesize >= 128) { - emit_opcode(cbuf, 0x81); // cmp [esp+0],0xbadb1ood - emit_d8(cbuf,0xBC); - emit_d8(cbuf,0x24); - emit_d32(cbuf,framesize); // Find majik cookie from ESP - emit_d32(cbuf, 0xbadb100d); - } - else { - emit_opcode(cbuf, 0x81); // cmp [esp+0],0xbadb1ood - emit_d8(cbuf,0x7C); - emit_d8(cbuf,0x24); - emit_d8(cbuf,framesize); // Find majik cookie from ESP - emit_d32(cbuf, 0xbadb100d); - } - // jmp EQ around INT3 - // QQQ TODO - const int jump_around = 5; // size of call to breakpoint, 1 for CC - emit_opcode(cbuf,0x74); - emit_d8(cbuf, jump_around); - // QQQ temporary - emit_break(cbuf); - // Die if stack mismatch - // emit_opcode(cbuf,0xCC); - } - %} - -%} - -// INSTRUCTIONS -- Platform dependent - -//----------OS and Locking Instructions---------------------------------------- - -// This name is KNOWN by the ADLC and cannot be changed. -// The ADLC forces a 'TypeRawPtr::BOTTOM' output type -// for this guy. -instruct tlsLoadP(eRegP dst, eFlagsReg cr) %{ - match(Set dst (ThreadLocal)); - effect(DEF dst, KILL cr); - - format %{ "MOV $dst, Thread::current()" %} - ins_encode( linux_tlsencode(dst) ); - ins_pipe( ialu_reg_fat ); -%} - -instruct TLS(eRegP dst) %{ - match(Set dst (ThreadLocal)); - - expand %{ - tlsLoadP(dst); - %} -%} - -// Die now -instruct ShouldNotReachHere( ) -%{ - match(Halt); - - // Use the following format syntax - format %{ "INT3 ; ShouldNotReachHere" %} - // QQQ TODO for now call breakpoint - // opcode(0xCC); - // ins_encode(Opc); - ins_encode(linux_breakpoint); - ins_pipe( pipe_slow ); -%} - - - -// Platform dependent source - -source %{ - -// emit an interrupt that is caught by the debugger -void emit_break(CodeBuffer &cbuf) { - - // Debugger doesn't really catch this but best we can do so far QQQ - MacroAssembler* masm = new MacroAssembler(&cbuf); - masm->call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint))); -} - -void MachBreakpointNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { - emit_break(cbuf); -} - - -uint MachBreakpointNode::size(PhaseRegAlloc *ra_) const { - return MachNode::size(ra_); -} - -%} diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/os_cpu/linux_x86/vm/linux_x86_64.ad --- a/hotspot/src/os_cpu/linux_x86/vm/linux_x86_64.ad Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/os_cpu/linux_x86/vm/linux_x86_64.ad Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ // -// Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2003, 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 @@ -55,8 +55,7 @@ // adding a syntax that specifies the sizes of fields in an order, // so that the adlc can build the emit functions automagically - enc_class Java_To_Runtime(method meth) - %{ + enc_class Java_To_Runtime(method meth) %{ // No relocation needed // movq r10, @@ -70,105 +69,15 @@ emit_opcode(cbuf, 0xD0 | (R10_enc - 8)); %} - enc_class linux_breakpoint - %{ - MacroAssembler* masm = new MacroAssembler(&cbuf); - masm->call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint))); - %} - - enc_class call_epilog - %{ - if (VerifyStackAtCalls) { - // Check that stack depth is unchanged: find majik cookie on stack - int framesize = - ra_->reg2offset_unchecked(OptoReg::add(ra_->_matcher._old_SP, -3*VMRegImpl::slots_per_word)); - if (framesize) { - if (framesize < 0x80) { - emit_opcode(cbuf, Assembler::REX_W); - emit_opcode(cbuf, 0x81); // cmpq [rsp+0],0xbadb1ood - emit_d8(cbuf, 0x7C); - emit_d8(cbuf, 0x24); - emit_d8(cbuf, framesize); // Find majik cookie from ESP - emit_d32(cbuf, 0xbadb100d); - } else { - emit_opcode(cbuf, Assembler::REX_W); - emit_opcode(cbuf, 0x81); // cmpq [rsp+0],0xbadb1ood - emit_d8(cbuf, 0xBC); - emit_d8(cbuf, 0x24); - emit_d32(cbuf, framesize); // Find majik cookie from ESP - emit_d32(cbuf, 0xbadb100d); - } - } - // jmp EQ around INT3 - // QQQ TODO - const int jump_around = 5; // size of call to breakpoint, 1 for CC - emit_opcode(cbuf, 0x74); - emit_d8(cbuf, jump_around); - // QQQ temporary - emit_break(cbuf); - // Die if stack mismatch - // emit_opcode(cbuf,0xCC); - } - %} - -%} - -// INSTRUCTIONS -- Platform dependent - -//----------OS and Locking Instructions---------------------------------------- - -// This name is KNOWN by the ADLC and cannot be changed. -// The ADLC forces a 'TypeRawPtr::BOTTOM' output type -// for this guy. -instruct tlsLoadP(r15_RegP dst) -%{ - match(Set dst (ThreadLocal)); - effect(DEF dst); - - size(0); - format %{ "# TLS is in R15" %} - ins_encode( /*empty encoding*/ ); - ins_pipe(ialu_reg_reg); -%} - -// Die now -instruct ShouldNotReachHere() -%{ - match(Halt); - - // Use the following format syntax - format %{ "int3\t# ShouldNotReachHere" %} - // QQQ TODO for now call breakpoint - // opcode(0xCC); - // ins_encode(Opc); - ins_encode(linux_breakpoint); - ins_pipe(pipe_slow); %} // Platform dependent source -source -%{ +source %{ int MachCallRuntimeNode::ret_addr_offset() { return 13; // movq r10,#addr; callq (r10) } -// emit an interrupt that is caught by the debugger -void emit_break(CodeBuffer& cbuf) { - // Debugger doesn't really catch this but best we can do so far QQQ - MacroAssembler* masm = new MacroAssembler(&cbuf); - masm->call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint))); -} - -void MachBreakpointNode::emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const { - emit_break(cbuf); -} - -uint MachBreakpointNode::size(PhaseRegAlloc* ra_) const { - // distance could be far and requires load and call through register - return MachNode::size(ra_); -} - %} diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_32.ad --- a/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_32.ad Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_32.ad Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ // -// Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. +// 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 @@ -24,144 +24,3 @@ // X86 Solaris Architecture Description File -//----------OS-DEPENDENT ENCODING BLOCK----------------------------------------------------- -// This block specifies the encoding classes used by the compiler to output -// byte streams. Encoding classes generate functions which are called by -// Machine Instruction Nodes in order to generate the bit encoding of the -// instruction. Operands specify their base encoding interface with the -// interface keyword. There are currently supported four interfaces, -// REG_INTER, CONST_INTER, MEMORY_INTER, & COND_INTER. REG_INTER causes an -// operand to generate a function which returns its register number when -// queried. CONST_INTER causes an operand to generate a function which -// returns the value of the constant when queried. MEMORY_INTER causes an -// operand to generate four functions which return the Base Register, the -// Index Register, the Scale Value, and the Offset Value of the operand when -// queried. COND_INTER causes an operand to generate six functions which -// return the encoding code (ie - encoding bits for the instruction) -// associated with each basic boolean condition for a conditional instruction. -// Instructions specify two basic values for encoding. They use the -// ins_encode keyword to specify their encoding class (which must be one of -// the class names specified in the encoding block), and they use the -// opcode keyword to specify, in order, their primary, secondary, and -// tertiary opcode. Only the opcode sections which a particular instruction -// needs for encoding need to be specified. -encode %{ - // Build emit functions for each basic byte or larger field in the intel - // encoding scheme (opcode, rm, sib, immediate), and call them from C++ - // code in the enc_class source block. Emit functions will live in the - // main source block for now. In future, we can generalize this by - // adding a syntax that specifies the sizes of fields in an order, - // so that the adlc can build the emit functions automagically - - enc_class solaris_tlsencode (eRegP dst) %{ - Register dstReg = as_Register($dst$$reg); - MacroAssembler* masm = new MacroAssembler(&cbuf); - masm->get_thread(dstReg); - %} - - enc_class solaris_breakpoint %{ - MacroAssembler* masm = new MacroAssembler(&cbuf); - // Really need to fix this - masm->push(rax); - masm->push(rcx); - masm->push(rdx); - masm->call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint))); - masm->pop(rdx); - masm->pop(rcx); - masm->pop(rax); - %} - - enc_class call_epilog %{ - if( VerifyStackAtCalls ) { - // Check that stack depth is unchanged: find majik cookie on stack - int framesize = ra_->reg2offset_unchecked(OptoReg::add(ra_->_matcher._old_SP,-3*VMRegImpl::slots_per_word)); - if(framesize >= 128) { - emit_opcode(cbuf, 0x81); // cmp [esp+0],0xbadb1ood - emit_d8(cbuf,0xBC); - emit_d8(cbuf,0x24); - emit_d32(cbuf,framesize); // Find majik cookie from ESP - emit_d32(cbuf, 0xbadb100d); - } - else { - emit_opcode(cbuf, 0x81); // cmp [esp+0],0xbadb1ood - emit_d8(cbuf,0x7C); - emit_d8(cbuf,0x24); - emit_d8(cbuf,framesize); // Find majik cookie from ESP - emit_d32(cbuf, 0xbadb100d); - } - // jmp EQ around INT3 - // QQQ TODO - const int jump_around = 11; // size of call to breakpoint (and register preserve), 1 for CC - emit_opcode(cbuf,0x74); - emit_d8(cbuf, jump_around); - // QQQ temporary - emit_break(cbuf); - // Die if stack mismatch - // emit_opcode(cbuf,0xCC); - } - %} - -%} - -// INSTRUCTIONS -- Platform dependent - -//----------OS and Locking Instructions---------------------------------------- - -// This name is KNOWN by the ADLC and cannot be changed. -// The ADLC forces a 'TypeRawPtr::BOTTOM' output type -// for this guy. -instruct tlsLoadP(eRegP dst, eFlagsReg cr) %{ - match(Set dst (ThreadLocal)); - effect(DEF dst, KILL cr); - - format %{ "MOV $dst, Thread::current()" %} - ins_encode( solaris_tlsencode(dst) ); - ins_pipe( ialu_reg_fat ); -%} - -instruct TLS(eRegP dst) %{ - match(Set dst (ThreadLocal)); - - expand %{ - tlsLoadP(dst); - %} -%} - -// Die now -instruct ShouldNotReachHere( ) -%{ - match(Halt); - - // Use the following format syntax - format %{ "INT3 ; ShouldNotReachHere" %} - // QQQ TODO for now call breakpoint - // opcode(0xCC); - // ins_encode(Opc); - ins_encode(solaris_breakpoint); - ins_pipe( pipe_slow ); -%} - - - -// Platform dependent source - -source %{ - -// emit an interrupt that is caught by the debugger -void emit_break(CodeBuffer &cbuf) { - - // Debugger doesn't really catch this but best we can do so far QQQ - MacroAssembler* masm = new MacroAssembler(&cbuf); - masm->call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint))); -} - -void MachBreakpointNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { - emit_break(cbuf); -} - - -uint MachBreakpointNode::size(PhaseRegAlloc *ra_) const { - return MachNode::size(ra_); -} - -%} diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_64.ad --- a/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_64.ad Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_64.ad Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ // -// Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2004, 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 @@ -55,8 +55,7 @@ // adding a syntax that specifies the sizes of fields in an order, // so that the adlc can build the emit functions automagically - enc_class Java_To_Runtime(method meth) - %{ + enc_class Java_To_Runtime(method meth) %{ // No relocation needed // movq r10, @@ -70,118 +69,24 @@ emit_opcode(cbuf, 0xD0 | (R10_enc - 8)); %} - enc_class solaris_breakpoint - %{ - MacroAssembler* masm = new MacroAssembler(&cbuf); - masm->call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint))); - %} - - enc_class call_epilog - %{ - if (VerifyStackAtCalls) { - // Check that stack depth is unchanged: find majik cookie on stack - int framesize = - ra_->reg2offset_unchecked(OptoReg::add(ra_->_matcher._old_SP, -3*VMRegImpl::slots_per_word)); - if (framesize) { - if (framesize < 0x80) { - emit_opcode(cbuf, Assembler::REX_W); - emit_opcode(cbuf, 0x81); // cmpq [rsp+0],0xbadb1ood - emit_d8(cbuf, 0x7C); - emit_d8(cbuf, 0x24); - emit_d8(cbuf, framesize); // Find majik cookie from ESP - emit_d32(cbuf, 0xbadb100d); - } else { - emit_opcode(cbuf, Assembler::REX_W); - emit_opcode(cbuf, 0x81); // cmpq [rsp+0],0xbadb1ood - emit_d8(cbuf, 0xBC); - emit_d8(cbuf, 0x24); - emit_d32(cbuf, framesize); // Find majik cookie from ESP - emit_d32(cbuf, 0xbadb100d); - } - } - // jmp EQ around INT3 - // QQQ TODO - const int jump_around = 5; // size of call to breakpoint, 1 for CC - emit_opcode(cbuf, 0x74); - emit_d8(cbuf, jump_around); - // QQQ temporary - emit_break(cbuf); - // Die if stack mismatch - // emit_opcode(cbuf,0xCC); + enc_class post_call_verify_mxcsr %{ + MacroAssembler _masm(&cbuf); + if (RestoreMXCSROnJNICalls) { + __ ldmxcsr(ExternalAddress(StubRoutines::amd64::mxcsr_std())); + } + else if (CheckJNICalls) { + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::amd64::verify_mxcsr_entry()))); } %} - - enc_class post_call_verify_mxcsr %{ - MacroAssembler masm(&cbuf); - if (RestoreMXCSROnJNICalls) { - masm.ldmxcsr(ExternalAddress(StubRoutines::amd64::mxcsr_std())); - } - else if (CheckJNICalls) { - masm.call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::amd64::verify_mxcsr_entry()))); - } - %} -%} - -// INSTRUCTIONS -- Platform dependent - -//----------OS and Locking Instructions---------------------------------------- - -// This name is KNOWN by the ADLC and cannot be changed. -// The ADLC forces a 'TypeRawPtr::BOTTOM' output type -// for this guy. -instruct tlsLoadP(r15_RegP dst) -%{ - match(Set dst (ThreadLocal)); - effect(DEF dst); - - size(0); - format %{ "# TLS is in R15" %} - ins_encode( /*empty encoding*/ ); - ins_pipe(ialu_reg_reg); -%} - -// Die now -instruct ShouldNotReachHere() -%{ - match(Halt); - - // Use the following format syntax - format %{ "int3\t# ShouldNotReachHere" %} - // QQQ TODO for now call breakpoint - // opcode(0xCC); - // ins_encode(Opc); - ins_encode(solaris_breakpoint); - ins_pipe(pipe_slow); %} // Platform dependent source -source -%{ +source %{ -int MachCallRuntimeNode::ret_addr_offset() -{ +int MachCallRuntimeNode::ret_addr_offset() { return 13; // movq r10,#addr; callq (r10) } -// emit an interrupt that is caught by the debugger -void emit_break(CodeBuffer& cbuf) -{ - // Debugger doesn't really catch this but best we can do so far QQQ - MacroAssembler* masm = new MacroAssembler(&cbuf); - masm->call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint))); -} - -void MachBreakpointNode::emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const -{ - emit_break(cbuf); -} - -uint MachBreakpointNode::size(PhaseRegAlloc* ra_) const -{ - // distance could be far and requires load and call through register - return MachNode::size(ra_); -} - %} diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/os_cpu/windows_x86/vm/windows_x86_32.ad --- a/hotspot/src/os_cpu/windows_x86/vm/windows_x86_32.ad Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/os_cpu/windows_x86/vm/windows_x86_32.ad Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ // -// Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. +// 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 @@ -24,134 +24,3 @@ // X86 Win32 Architecture Description File -//----------OS-DEPENDENT ENCODING BLOCK----------------------------------------------------- -// This block specifies the encoding classes used by the compiler to output -// byte streams. Encoding classes generate functions which are called by -// Machine Instruction Nodes in order to generate the bit encoding of the -// instruction. Operands specify their base encoding interface with the -// interface keyword. There are currently supported four interfaces, -// REG_INTER, CONST_INTER, MEMORY_INTER, & COND_INTER. REG_INTER causes an -// operand to generate a function which returns its register number when -// queried. CONST_INTER causes an operand to generate a function which -// returns the value of the constant when queried. MEMORY_INTER causes an -// operand to generate four functions which return the Base Register, the -// Index Register, the Scale Value, and the Offset Value of the operand when -// queried. COND_INTER causes an operand to generate six functions which -// return the encoding code (ie - encoding bits for the instruction) -// associated with each basic boolean condition for a conditional instruction. -// Instructions specify two basic values for encoding. They use the -// ins_encode keyword to specify their encoding class (which must be one of -// the class names specified in the encoding block), and they use the -// opcode keyword to specify, in order, their primary, secondary, and -// tertiary opcode. Only the opcode sections which a particular instruction -// needs for encoding need to be specified. -encode %{ - // Build emit functions for each basic byte or larger field in the intel - // encoding scheme (opcode, rm, sib, immediate), and call them from C++ - // code in the enc_class source block. Emit functions will live in the - // main source block for now. In future, we can generalize this by - // adding a syntax that specifies the sizes of fields in an order, - // so that the adlc can build the emit functions automagically - - enc_class tlsencode (eRegP dst, eRegP src) %{ - emit_rm(cbuf, 0x2, $dst$$reg, $src$$reg); - emit_d32(cbuf, ThreadLocalStorage::get_thread_ptr_offset() ); - %} - - enc_class call_epilog %{ - if( VerifyStackAtCalls ) { - // Check that stack depth is unchanged: find majik cookie on stack - int framesize = ra_->reg2offset_unchecked(OptoReg::add(ra_->_matcher._old_SP,-3*VMRegImpl::slots_per_word)); - if(framesize >= 128) { - emit_opcode(cbuf, 0x81); // cmp [esp+0],0xbadb1ood - emit_d8(cbuf,0xBC); - emit_d8(cbuf,0x24); - emit_d32(cbuf,framesize); // Find majik cookie from ESP - emit_d32(cbuf, 0xbadb100d); - } - else { - emit_opcode(cbuf, 0x81); // cmp [esp+0],0xbadb1ood - emit_d8(cbuf,0x7C); - emit_d8(cbuf,0x24); - emit_d8(cbuf,framesize); // Find majik cookie from ESP - emit_d32(cbuf, 0xbadb100d); - } - // jmp EQ around INT3 - emit_opcode(cbuf,0x74); - emit_d8(cbuf,1); - // Die if stack mismatch - emit_opcode(cbuf,0xCC); - } - %} - -%} - -// INSTRUCTIONS -- Platform dependent - - -//----------OS and Locking Instructions---------------------------------------- - -// The prefix of this name is KNOWN by the ADLC and cannot be changed. -instruct tlsLoadP_prefixLoadP(eRegP t1) %{ - effect(DEF t1); - - format %{ "MOV $t1,FS:[0x00] "%} - opcode(0x8B, 0x64); - ins_encode(OpcS, OpcP, conmemref(t1)); - ins_pipe( ialu_reg_fat ); -%} - -// This name is KNOWN by the ADLC and cannot be changed. -// The ADLC forces a 'TypeRawPtr::BOTTOM' output type -// for this guy. -// %%% Should do this with a clause like: bottom_type(TypeRawPtr::BOTTOM); -instruct tlsLoadP(eRegP dst, eRegP t1) %{ - effect(DEF dst, USE t1); - - format %{ "MOV $dst,[$t1 + TLS::thread_ptr_offset()]" %} - opcode(0x8B); - ins_encode(OpcP, tlsencode(dst, t1)); - ins_pipe( ialu_reg_reg_fat ); -%} - -instruct TLS(eRegP dst) %{ - match(Set dst (ThreadLocal)); - expand %{ - eRegP t1; - tlsLoadP_prefixLoadP(t1); - tlsLoadP(dst, t1); - %} -%} - -// Die now -instruct ShouldNotReachHere( ) -%{ - match(Halt); - // Use the following format syntax - format %{ "INT3 ; ShouldNotReachHere" %} - opcode(0xCC); - ins_encode(OpcP); - ins_pipe( pipe_slow ); -%} - -// -// Platform dependent source -// -source %{ - -// emit an interrupt that is caught by the debugger -void emit_break(CodeBuffer &cbuf) { - cbuf.insts()->emit_int8((unsigned char) 0xcc); -} - -void MachBreakpointNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { - emit_break(cbuf); -} - - -uint MachBreakpointNode::size(PhaseRegAlloc *ra_) const { - return 1; -} - - -%} diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/os_cpu/windows_x86/vm/windows_x86_64.ad --- a/hotspot/src/os_cpu/windows_x86/vm/windows_x86_64.ad Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/os_cpu/windows_x86/vm/windows_x86_64.ad Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ // -// Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2003, 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 @@ -67,69 +67,6 @@ emit_opcode(cbuf, 0xD0 | (R10_enc - 8)); %} - enc_class call_epilog %{ - if (VerifyStackAtCalls) { - // Check that stack depth is unchanged: find majik cookie on stack - int framesize = - ra_->reg2offset_unchecked(OptoReg::add(ra_->_matcher._old_SP, -3*VMRegImpl::slots_per_word)); - if (framesize) { - if (framesize < 0x80) { - emit_opcode(cbuf, Assembler::REX_W); - emit_opcode(cbuf, 0x81); // cmpq [rsp+0],0xbadb1ood - emit_d8(cbuf, 0x7C); - emit_d8(cbuf, 0x24); - emit_d8(cbuf, framesize); // Find majik cookie from ESP - emit_d32(cbuf, 0xbadb100d); - } else { - emit_opcode(cbuf, Assembler::REX_W); - emit_opcode(cbuf, 0x81); // cmpq [rsp+0],0xbadb1ood - emit_d8(cbuf, 0xBC); - emit_d8(cbuf, 0x24); - emit_d32(cbuf, framesize); // Find majik cookie from ESP - emit_d32(cbuf, 0xbadb100d); - } - } - // jmp EQ around INT3 - // QQQ TODO - const int jump_around = 5; // size of call to breakpoint, 1 for CC - emit_opcode(cbuf, 0x74); - emit_d8(cbuf, jump_around); - // QQQ temporary - emit_break(cbuf); - // Die if stack mismatch - // emit_opcode(cbuf,0xCC); - } - %} -%} - -// INSTRUCTIONS -- Platform dependent - - -//----------OS and Locking Instructions---------------------------------------- - -// This name is KNOWN by the ADLC and cannot be changed. -// The ADLC forces a 'TypeRawPtr::BOTTOM' output type -// for this guy. -instruct tlsLoadP(r15_RegP dst) -%{ - match(Set dst (ThreadLocal)); - effect(DEF dst); - - size(0); - format %{ "# TLS is in R15" %} - ins_encode( /*empty encoding*/ ); - ins_pipe(ialu_reg_reg); -%} - -// Die now -instruct ShouldNotReachHere( ) -%{ - match(Halt); - // Use the following format syntax - format %{ "INT3 ; ShouldNotReachHere" %} - opcode(0xCC); - ins_encode(OpcP); - ins_pipe( pipe_slow ); %} // @@ -142,17 +79,4 @@ return 13; // movq r10,#addr; callq (r10) } -// emit an interrupt that is caught by the debugger -void emit_break(CodeBuffer &cbuf) { - cbuf.insts()->emit_int8((unsigned char) 0xcc); -} - -void MachBreakpointNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { - emit_break(cbuf); -} - -uint MachBreakpointNode::size(PhaseRegAlloc *ra_) const { - return 1; -} - %} diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/tools/hsdis/hsdis.c --- a/hotspot/src/share/tools/hsdis/hsdis.c Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/tools/hsdis/hsdis.c Wed Feb 22 10:17:57 2012 -0800 @@ -356,7 +356,7 @@ if (plen > mach_size) plen = mach_size; strncpy(mach_option, p, plen); mach_option[plen] = '\0'; - } else if (plen > 6 && strncmp(p, "hsdis-", 6)) { + } else if (plen > 6 && strncmp(p, "hsdis-", 6) == 0) { // do not pass these to the next level } else { /* just copy it; {i386,sparc}-dis.c might like to see it */ diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/c1/c1_Canonicalizer.cpp --- a/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -594,6 +594,13 @@ return false; } +static bool is_safepoint(BlockEnd* x, BlockBegin* sux) { + // An Instruction with multiple successors, x, is replaced by a Goto + // to a single successor, sux. Is a safepoint check needed = was the + // instruction being replaced a safepoint and the single remaining + // successor a back branch? + return x->is_safepoint() && (sux->bci() < x->state_before()->bci()); +} void Canonicalizer::do_If(If* x) { // move const to right @@ -614,7 +621,7 @@ case If::geq: sux = x->sux_for(true); break; } // If is a safepoint then the debug information should come from the state_before of the If. - set_canonical(new Goto(sux, x->state_before(), x->is_safepoint())); + set_canonical(new Goto(sux, x->state_before(), is_safepoint(x, sux))); return; } @@ -626,7 +633,7 @@ x->sux_for(false)); if (sux != NULL) { // If is a safepoint then the debug information should come from the state_before of the If. - set_canonical(new Goto(sux, x->state_before(), x->is_safepoint())); + set_canonical(new Goto(sux, x->state_before(), is_safepoint(x, sux))); } } } else if (rt->as_IntConstant() != NULL) { @@ -694,10 +701,12 @@ } } else if (rt == objectNull && (l->as_NewInstance() || l->as_NewArray())) { if (x->cond() == Instruction::eql) { - set_canonical(new Goto(x->fsux(), x->state_before(), x->is_safepoint())); + BlockBegin* sux = x->fsux(); + set_canonical(new Goto(sux, x->state_before(), is_safepoint(x, sux))); } else { assert(x->cond() == Instruction::neq, "only other valid case"); - set_canonical(new Goto(x->tsux(), x->state_before(), x->is_safepoint())); + BlockBegin* sux = x->tsux(); + set_canonical(new Goto(sux, x->state_before(), is_safepoint(x, sux))); } } } @@ -710,7 +719,7 @@ if (v >= x->lo_key() && v <= x->hi_key()) { sux = x->sux_at(v - x->lo_key()); } - set_canonical(new Goto(sux, x->state_before(), x->is_safepoint())); + set_canonical(new Goto(sux, x->state_before(), is_safepoint(x, sux))); } else if (x->number_of_sux() == 1) { // NOTE: Code permanently disabled for now since the switch statement's // tag expression may produce side-effects in which case it must @@ -741,7 +750,7 @@ sux = x->sux_at(i); } } - set_canonical(new Goto(sux, x->state_before(), x->is_safepoint())); + set_canonical(new Goto(sux, x->state_before(), is_safepoint(x, sux))); } else if (x->number_of_sux() == 1) { // NOTE: Code permanently disabled for now since the switch statement's // tag expression may produce side-effects in which case it must diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/c1/c1_GraphBuilder.cpp --- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -1181,6 +1181,11 @@ bool is_bb = tsux->bci() < stream()->cur_bci() || fsux->bci() < stream()->cur_bci(); Instruction *i = append(new If(x, cond, false, y, tsux, fsux, is_bb ? state_before : NULL, is_bb)); + assert(i->as_Goto() == NULL || + (i->as_Goto()->sux_at(0) == tsux && i->as_Goto()->is_safepoint() == tsux->bci() < stream()->cur_bci()) || + (i->as_Goto()->sux_at(0) == fsux && i->as_Goto()->is_safepoint() == fsux->bci() < stream()->cur_bci()), + "safepoint state of Goto returned by canonicalizer incorrect"); + if (is_profiling()) { If* if_node = i->as_If(); if (if_node != NULL) { @@ -1303,7 +1308,16 @@ // add default successor sux->at_put(i, block_at(bci() + sw.default_offset())); ValueStack* state_before = has_bb ? copy_state_before() : NULL; - append(new TableSwitch(ipop(), sux, sw.low_key(), state_before, has_bb)); + Instruction* res = append(new TableSwitch(ipop(), sux, sw.low_key(), state_before, has_bb)); +#ifdef ASSERT + if (res->as_Goto()) { + for (i = 0; i < l; i++) { + if (sux->at(i) == res->as_Goto()->sux_at(0)) { + assert(res->as_Goto()->is_safepoint() == sw.dest_offset_at(i) < 0, "safepoint state of Goto returned by canonicalizer incorrect"); + } + } + } +#endif } } @@ -1338,7 +1352,16 @@ // add default successor sux->at_put(i, block_at(bci() + sw.default_offset())); ValueStack* state_before = has_bb ? copy_state_before() : NULL; - append(new LookupSwitch(ipop(), sux, keys, state_before, has_bb)); + Instruction* res = append(new LookupSwitch(ipop(), sux, keys, state_before, has_bb)); +#ifdef ASSERT + if (res->as_Goto()) { + for (i = 0; i < l; i++) { + if (sux->at(i) == res->as_Goto()->sux_at(0)) { + assert(res->as_Goto()->is_safepoint() == sw.pair_at(i).offset() < 0, "safepoint state of Goto returned by canonicalizer incorrect"); + } + } + } +#endif } } diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/c1/c1_LinearScan.cpp --- a/hotspot/src/share/vm/c1/c1_LinearScan.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/c1/c1_LinearScan.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -2464,12 +2464,15 @@ // frequently used constants -ConstantOopWriteValue LinearScan::_oop_null_scope_value = ConstantOopWriteValue(NULL); -ConstantIntValue LinearScan::_int_m1_scope_value = ConstantIntValue(-1); -ConstantIntValue LinearScan::_int_0_scope_value = ConstantIntValue(0); -ConstantIntValue LinearScan::_int_1_scope_value = ConstantIntValue(1); -ConstantIntValue LinearScan::_int_2_scope_value = ConstantIntValue(2); -LocationValue _illegal_value = LocationValue(Location()); +// Allocate them with new so they are never destroyed (otherwise, a +// forced exit could destroy these objects while they are still in +// use). +ConstantOopWriteValue* LinearScan::_oop_null_scope_value = new (ResourceObj::C_HEAP) ConstantOopWriteValue(NULL); +ConstantIntValue* LinearScan::_int_m1_scope_value = new (ResourceObj::C_HEAP) ConstantIntValue(-1); +ConstantIntValue* LinearScan::_int_0_scope_value = new (ResourceObj::C_HEAP) ConstantIntValue(0); +ConstantIntValue* LinearScan::_int_1_scope_value = new (ResourceObj::C_HEAP) ConstantIntValue(1); +ConstantIntValue* LinearScan::_int_2_scope_value = new (ResourceObj::C_HEAP) ConstantIntValue(2); +LocationValue* _illegal_value = new (ResourceObj::C_HEAP) LocationValue(Location()); void LinearScan::init_compute_debug_info() { // cache for frequently used scope values @@ -2508,7 +2511,7 @@ case T_OBJECT: { jobject value = c->as_jobject(); if (value == NULL) { - scope_values->append(&_oop_null_scope_value); + scope_values->append(_oop_null_scope_value); } else { scope_values->append(new ConstantOopWriteValue(c->as_jobject())); } @@ -2519,10 +2522,10 @@ case T_FLOAT: { int value = c->as_jint_bits(); switch (value) { - case -1: scope_values->append(&_int_m1_scope_value); break; - case 0: scope_values->append(&_int_0_scope_value); break; - case 1: scope_values->append(&_int_1_scope_value); break; - case 2: scope_values->append(&_int_2_scope_value); break; + case -1: scope_values->append(_int_m1_scope_value); break; + case 0: scope_values->append(_int_0_scope_value); break; + case 1: scope_values->append(_int_1_scope_value); break; + case 2: scope_values->append(_int_2_scope_value); break; default: scope_values->append(new ConstantIntValue(c->as_jint_bits())); break; } return 1; @@ -2531,7 +2534,7 @@ case T_LONG: // fall through case T_DOUBLE: { #ifdef _LP64 - scope_values->append(&_int_0_scope_value); + scope_values->append(_int_0_scope_value); scope_values->append(new ConstantLongValue(c->as_jlong_bits())); #else if (hi_word_offset_in_bytes > lo_word_offset_in_bytes) { @@ -2657,7 +2660,7 @@ } // Does this reverse on x86 vs. sparc? first = new LocationValue(loc1); - second = &_int_0_scope_value; + second = _int_0_scope_value; #else Location loc1, loc2; if (!frame_map()->locations_for_slot(opr->double_stack_ix(), Location::normal, &loc1, &loc2)) { @@ -2671,7 +2674,7 @@ #ifdef _LP64 VMReg rname_first = opr->as_register_lo()->as_VMReg(); first = new LocationValue(Location::new_reg_loc(Location::lng, rname_first)); - second = &_int_0_scope_value; + second = _int_0_scope_value; #else VMReg rname_first = opr->as_register_lo()->as_VMReg(); VMReg rname_second = opr->as_register_hi()->as_VMReg(); @@ -2694,7 +2697,7 @@ VMReg rname_first = opr->as_xmm_double_reg()->as_VMReg(); # ifdef _LP64 first = new LocationValue(Location::new_reg_loc(Location::dbl, rname_first)); - second = &_int_0_scope_value; + second = _int_0_scope_value; # else first = new LocationValue(Location::new_reg_loc(Location::normal, rname_first)); // %%% This is probably a waste but we'll keep things as they were for now @@ -2741,7 +2744,7 @@ #ifdef _LP64 first = new LocationValue(Location::new_reg_loc(Location::dbl, rname_first)); - second = &_int_0_scope_value; + second = _int_0_scope_value; #else first = new LocationValue(Location::new_reg_loc(Location::normal, rname_first)); // %%% This is probably a waste but we'll keep things as they were for now @@ -2822,7 +2825,7 @@ } } else { // append a dummy value because real value not needed - scope_values->append(&_illegal_value); + scope_values->append(_illegal_value); return 1; } } @@ -2865,7 +2868,7 @@ nof_locals = cur_scope->method()->max_locals(); locals = new GrowableArray(nof_locals); for(int i = 0; i < nof_locals; i++) { - locals->append(&_illegal_value); + locals->append(_illegal_value); } } diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/c1/c1_LinearScan.hpp --- a/hotspot/src/share/vm/c1/c1_LinearScan.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/c1/c1_LinearScan.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -160,11 +160,11 @@ // TODO: cached scope values for registers could be static ScopeValueArray _scope_value_cache; - static ConstantOopWriteValue _oop_null_scope_value; - static ConstantIntValue _int_m1_scope_value; - static ConstantIntValue _int_0_scope_value; - static ConstantIntValue _int_1_scope_value; - static ConstantIntValue _int_2_scope_value; + static ConstantOopWriteValue* _oop_null_scope_value; + static ConstantIntValue* _int_m1_scope_value; + static ConstantIntValue* _int_0_scope_value; + static ConstantIntValue* _int_1_scope_value; + static ConstantIntValue* _int_2_scope_value; // accessors IR* ir() const { return _ir; } diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/classfile/vmSymbols.hpp --- a/hotspot/src/share/vm/classfile/vmSymbols.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -284,6 +284,7 @@ template(run_method_name, "run") \ template(exit_method_name, "exit") \ template(add_method_name, "add") \ + template(remove_method_name, "remove") \ template(parent_name, "parent") \ template(threads_name, "threads") \ template(groups_name, "groups") \ diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/compiler/compileBroker.cpp --- a/hotspot/src/share/vm/compiler/compileBroker.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/compiler/compileBroker.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -204,7 +204,8 @@ } void log_nmethod(JavaThread* thread, nmethod* nm) { - log(thread, "nmethod " INTPTR_FORMAT " code ["INTPTR_FORMAT ", " INTPTR_FORMAT "]", + log(thread, "nmethod %d%s " INTPTR_FORMAT " code ["INTPTR_FORMAT ", " INTPTR_FORMAT "]", + nm->compile_id(), nm->is_osr_method() ? "%" : "", nm, nm->code_begin(), nm->code_end()); } diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -6092,7 +6092,11 @@ _inter_sweep_timer.reset(); _inter_sweep_timer.start(); - update_time_of_last_gc(os::javaTimeMillis()); + // We need to use a monotonically non-deccreasing time in ms + // or we will see time-warp warnings and os::javaTimeMillis() + // does not guarantee monotonicity. + jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC; + update_time_of_last_gc(now); // NOTE on abstract state transitions: // Mutators allocate-live and/or mark the mod-union table dirty diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.cpp --- a/hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -48,6 +48,8 @@ #ifndef PRODUCT bool CSetChooserCache::verify() { + guarantee(false, "CSetChooserCache::verify(): don't call this any more"); + int index = _first; HeapRegion *prev = NULL; for (int i = 0; i < _occupancy; ++i) { @@ -75,6 +77,8 @@ #endif // PRODUCT void CSetChooserCache::insert(HeapRegion *hr) { + guarantee(false, "CSetChooserCache::insert(): don't call this any more"); + assert(!is_full(), "cache should not be empty"); hr->calc_gc_efficiency(); @@ -104,6 +108,9 @@ } HeapRegion *CSetChooserCache::remove_first() { + guarantee(false, "CSetChooserCache::remove_first(): " + "don't call this any more"); + if (_occupancy > 0) { assert(_cache[_first] != NULL, "cache should have at least one region"); HeapRegion *ret = _cache[_first]; @@ -118,16 +125,35 @@ } } -static inline int orderRegions(HeapRegion* hr1, HeapRegion* hr2) { +// Even though we don't use the GC efficiency in our heuristics as +// much as we used to, we still order according to GC efficiency. This +// will cause regions with a lot of live objects and large RSets to +// end up at the end of the array. Given that we might skip collecting +// the last few old regions, if after a few mixed GCs the remaining +// have reclaimable bytes under a certain threshold, the hope is that +// the ones we'll skip are ones with both large RSets and a lot of +// live objects, not the ones with just a lot of live objects if we +// ordered according to the amount of reclaimable bytes per region. +static int orderRegions(HeapRegion* hr1, HeapRegion* hr2) { if (hr1 == NULL) { - if (hr2 == NULL) return 0; - else return 1; + if (hr2 == NULL) { + return 0; + } else { + return 1; + } } else if (hr2 == NULL) { return -1; } - if (hr2->gc_efficiency() < hr1->gc_efficiency()) return -1; - else if (hr1->gc_efficiency() < hr2->gc_efficiency()) return 1; - else return 0; + + double gc_eff1 = hr1->gc_efficiency(); + double gc_eff2 = hr2->gc_efficiency(); + if (gc_eff1 > gc_eff2) { + return -1; + } if (gc_eff1 < gc_eff2) { + return 1; + } else { + return 0; + } } static int orderRegions(HeapRegion** hr1p, HeapRegion** hr2p) { @@ -151,51 +177,61 @@ // _markedRegions((ResourceObj::set_allocation_type((address)&_markedRegions, ResourceObj::C_HEAP), - 100), - true), - _curMarkedIndex(0), - _numMarkedRegions(0), - _unmarked_age_1_returned_as_new(false), - _first_par_unreserved_idx(0) -{} - - + 100), true /* C_Heap */), + _curr_index(0), _length(0), + _regionLiveThresholdBytes(0), _remainingReclaimableBytes(0), + _first_par_unreserved_idx(0) { + _regionLiveThresholdBytes = + HeapRegion::GrainBytes * (size_t) G1OldCSetRegionLiveThresholdPercent / 100; +} #ifndef PRODUCT bool CollectionSetChooser::verify() { + guarantee(_length >= 0, err_msg("_length: %d", _length)); + guarantee(0 <= _curr_index && _curr_index <= _length, + err_msg("_curr_index: %d _length: %d", _curr_index, _length)); int index = 0; - guarantee(_curMarkedIndex <= _numMarkedRegions, - "_curMarkedIndex should be within bounds"); - while (index < _curMarkedIndex) { - guarantee(_markedRegions.at(index++) == NULL, - "all entries before _curMarkedIndex should be NULL"); + size_t sum_of_reclaimable_bytes = 0; + while (index < _curr_index) { + guarantee(_markedRegions.at(index) == NULL, + "all entries before _curr_index should be NULL"); + index += 1; } HeapRegion *prev = NULL; - while (index < _numMarkedRegions) { + while (index < _length) { HeapRegion *curr = _markedRegions.at(index++); guarantee(curr != NULL, "Regions in _markedRegions array cannot be NULL"); int si = curr->sort_index(); guarantee(!curr->is_young(), "should not be young!"); + guarantee(!curr->isHumongous(), "should not be humongous!"); guarantee(si > -1 && si == (index-1), "sort index invariant"); if (prev != NULL) { - guarantee(orderRegions(prev, curr) != 1, "regions should be sorted"); + guarantee(orderRegions(prev, curr) != 1, + err_msg("GC eff prev: %1.4f GC eff curr: %1.4f", + prev->gc_efficiency(), curr->gc_efficiency())); } + sum_of_reclaimable_bytes += curr->reclaimable_bytes(); prev = curr; } - return _cache.verify(); + guarantee(sum_of_reclaimable_bytes == _remainingReclaimableBytes, + err_msg("reclaimable bytes inconsistent, " + "remaining: "SIZE_FORMAT" sum: "SIZE_FORMAT, + _remainingReclaimableBytes, sum_of_reclaimable_bytes)); + return true; } #endif -void -CollectionSetChooser::fillCache() { - while (!_cache.is_full() && (_curMarkedIndex < _numMarkedRegions)) { - HeapRegion* hr = _markedRegions.at(_curMarkedIndex); +void CollectionSetChooser::fillCache() { + guarantee(false, "fillCache: don't call this any more"); + + while (!_cache.is_full() && (_curr_index < _length)) { + HeapRegion* hr = _markedRegions.at(_curr_index); assert(hr != NULL, err_msg("Unexpected NULL hr in _markedRegions at index %d", - _curMarkedIndex)); - _curMarkedIndex += 1; + _curr_index)); + _curr_index += 1; assert(!hr->is_young(), "should not be young!"); - assert(hr->sort_index() == _curMarkedIndex-1, "sort_index invariant"); + assert(hr->sort_index() == _curr_index-1, "sort_index invariant"); _markedRegions.at_put(hr->sort_index(), NULL); _cache.insert(hr); assert(!_cache.is_empty(), "cache should not be empty"); @@ -203,9 +239,7 @@ assert(verify(), "cache should be consistent"); } -void -CollectionSetChooser::sortMarkedHeapRegions() { - guarantee(_cache.is_empty(), "cache should be empty"); +void CollectionSetChooser::sortMarkedHeapRegions() { // First trim any unused portion of the top in the parallel case. if (_first_par_unreserved_idx > 0) { if (G1PrintParCleanupStats) { @@ -217,43 +251,78 @@ _markedRegions.trunc_to(_first_par_unreserved_idx); } _markedRegions.sort(orderRegions); - assert(_numMarkedRegions <= _markedRegions.length(), "Requirement"); - assert(_numMarkedRegions == 0 - || _markedRegions.at(_numMarkedRegions-1) != NULL, - "Testing _numMarkedRegions"); - assert(_numMarkedRegions == _markedRegions.length() - || _markedRegions.at(_numMarkedRegions) == NULL, - "Testing _numMarkedRegions"); + assert(_length <= _markedRegions.length(), "Requirement"); + assert(_length == 0 || _markedRegions.at(_length - 1) != NULL, + "Testing _length"); + assert(_length == _markedRegions.length() || + _markedRegions.at(_length) == NULL, "Testing _length"); if (G1PrintParCleanupStats) { - gclog_or_tty->print_cr(" Sorted %d marked regions.", _numMarkedRegions); + gclog_or_tty->print_cr(" Sorted %d marked regions.", _length); } - for (int i = 0; i < _numMarkedRegions; i++) { + for (int i = 0; i < _length; i++) { assert(_markedRegions.at(i) != NULL, "Should be true by sorting!"); _markedRegions.at(i)->set_sort_index(i); } if (G1PrintRegionLivenessInfo) { G1PrintRegionLivenessInfoClosure cl(gclog_or_tty, "Post-Sorting"); - for (int i = 0; i < _numMarkedRegions; ++i) { + for (int i = 0; i < _length; ++i) { HeapRegion* r = _markedRegions.at(i); cl.doHeapRegion(r); } } - assert(verify(), "should now be sorted"); + assert(verify(), "CSet chooser verification"); } -void -CollectionSetChooser::addMarkedHeapRegion(HeapRegion* hr) { +size_t CollectionSetChooser::calcMinOldCSetLength() { + // The min old CSet region bound is based on the maximum desired + // number of mixed GCs after a cycle. I.e., even if some old regions + // look expensive, we should add them to the CSet anyway to make + // sure we go through the available old regions in no more than the + // maximum desired number of mixed GCs. + // + // The calculation is based on the number of marked regions we added + // to the CSet chooser in the first place, not how many remain, so + // that the result is the same during all mixed GCs that follow a cycle. + + const size_t region_num = (size_t) _length; + const size_t gc_num = (size_t) G1MaxMixedGCNum; + size_t result = region_num / gc_num; + // emulate ceiling + if (result * gc_num < region_num) { + result += 1; + } + return result; +} + +size_t CollectionSetChooser::calcMaxOldCSetLength() { + // The max old CSet region bound is based on the threshold expressed + // as a percentage of the heap size. I.e., it should bound the + // number of old regions added to the CSet irrespective of how many + // of them are available. + + G1CollectedHeap* g1h = G1CollectedHeap::heap(); + const size_t region_num = g1h->n_regions(); + const size_t perc = (size_t) G1OldCSetRegionThresholdPercent; + size_t result = region_num * perc / 100; + // emulate ceiling + if (100 * result < region_num * perc) { + result += 1; + } + return result; +} + +void CollectionSetChooser::addMarkedHeapRegion(HeapRegion* hr) { assert(!hr->isHumongous(), "Humongous regions shouldn't be added to the collection set"); assert(!hr->is_young(), "should not be young!"); _markedRegions.append(hr); - _numMarkedRegions++; + _length++; + _remainingReclaimableBytes += hr->reclaimable_bytes(); hr->calc_gc_efficiency(); } -void -CollectionSetChooser:: -prepareForAddMarkedHeapRegionsPar(size_t n_regions, size_t chunkSize) { +void CollectionSetChooser::prepareForAddMarkedHeapRegionsPar(size_t n_regions, + size_t chunkSize) { _first_par_unreserved_idx = 0; int n_threads = ParallelGCThreads; if (UseDynamicNumberOfGCThreads) { @@ -274,8 +343,7 @@ _markedRegions.at_put_grow((int)(aligned_n_regions + max_waste - 1), NULL); } -jint -CollectionSetChooser::getParMarkedHeapRegionChunk(jint n_regions) { +jint CollectionSetChooser::getParMarkedHeapRegionChunk(jint n_regions) { // Don't do this assert because this can be called at a point // where the loop up stream will not execute again but might // try to claim more chunks (loop test has not been done yet). @@ -287,83 +355,37 @@ return res - n_regions; } -void -CollectionSetChooser::setMarkedHeapRegion(jint index, HeapRegion* hr) { +void CollectionSetChooser::setMarkedHeapRegion(jint index, HeapRegion* hr) { assert(_markedRegions.at(index) == NULL, "precondition"); assert(!hr->is_young(), "should not be young!"); _markedRegions.at_put(index, hr); hr->calc_gc_efficiency(); } -void -CollectionSetChooser::incNumMarkedHeapRegions(jint inc_by) { - (void)Atomic::add(inc_by, &_numMarkedRegions); -} - -void -CollectionSetChooser::clearMarkedHeapRegions(){ - for (int i = 0; i < _markedRegions.length(); i++) { - HeapRegion* r = _markedRegions.at(i); - if (r != NULL) r->set_sort_index(-1); +void CollectionSetChooser::updateTotals(jint region_num, + size_t reclaimable_bytes) { + // Only take the lock if we actually need to update the totals. + if (region_num > 0) { + assert(reclaimable_bytes > 0, "invariant"); + // We could have just used atomics instead of taking the + // lock. However, we currently don't have an atomic add for size_t. + MutexLockerEx x(ParGCRareEvent_lock, Mutex::_no_safepoint_check_flag); + _length += (int) region_num; + _remainingReclaimableBytes += reclaimable_bytes; + } else { + assert(reclaimable_bytes == 0, "invariant"); } - _markedRegions.clear(); - _curMarkedIndex = 0; - _numMarkedRegions = 0; - _cache.clear(); -}; - -void -CollectionSetChooser::updateAfterFullCollection() { - clearMarkedHeapRegions(); } -// if time_remaining < 0.0, then this method should try to return -// a region, whether it fits within the remaining time or not -HeapRegion* -CollectionSetChooser::getNextMarkedRegion(double time_remaining, - double avg_prediction) { - G1CollectedHeap* g1h = G1CollectedHeap::heap(); - G1CollectorPolicy* g1p = g1h->g1_policy(); - fillCache(); - if (_cache.is_empty()) { - assert(_curMarkedIndex == _numMarkedRegions, - "if cache is empty, list should also be empty"); - ergo_verbose0(ErgoCSetConstruction, - "stop adding old regions to CSet", - ergo_format_reason("cache is empty")); - return NULL; - } - - HeapRegion *hr = _cache.get_first(); - assert(hr != NULL, "if cache not empty, first entry should be non-null"); - double predicted_time = g1h->predict_region_elapsed_time_ms(hr, false); - - if (g1p->adaptive_young_list_length()) { - if (time_remaining - predicted_time < 0.0) { - g1h->check_if_region_is_too_expensive(predicted_time); - ergo_verbose2(ErgoCSetConstruction, - "stop adding old regions to CSet", - ergo_format_reason("predicted old region time higher than remaining time") - ergo_format_ms("predicted old region time") - ergo_format_ms("remaining time"), - predicted_time, time_remaining); - return NULL; - } - } else { - double threshold = 2.0 * avg_prediction; - if (predicted_time > threshold) { - ergo_verbose2(ErgoCSetConstruction, - "stop adding old regions to CSet", - ergo_format_reason("predicted old region time higher than threshold") - ergo_format_ms("predicted old region time") - ergo_format_ms("threshold"), - predicted_time, threshold); - return NULL; +void CollectionSetChooser::clearMarkedHeapRegions() { + for (int i = 0; i < _markedRegions.length(); i++) { + HeapRegion* r = _markedRegions.at(i); + if (r != NULL) { + r->set_sort_index(-1); } } - - HeapRegion *hr2 = _cache.remove_first(); - assert(hr == hr2, "cache contents should not have changed"); - - return hr; -} + _markedRegions.clear(); + _curr_index = 0; + _length = 0; + _remainingReclaimableBytes = 0; +}; diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.hpp --- a/hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -28,28 +28,6 @@ #include "gc_implementation/g1/heapRegion.hpp" #include "utilities/growableArray.hpp" -// We need to sort heap regions by collection desirability. -// This sorting is currently done in two "stages". An initial sort is -// done following a cleanup pause as soon as all of the marked but -// non-empty regions have been identified and the completely empty -// ones reclaimed. -// This gives us a global sort on a GC efficiency metric -// based on predictive data available at that time. However, -// any of these regions that are collected will only be collected -// during a future GC pause, by which time it is possible that newer -// data might allow us to revise and/or refine the earlier -// pause predictions, leading to changes in expected gc efficiency -// order. To somewhat mitigate this obsolescence, more so in the -// case of regions towards the end of the list, which will be -// picked later, these pre-sorted regions from the _markedRegions -// array are not used as is, but a small prefix thereof is -// insertion-sorted again into a small cache, based on more -// recent remembered set information. Regions are then drawn -// from this cache to construct the collection set at each -// incremental GC. -// This scheme and/or its implementation may be subject to -// revision in the future. - class CSetChooserCache VALUE_OBJ_CLASS_SPEC { private: enum { @@ -103,24 +81,82 @@ class CollectionSetChooser: public CHeapObj { GrowableArray _markedRegions; - int _curMarkedIndex; - int _numMarkedRegions; - CSetChooserCache _cache; + + // The index of the next candidate old region to be considered for + // addition to the CSet. + int _curr_index; + + // The number of candidate old regions added to the CSet chooser. + int _length; - // True iff last collection pause ran of out new "age 0" regions, and - // returned an "age 1" region. - bool _unmarked_age_1_returned_as_new; + CSetChooserCache _cache; + jint _first_par_unreserved_idx; - jint _first_par_unreserved_idx; + // If a region has more live bytes than this threshold, it will not + // be added to the CSet chooser and will not be a candidate for + // collection. + size_t _regionLiveThresholdBytes; + + // The sum of reclaimable bytes over all the regions in the CSet chooser. + size_t _remainingReclaimableBytes; public: - HeapRegion* getNextMarkedRegion(double time_so_far, double avg_prediction); + // Return the current candidate region to be considered for + // collection without removing it from the CSet chooser. + HeapRegion* peek() { + HeapRegion* res = NULL; + if (_curr_index < _length) { + res = _markedRegions.at(_curr_index); + assert(res != NULL, + err_msg("Unexpected NULL hr in _markedRegions at index %d", + _curr_index)); + } + return res; + } + + // Remove the given region from the CSet chooser and move to the + // next one. The given region should be the current candidate region + // in the CSet chooser. + void remove_and_move_to_next(HeapRegion* hr) { + assert(hr != NULL, "pre-condition"); + assert(_curr_index < _length, "pre-condition"); + assert(_markedRegions.at(_curr_index) == hr, "pre-condition"); + hr->set_sort_index(-1); + _markedRegions.at_put(_curr_index, NULL); + assert(hr->reclaimable_bytes() <= _remainingReclaimableBytes, + err_msg("remaining reclaimable bytes inconsistent " + "from region: "SIZE_FORMAT" remaining: "SIZE_FORMAT, + hr->reclaimable_bytes(), _remainingReclaimableBytes)); + _remainingReclaimableBytes -= hr->reclaimable_bytes(); + _curr_index += 1; + } CollectionSetChooser(); void sortMarkedHeapRegions(); void fillCache(); + + // Determine whether to add the given region to the CSet chooser or + // not. Currently, we skip humongous regions (we never add them to + // the CSet, we only reclaim them during cleanup) and regions whose + // live bytes are over the threshold. + bool shouldAdd(HeapRegion* hr) { + assert(hr->is_marked(), "pre-condition"); + assert(!hr->is_young(), "should never consider young regions"); + return !hr->isHumongous() && + hr->live_bytes() < _regionLiveThresholdBytes; + } + + // Calculate the minimum number of old regions we'll add to the CSet + // during a mixed GC. + size_t calcMinOldCSetLength(); + + // Calculate the maximum number of old regions we'll add to the CSet + // during a mixed GC. + size_t calcMaxOldCSetLength(); + + // Serial version. void addMarkedHeapRegion(HeapRegion *hr); // Must be called before calls to getParMarkedHeapRegionChunk. @@ -133,14 +169,21 @@ // Set the marked array entry at index to hr. Careful to claim the index // first if in parallel. void setMarkedHeapRegion(jint index, HeapRegion* hr); - // Atomically increment the number of claimed regions by "inc_by". - void incNumMarkedHeapRegions(jint inc_by); + // Atomically increment the number of added regions by region_num + // and the amount of reclaimable bytes by reclaimable_bytes. + void updateTotals(jint region_num, size_t reclaimable_bytes); void clearMarkedHeapRegions(); - void updateAfterFullCollection(); + // Return the number of candidate regions that remain to be collected. + size_t remainingRegions() { return _length - _curr_index; } - bool unmarked_age_1_returned_as_new() { return _unmarked_age_1_returned_as_new; } + // Determine whether the CSet chooser has more candidate regions or not. + bool isEmpty() { return remainingRegions() == 0; } + + // Return the reclaimable bytes that remain to be collected on + // all the candidate regions in the CSet chooser. + size_t remainingReclaimableBytes () { return _remainingReclaimableBytes; } // Returns true if the used portion of "_markedRegions" is properly // sorted, otherwise asserts false. @@ -148,9 +191,17 @@ bool verify(void); bool regionProperlyOrdered(HeapRegion* r) { int si = r->sort_index(); - return (si == -1) || - (si > -1 && _markedRegions.at(si) == r) || - (si < -1 && _cache.region_in_cache(r)); + if (si > -1) { + guarantee(_curr_index <= si && si < _length, + err_msg("curr: %d sort index: %d: length: %d", + _curr_index, si, _length)); + guarantee(_markedRegions.at(si) == r, + err_msg("sort index: %d at: "PTR_FORMAT" r: "PTR_FORMAT, + si, _markedRegions.at(si), r)); + } else { + guarantee(si == -1, err_msg("sort index: %d", si)); + } + return true; } #endif diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -958,7 +958,7 @@ should_try_gc = false; } else { // Read the GC count while still holding the Heap_lock. - gc_count_before = SharedHeap::heap()->total_collections(); + gc_count_before = total_collections(); should_try_gc = true; } } @@ -976,7 +976,7 @@ // failed to allocate. No point in trying to allocate // further. We'll just return NULL. MutexLockerEx x(Heap_lock); - *gc_count_before_ret = SharedHeap::heap()->total_collections(); + *gc_count_before_ret = total_collections(); return NULL; } } else { @@ -1031,7 +1031,8 @@ // the check before we do the actual allocation. The reason for doing it // before the allocation is that we avoid having to keep track of the newly // allocated memory while we do a GC. - if (g1_policy()->need_to_start_conc_mark("concurrent humongous allocation", word_size)) { + if (g1_policy()->need_to_start_conc_mark("concurrent humongous allocation", + word_size)) { collect(GCCause::_g1_humongous_allocation); } @@ -1059,7 +1060,7 @@ should_try_gc = false; } else { // Read the GC count while still holding the Heap_lock. - gc_count_before = SharedHeap::heap()->total_collections(); + gc_count_before = total_collections(); should_try_gc = true; } } @@ -1081,7 +1082,7 @@ // failed to allocate. No point in trying to allocate // further. We'll just return NULL. MutexLockerEx x(Heap_lock); - *gc_count_before_ret = SharedHeap::heap()->total_collections(); + *gc_count_before_ret = total_collections(); return NULL; } } else { @@ -2311,10 +2312,12 @@ } bool G1CollectedHeap::should_do_concurrent_full_gc(GCCause::Cause cause) { - return - ((cause == GCCause::_gc_locker && GCLockerInvokesConcurrent) || - (cause == GCCause::_java_lang_system_gc && ExplicitGCInvokesConcurrent) || - cause == GCCause::_g1_humongous_allocation); + switch (cause) { + case GCCause::_gc_locker: return GCLockerInvokesConcurrent; + case GCCause::_java_lang_system_gc: return ExplicitGCInvokesConcurrent; + case GCCause::_g1_humongous_allocation: return true; + default: return false; + } } #ifndef PRODUCT @@ -2408,47 +2411,66 @@ } void G1CollectedHeap::collect(GCCause::Cause cause) { - // The caller doesn't have the Heap_lock - assert(!Heap_lock->owned_by_self(), "this thread should not own the Heap_lock"); + assert_heap_not_locked(); unsigned int gc_count_before; unsigned int full_gc_count_before; - { - MutexLocker ml(Heap_lock); - - // Read the GC count while holding the Heap_lock - gc_count_before = SharedHeap::heap()->total_collections(); - full_gc_count_before = SharedHeap::heap()->total_full_collections(); - } - - if (should_do_concurrent_full_gc(cause)) { - // Schedule an initial-mark evacuation pause that will start a - // concurrent cycle. We're setting word_size to 0 which means that - // we are not requesting a post-GC allocation. - VM_G1IncCollectionPause op(gc_count_before, - 0, /* word_size */ - true, /* should_initiate_conc_mark */ - g1_policy()->max_pause_time_ms(), - cause); - VMThread::execute(&op); - } else { - if (cause == GCCause::_gc_locker - DEBUG_ONLY(|| cause == GCCause::_scavenge_alot)) { - - // Schedule a standard evacuation pause. We're setting word_size - // to 0 which means that we are not requesting a post-GC allocation. + bool retry_gc; + + do { + retry_gc = false; + + { + MutexLocker ml(Heap_lock); + + // Read the GC count while holding the Heap_lock + gc_count_before = total_collections(); + full_gc_count_before = total_full_collections(); + } + + if (should_do_concurrent_full_gc(cause)) { + // Schedule an initial-mark evacuation pause that will start a + // concurrent cycle. We're setting word_size to 0 which means that + // we are not requesting a post-GC allocation. VM_G1IncCollectionPause op(gc_count_before, 0, /* word_size */ - false, /* should_initiate_conc_mark */ + true, /* should_initiate_conc_mark */ g1_policy()->max_pause_time_ms(), cause); VMThread::execute(&op); + if (!op.pause_succeeded()) { + // Another GC got scheduled and prevented us from scheduling + // the initial-mark GC. It's unlikely that the GC that + // pre-empted us was also an initial-mark GC. So, we'll retry + // the initial-mark GC. + + if (full_gc_count_before == total_full_collections()) { + retry_gc = true; + } else { + // A Full GC happened while we were trying to schedule the + // initial-mark GC. No point in starting a new cycle given + // that the whole heap was collected anyway. + } + } } else { - // Schedule a Full GC. - VM_G1CollectFull op(gc_count_before, full_gc_count_before, cause); - VMThread::execute(&op); + if (cause == GCCause::_gc_locker + DEBUG_ONLY(|| cause == GCCause::_scavenge_alot)) { + + // Schedule a standard evacuation pause. We're setting word_size + // to 0 which means that we are not requesting a post-GC allocation. + VM_G1IncCollectionPause op(gc_count_before, + 0, /* word_size */ + false, /* should_initiate_conc_mark */ + g1_policy()->max_pause_time_ms(), + cause); + VMThread::execute(&op); + } else { + // Schedule a Full GC. + VM_G1CollectFull op(gc_count_before, full_gc_count_before, cause); + VMThread::execute(&op); + } } - } + } while (retry_gc); } bool G1CollectedHeap::is_in(const void* p) const { @@ -3149,12 +3171,12 @@ // We apply the relevant closures to all the oops in the // system dictionary, the string table and the code cache. - const int so = SharedHeap::SO_AllClasses | SharedHeap::SO_Strings | SharedHeap::SO_CodeCache; + const int so = SO_AllClasses | SO_Strings | SO_CodeCache; process_strong_roots(true, // activate StrongRootsScope true, // we set "collecting perm gen" to true, // so we don't reset the dirty cards in the perm gen. - SharedHeap::ScanningOption(so), // roots scanning options + ScanningOption(so), // roots scanning options &rootsCl, &blobsCl, &rootsCl); @@ -3425,16 +3447,6 @@ } } -double G1CollectedHeap::predict_region_elapsed_time_ms(HeapRegion *hr, - bool young) { - return _g1_policy->predict_region_elapsed_time_ms(hr, young); -} - -void G1CollectedHeap::check_if_region_is_too_expensive(double - predicted_time_ms) { - _g1_policy->check_if_region_is_too_expensive(predicted_time_ms); -} - size_t G1CollectedHeap::pending_card_num() { size_t extra_cards = 0; JavaThread *curr = Threads::first(); @@ -3706,12 +3718,12 @@ g1_policy()->print_collection_set(g1_policy()->inc_cset_head(), gclog_or_tty); #endif // YOUNG_LIST_VERBOSE - g1_policy()->choose_collection_set(target_pause_time_ms); + g1_policy()->finalize_cset(target_pause_time_ms); _cm->note_start_of_gc(); // We should not verify the per-thread SATB buffers given that // we have not filtered them yet (we'll do so during the - // GC). We also call this after choose_collection_set() to + // GC). We also call this after finalize_cset() to // ensure that the CSet has been finalized. _cm->verify_no_cset_oops(true /* verify_stacks */, true /* verify_enqueued_buffers */, @@ -4734,7 +4746,7 @@ void G1CollectedHeap:: g1_process_strong_roots(bool collecting_perm_gen, - SharedHeap::ScanningOption so, + ScanningOption so, OopClosure* scan_non_heap_roots, OopsInHeapRegionClosure* scan_rs, OopsInGenClosure* scan_perm, diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -770,7 +770,7 @@ // the "i" of the calling parallel worker thread's work(i) function. // In the sequential case this param will be ignored. void g1_process_strong_roots(bool collecting_perm_gen, - SharedHeap::ScanningOption so, + ScanningOption so, OopClosure* scan_non_heap_roots, OopsInHeapRegionClosure* scan_rs, OopsInGenClosure* scan_perm, @@ -1182,6 +1182,12 @@ bool free_regions_coming() { return _free_regions_coming; } void wait_while_free_regions_coming(); + // Determine whether the given region is one that we are using as an + // old GC alloc region. + bool is_old_gc_alloc_region(HeapRegion* hr) { + return hr == _retained_old_gc_alloc_region; + } + // Perform a collection of the heap; intended for use in implementing // "System.gc". This probably implies as full a collection as the // "CollectedHeap" supports. @@ -1662,8 +1668,6 @@ public: void stop_conc_gc_threads(); - double predict_region_elapsed_time_ms(HeapRegion* hr, bool young); - void check_if_region_is_too_expensive(double predicted_time_ms); size_t pending_card_num(); size_t max_pending_card_num(); size_t cards_scanned(); diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -206,7 +206,6 @@ _initiate_conc_mark_if_possible(false), _during_initial_mark_pause(false), - _should_revert_to_young_gcs(false), _last_young_gc(false), _last_gc_was_young(false), @@ -295,9 +294,6 @@ _par_last_gc_worker_times_ms = new double[_parallel_gc_threads]; _par_last_gc_worker_other_times_ms = new double[_parallel_gc_threads]; - // start conservatively - _expensive_region_limit_ms = 0.5 * (double) MaxGCPauseMillis; - int index; if (ParallelGCThreads == 0) index = 0; @@ -629,16 +625,9 @@ // possible to maximize how many old regions we can add to it. } } else { - if (gcs_are_young()) { - young_list_target_length = _young_list_fixed_length; - } else { - // A bit arbitrary: during mixed GCs we allocate half - // the young regions to try to add old regions to the CSet. - young_list_target_length = _young_list_fixed_length / 2; - // We choose to accept that we might go under the desired min - // length given that we intentionally ask for a smaller young gen. - desired_min_length = absolute_min_length; - } + // The user asked for a fixed young gen so we'll fix the young gen + // whether the next GC is young or mixed. + young_list_target_length = _young_list_fixed_length; } // Make sure we don't go over the desired max length, nor under the @@ -872,7 +861,6 @@ // transitions and make sure we start with young GCs after the Full GC. set_gcs_are_young(true); _last_young_gc = false; - _should_revert_to_young_gcs = false; clear_initiate_conc_mark_if_possible(); clear_during_initial_mark_pause(); _known_garbage_bytes = 0; @@ -889,7 +877,7 @@ // Reset survivors SurvRateGroup. _survivor_surv_rate_group->reset(); update_young_list_target_length(); - _collectionSetChooser->updateAfterFullCollection(); + _collectionSetChooser->clearMarkedHeapRegions(); } void G1CollectorPolicy::record_stop_world_start() { @@ -1000,7 +988,6 @@ } void G1CollectorPolicy::record_concurrent_mark_cleanup_completed() { - _should_revert_to_young_gcs = false; _last_young_gc = true; _in_marking_window = false; } @@ -1205,9 +1192,7 @@ last_pause_included_initial_mark = during_initial_mark_pause(); if (last_pause_included_initial_mark) { record_concurrent_mark_init_end(0.0); - } - - if (!_last_young_gc && need_to_start_conc_mark("end of GC")) { + } else if (!_last_young_gc && need_to_start_conc_mark("end of GC")) { // Note: this might have already been set, if during the last // pause we decided to start a cycle but at the beginning of // this pause we decided to postpone it. That's OK. @@ -1492,12 +1477,14 @@ } if (_last_young_gc) { + // This is supposed to to be the "last young GC" before we start + // doing mixed GCs. Here we decide whether to start mixed GCs or not. + if (!last_pause_included_initial_mark) { - ergo_verbose2(ErgoMixedGCs, - "start mixed GCs", - ergo_format_byte_perc("known garbage"), - _known_garbage_bytes, _known_garbage_ratio * 100.0); - set_gcs_are_young(false); + if (next_gc_should_be_mixed("start mixed GCs", + "do not start mixed GCs")) { + set_gcs_are_young(false); + } } else { ergo_verbose0(ErgoMixedGCs, "do not start mixed GCs", @@ -1507,39 +1494,14 @@ } if (!_last_gc_was_young) { - if (_should_revert_to_young_gcs) { - ergo_verbose2(ErgoMixedGCs, - "end mixed GCs", - ergo_format_reason("mixed GCs end requested") - ergo_format_byte_perc("known garbage"), - _known_garbage_bytes, _known_garbage_ratio * 100.0); - set_gcs_are_young(true); - } else if (_known_garbage_ratio < 0.05) { - ergo_verbose3(ErgoMixedGCs, - "end mixed GCs", - ergo_format_reason("known garbage percent lower than threshold") - ergo_format_byte_perc("known garbage") - ergo_format_perc("threshold"), - _known_garbage_bytes, _known_garbage_ratio * 100.0, - 0.05 * 100.0); - set_gcs_are_young(true); - } else if (adaptive_young_list_length() && - (get_gc_eff_factor() * cur_efficiency < predict_young_gc_eff())) { - ergo_verbose5(ErgoMixedGCs, - "end mixed GCs", - ergo_format_reason("current GC efficiency lower than " - "predicted young GC efficiency") - ergo_format_double("GC efficiency factor") - ergo_format_double("current GC efficiency") - ergo_format_double("predicted young GC efficiency") - ergo_format_byte_perc("known garbage"), - get_gc_eff_factor(), cur_efficiency, - predict_young_gc_eff(), - _known_garbage_bytes, _known_garbage_ratio * 100.0); + // This is a mixed GC. Here we decide whether to continue doing + // mixed GCs or not. + + if (!next_gc_should_be_mixed("continue mixed GCs", + "do not continue mixed GCs")) { set_gcs_are_young(true); } } - _should_revert_to_young_gcs = false; if (_last_gc_was_young && !_during_marking) { _young_gc_eff_seq->add(cur_efficiency); @@ -1648,15 +1610,6 @@ _pending_cards_seq->add((double) _pending_cards); _rs_lengths_seq->add((double) _max_rs_lengths); - - double expensive_region_limit_ms = - (double) MaxGCPauseMillis - predict_constant_other_time_ms(); - if (expensive_region_limit_ms < 0.0) { - // this means that the other time was predicted to be longer than - // than the max pause time - expensive_region_limit_ms = (double) MaxGCPauseMillis; - } - _expensive_region_limit_ms = expensive_region_limit_ms; } _in_marking_window = new_in_marking_window; @@ -1838,13 +1791,11 @@ if (hr->is_marked()) bytes_to_copy = hr->max_live_bytes(); else { - guarantee( hr->is_young() && hr->age_in_surv_rate_group() != -1, - "invariant" ); + assert(hr->is_young() && hr->age_in_surv_rate_group() != -1, "invariant"); int age = hr->age_in_surv_rate_group(); double yg_surv_rate = predict_yg_surv_rate(age, hr->surv_rate_group()); bytes_to_copy = (size_t) ((double) hr->used() * yg_surv_rate); } - return bytes_to_copy; } @@ -1860,22 +1811,6 @@ _recorded_rs_lengths = rs_lengths; } -void G1CollectorPolicy::check_if_region_is_too_expensive(double - predicted_time_ms) { - // I don't think we need to do this when in young GC mode since - // marking will be initiated next time we hit the soft limit anyway... - if (predicted_time_ms > _expensive_region_limit_ms) { - ergo_verbose2(ErgoMixedGCs, - "request mixed GCs end", - ergo_format_reason("predicted region time higher than threshold") - ergo_format_ms("predicted region time") - ergo_format_ms("threshold"), - predicted_time_ms, _expensive_region_limit_ms); - // no point in doing another mixed GC - _should_revert_to_young_gcs = true; - } -} - void G1CollectorPolicy::update_recent_gc_times(double end_time_sec, double elapsed_ms) { _recent_gc_times_ms->add(elapsed_ms); @@ -2274,12 +2209,12 @@ } class KnownGarbageClosure: public HeapRegionClosure { + G1CollectedHeap* _g1h; CollectionSetChooser* _hrSorted; public: KnownGarbageClosure(CollectionSetChooser* hrSorted) : - _hrSorted(hrSorted) - {} + _g1h(G1CollectedHeap::heap()), _hrSorted(hrSorted) { } bool doHeapRegion(HeapRegion* r) { // We only include humongous regions in collection @@ -2288,11 +2223,10 @@ // Do we have any marking information for this region? if (r->is_marked()) { - // We don't include humongous regions in collection - // sets because we collect them immediately at the end of a marking - // cycle. We also don't include young regions because we *must* - // include them in the next collection pause. - if (!r->isHumongous() && !r->is_young()) { + // We will skip any region that's currently used as an old GC + // alloc region (we should not consider those for collection + // before we fill them up). + if (_hrSorted->shouldAdd(r) && !_g1h->is_old_gc_alloc_region(r)) { _hrSorted->addMarkedHeapRegion(r); } } @@ -2301,8 +2235,10 @@ }; class ParKnownGarbageHRClosure: public HeapRegionClosure { + G1CollectedHeap* _g1h; CollectionSetChooser* _hrSorted; jint _marked_regions_added; + size_t _reclaimable_bytes_added; jint _chunk_size; jint _cur_chunk_idx; jint _cur_chunk_end; // Cur chunk [_cur_chunk_idx, _cur_chunk_end) @@ -2320,6 +2256,7 @@ assert(_cur_chunk_idx < _cur_chunk_end, "postcondition"); _hrSorted->setMarkedHeapRegion(_cur_chunk_idx, r); _marked_regions_added++; + _reclaimable_bytes_added += r->reclaimable_bytes(); _cur_chunk_idx++; } @@ -2327,10 +2264,10 @@ ParKnownGarbageHRClosure(CollectionSetChooser* hrSorted, jint chunk_size, int worker) : - _hrSorted(hrSorted), _chunk_size(chunk_size), _worker(worker), - _marked_regions_added(0), _cur_chunk_idx(0), _cur_chunk_end(0), - _invokes(0) - {} + _g1h(G1CollectedHeap::heap()), + _hrSorted(hrSorted), _chunk_size(chunk_size), _worker(worker), + _marked_regions_added(0), _reclaimable_bytes_added(0), + _cur_chunk_idx(0), _cur_chunk_end(0), _invokes(0) { } bool doHeapRegion(HeapRegion* r) { // We only include humongous regions in collection @@ -2340,17 +2277,17 @@ // Do we have any marking information for this region? if (r->is_marked()) { - // We don't include humongous regions in collection - // sets because we collect them immediately at the end of a marking - // cycle. - // We also do not include young regions in collection sets - if (!r->isHumongous() && !r->is_young()) { + // We will skip any region that's currently used as an old GC + // alloc region (we should not consider those for collection + // before we fill them up). + if (_hrSorted->shouldAdd(r) && !_g1h->is_old_gc_alloc_region(r)) { add_region(r); } } return false; } jint marked_regions_added() { return _marked_regions_added; } + size_t reclaimable_bytes_added() { return _reclaimable_bytes_added; } int invokes() { return _invokes; } }; @@ -2362,8 +2299,7 @@ ParKnownGarbageTask(CollectionSetChooser* hrSorted, jint chunk_size) : AbstractGangTask("ParKnownGarbageTask"), _hrSorted(hrSorted), _chunk_size(chunk_size), - _g1(G1CollectedHeap::heap()) - {} + _g1(G1CollectedHeap::heap()) { } void work(uint worker_id) { ParKnownGarbageHRClosure parKnownGarbageCl(_hrSorted, @@ -2374,7 +2310,9 @@ _g1->workers()->active_workers(), HeapRegion::InitialClaimValue); jint regions_added = parKnownGarbageCl.marked_regions_added(); - _hrSorted->incNumMarkedHeapRegions(regions_added); + size_t reclaimable_bytes_added = + parKnownGarbageCl.reclaimable_bytes_added(); + _hrSorted->updateTotals(regions_added, reclaimable_bytes_added); if (G1PrintParCleanupStats) { gclog_or_tty->print_cr(" Thread %d called %d times, added %d regions to list.", worker_id, parKnownGarbageCl.invokes(), regions_added); @@ -2658,7 +2596,43 @@ } #endif // !PRODUCT -void G1CollectorPolicy::choose_collection_set(double target_pause_time_ms) { +bool G1CollectorPolicy::next_gc_should_be_mixed(const char* true_action_str, + const char* false_action_str) { + CollectionSetChooser* cset_chooser = _collectionSetChooser; + if (cset_chooser->isEmpty()) { + ergo_verbose0(ErgoMixedGCs, + false_action_str, + ergo_format_reason("candidate old regions not available")); + return false; + } + size_t reclaimable_bytes = cset_chooser->remainingReclaimableBytes(); + size_t capacity_bytes = _g1->capacity(); + double perc = (double) reclaimable_bytes * 100.0 / (double) capacity_bytes; + double threshold = (double) G1OldReclaimableThresholdPercent; + if (perc < threshold) { + ergo_verbose4(ErgoMixedGCs, + false_action_str, + ergo_format_reason("reclaimable percentage lower than threshold") + ergo_format_region("candidate old regions") + ergo_format_byte_perc("reclaimable") + ergo_format_perc("threshold"), + cset_chooser->remainingRegions(), + reclaimable_bytes, perc, threshold); + return false; + } + + ergo_verbose4(ErgoMixedGCs, + true_action_str, + ergo_format_reason("candidate old regions available") + ergo_format_region("candidate old regions") + ergo_format_byte_perc("reclaimable") + ergo_format_perc("threshold"), + cset_chooser->remainingRegions(), + reclaimable_bytes, perc, threshold); + return true; +} + +void G1CollectorPolicy::finalize_cset(double target_pause_time_ms) { // Set this here - in case we're not doing young collections. double non_young_start_time_sec = os::elapsedTime(); @@ -2672,7 +2646,6 @@ double base_time_ms = predict_base_elapsed_time_ms(_pending_cards); double predicted_pause_time_ms = base_time_ms; - double time_remaining_ms = target_pause_time_ms - base_time_ms; ergo_verbose3(ErgoCSetConstruction | ErgoHigh, @@ -2682,22 +2655,6 @@ ergo_format_ms("target pause time"), base_time_ms, time_remaining_ms, target_pause_time_ms); - // the 10% and 50% values are arbitrary... - double threshold = 0.10 * target_pause_time_ms; - if (time_remaining_ms < threshold) { - double prev_time_remaining_ms = time_remaining_ms; - time_remaining_ms = 0.50 * target_pause_time_ms; - ergo_verbose3(ErgoCSetConstruction, - "adjust remaining time", - ergo_format_reason("remaining time lower than threshold") - ergo_format_ms("remaining time") - ergo_format_ms("threshold") - ergo_format_ms("adjusted remaining time"), - prev_time_remaining_ms, threshold, time_remaining_ms); - } - - size_t expansion_bytes = _g1->expansion_regions() * HeapRegion::GrainBytes; - HeapRegion* hr; double young_start_time_sec = os::elapsedTime(); @@ -2752,78 +2709,97 @@ non_young_start_time_sec = young_end_time_sec; if (!gcs_are_young()) { - bool should_continue = true; - NumberSeq seq; - double avg_prediction = 100000000000000000.0; // something very large - - double prev_predicted_pause_time_ms = predicted_pause_time_ms; - do { - // Note that add_old_region_to_cset() increments the - // _old_cset_region_length field and cset_region_length() returns the - // sum of _eden_cset_region_length, _survivor_cset_region_length, and - // _old_cset_region_length. So, as old regions are added to the - // CSet, _old_cset_region_length will be incremented and - // cset_region_length(), which is used below, will always reflect - // the the total number of regions added up to this point to the CSet. - - hr = _collectionSetChooser->getNextMarkedRegion(time_remaining_ms, - avg_prediction); - if (hr != NULL) { - _g1->old_set_remove(hr); - double predicted_time_ms = predict_region_elapsed_time_ms(hr, false); - time_remaining_ms -= predicted_time_ms; - predicted_pause_time_ms += predicted_time_ms; - add_old_region_to_cset(hr); - seq.add(predicted_time_ms); - avg_prediction = seq.avg() + seq.sd(); + CollectionSetChooser* cset_chooser = _collectionSetChooser; + assert(cset_chooser->verify(), "CSet Chooser verification - pre"); + const size_t min_old_cset_length = cset_chooser->calcMinOldCSetLength(); + const size_t max_old_cset_length = cset_chooser->calcMaxOldCSetLength(); + + size_t expensive_region_num = 0; + bool check_time_remaining = adaptive_young_list_length(); + HeapRegion* hr = cset_chooser->peek(); + while (hr != NULL) { + if (old_cset_region_length() >= max_old_cset_length) { + // Added maximum number of old regions to the CSet. + ergo_verbose2(ErgoCSetConstruction, + "finish adding old regions to CSet", + ergo_format_reason("old CSet region num reached max") + ergo_format_region("old") + ergo_format_region("max"), + old_cset_region_length(), max_old_cset_length); + break; } - should_continue = true; - if (hr == NULL) { - // No need for an ergo verbose message here, - // getNextMarkRegion() does this when it returns NULL. - should_continue = false; + double predicted_time_ms = predict_region_elapsed_time_ms(hr, false); + if (check_time_remaining) { + if (predicted_time_ms > time_remaining_ms) { + // Too expensive for the current CSet. + + if (old_cset_region_length() >= min_old_cset_length) { + // We have added the minimum number of old regions to the CSet, + // we are done with this CSet. + ergo_verbose4(ErgoCSetConstruction, + "finish adding old regions to CSet", + ergo_format_reason("predicted time is too high") + ergo_format_ms("predicted time") + ergo_format_ms("remaining time") + ergo_format_region("old") + ergo_format_region("min"), + predicted_time_ms, time_remaining_ms, + old_cset_region_length(), min_old_cset_length); + break; + } + + // We'll add it anyway given that we haven't reached the + // minimum number of old regions. + expensive_region_num += 1; + } } else { - if (adaptive_young_list_length()) { - if (time_remaining_ms < 0.0) { - ergo_verbose1(ErgoCSetConstruction, - "stop adding old regions to CSet", - ergo_format_reason("remaining time is lower than 0") - ergo_format_ms("remaining time"), - time_remaining_ms); - should_continue = false; - } - } else { - if (cset_region_length() >= _young_list_fixed_length) { - ergo_verbose2(ErgoCSetConstruction, - "stop adding old regions to CSet", - ergo_format_reason("CSet length reached target") - ergo_format_region("CSet") - ergo_format_region("young target"), - cset_region_length(), _young_list_fixed_length); - should_continue = false; - } + if (old_cset_region_length() >= min_old_cset_length) { + // In the non-auto-tuning case, we'll finish adding regions + // to the CSet if we reach the minimum. + ergo_verbose2(ErgoCSetConstruction, + "finish adding old regions to CSet", + ergo_format_reason("old CSet region num reached min") + ergo_format_region("old") + ergo_format_region("min"), + old_cset_region_length(), min_old_cset_length); + break; } } - } while (should_continue); - - if (!adaptive_young_list_length() && - cset_region_length() < _young_list_fixed_length) { - ergo_verbose2(ErgoCSetConstruction, - "request mixed GCs end", - ergo_format_reason("CSet length lower than target") - ergo_format_region("CSet") - ergo_format_region("young target"), - cset_region_length(), _young_list_fixed_length); - _should_revert_to_young_gcs = true; + + // We will add this region to the CSet. + time_remaining_ms -= predicted_time_ms; + predicted_pause_time_ms += predicted_time_ms; + cset_chooser->remove_and_move_to_next(hr); + _g1->old_set_remove(hr); + add_old_region_to_cset(hr); + + hr = cset_chooser->peek(); + } + if (hr == NULL) { + ergo_verbose0(ErgoCSetConstruction, + "finish adding old regions to CSet", + ergo_format_reason("candidate old regions not available")); } - ergo_verbose2(ErgoCSetConstruction | ErgoHigh, - "add old regions to CSet", - ergo_format_region("old") - ergo_format_ms("predicted old region time"), - old_cset_region_length(), - predicted_pause_time_ms - prev_predicted_pause_time_ms); + if (expensive_region_num > 0) { + // We print the information once here at the end, predicated on + // whether we added any apparently expensive regions or not, to + // avoid generating output per region. + ergo_verbose4(ErgoCSetConstruction, + "added expensive regions to CSet", + ergo_format_reason("old CSet region num not reached min") + ergo_format_region("old") + ergo_format_region("expensive") + ergo_format_region("min") + ergo_format_ms("remaining time"), + old_cset_region_length(), + expensive_region_num, + min_old_cset_length, + time_remaining_ms); + } + + assert(cset_chooser->verify(), "CSet Chooser verification - post"); } stop_incremental_cset_building(); diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -312,16 +312,13 @@ double _recorded_non_young_free_cset_time_ms; double _sigma; - double _expensive_region_limit_ms; size_t _rs_lengths_prediction; size_t _known_garbage_bytes; double _known_garbage_ratio; - double sigma() { - return _sigma; - } + double sigma() { return _sigma; } // A function that prevents us putting too much stock in small sample // sets. Returns a number between 2.0 and 1.0, depending on the number @@ -491,8 +488,6 @@ get_new_prediction(_non_young_other_cost_per_region_ms_seq); } - void check_if_region_is_too_expensive(double predicted_time_ms); - double predict_young_collection_elapsed_time_ms(size_t adjustment); double predict_base_elapsed_time_ms(size_t pending_cards); double predict_base_elapsed_time_ms(size_t pending_cards, @@ -707,7 +702,6 @@ // initial-mark work. volatile bool _during_initial_mark_pause; - bool _should_revert_to_young_gcs; bool _last_young_gc; // This set of variables tracks the collector efficiency, in order to @@ -946,10 +940,17 @@ return _bytes_copied_during_gc; } + // Determine whether the next GC should be mixed. Called to determine + // whether to start mixed GCs or whether to carry on doing mixed + // GCs. The two action strings are used in the ergo output when the + // method returns true or false. + bool next_gc_should_be_mixed(const char* true_action_str, + const char* false_action_str); + // Choose a new collection set. Marks the chosen regions as being // "in_collection_set", and links them together. The head and number of // the collection set are available via access methods. - void choose_collection_set(double target_pause_time_ms); + void finalize_cset(double target_pause_time_ms); // The head of the list (via "next_in_collection_set()") representing the // current collection set. diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_implementation/g1/g1ErgoVerbose.hpp --- a/hotspot/src/share/vm/gc_implementation/g1/g1ErgoVerbose.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_implementation/g1/g1ErgoVerbose.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -131,8 +131,8 @@ ", " _name_ ": "SIZE_FORMAT" bytes (%1.2f %%)" // Generates the format string -#define ergo_format(_action_, _extra_format_) \ - " %1.3f: [G1Ergonomics (%s) " _action_ _extra_format_ "]" +#define ergo_format(_extra_format_) \ + " %1.3f: [G1Ergonomics (%s) %s" _extra_format_ "]" // Conditionally, prints an ergonomic decision record. _extra_format_ // is the format string for the optional items we'd like to print @@ -145,20 +145,21 @@ // them to the print method. For convenience, we have wrapper macros // below which take a specific number of arguments and set the rest to // a default value. -#define ergo_verbose_common(_tag_, _action_, _extra_format_, \ +#define ergo_verbose_common(_tag_, _action_, _extra_format_, \ _arg0_, _arg1_, _arg2_, _arg3_, _arg4_, _arg5_) \ - do { \ - if (G1ErgoVerbose::enabled((_tag_))) { \ - gclog_or_tty->print_cr(ergo_format(_action_, _extra_format_), \ - os::elapsedTime(), \ - G1ErgoVerbose::to_string((_tag_)), \ - (_arg0_), (_arg1_), (_arg2_), \ - (_arg3_), (_arg4_), (_arg5_)); \ - } \ + do { \ + if (G1ErgoVerbose::enabled((_tag_))) { \ + gclog_or_tty->print_cr(ergo_format(_extra_format_), \ + os::elapsedTime(), \ + G1ErgoVerbose::to_string((_tag_)), \ + (_action_), \ + (_arg0_), (_arg1_), (_arg2_), \ + (_arg3_), (_arg4_), (_arg5_)); \ + } \ } while (0) -#define ergo_verbose(_tag_, _action_) \ +#define ergo_verbose(_tag_, _action_) \ ergo_verbose_common(_tag_, _action_, "", 0, 0, 0, 0, 0, 0) #define ergo_verbose0(_tag_, _action_, _extra_format_) \ diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp --- a/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -297,7 +297,23 @@ \ develop(uintx, G1DefaultMaxNewGenPercent, 80, \ "Percentage (0-100) of the heap size to use as maximum " \ - "young gen size.") + "young gen size.") \ + \ + develop(uintx, G1OldCSetRegionLiveThresholdPercent, 95, \ + "Threshold for regions to be added to the collection set. " \ + "Regions with more live bytes that this will not be collected.") \ + \ + develop(uintx, G1OldReclaimableThresholdPercent, 1, \ + "Threshold for the remaining old reclaimable bytes, expressed " \ + "as a percentage of the heap size. If the old reclaimable bytes " \ + "are under this we will not collect them with more mixed GCs.") \ + \ + develop(uintx, G1MaxMixedGCNum, 4, \ + "The maximum desired number of mixed GCs after a marking cycle.") \ + \ + develop(uintx, G1OldCSetRegionThresholdPercent, 10, \ + "An upper bound for the number of old CSet regions expressed " \ + "as a percentage of the heap size.") G1_FLAGS(DECLARE_DEVELOPER_FLAG, DECLARE_PD_DEVELOPER_FLAG, DECLARE_PRODUCT_FLAG, DECLARE_PD_PRODUCT_FLAG, DECLARE_DIAGNOSTIC_FLAG, DECLARE_EXPERIMENTAL_FLAG, DECLARE_NOTPRODUCT_FLAG, DECLARE_MANAGEABLE_FLAG, DECLARE_PRODUCT_RW_FLAG) diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp --- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -387,13 +387,12 @@ ct_bs->clear(MemRegion(bottom(), end())); } -// void HeapRegion::calc_gc_efficiency() { G1CollectedHeap* g1h = G1CollectedHeap::heap(); - _gc_efficiency = (double) garbage_bytes() / - g1h->predict_region_elapsed_time_ms(this, false); + G1CollectorPolicy* g1p = g1h->g1_policy(); + _gc_efficiency = (double) reclaimable_bytes() / + g1p->predict_region_elapsed_time_ms(this, false); } -// void HeapRegion::set_startsHumongous(HeapWord* new_top, HeapWord* new_end) { assert(!isHumongous(), "sanity / pre-condition"); diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp --- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -415,6 +415,16 @@ return used_at_mark_start_bytes - marked_bytes(); } + // Return the amount of bytes we'll reclaim if we collect this + // region. This includes not only the known garbage bytes in the + // region but also any unallocated space in it, i.e., [top, end), + // since it will also be reclaimed if we collect the region. + size_t reclaimable_bytes() { + size_t known_live_bytes = live_bytes(); + assert(known_live_bytes <= capacity(), "sanity"); + return capacity() - known_live_bytes; + } + // An upper bound on the number of live bytes in the region. size_t max_live_bytes() { return used() - garbage_bytes(); } @@ -648,10 +658,8 @@ init_top_at_mark_start(); } - // void calc_gc_efficiency(void); double gc_efficiency() { return _gc_efficiency;} - // bool is_young() const { return _young_type != NotYoung; } bool is_survivor() const { return _young_type == Survivor; } diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp --- a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -1042,7 +1042,11 @@ size_policy->avg_survived()->sample(from()->used()); } - update_time_of_last_gc(os::javaTimeMillis()); + // We need to use a monotonically non-deccreasing time in ms + // or we will see time-warp warnings and os::javaTimeMillis() + // does not guarantee monotonicity. + jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC; + update_time_of_last_gc(now); SpecializationStats::print(); diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -418,25 +418,17 @@ gc_count = Universe::heap()->total_collections(); result = young_gen()->allocate(size); - - // (1) If the requested object is too large to easily fit in the - // young_gen, or - // (2) If GC is locked out via GCLocker, young gen is full and - // the need for a GC already signalled to GCLocker (done - // at a safepoint), - // ... then, rather than force a safepoint and (a potentially futile) - // collection (attempt) for each allocation, try allocation directly - // in old_gen. For case (2) above, we may in the future allow - // TLAB allocation directly in the old gen. if (result != NULL) { return result; } - if (size >= (young_gen()->eden_space()->capacity_in_words(Thread::current()) / 2)) { - result = old_gen()->allocate(size); - if (result != NULL) { - return result; - } + + // If certain conditions hold, try allocating from the old gen. + result = mem_allocate_old_gen(size); + if (result != NULL) { + return result; } + + // Failed to allocate without a gc. if (GC_locker::is_active_and_needs_gc()) { // If this thread is not in a jni critical section, we stall // the requestor until the critical section has cleared and @@ -460,7 +452,6 @@ } if (result == NULL) { - // Generate a VM operation VM_ParallelGCFailedAllocation op(size, gc_count); VMThread::execute(&op); @@ -523,6 +514,42 @@ return result; } +// A "death march" is a series of ultra-slow allocations in which a full gc is +// done before each allocation, and after the full gc the allocation still +// cannot be satisfied from the young gen. This routine detects that condition; +// it should be called after a full gc has been done and the allocation +// attempted from the young gen. The parameter 'addr' should be the result of +// that young gen allocation attempt. +void +ParallelScavengeHeap::death_march_check(HeapWord* const addr, size_t size) { + if (addr != NULL) { + _death_march_count = 0; // death march has ended + } else if (_death_march_count == 0) { + if (should_alloc_in_eden(size)) { + _death_march_count = 1; // death march has started + } + } +} + +HeapWord* ParallelScavengeHeap::mem_allocate_old_gen(size_t size) { + if (!should_alloc_in_eden(size) || GC_locker::is_active_and_needs_gc()) { + // Size is too big for eden, or gc is locked out. + return old_gen()->allocate(size); + } + + // If a "death march" is in progress, allocate from the old gen a limited + // number of times before doing a GC. + if (_death_march_count > 0) { + if (_death_march_count < 64) { + ++_death_march_count; + return old_gen()->allocate(size); + } else { + _death_march_count = 0; + } + } + return NULL; +} + // Failed allocation policy. Must be called from the VM thread, and // only at a safepoint! Note that this method has policy for allocation // flow, and NOT collection policy. So we do not check for gc collection @@ -535,27 +562,22 @@ assert(!Universe::heap()->is_gc_active(), "not reentrant"); assert(!Heap_lock->owned_by_self(), "this thread should not own the Heap_lock"); - size_t mark_sweep_invocation_count = total_invocations(); - - // We assume (and assert!) that an allocation at this point will fail - // unless we collect. + // We assume that allocation in eden will fail unless we collect. // First level allocation failure, scavenge and allocate in young gen. GCCauseSetter gccs(this, GCCause::_allocation_failure); - PSScavenge::invoke(); + const bool invoked_full_gc = PSScavenge::invoke(); HeapWord* result = young_gen()->allocate(size); // Second level allocation failure. // Mark sweep and allocate in young generation. - if (result == NULL) { - // There is some chance the scavenge method decided to invoke mark_sweep. - // Don't mark sweep twice if so. - if (mark_sweep_invocation_count == total_invocations()) { - invoke_full_gc(false); - result = young_gen()->allocate(size); - } + if (result == NULL && !invoked_full_gc) { + invoke_full_gc(false); + result = young_gen()->allocate(size); } + death_march_check(result, size); + // Third level allocation failure. // After mark sweep and young generation allocation failure, // allocate in old generation. diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -64,6 +64,7 @@ // Collection of generations that are adjacent in the // space reserved for the heap. AdjoiningGenerations* _gens; + unsigned int _death_march_count; static GCTaskManager* _gc_task_manager; // The task manager. @@ -71,8 +72,13 @@ static inline size_t total_invocations(); HeapWord* allocate_new_tlab(size_t size); + inline bool should_alloc_in_eden(size_t size) const; + inline void death_march_check(HeapWord* const result, size_t size); + HeapWord* mem_allocate_old_gen(size_t size); + public: ParallelScavengeHeap() : CollectedHeap() { + _death_march_count = 0; set_alignment(_perm_gen_alignment, intra_heap_alignment()); set_alignment(_young_gen_alignment, intra_heap_alignment()); set_alignment(_old_gen_alignment, intra_heap_alignment()); diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.inline.hpp --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.inline.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.inline.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -36,6 +36,12 @@ PSMarkSweep::total_invocations(); } +inline bool ParallelScavengeHeap::should_alloc_in_eden(const size_t size) const +{ + const size_t eden_size = young_gen()->eden_space()->capacity_in_words(); + return size < eden_size / 2; +} + inline void ParallelScavengeHeap::invoke_scavenge() { PSScavenge::invoke(); diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -100,12 +100,12 @@ // This method contains no policy. You should probably // be calling invoke() instead. -void PSMarkSweep::invoke_no_policy(bool clear_all_softrefs) { +bool PSMarkSweep::invoke_no_policy(bool clear_all_softrefs) { assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint"); assert(ref_processor() != NULL, "Sanity"); if (GC_locker::check_active_before_gc()) { - return; + return false; } ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); @@ -382,6 +382,8 @@ #ifdef TRACESPINNING ParallelTaskTerminator::print_termination_counts(); #endif + + return true; } bool PSMarkSweep::absorb_live_data_from_eden(PSAdaptiveSizePolicy* size_policy, diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.hpp --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -78,7 +78,7 @@ public: static void invoke(bool clear_all_softrefs); - static void invoke_no_policy(bool clear_all_softrefs); + static bool invoke_no_policy(bool clear_all_softrefs); static void initialize(); diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -1993,12 +1993,12 @@ // This method contains no policy. You should probably // be calling invoke() instead. -void PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) { +bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) { assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint"); assert(ref_processor() != NULL, "Sanity"); if (GC_locker::check_active_before_gc()) { - return; + return false; } TimeStamp marking_start; @@ -2248,6 +2248,8 @@ #ifdef TRACESPINNING ParallelTaskTerminator::print_termination_counts(); #endif + + return true; } bool PSParallelCompact::absorb_live_data_from_eden(PSAdaptiveSizePolicy* size_policy, diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -1057,7 +1057,7 @@ } static void invoke(bool maximum_heap_compaction); - static void invoke_no_policy(bool maximum_heap_compaction); + static bool invoke_no_policy(bool maximum_heap_compaction); static void post_initialize(); // Perform initialization for PSParallelCompact that requires diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -247,167 +247,6 @@ } } -// -// This method is pretty bulky. It would be nice to split it up -// into smaller submethods, but we need to be careful not to hurt -// performance. -// - -oop PSPromotionManager::copy_to_survivor_space(oop o) { - assert(PSScavenge::should_scavenge(&o), "Sanity"); - - oop new_obj = NULL; - - // NOTE! We must be very careful with any methods that access the mark - // in o. There may be multiple threads racing on it, and it may be forwarded - // at any time. Do not use oop methods for accessing the mark! - markOop test_mark = o->mark(); - - // The same test as "o->is_forwarded()" - if (!test_mark->is_marked()) { - bool new_obj_is_tenured = false; - size_t new_obj_size = o->size(); - - // Find the objects age, MT safe. - int age = (test_mark->has_displaced_mark_helper() /* o->has_displaced_mark() */) ? - test_mark->displaced_mark_helper()->age() : test_mark->age(); - - // Try allocating obj in to-space (unless too old) - if (age < PSScavenge::tenuring_threshold()) { - new_obj = (oop) _young_lab.allocate(new_obj_size); - if (new_obj == NULL && !_young_gen_is_full) { - // Do we allocate directly, or flush and refill? - if (new_obj_size > (YoungPLABSize / 2)) { - // Allocate this object directly - new_obj = (oop)young_space()->cas_allocate(new_obj_size); - } else { - // Flush and fill - _young_lab.flush(); - - HeapWord* lab_base = young_space()->cas_allocate(YoungPLABSize); - if (lab_base != NULL) { - _young_lab.initialize(MemRegion(lab_base, YoungPLABSize)); - // Try the young lab allocation again. - new_obj = (oop) _young_lab.allocate(new_obj_size); - } else { - _young_gen_is_full = true; - } - } - } - } - - // Otherwise try allocating obj tenured - if (new_obj == NULL) { -#ifndef PRODUCT - if (Universe::heap()->promotion_should_fail()) { - return oop_promotion_failed(o, test_mark); - } -#endif // #ifndef PRODUCT - - new_obj = (oop) _old_lab.allocate(new_obj_size); - new_obj_is_tenured = true; - - if (new_obj == NULL) { - if (!_old_gen_is_full) { - // Do we allocate directly, or flush and refill? - if (new_obj_size > (OldPLABSize / 2)) { - // Allocate this object directly - new_obj = (oop)old_gen()->cas_allocate(new_obj_size); - } else { - // Flush and fill - _old_lab.flush(); - - HeapWord* lab_base = old_gen()->cas_allocate(OldPLABSize); - if(lab_base != NULL) { - _old_lab.initialize(MemRegion(lab_base, OldPLABSize)); - // Try the old lab allocation again. - new_obj = (oop) _old_lab.allocate(new_obj_size); - } - } - } - - // This is the promotion failed test, and code handling. - // The code belongs here for two reasons. It is slightly - // different thatn the code below, and cannot share the - // CAS testing code. Keeping the code here also minimizes - // the impact on the common case fast path code. - - if (new_obj == NULL) { - _old_gen_is_full = true; - return oop_promotion_failed(o, test_mark); - } - } - } - - assert(new_obj != NULL, "allocation should have succeeded"); - - // Copy obj - Copy::aligned_disjoint_words((HeapWord*)o, (HeapWord*)new_obj, new_obj_size); - - // Now we have to CAS in the header. - if (o->cas_forward_to(new_obj, test_mark)) { - // We won any races, we "own" this object. - assert(new_obj == o->forwardee(), "Sanity"); - - // Increment age if obj still in new generation. Now that - // we're dealing with a markOop that cannot change, it is - // okay to use the non mt safe oop methods. - if (!new_obj_is_tenured) { - new_obj->incr_age(); - assert(young_space()->contains(new_obj), "Attempt to push non-promoted obj"); - } - - // Do the size comparison first with new_obj_size, which we - // already have. Hopefully, only a few objects are larger than - // _min_array_size_for_chunking, and most of them will be arrays. - // So, the is->objArray() test would be very infrequent. - if (new_obj_size > _min_array_size_for_chunking && - new_obj->is_objArray() && - PSChunkLargeArrays) { - // we'll chunk it - oop* const masked_o = mask_chunked_array_oop(o); - push_depth(masked_o); - TASKQUEUE_STATS_ONLY(++_arrays_chunked; ++_masked_pushes); - } else { - // we'll just push its contents - new_obj->push_contents(this); - } - } else { - // We lost, someone else "owns" this object - guarantee(o->is_forwarded(), "Object must be forwarded if the cas failed."); - - // Try to deallocate the space. If it was directly allocated we cannot - // deallocate it, so we have to test. If the deallocation fails, - // overwrite with a filler object. - if (new_obj_is_tenured) { - if (!_old_lab.unallocate_object((HeapWord*) new_obj, new_obj_size)) { - CollectedHeap::fill_with_object((HeapWord*) new_obj, new_obj_size); - } - } else if (!_young_lab.unallocate_object((HeapWord*) new_obj, new_obj_size)) { - CollectedHeap::fill_with_object((HeapWord*) new_obj, new_obj_size); - } - - // don't update this before the unallocation! - new_obj = o->forwardee(); - } - } else { - assert(o->is_forwarded(), "Sanity"); - new_obj = o->forwardee(); - } - -#ifdef DEBUG - // This code must come after the CAS test, or it will print incorrect - // information. - if (TraceScavenge) { - gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (" SIZE_FORMAT ")}", - PSScavenge::should_scavenge(&new_obj) ? "copying" : "tenuring", - new_obj->blueprint()->internal_name(), o, new_obj, new_obj->size()); - } -#endif - - return new_obj; -} - template void PSPromotionManager::process_array_chunk_work( oop obj, int start, int end) { diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.hpp --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -171,7 +171,7 @@ void set_old_gen_is_full(bool state) { _old_gen_is_full = state; } // Promotion methods - oop copy_to_survivor_space(oop o); + template oop copy_to_survivor_space(oop o); oop oop_promotion_failed(oop obj, markOop obj_mark); void reset(); diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -61,6 +61,170 @@ claim_or_forward_internal_depth(p); } +// +// This method is pretty bulky. It would be nice to split it up +// into smaller submethods, but we need to be careful not to hurt +// performance. +// +template +oop PSPromotionManager::copy_to_survivor_space(oop o) { + assert(PSScavenge::should_scavenge(&o), "Sanity"); + + oop new_obj = NULL; + + // NOTE! We must be very careful with any methods that access the mark + // in o. There may be multiple threads racing on it, and it may be forwarded + // at any time. Do not use oop methods for accessing the mark! + markOop test_mark = o->mark(); + + // The same test as "o->is_forwarded()" + if (!test_mark->is_marked()) { + bool new_obj_is_tenured = false; + size_t new_obj_size = o->size(); + + if (!promote_immediately) { + // Find the objects age, MT safe. + int age = (test_mark->has_displaced_mark_helper() /* o->has_displaced_mark() */) ? + test_mark->displaced_mark_helper()->age() : test_mark->age(); + + // Try allocating obj in to-space (unless too old) + if (age < PSScavenge::tenuring_threshold()) { + new_obj = (oop) _young_lab.allocate(new_obj_size); + if (new_obj == NULL && !_young_gen_is_full) { + // Do we allocate directly, or flush and refill? + if (new_obj_size > (YoungPLABSize / 2)) { + // Allocate this object directly + new_obj = (oop)young_space()->cas_allocate(new_obj_size); + } else { + // Flush and fill + _young_lab.flush(); + + HeapWord* lab_base = young_space()->cas_allocate(YoungPLABSize); + if (lab_base != NULL) { + _young_lab.initialize(MemRegion(lab_base, YoungPLABSize)); + // Try the young lab allocation again. + new_obj = (oop) _young_lab.allocate(new_obj_size); + } else { + _young_gen_is_full = true; + } + } + } + } + } + + // Otherwise try allocating obj tenured + if (new_obj == NULL) { +#ifndef PRODUCT + if (Universe::heap()->promotion_should_fail()) { + return oop_promotion_failed(o, test_mark); + } +#endif // #ifndef PRODUCT + + new_obj = (oop) _old_lab.allocate(new_obj_size); + new_obj_is_tenured = true; + + if (new_obj == NULL) { + if (!_old_gen_is_full) { + // Do we allocate directly, or flush and refill? + if (new_obj_size > (OldPLABSize / 2)) { + // Allocate this object directly + new_obj = (oop)old_gen()->cas_allocate(new_obj_size); + } else { + // Flush and fill + _old_lab.flush(); + + HeapWord* lab_base = old_gen()->cas_allocate(OldPLABSize); + if(lab_base != NULL) { + _old_lab.initialize(MemRegion(lab_base, OldPLABSize)); + // Try the old lab allocation again. + new_obj = (oop) _old_lab.allocate(new_obj_size); + } + } + } + + // This is the promotion failed test, and code handling. + // The code belongs here for two reasons. It is slightly + // different thatn the code below, and cannot share the + // CAS testing code. Keeping the code here also minimizes + // the impact on the common case fast path code. + + if (new_obj == NULL) { + _old_gen_is_full = true; + return oop_promotion_failed(o, test_mark); + } + } + } + + assert(new_obj != NULL, "allocation should have succeeded"); + + // Copy obj + Copy::aligned_disjoint_words((HeapWord*)o, (HeapWord*)new_obj, new_obj_size); + + // Now we have to CAS in the header. + if (o->cas_forward_to(new_obj, test_mark)) { + // We won any races, we "own" this object. + assert(new_obj == o->forwardee(), "Sanity"); + + // Increment age if obj still in new generation. Now that + // we're dealing with a markOop that cannot change, it is + // okay to use the non mt safe oop methods. + if (!new_obj_is_tenured) { + new_obj->incr_age(); + assert(young_space()->contains(new_obj), "Attempt to push non-promoted obj"); + } + + // Do the size comparison first with new_obj_size, which we + // already have. Hopefully, only a few objects are larger than + // _min_array_size_for_chunking, and most of them will be arrays. + // So, the is->objArray() test would be very infrequent. + if (new_obj_size > _min_array_size_for_chunking && + new_obj->is_objArray() && + PSChunkLargeArrays) { + // we'll chunk it + oop* const masked_o = mask_chunked_array_oop(o); + push_depth(masked_o); + TASKQUEUE_STATS_ONLY(++_arrays_chunked; ++_masked_pushes); + } else { + // we'll just push its contents + new_obj->push_contents(this); + } + } else { + // We lost, someone else "owns" this object + guarantee(o->is_forwarded(), "Object must be forwarded if the cas failed."); + + // Try to deallocate the space. If it was directly allocated we cannot + // deallocate it, so we have to test. If the deallocation fails, + // overwrite with a filler object. + if (new_obj_is_tenured) { + if (!_old_lab.unallocate_object((HeapWord*) new_obj, new_obj_size)) { + CollectedHeap::fill_with_object((HeapWord*) new_obj, new_obj_size); + } + } else if (!_young_lab.unallocate_object((HeapWord*) new_obj, new_obj_size)) { + CollectedHeap::fill_with_object((HeapWord*) new_obj, new_obj_size); + } + + // don't update this before the unallocation! + new_obj = o->forwardee(); + } + } else { + assert(o->is_forwarded(), "Sanity"); + new_obj = o->forwardee(); + } + +#ifdef DEBUG + // This code must come after the CAS test, or it will print incorrect + // information. + if (TraceScavenge) { + gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (" SIZE_FORMAT ")}", + PSScavenge::should_scavenge(&new_obj) ? "copying" : "tenuring", + new_obj->blueprint()->internal_name(), o, new_obj, new_obj->size()); + } +#endif + + return new_obj; +} + + inline void PSPromotionManager::process_popped_location_depth(StarTask p) { if (is_oop_masked(p)) { assert(PSChunkLargeArrays, "invariant"); @@ -69,9 +233,9 @@ } else { if (p.is_narrow()) { assert(UseCompressedOops, "Error"); - PSScavenge::copy_and_push_safe_barrier(this, (narrowOop*)p); + PSScavenge::copy_and_push_safe_barrier(this, p); } else { - PSScavenge::copy_and_push_safe_barrier(this, (oop*)p); + PSScavenge::copy_and_push_safe_barrier(this, p); } } } diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "classfile/symbolTable.hpp" +#include "code/codeCache.hpp" #include "gc_implementation/parallelScavenge/cardTableExtension.hpp" #include "gc_implementation/parallelScavenge/gcTaskManager.hpp" #include "gc_implementation/parallelScavenge/generationSizer.hpp" @@ -100,7 +101,7 @@ // Weak refs may be visited more than once. if (PSScavenge::should_scavenge(p, _to_space)) { - PSScavenge::copy_and_push_safe_barrier(_promotion_manager, p); + PSScavenge::copy_and_push_safe_barrier(_promotion_manager, p); } } virtual void do_oop(oop* p) { PSKeepAliveClosure::do_oop_work(p); } @@ -214,36 +215,41 @@ // // Note that this method should only be called from the vm_thread while // at a safepoint! -void PSScavenge::invoke() { +bool PSScavenge::invoke() { assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint"); assert(Thread::current() == (Thread*)VMThread::vm_thread(), "should be in vm thread"); assert(!Universe::heap()->is_gc_active(), "not reentrant"); - ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); + ParallelScavengeHeap* const heap = (ParallelScavengeHeap*)Universe::heap(); assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); PSAdaptiveSizePolicy* policy = heap->size_policy(); IsGCActiveMark mark; - bool scavenge_was_done = PSScavenge::invoke_no_policy(); + const bool scavenge_done = PSScavenge::invoke_no_policy(); + const bool need_full_gc = !scavenge_done || + policy->should_full_GC(heap->old_gen()->free_in_bytes()); + bool full_gc_done = false; - PSGCAdaptivePolicyCounters* counters = heap->gc_policy_counters(); - if (UsePerfData) - counters->update_full_follows_scavenge(0); - if (!scavenge_was_done || - policy->should_full_GC(heap->old_gen()->free_in_bytes())) { - if (UsePerfData) - counters->update_full_follows_scavenge(full_follows_scavenge); + if (UsePerfData) { + PSGCAdaptivePolicyCounters* const counters = heap->gc_policy_counters(); + const int ffs_val = need_full_gc ? full_follows_scavenge : not_skipped; + counters->update_full_follows_scavenge(ffs_val); + } + + if (need_full_gc) { GCCauseSetter gccs(heap, GCCause::_adaptive_size_policy); CollectorPolicy* cp = heap->collector_policy(); const bool clear_all_softrefs = cp->should_clear_all_soft_refs(); if (UseParallelOldGC) { - PSParallelCompact::invoke_no_policy(clear_all_softrefs); + full_gc_done = PSParallelCompact::invoke_no_policy(clear_all_softrefs); } else { - PSMarkSweep::invoke_no_policy(clear_all_softrefs); + full_gc_done = PSMarkSweep::invoke_no_policy(clear_all_softrefs); } } + + return full_gc_done; } // This method contains no policy. You should probably @@ -602,6 +608,8 @@ NOT_PRODUCT(reference_processor()->verify_no_references_recorded()); + CodeCache::prune_scavenge_root_nmethods(); + // Re-verify object start arrays if (VerifyObjectStartArray && VerifyAfterGC) { diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.hpp --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -117,10 +117,9 @@ // Called by parallelScavengeHeap to init the tenuring threshold static void initialize(); - // Scavenge entry point - static void invoke(); - // Return true is a collection was done. Return - // false if the collection was skipped. + // Scavenge entry point. This may invoke a full gc; return true if so. + static bool invoke(); + // Return true if a collection was done; false otherwise. static bool invoke_no_policy(); // If an attempt to promote fails, this method is invoked @@ -135,7 +134,8 @@ template static inline bool should_scavenge(T* p, MutableSpace* to_space); template static inline bool should_scavenge(T* p, bool check_to_space); - template inline static void copy_and_push_safe_barrier(PSPromotionManager* pm, T* p); + template + inline static void copy_and_push_safe_barrier(PSPromotionManager* pm, T* p); // Is an object in the young generation // This assumes that the HeapWord argument is in the heap, diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -28,6 +28,7 @@ #include "gc_implementation/parallelScavenge/cardTableExtension.hpp" #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp" #include "gc_implementation/parallelScavenge/psPromotionManager.hpp" +#include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp" #include "gc_implementation/parallelScavenge/psScavenge.hpp" inline void PSScavenge::save_to_space_top_before_gc() { @@ -65,7 +66,7 @@ // Attempt to "claim" oop at p via CAS, push the new obj if successful // This version tests the oop* to make sure it is within the heap before // attempting marking. -template +template inline void PSScavenge::copy_and_push_safe_barrier(PSPromotionManager* pm, T* p) { assert(should_scavenge(p, true), "revisiting object?"); @@ -73,7 +74,7 @@ oop o = oopDesc::load_decode_heap_oop_not_null(p); oop new_obj = o->is_forwarded() ? o->forwardee() - : pm->copy_to_survivor_space(o); + : pm->copy_to_survivor_space(o); oopDesc::encode_store_heap_oop_not_null(p, new_obj); // We cannot mark without test, as some code passes us pointers @@ -86,7 +87,8 @@ } } -class PSScavengeRootsClosure: public OopClosure { +template +class PSRootsClosure: public OopClosure { private: PSPromotionManager* _promotion_manager; @@ -94,13 +96,16 @@ template void do_oop_work(T *p) { if (PSScavenge::should_scavenge(p)) { // We never card mark roots, maybe call a func without test? - PSScavenge::copy_and_push_safe_barrier(_promotion_manager, p); + PSScavenge::copy_and_push_safe_barrier(_promotion_manager, p); } } public: - PSScavengeRootsClosure(PSPromotionManager* pm) : _promotion_manager(pm) { } - void do_oop(oop* p) { PSScavengeRootsClosure::do_oop_work(p); } - void do_oop(narrowOop* p) { PSScavengeRootsClosure::do_oop_work(p); } + PSRootsClosure(PSPromotionManager* pm) : _promotion_manager(pm) { } + void do_oop(oop* p) { PSRootsClosure::do_oop_work(p); } + void do_oop(narrowOop* p) { PSRootsClosure::do_oop_work(p); } }; +typedef PSRootsClosure PSScavengeRootsClosure; +typedef PSRootsClosure PSPromoteRootsClosure; + #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_INLINE_HPP diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -51,6 +51,7 @@ PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which); PSScavengeRootsClosure roots_closure(pm); + PSPromoteRootsClosure roots_to_old_closure(pm); switch (_root_type) { case universe: @@ -91,7 +92,7 @@ case code_cache: { - CodeBlobToOopClosure each_scavengable_code_blob(&roots_closure, /*do_marking=*/ true); + CodeBlobToOopClosure each_scavengable_code_blob(&roots_to_old_closure, /*do_marking=*/ true); CodeCache::scavenge_root_nmethods_do(&each_scavengable_code_blob); } break; diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/gc_interface/collectedHeap.cpp --- a/hotspot/src/share/vm/gc_interface/collectedHeap.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/gc_interface/collectedHeap.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -62,7 +62,7 @@ return; } - jlong timestamp = os::javaTimeNanos() / NANOSECS_PER_MILLISEC; + double timestamp = fetch_timestamp(); MutexLockerEx ml(&_mutex, Mutex::_no_safepoint_check_flag); int index = compute_log_index(); _records[index].thread = NULL; // Its the GC thread so it's not that interesting. @@ -70,9 +70,9 @@ _records[index].data.is_before = before; stringStream st(_records[index].data.buffer(), _records[index].data.size()); if (before) { - Universe::print_heap_before_gc(&st); + Universe::print_heap_before_gc(&st, true); } else { - Universe::print_heap_after_gc(&st); + Universe::print_heap_after_gc(&st, true); } } diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/memory/compactingPermGenGen.cpp --- a/hotspot/src/share/vm/memory/compactingPermGenGen.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/memory/compactingPermGenGen.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -240,9 +240,6 @@ if (_ro_space == NULL || _rw_space == NULL) vm_exit_during_initialization("Could not allocate a shared space"); - // Cover both shared spaces entirely with cards. - _rs->resize_covered_region(MemRegion(readonly_bottom, readwrite_end)); - if (UseSharedSpaces) { // Map in the regions in the shared file. @@ -279,10 +276,14 @@ delete _rw_space; _rw_space = NULL; shared_end = (HeapWord*)(rs.base() + rs.size()); - _rs->resize_covered_region(MemRegion(shared_bottom, shared_bottom)); } } + if (spec()->enable_shared_spaces()) { + // Cover both shared spaces entirely with cards. + _rs->resize_covered_region(MemRegion(readonly_bottom, readwrite_end)); + } + // Reserved region includes shared spaces for oop.is_in_reserved(). _reserved.set_end(shared_end); diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/memory/defNewGeneration.cpp --- a/hotspot/src/share/vm/memory/defNewGeneration.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/memory/defNewGeneration.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -655,7 +655,12 @@ from()->set_concurrent_iteration_safe_limit(from()->top()); to()->set_concurrent_iteration_safe_limit(to()->top()); SpecializationStats::print(); - update_time_of_last_gc(os::javaTimeMillis()); + + // We need to use a monotonically non-deccreasing time in ms + // or we will see time-warp warnings and os::javaTimeMillis() + // does not guarantee monotonicity. + jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC; + update_time_of_last_gc(now); } class RemoveForwardPointerClosure: public ObjectClosure { diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/memory/gcLocker.cpp --- a/hotspot/src/share/vm/memory/gcLocker.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/memory/gcLocker.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -31,7 +31,6 @@ volatile jint GC_locker::_lock_count = 0; volatile bool GC_locker::_needs_gc = false; volatile bool GC_locker::_doing_gc = false; -jlong GC_locker::_wait_begin = 0; #ifdef ASSERT volatile jint GC_locker::_debug_jni_lock_count = 0; @@ -69,9 +68,8 @@ _needs_gc = true; if (PrintJNIGCStalls && PrintGCDetails) { ResourceMark rm; // JavaThread::name() allocates to convert to UTF8 - _wait_begin = os::javaTimeNanos() / NANOSECS_PER_MILLISEC; - gclog_or_tty->print_cr(INT64_FORMAT ": Setting _needs_gc. Thread \"%s\" %d locked.", - _wait_begin, Thread::current()->name(), _jni_lock_count); + gclog_or_tty->print_cr("%.3f: Setting _needs_gc. Thread \"%s\" %d locked.", + gclog_or_tty->time_stamp().seconds(), Thread::current()->name(), _jni_lock_count); } } @@ -85,8 +83,8 @@ if (needs_gc()) { if (PrintJNIGCStalls && PrintGCDetails) { ResourceMark rm; // JavaThread::name() allocates to convert to UTF8 - gclog_or_tty->print_cr(INT64_FORMAT ": Allocation failed. Thread \"%s\" is stalled by JNI critical section, %d locked.", - (os::javaTimeNanos() / NANOSECS_PER_MILLISEC) - _wait_begin, Thread::current()->name(), _jni_lock_count); + gclog_or_tty->print_cr("%.3f: Allocation failed. Thread \"%s\" is stalled by JNI critical section, %d locked.", + gclog_or_tty->time_stamp().seconds(), Thread::current()->name(), _jni_lock_count); } } @@ -131,8 +129,8 @@ MutexUnlocker munlock(JNICritical_lock); if (PrintJNIGCStalls && PrintGCDetails) { ResourceMark rm; // JavaThread::name() allocates to convert to UTF8 - gclog_or_tty->print_cr(INT64_FORMAT ": Thread \"%s\" is performing GC after exiting critical section, %d locked", - (os::javaTimeNanos() / NANOSECS_PER_MILLISEC) - _wait_begin, Thread::current()->name(), _jni_lock_count); + gclog_or_tty->print_cr("%.3f: Thread \"%s\" is performing GC after exiting critical section, %d locked", + gclog_or_tty->time_stamp().seconds(), Thread::current()->name(), _jni_lock_count); } Universe::heap()->collect(GCCause::_gc_locker); } diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/memory/gcLocker.hpp --- a/hotspot/src/share/vm/memory/gcLocker.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/memory/gcLocker.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -63,9 +63,6 @@ // note: bool is typedef'd as jint static volatile bool _doing_gc; // unlock_critical() is doing a GC - static jlong _wait_begin; // Timestamp for the setting of _needs_gc. - // Used only by printing code. - #ifdef ASSERT // This lock count is updated for all operations and is used to // validate the jni_lock_count that is computed during safepoints. @@ -86,13 +83,26 @@ static void jni_lock(JavaThread* thread); static void jni_unlock(JavaThread* thread); + static bool is_active_internal() { + verify_critical_count(); + return _lock_count > 0 || _jni_lock_count > 0; + } + public: // Accessors - static bool is_active(); + static bool is_active() { + assert(_needs_gc || SafepointSynchronize::is_at_safepoint(), "only read at safepoint"); + return is_active_internal(); + } static bool needs_gc() { return _needs_gc; } // Shorthand - static bool is_active_and_needs_gc() { return needs_gc() && is_active(); } + static bool is_active_and_needs_gc() { + // Use is_active_internal since _needs_gc can change from true to + // false outside of a safepoint, triggering the assert in + // is_active. + return needs_gc() && is_active_internal(); + } // In debug mode track the locking state at all times static void increment_debug_jni_lock_count() { diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/memory/gcLocker.inline.hpp --- a/hotspot/src/share/vm/memory/gcLocker.inline.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/memory/gcLocker.inline.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -27,12 +27,6 @@ #include "memory/gcLocker.hpp" -inline bool GC_locker::is_active() { - assert(_needs_gc || SafepointSynchronize::is_at_safepoint(), "only read at safepoint"); - verify_critical_count(); - return _lock_count > 0 || _jni_lock_count > 0; -} - inline void GC_locker::lock() { // cast away volatile Atomic::inc(&_lock_count); diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/memory/genMarkSweep.cpp --- a/hotspot/src/share/vm/memory/genMarkSweep.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/memory/genMarkSweep.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -176,7 +176,11 @@ // Update time of last gc for all generations we collected // (which curently is all the generations in the heap). - gch->update_time_of_last_gc(os::javaTimeMillis()); + // We need to use a monotonically non-deccreasing time in ms + // or we will see time-warp warnings and os::javaTimeMillis() + // does not guarantee monotonicity. + jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC; + gch->update_time_of_last_gc(now); } void GenMarkSweep::allocate_stacks() { diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/memory/universe.cpp --- a/hotspot/src/share/vm/memory/universe.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/memory/universe.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -1303,22 +1303,22 @@ } } -void Universe::print_heap_before_gc(outputStream* st) { +void Universe::print_heap_before_gc(outputStream* st, bool ignore_extended) { st->print_cr("{Heap before GC invocations=%u (full %u):", heap()->total_collections(), heap()->total_full_collections()); - if (!PrintHeapAtGCExtended) { + if (!PrintHeapAtGCExtended || ignore_extended) { heap()->print_on(st); } else { heap()->print_extended_on(st); } } -void Universe::print_heap_after_gc(outputStream* st) { +void Universe::print_heap_after_gc(outputStream* st, bool ignore_extended) { st->print_cr("Heap after GC invocations=%u (full %u):", heap()->total_collections(), heap()->total_full_collections()); - if (!PrintHeapAtGCExtended) { + if (!PrintHeapAtGCExtended || ignore_extended) { heap()->print_on(st); } else { heap()->print_extended_on(st); diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/memory/universe.hpp --- a/hotspot/src/share/vm/memory/universe.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/memory/universe.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -424,8 +424,8 @@ static void print_heap_at_SIGBREAK(); static void print_heap_before_gc() { print_heap_before_gc(gclog_or_tty); } static void print_heap_after_gc() { print_heap_after_gc(gclog_or_tty); } - static void print_heap_before_gc(outputStream* st); - static void print_heap_after_gc(outputStream* st); + static void print_heap_before_gc(outputStream* st, bool ignore_extended = false); + static void print_heap_after_gc(outputStream* st, bool ignore_extended = false); // Change the number of dummy objects kept reachable by the full gc dummy // array; this should trigger relocation in a sliding compaction collector. diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/opto/chaitin.cpp --- a/hotspot/src/share/vm/opto/chaitin.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/opto/chaitin.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -1946,18 +1946,29 @@ reg2offset_unchecked(OptoReg::add(_matcher._old_SP,-1)) - reg2offset_unchecked(_matcher._new_SP)+jintSize); // Preserve area dump + int fixed_slots = C->fixed_slots(); + OptoReg::Name begin_in_preserve = OptoReg::add(_matcher._old_SP, -(int)C->in_preserve_stack_slots()); + OptoReg::Name return_addr = _matcher.return_addr(); + reg = OptoReg::add(reg, -1); - while( OptoReg::is_stack(reg)) { + while (OptoReg::is_stack(reg)) { tty->print("#r%3.3d %s+%2d: ",reg,fp,reg2offset_unchecked(reg)); - if( _matcher.return_addr() == reg ) + if (return_addr == reg) { tty->print_cr("return address"); - else if( _matcher.return_addr() == OptoReg::add(reg,1) && - VerifyStackAtCalls ) - tty->print_cr("0xBADB100D +VerifyStackAtCalls"); - else if ((int)OptoReg::reg2stack(reg) < C->fixed_slots()) + } else if (reg >= begin_in_preserve) { + // Preserved slots are present on x86 + if (return_addr == OptoReg::add(reg, VMRegImpl::slots_per_word)) + tty->print_cr("saved fp register"); + else if (return_addr == OptoReg::add(reg, 2*VMRegImpl::slots_per_word) && + VerifyStackAtCalls) + tty->print_cr("0xBADB100D +VerifyStackAtCalls"); + else + tty->print_cr("in_preserve"); + } else if ((int)OptoReg::reg2stack(reg) < fixed_slots) { tty->print_cr("Fixed slot %d", OptoReg::reg2stack(reg)); - else - tty->print_cr("pad2, in_preserve"); + } else { + tty->print_cr("pad2, stack alignment"); + } reg = OptoReg::add(reg, -1); } diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/opto/escape.cpp --- a/hotspot/src/share/vm/opto/escape.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/opto/escape.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -1687,12 +1687,23 @@ // Observed 8 passes in jvm2008 compiler.compiler. // Set limit to 20 to catch situation when something // did go wrong and recompile the method without EA. + // Also limit build time to 30 sec (60 in debug VM). #define CG_BUILD_ITER_LIMIT 20 +#ifdef ASSERT +#define CG_BUILD_TIME_LIMIT 60.0 +#else +#define CG_BUILD_TIME_LIMIT 30.0 +#endif + uint length = worklist.length(); int iterations = 0; - while(_progress && (iterations++ < CG_BUILD_ITER_LIMIT)) { + elapsedTimer time; + while(_progress && + (iterations++ < CG_BUILD_ITER_LIMIT) && + (time.seconds() < CG_BUILD_TIME_LIMIT)) { + time.start(); _progress = false; for( uint next = 0; next < length; ++next ) { int ni = worklist.at(next); @@ -1701,18 +1712,19 @@ assert(n != NULL, "should be known node"); build_connection_graph(n, igvn); } + time.stop(); } - if (iterations >= CG_BUILD_ITER_LIMIT) { - assert(iterations < CG_BUILD_ITER_LIMIT, - err_msg("infinite EA connection graph build with %d nodes and worklist size %d", - nodes_size(), length)); + if ((iterations >= CG_BUILD_ITER_LIMIT) || + (time.seconds() >= CG_BUILD_TIME_LIMIT)) { + assert(false, err_msg("infinite EA connection graph build (%f sec, %d iterations) with %d nodes and worklist size %d", + time.seconds(), iterations, nodes_size(), length)); // Possible infinite build_connection_graph loop, - // retry compilation without escape analysis. - C->record_failure(C2Compiler::retry_no_escape_analysis()); + // bailout (no changes to ideal graph were made). _collecting = false; return false; } #undef CG_BUILD_ITER_LIMIT +#undef CG_BUILD_TIME_LIMIT // 5. Propagate escaped states. worklist.clear(); @@ -2292,9 +2304,35 @@ PointsToNode::EscapeState arg_esc = ptnode_adr(arg->_idx)->escape_state(); if (!arg->is_top() && at->isa_ptr() && aat->isa_ptr() && (is_arraycopy || arg_esc < PointsToNode::ArgEscape)) { - +#ifdef ASSERT assert(aat == Type::TOP || aat == TypePtr::NULL_PTR || aat->isa_ptr() != NULL, "expecting an Ptr"); + if (!(is_arraycopy || + call->as_CallLeaf()->_name != NULL && + (strcmp(call->as_CallLeaf()->_name, "g1_wb_pre") == 0 || + strcmp(call->as_CallLeaf()->_name, "g1_wb_post") == 0 )) + ) { + call->dump(); + assert(false, "EA: unexpected CallLeaf"); + } +#endif + if (arg_esc < PointsToNode::ArgEscape) { + set_escape_state(arg->_idx, PointsToNode::ArgEscape); + Node* arg_base = arg; + if (arg->is_AddP()) { + // + // The inline_native_clone() case when the arraycopy stub is called + // after the allocation before Initialize and CheckCastPP nodes. + // Or normal arraycopy for object arrays case. + // + // Set AddP's base (Allocate) as not scalar replaceable since + // pointer to the base (with offset) is passed as argument. + // + arg_base = get_addp_base(arg); + set_escape_state(arg_base->_idx, PointsToNode::ArgEscape); + } + } + bool arg_has_oops = aat->isa_oopptr() && (aat->isa_oopptr()->klass() == NULL || aat->isa_instptr() || (aat->isa_aryptr() && aat->isa_aryptr()->klass()->is_obj_array_klass())); @@ -2307,85 +2345,33 @@ // arraycopy(char[],0,Object*,0,size); // arraycopy(Object*,0,char[],0,size); // - // Don't add edges from dst's fields in such cases. + // Do nothing special in such cases. // - bool arg_is_arraycopy_dest = src_has_oops && is_arraycopy && - arg_has_oops && (i > TypeFunc::Parms); -#ifdef ASSERT - if (!(is_arraycopy || - call->as_CallLeaf()->_name != NULL && - (strcmp(call->as_CallLeaf()->_name, "g1_wb_pre") == 0 || - strcmp(call->as_CallLeaf()->_name, "g1_wb_post") == 0 )) - ) { - call->dump(); - assert(false, "EA: unexpected CallLeaf"); - } -#endif - // Always process arraycopy's destination object since - // we need to add all possible edges to references in - // source object. - if (arg_esc >= PointsToNode::ArgEscape && - !arg_is_arraycopy_dest) { - continue; - } - set_escape_state(arg->_idx, PointsToNode::ArgEscape); - Node* arg_base = arg; - if (arg->is_AddP()) { - // - // The inline_native_clone() case when the arraycopy stub is called - // after the allocation before Initialize and CheckCastPP nodes. - // Or normal arraycopy for object arrays case. - // - // Set AddP's base (Allocate) as not scalar replaceable since - // pointer to the base (with offset) is passed as argument. - // - arg_base = get_addp_base(arg); - } - VectorSet argset = *PointsTo(arg_base); // Clone set - for( VectorSetI j(&argset); j.test(); ++j ) { - uint pd = j.elem; // Destination object - set_escape_state(pd, PointsToNode::ArgEscape); - - if (arg_is_arraycopy_dest) { - PointsToNode* ptd = ptnode_adr(pd); - // Conservatively reference an unknown object since - // not all source's fields/elements may be known. - add_edge_from_fields(pd, _phantom_object, Type::OffsetBot); - - Node *src = call->in(TypeFunc::Parms)->uncast(); - Node* src_base = src; - if (src->is_AddP()) { - src_base = get_addp_base(src); - } - // Create edges from destination's fields to - // everything known source's fields could point to. - for( VectorSetI s(PointsTo(src_base)); s.test(); ++s ) { - uint ps = s.elem; - bool has_bottom_offset = false; - for (uint fd = 0; fd < ptd->edge_count(); fd++) { - assert(ptd->edge_type(fd) == PointsToNode::FieldEdge, "expecting a field edge"); - int fdi = ptd->edge_target(fd); - PointsToNode* pfd = ptnode_adr(fdi); - int offset = pfd->offset(); - if (offset == Type::OffsetBot) - has_bottom_offset = true; - assert(offset != -1, "offset should be set"); - add_deferred_edge_to_fields(fdi, ps, offset); - } - // Destination object may not have access (no field edge) - // to fields which are accessed in source object. - // As result no edges will be created to those source's - // fields and escape state of destination object will - // not be propagated to those fields. - // - // Mark source object as global escape except in - // the case with Type::OffsetBot field (which is - // common case for array elements access) when - // edges are created to all source's fields. - if (!has_bottom_offset) { - set_escape_state(ps, PointsToNode::GlobalEscape); - } - } + if (is_arraycopy && (i > TypeFunc::Parms) && + src_has_oops && arg_has_oops) { + // Destination object's fields reference an unknown object. + Node* arg_base = arg; + if (arg->is_AddP()) { + arg_base = get_addp_base(arg); + } + for (VectorSetI s(PointsTo(arg_base)); s.test(); ++s) { + uint ps = s.elem; + set_escape_state(ps, PointsToNode::ArgEscape); + add_edge_from_fields(ps, _phantom_object, Type::OffsetBot); + } + // Conservatively all values in source object fields globally escape + // since we don't know if values in destination object fields + // escape (it could be traced but it is too expensive). + Node* src = call->in(TypeFunc::Parms)->uncast(); + Node* src_base = src; + if (src->is_AddP()) { + src_base = get_addp_base(src); + } + for (VectorSetI s(PointsTo(src_base)); s.test(); ++s) { + uint ps = s.elem; + set_escape_state(ps, PointsToNode::ArgEscape); + // Use OffsetTop to indicate fields global escape. + add_edge_from_fields(ps, _phantom_object, Type::OffsetTop); } } } diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/opto/output.cpp --- a/hotspot/src/share/vm/opto/output.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/opto/output.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -167,7 +167,7 @@ // Determine if we need to generate a stack overflow check. // Do it if the method is not a stub function and // has java calls or has frame size > vm_page_size/8. - return (stub_function() == NULL && + return (UseStackBanging && stub_function() == NULL && (has_java_calls() || frame_size_in_bytes > os::vm_page_size()>>3)); } diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/prims/jvmtiTagMap.cpp --- a/hotspot/src/share/vm/prims/jvmtiTagMap.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/prims/jvmtiTagMap.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -2999,7 +2999,8 @@ char type = field->field_type(); if (!is_primitive_field_type(type)) { oop fld_o = o->obj_field(field->field_offset()); - if (fld_o != NULL) { + // ignore any objects that aren't visible to profiler + if (fld_o != NULL && ServiceUtil::visible_oop(fld_o)) { // reflection code may have a reference to a klassOop. // - see sun.reflect.UnsafeStaticFieldAccessorImpl and sun.misc.Unsafe if (fld_o->is_klass()) { diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/runtime/arguments.cpp --- a/hotspot/src/share/vm/runtime/arguments.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/runtime/arguments.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -102,8 +102,6 @@ char* Arguments::_meta_index_path = NULL; char* Arguments::_meta_index_dir = NULL; -static bool force_client_mode = false; - // Check if head of 'option' matches 'name', and sets 'tail' remaining part of option string static bool match_option(const JavaVMOption *option, const char* name, @@ -1345,7 +1343,7 @@ return; } - if (os::is_server_class_machine() && !force_client_mode ) { + if (os::is_server_class_machine()) { // If no other collector is requested explicitly, // let the VM select the collector based on // machine class and automatic selection policy. @@ -1370,12 +1368,9 @@ // by ergonomics. if (MaxHeapSize <= max_heap_for_compressed_oops()) { #if !defined(COMPILER1) || defined(TIERED) -// disable UseCompressedOops by default on MacOS X until 7118647 is fixed -#ifndef __APPLE__ if (FLAG_IS_DEFAULT(UseCompressedOops)) { FLAG_SET_ERGO(bool, UseCompressedOops, true); } -#endif // !__APPLE__ #endif #ifdef _WIN64 if (UseLargePages && UseCompressedOops) { @@ -2940,11 +2935,6 @@ // Construct the path to the archive char jvm_path[JVM_MAXPATHLEN]; os::jvm_path(jvm_path, sizeof(jvm_path)); -#ifdef TIERED - if (strstr(jvm_path, "client") != NULL) { - force_client_mode = true; - } -#endif // TIERED char *end = strrchr(jvm_path, *os::file_separator()); if (end != NULL) *end = '\0'; char *shared_archive_path = NEW_C_HEAP_ARRAY(char, strlen(jvm_path) + diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/runtime/dtraceJSDT.cpp --- a/hotspot/src/share/vm/runtime/dtraceJSDT.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/runtime/dtraceJSDT.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -82,7 +82,7 @@ int handle = pd_activate((void*)probes, module_name, providers_count, providers); - if (handle <= 0) { + if (handle < 0) { delete probes; THROW_MSG_0(vmSymbols::java_lang_RuntimeException(), "Unable to register DTrace probes (internal error)."); diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/runtime/globals.hpp --- a/hotspot/src/share/vm/runtime/globals.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/runtime/globals.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -3013,7 +3013,7 @@ product(intx, SafepointTimeoutDelay, 10000, \ "Delay in milliseconds for option SafepointTimeout") \ \ - product(intx, NmethodSweepFraction, 4, \ + product(intx, NmethodSweepFraction, 16, \ "Number of invocations of sweeper to cover all nmethods") \ \ product(intx, NmethodSweepCheckInterval, 5, \ diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/runtime/sharedRuntime.cpp --- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -804,6 +804,7 @@ if (thread->deopt_mark() != NULL) { Deoptimization::cleanup_deopt_info(thread, NULL); } + Events::log_exception(thread, "StackOverflowError at " INTPTR_FORMAT, pc); return StubRoutines::throw_StackOverflowError_entry(); } @@ -820,8 +821,10 @@ if (vt_stub->is_abstract_method_error(pc)) { assert(!vt_stub->is_vtable_stub(), "should never see AbstractMethodErrors from vtable-type VtableStubs"); + Events::log_exception(thread, "AbstractMethodError at " INTPTR_FORMAT, pc); return StubRoutines::throw_AbstractMethodError_entry(); } else { + Events::log_exception(thread, "NullPointerException at vtable entry " INTPTR_FORMAT, pc); return StubRoutines::throw_NullPointerException_at_call_entry(); } } else { @@ -838,6 +841,7 @@ if (!cb->is_nmethod()) { guarantee(cb->is_adapter_blob() || cb->is_method_handles_adapter_blob(), "exception happened outside interpreter, nmethods and vtable stubs (1)"); + Events::log_exception(thread, "NullPointerException in code blob at " INTPTR_FORMAT, pc); // There is no handler here, so we will simply unwind. return StubRoutines::throw_NullPointerException_at_call_entry(); } @@ -849,6 +853,7 @@ // => the nmethod is not yet active (i.e., the frame // is not set up yet) => use return address pushed by // caller => don't push another return address + Events::log_exception(thread, "NullPointerException in IC check " INTPTR_FORMAT, pc); return StubRoutines::throw_NullPointerException_at_call_entry(); } diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/runtime/sweeper.cpp --- a/hotspot/src/share/vm/runtime/sweeper.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/runtime/sweeper.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -266,7 +266,17 @@ // The last invocation iterates until there are no more nmethods for (int i = 0; (i < todo || _invocations == 1) && _current != NULL; i++) { + if (SafepointSynchronize::is_synchronizing()) { // Safepoint request + if (PrintMethodFlushing && Verbose) { + tty->print_cr("### Sweep at %d out of %d, invocation: %d, yielding to safepoint", _seen, CodeCache::nof_nmethods(), _invocations); + } + MutexUnlockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); + assert(Thread::current()->is_Java_thread(), "should be java thread"); + JavaThread* thread = (JavaThread*)Thread::current(); + ThreadBlockInVM tbivm(thread); + thread->java_suspend_self(); + } // Since we will give up the CodeCache_lock, always skip ahead // to the next nmethod. Other blobs can be deleted by other // threads but nmethods are only reclaimed by the sweeper. diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/runtime/thread.cpp --- a/hotspot/src/share/vm/runtime/thread.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/runtime/thread.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -3220,11 +3220,6 @@ return status; } - // Must be run after init_ft which initializes ft_enabled - if (TRACE_INITIALIZE() != JNI_OK) { - vm_exit_during_initialization("Failed to initialize tracing backend"); - } - // Should be done after the heap is fully created main_thread->cache_global_variables(); @@ -3366,6 +3361,7 @@ initialize_class(vmSymbols::java_lang_ArithmeticException(), CHECK_0); initialize_class(vmSymbols::java_lang_StackOverflowError(), CHECK_0); initialize_class(vmSymbols::java_lang_IllegalMonitorStateException(), CHECK_0); + initialize_class(vmSymbols::java_lang_IllegalArgumentException(), CHECK_0); } else { warning("java.lang.OutOfMemoryError has not been initialized"); warning("java.lang.NullPointerException has not been initialized"); @@ -3373,6 +3369,7 @@ warning("java.lang.ArrayStoreException has not been initialized"); warning("java.lang.ArithmeticException has not been initialized"); warning("java.lang.StackOverflowError has not been initialized"); + warning("java.lang.IllegalArgumentException has not been initialized"); } } @@ -3402,6 +3399,11 @@ quicken_jni_functions(); + // Must be run after init_ft which initializes ft_enabled + if (TRACE_INITIALIZE() != JNI_OK) { + vm_exit_during_initialization("Failed to initialize tracing backend"); + } + // Set flag that basic initialization has completed. Used by exceptions and various // debug stuff, that does not work until all basic classes have been initialized. set_init_completed(); diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/runtime/virtualspace.cpp --- a/hotspot/src/share/vm/runtime/virtualspace.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/runtime/virtualspace.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -455,7 +455,7 @@ void ReservedSpace::protect_noaccess_prefix(const size_t size) { assert( (_noaccess_prefix != 0) == (UseCompressedOops && _base != NULL && - (size_t(_base + _size) > OopEncodingHeapMax) && + (Universe::narrow_oop_base() != NULL) && Universe::narrow_oop_use_implicit_null_checks()), "noaccess_prefix should be used only with non zero based compressed oops"); diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/services/diagnosticArgument.cpp --- a/hotspot/src/share/vm/services/diagnosticArgument.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/services/diagnosticArgument.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -28,9 +28,16 @@ #include "services/diagnosticArgument.hpp" void GenDCmdArgument::read_value(const char* str, size_t len, TRAPS) { - if (is_set()) { + /* NOTE:Some argument types doesn't require a value, + * for instance boolean arguments: "enableFeatureX". is + * equivalent to "enableFeatureX=true". In these cases, + * str will be null. This is perfectly valid. + * All argument types must perform null checks on str. + */ + + if (is_set() && !allow_multiple()) { THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), - "Duplicates in diagnostic command arguments"); + "Duplicates in diagnostic command arguments\n"); } parse_value(str, len, CHECK); set_is_set(true); @@ -38,9 +45,9 @@ template <> void DCmdArgument::parse_value(const char* str, size_t len, TRAPS) { - if (sscanf(str, INT64_FORMAT, &_value) != 1) { + if (str == NULL || sscanf(str, INT64_FORMAT, &_value) != 1) { THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), - "Integer parsing error in diagnostic command arguments"); + "Integer parsing error in diagnostic command arguments\n"); } } @@ -89,16 +96,20 @@ template <> void DCmdArgument::parse_value(const char* str, size_t len, TRAPS) { - _value = NEW_C_HEAP_ARRAY(char, len+1); - strncpy(_value, str, len); - _value[len] = 0; + if (str == NULL) { + _value = NULL; + } else { + _value = NEW_C_HEAP_ARRAY(char, len+1); + strncpy(_value, str, len); + _value[len] = 0; + } } template <> void DCmdArgument::init_value(TRAPS) { - if (has_default()) { + if (has_default() && _default_string != NULL) { this->parse_value(_default_string, strlen(_default_string), THREAD); if (HAS_PENDING_EXCEPTION) { - fatal("Default string must be parsable"); + fatal("Default string must be parsable"); } } else { set_value(NULL); @@ -111,3 +122,153 @@ set_value(NULL); } } + +template <> void DCmdArgument::parse_value(const char* str, + size_t len, TRAPS) { + if (str == NULL) { + THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), + "Integer parsing error nanotime value: syntax error"); + } + + int argc = sscanf(str, INT64_FORMAT , &_value._time); + if (argc != 1) { + THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), + "Integer parsing error nanotime value: syntax error"); + } + size_t idx = 0; + while(idx < len && isdigit(str[idx])) { + idx++; + } + if (idx == len) { + // only accept missing unit if the value is 0 + if (_value._time != 0) { + THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), + "Integer parsing error nanotime value: unit required"); + } else { + _value._nanotime = 0; + strcpy(_value._unit, "ns"); + return; + } + } else if(len - idx > 2) { + THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), + "Integer parsing error nanotime value: illegal unit"); + } else { + strncpy(_value._unit, &str[idx], len - idx); + /*Write an extra null termination. This is safe because _value._unit + * is declared as char[3], and length is checked to be not larger than + * two above. Also, this is necessary, since length might be 1, and the + * default value already in the string is ns, which is two chars. + */ + _value._unit[len-idx] = '\0'; + } + + if (strcmp(_value._unit, "ns") == 0) { + _value._nanotime = _value._time; + } else if (strcmp(_value._unit, "us") == 0) { + _value._nanotime = _value._time * 1000; + } else if (strcmp(_value._unit, "ms") == 0) { + _value._nanotime = _value._time * 1000 * 1000; + } else if (strcmp(_value._unit, "s") == 0) { + _value._nanotime = _value._time * 1000 * 1000 * 1000; + } else if (strcmp(_value._unit, "m") == 0) { + _value._nanotime = _value._time * 60 * 1000 * 1000 * 1000; + } else if (strcmp(_value._unit, "h") == 0) { + _value._nanotime = _value._time * 60 * 60 * 1000 * 1000 * 1000; + } else if (strcmp(_value._unit, "d") == 0) { + _value._nanotime = _value._time * 24 * 60 * 60 * 1000 * 1000 * 1000; + } else { + THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), + "Integer parsing error nanotime value: illegal unit"); + } +} + +template <> void DCmdArgument::init_value(TRAPS) { + if (has_default()) { + this->parse_value(_default_string, strlen(_default_string), THREAD); + if (HAS_PENDING_EXCEPTION) { + fatal("Default string must be parsable"); + } + } else { + _value._time = 0; + _value._nanotime = 0; + strcmp(_value._unit, "ns"); + } +} + +template <> void DCmdArgument::destroy_value() { } + +// WARNING StringArrayArgument can only be used as an option, it cannot be +// used as an argument with the DCmdParser + +template <> void DCmdArgument::parse_value(const char* str, + size_t len, TRAPS) { + _value->add(str,len); +} + +template <> void DCmdArgument::init_value(TRAPS) { + _value = new StringArrayArgument(); + _allow_multiple = true; + if (has_default()) { + fatal("StringArrayArgument cannot have default value"); + } +} + +template <> void DCmdArgument::destroy_value() { + if (_value != NULL) { + delete _value; + set_value(NULL); + } +} + +template <> void DCmdArgument::parse_value(const char* str, + size_t len, TRAPS) { + if (str == NULL) { + THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), + "Integer parsing error nanotime value: syntax error"); + } + + if (*str == '-') { + THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), + "Parsing error memory size value: negative values not allowed"); + } + int res = sscanf(str, UINT64_FORMAT "%c", &_value._val, &_value._multiplier); + if (res == 2) { + switch (_value._multiplier) { + case 'k': case 'K': + _value._size = _value._val * 1024; + break; + case 'm': case 'M': + _value._size = _value._val * 1024 * 1024; + break; + case 'g': case 'G': + _value._size = _value._val * 1024 * 1024 * 1024; + break; + default: + _value._size = _value._val; + _value._multiplier = ' '; + //default case should be to break with no error, since user + //can write size in bytes, or might have a delimiter and next arg + break; + } + } else if (res == 1) { + _value._size = _value._val; + } else { + THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), + "Parsing error memory size value: invalid value"); + } +} + +template <> void DCmdArgument::init_value(TRAPS) { + if (has_default()) { + this->parse_value(_default_string, strlen(_default_string), THREAD); + if (HAS_PENDING_EXCEPTION) { + fatal("Default string must be parsable"); + } + } else { + _value._size = 0; + _value._val = 0; + _value._multiplier = ' '; + } +} + +template <> void DCmdArgument::destroy_value() { } diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/services/diagnosticArgument.hpp --- a/hotspot/src/share/vm/services/diagnosticArgument.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/services/diagnosticArgument.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,49 @@ #include "runtime/thread.hpp" #include "utilities/exceptions.hpp" +class StringArrayArgument : public CHeapObj { +private: + GrowableArray* _array; +public: + StringArrayArgument() { + _array = new(ResourceObj::C_HEAP)GrowableArray(32, true); + assert(_array != NULL, "Sanity check"); + } + void add(const char* str, size_t len) { + if (str != NULL) { + char* ptr = NEW_C_HEAP_ARRAY(char, len+1); + strncpy(ptr, str, len); + ptr[len] = 0; + _array->append(ptr); + } + } + GrowableArray* array() { + return _array; + } + ~StringArrayArgument() { + for (int i=0; i<_array->length(); i++) { + if(_array->at(i) != NULL) { // Safety check + FREE_C_HEAP_ARRAY(char, _array->at(i)); + } + } + delete _array; + } +}; + +class NanoTimeArgument { +public: + jlong _nanotime; + jlong _time; + char _unit[3]; +}; + +class MemorySizeArgument { +public: + u8 _size; + u8 _val; + char _multiplier; +}; + class GenDCmdArgument : public ResourceObj { protected: GenDCmdArgument* _next; @@ -40,6 +83,7 @@ const char* _default_string; bool _is_set; bool _is_mandatory; + bool _allow_multiple; GenDCmdArgument(const char* name, const char* description, const char* type, const char* default_string, bool mandatory) { _name = name; @@ -48,6 +92,7 @@ _default_string = default_string; _is_mandatory = mandatory; _is_set = false; + _allow_multiple = false; }; public: const char* name() { return _name; } @@ -56,6 +101,7 @@ const char* default_string() { return _default_string; } bool is_set() { return _is_set; } void set_is_set(bool b) { _is_set = b; } + bool allow_multiple() { return _allow_multiple; } bool is_mandatory() { return _is_mandatory; } bool has_value() { return _is_set || _default_string != NULL; } bool has_default() { return _default_string != NULL; } diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/services/diagnosticFramework.cpp --- a/hotspot/src/share/vm/services/diagnosticFramework.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/services/diagnosticFramework.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -61,7 +61,7 @@ bool DCmdArgIter::next(TRAPS) { if (_len == 0) return false; // skipping spaces - while (_cursor < _len - 1 && isspace(_buffer[_cursor])) { + while (_cursor < _len - 1 && _buffer[_cursor] == _delim) { _cursor++; } // handling end of command line diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/services/diagnosticFramework.hpp --- a/hotspot/src/share/vm/services/diagnosticFramework.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/services/diagnosticFramework.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -195,6 +195,7 @@ DCmdParser() { _options = NULL; _arguments_list = NULL; + _delim = ' '; } void add_dcmd_option(GenDCmdArgument* arg); void add_dcmd_argument(GenDCmdArgument* arg); diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/services/gcNotifier.cpp --- a/hotspot/src/share/vm/services/gcNotifier.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/services/gcNotifier.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -180,17 +180,43 @@ } void GCNotifier::sendNotification(TRAPS) { + GCNotifier::sendNotificationInternal(THREAD); + // Clearing pending exception to avoid premature termination of + // the service thread + if (HAS_PENDING_EXCEPTION) { + CLEAR_PENDING_EXCEPTION; + } +} + +class NotificationMark : public StackObj { + // This class is used in GCNotifier::sendNotificationInternal to ensure that + // the GCNotificationRequest object is properly cleaned up, whatever path + // is used to exit the method. + GCNotificationRequest* _request; +public: + NotificationMark(GCNotificationRequest* r) { + _request = r; + } + ~NotificationMark() { + assert(_request != NULL, "Sanity check"); + delete _request; + } +}; + +void GCNotifier::sendNotificationInternal(TRAPS) { ResourceMark rm(THREAD); + HandleMark hm(THREAD); GCNotificationRequest *request = getRequest(); - if(request != NULL) { - Handle objGcInfo = createGcInfo(request->gcManager,request->gcStatInfo,THREAD); + if (request != NULL) { + NotificationMark nm(request); + Handle objGcInfo = createGcInfo(request->gcManager, request->gcStatInfo, THREAD); Handle objName = java_lang_String::create_from_platform_dependent_str(request->gcManager->name(), CHECK); Handle objAction = java_lang_String::create_from_platform_dependent_str(request->gcAction, CHECK); Handle objCause = java_lang_String::create_from_platform_dependent_str(request->gcCause, CHECK); klassOop k = Management::sun_management_GarbageCollectorImpl_klass(CHECK); - instanceKlassHandle gc_mbean_klass (THREAD, k); + instanceKlassHandle gc_mbean_klass(THREAD, k); instanceOop gc_mbean = request->gcManager->get_memory_manager_instance(THREAD); instanceHandle gc_mbean_h(THREAD, gc_mbean); @@ -213,11 +239,6 @@ vmSymbols::createGCNotification_signature(), &args, CHECK); - if (HAS_PENDING_EXCEPTION) { - CLEAR_PENDING_EXCEPTION; - } - - delete request; } } diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/services/gcNotifier.hpp --- a/hotspot/src/share/vm/services/gcNotifier.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/services/gcNotifier.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -60,6 +60,7 @@ static GCNotificationRequest *last_request; static void addRequest(GCNotificationRequest *request); static GCNotificationRequest *getRequest(); + static void sendNotificationInternal(TRAPS); public: static void pushNotification(GCMemoryManager *manager, const char *action, const char *cause); static bool has_event(); diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/utilities/debug.cpp --- a/hotspot/src/share/vm/utilities/debug.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/utilities/debug.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -600,6 +600,10 @@ tty->flush(); } +extern "C" void events() { + Command c("events"); + Events::print(); +} // Given a heap address that was valid before the most recent GC, if // the oop that used to contain it is still live, prints the new @@ -759,7 +763,7 @@ tty->print_cr("misc."); tty->print_cr(" flush() - flushes the log file"); - tty->print_cr(" events() - dump last 50 events"); + tty->print_cr(" events() - dump events from ring buffers"); tty->print_cr("compiler debugging"); diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/utilities/decoder.cpp --- a/hotspot/src/share/vm/utilities/decoder.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/utilities/decoder.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -25,7 +25,9 @@ #include "precompiled.hpp" #include "prims/jvm.h" #include "runtime/mutexLocker.hpp" +#include "runtime/os.hpp" #include "utilities/decoder.hpp" +#include "utilities/vmError.hpp" #if defined(_WINDOWS) #include "decoder_windows.hpp" @@ -35,74 +37,94 @@ #include "decoder_elf.hpp" #endif -NullDecoder* Decoder::_decoder = NULL; -NullDecoder Decoder::_do_nothing_decoder; -Mutex* Decoder::_decoder_lock = new Mutex(Mutex::safepoint, - "DecoderLock"); +AbstractDecoder* Decoder::_shared_decoder = NULL; +AbstractDecoder* Decoder::_error_handler_decoder = NULL; +NullDecoder Decoder::_do_nothing_decoder; +Mutex* Decoder::_shared_decoder_lock = new Mutex(Mutex::native, + "SharedDecoderLock"); -// _decoder_lock should already acquired before enter this method -NullDecoder* Decoder::get_decoder() { - assert(_decoder_lock != NULL && _decoder_lock->owned_by_self(), +AbstractDecoder* Decoder::get_shared_instance() { + assert(_shared_decoder_lock != NULL && _shared_decoder_lock->owned_by_self(), "Require DecoderLock to enter"); - if (_decoder != NULL) { - return _decoder; + if (_shared_decoder == NULL) { + _shared_decoder = create_decoder(); } + return _shared_decoder; +} - // Decoder is a secondary service. Although, it is good to have, - // but we can live without it. +AbstractDecoder* Decoder::get_error_handler_instance() { + if (_error_handler_decoder == NULL) { + _error_handler_decoder = create_decoder(); + } + return _error_handler_decoder; +} + + +AbstractDecoder* Decoder::create_decoder() { + AbstractDecoder* decoder; #if defined(_WINDOWS) - _decoder = new (std::nothrow) WindowsDecoder(); + decoder = new (std::nothrow) WindowsDecoder(); #elif defined (__APPLE__) - _decoder = new (std::nothrow)MachODecoder(); + decoder = new (std::nothrow)MachODecoder(); #else - _decoder = new (std::nothrow)ElfDecoder(); + decoder = new (std::nothrow)ElfDecoder(); #endif - if (_decoder == NULL || _decoder->has_error()) { - if (_decoder != NULL) { - delete _decoder; + if (decoder == NULL || decoder->has_error()) { + if (decoder != NULL) { + delete decoder; } - _decoder = &_do_nothing_decoder; + decoder = &_do_nothing_decoder; } - return _decoder; + return decoder; } bool Decoder::decode(address addr, char* buf, int buflen, int* offset, const char* modulepath) { - assert(_decoder_lock != NULL, "Just check"); - MutexLockerEx locker(_decoder_lock, true); - NullDecoder* decoder = get_decoder(); + assert(_shared_decoder_lock != NULL, "Just check"); + bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; + MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true); + AbstractDecoder* decoder = error_handling_thread ? + get_error_handler_instance(): get_shared_instance(); assert(decoder != NULL, "null decoder"); return decoder->decode(addr, buf, buflen, offset, modulepath); } bool Decoder::demangle(const char* symbol, char* buf, int buflen) { - assert(_decoder_lock != NULL, "Just check"); - MutexLockerEx locker(_decoder_lock, true); - NullDecoder* decoder = get_decoder(); + assert(_shared_decoder_lock != NULL, "Just check"); + bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; + MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true); + AbstractDecoder* decoder = error_handling_thread ? + get_error_handler_instance(): get_shared_instance(); assert(decoder != NULL, "null decoder"); return decoder->demangle(symbol, buf, buflen); } bool Decoder::can_decode_C_frame_in_vm() { - assert(_decoder_lock != NULL, "Just check"); - MutexLockerEx locker(_decoder_lock, true); - NullDecoder* decoder = get_decoder(); + assert(_shared_decoder_lock != NULL, "Just check"); + bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid; + MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true); + AbstractDecoder* decoder = error_handling_thread ? + get_error_handler_instance(): get_shared_instance(); assert(decoder != NULL, "null decoder"); return decoder->can_decode_C_frame_in_vm(); } -// shutdown real decoder and replace it with -// _do_nothing_decoder +/* + * Shutdown shared decoder and replace it with + * _do_nothing_decoder. Do nothing with error handler + * instance, since the JVM is going down. + */ void Decoder::shutdown() { - assert(_decoder_lock != NULL, "Just check"); - MutexLockerEx locker(_decoder_lock, true); + assert(_shared_decoder_lock != NULL, "Just check"); + MutexLockerEx locker(_shared_decoder_lock, true); - if (_decoder != NULL && _decoder != &_do_nothing_decoder) { - delete _decoder; + if (_shared_decoder != NULL && + _shared_decoder != &_do_nothing_decoder) { + delete _shared_decoder; } - _decoder = &_do_nothing_decoder; + _shared_decoder = &_do_nothing_decoder; } diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/utilities/decoder.hpp --- a/hotspot/src/share/vm/utilities/decoder.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/utilities/decoder.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -29,7 +29,7 @@ #include "memory/allocation.hpp" #include "runtime/mutex.hpp" -class NullDecoder: public CHeapObj { +class AbstractDecoder : public CHeapObj { public: // status code for decoding native C frame enum decoder_status { @@ -43,6 +43,34 @@ helper_init_error // SymInitialize failed (Windows only) }; + // decode an pc address to corresponding function name and an offset from the beginning of + // the function + virtual bool decode(address pc, char* buf, int buflen, int* offset, + const char* modulepath = NULL) = 0; + // demangle a C++ symbol + virtual bool demangle(const char* symbol, char* buf, int buflen) = 0; + // if the decoder can decode symbols in vm + virtual bool can_decode_C_frame_in_vm() const = 0; + + virtual decoder_status status() const { + return _decoder_status; + } + + virtual bool has_error() const { + return is_error(_decoder_status); + } + + static bool is_error(decoder_status status) { + return (status > 0); + } + +protected: + decoder_status _decoder_status; +}; + +// Do nothing decoder +class NullDecoder : public AbstractDecoder { +public: NullDecoder() { _decoder_status = not_available; } @@ -61,40 +89,34 @@ virtual bool can_decode_C_frame_in_vm() const { return false; } - - virtual decoder_status status() const { - return _decoder_status; - } - - virtual bool has_error() const { - return is_error(_decoder_status); - } - - static bool is_error(decoder_status status) { - return (status > 0); - } - -protected: - decoder_status _decoder_status; }; -class Decoder: AllStatic { +class Decoder : AllStatic { public: static bool decode(address pc, char* buf, int buflen, int* offset, const char* modulepath = NULL); static bool demangle(const char* symbol, char* buf, int buflen); static bool can_decode_C_frame_in_vm(); + // shutdown shared instance static void shutdown(); protected: - static NullDecoder* get_decoder(); + // shared decoder instance, _shared_instance_lock is needed + static AbstractDecoder* get_shared_instance(); + // a private instance for error handler. Error handler can be + // triggered almost everywhere, including signal handler, where + // no lock can be taken. So the shared decoder can not be used + // in this scenario. + static AbstractDecoder* get_error_handler_instance(); + static AbstractDecoder* create_decoder(); private: - static NullDecoder* _decoder; - static NullDecoder _do_nothing_decoder; + static AbstractDecoder* _shared_decoder; + static AbstractDecoder* _error_handler_decoder; + static NullDecoder _do_nothing_decoder; protected: - static Mutex* _decoder_lock; + static Mutex* _shared_decoder_lock; }; #endif // SHARE_VM_UTILITIES_DECODER_HPP diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/utilities/decoder_elf.hpp --- a/hotspot/src/share/vm/utilities/decoder_elf.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/utilities/decoder_elf.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -30,7 +30,7 @@ #include "utilities/decoder.hpp" #include "utilities/elfFile.hpp" -class ElfDecoder: public NullDecoder { +class ElfDecoder : public AbstractDecoder { public: ElfDecoder() { diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/utilities/events.cpp --- a/hotspot/src/share/vm/utilities/events.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/utilities/events.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -68,6 +68,10 @@ } } +void Events::print() { + print_all(tty); +} + void Events::init() { if (LogEvents) { _messages = new StringEventLog("Events"); diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/utilities/events.hpp --- a/hotspot/src/share/vm/utilities/events.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/utilities/events.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -35,20 +35,12 @@ // This facility is extremly useful for post-mortem debugging. The eventlog // often provides crucial information about events leading up to the crash. // -// All arguments past the format string must be passed as an intptr_t. -// -// To log a single event use: -// Events::log("New nmethod has been created " INTPTR_FORMAT, nm); -// -// To log a block of events use: -// EventMark m("GarbageCollecting %d", (intptr_t)gc_number); -// -// The constructor to eventlog indents the eventlog until the -// destructor has been executed. -// -// IMPLEMENTATION RESTRICTION: -// Max 3 arguments are saved for each logged event. -// +// Abstractly the logs can record whatever they way but normally they +// would record at least a timestamp and the current Thread, along +// with whatever data they need in a ring buffer. Commonly fixed +// length text messages are recorded for simplicity but other +// strategies could be used. Several logs are provided by default but +// new instances can be created as needed. // The base event log dumping class that is registered for dumping at // crash time. This is a very generic interface that is mainly here @@ -79,7 +71,7 @@ template class EventLogBase : public EventLog { template class EventRecord { public: - jlong timestamp; + double timestamp; Thread* thread; X data; }; @@ -102,6 +94,10 @@ _records = new EventRecord[length]; } + double fetch_timestamp() { + return os::elapsedTime(); + } + // move the ring buffer to next open slot and return the index of // the slot to use for the current message. Should only be called // while mutex is held. @@ -130,7 +126,7 @@ void print(outputStream* out, T& e); void print(outputStream* out, EventRecord& e) { - out->print("Event: " INT64_FORMAT " ", e.timestamp); + out->print("Event: %.3f ", e.timestamp); if (e.thread != NULL) { out->print("Thread " INTPTR_FORMAT " ", e.thread); } @@ -155,7 +151,7 @@ void logv(Thread* thread, const char* format, va_list ap) { if (!should_log()) return; - jlong timestamp = os::javaTimeNanos() / NANOSECS_PER_MILLISEC; + double timestamp = fetch_timestamp(); MutexLockerEx ml(&_mutex, Mutex::_no_safepoint_check_flag); int index = compute_log_index(); _records[index].thread = thread; @@ -193,9 +189,8 @@ public: static void print_all(outputStream* out); - static void print() { - print_all(tty); - } + // Dump all events to the tty + static void print(); // Logs a generic message with timestamp and format as printf. static void log(Thread* thread, const char* format, ...); @@ -255,6 +250,7 @@ out->print_cr("%s (%d events):", _name, _count); if (_count == 0) { out->print_cr("No events"); + out->cr(); return; } diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/utilities/preserveException.cpp --- a/hotspot/src/share/vm/utilities/preserveException.cpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/utilities/preserveException.cpp Wed Feb 22 10:17:57 2012 -0800 @@ -32,9 +32,9 @@ thread = Thread::current(); _thread = thread; _preserved_exception_oop = Handle(thread, _thread->pending_exception()); - _thread->clear_pending_exception(); // Needed to avoid infinite recursion _preserved_exception_line = _thread->exception_line(); _preserved_exception_file = _thread->exception_file(); + _thread->clear_pending_exception(); // Needed to avoid infinite recursion } diff -r eab1e4be8495 -r 09f5d262e329 hotspot/src/share/vm/utilities/vmError.hpp --- a/hotspot/src/share/vm/utilities/vmError.hpp Fri Feb 17 10:18:50 2012 -0800 +++ b/hotspot/src/share/vm/utilities/vmError.hpp Wed Feb 22 10:17:57 2012 -0800 @@ -27,11 +27,12 @@ #include "utilities/globalDefinitions.hpp" - +class Decoder; class VM_ReportJavaOutOfMemory; class VMError : public StackObj { friend class VM_ReportJavaOutOfMemory; + friend class Decoder; enum ErrorType { internal_error = 0xe0000000, diff -r eab1e4be8495 -r 09f5d262e329 jaxp/.hgtags --- a/jaxp/.hgtags Fri Feb 17 10:18:50 2012 -0800 +++ b/jaxp/.hgtags Wed Feb 22 10:17:57 2012 -0800 @@ -147,3 +147,4 @@ 95102fd334183d15dc98a95dd0d749527b6c7300 jdk8-b23 7836655e2495646c462f13de73dcc3ada197b64f jdk8-b24 bb694c151fc7b5c8f9edc8af6a80738530feacaf jdk8-b25 +dbb7283c197b27da1fc12ae8a83785c851b68c12 jdk8-b26 diff -r eab1e4be8495 -r 09f5d262e329 jaxws/.hgtags --- a/jaxws/.hgtags Fri Feb 17 10:18:50 2012 -0800 +++ b/jaxws/.hgtags Wed Feb 22 10:17:57 2012 -0800 @@ -147,3 +147,4 @@ 25ce7a0004874273f6aeda14e7c3538cba34bdf1 jdk8-b23 e0d90803439b174fe0b0033e09d50444ba12498f jdk8-b24 b376d901e006cd9e0c59733c84e190aace23eec6 jdk8-b25 +3518639eab6ce5c7b482bdb0a60342c392ab97a8 jdk8-b26 diff -r eab1e4be8495 -r 09f5d262e329 jaxws/build-defs.xml --- a/jaxws/build-defs.xml Fri Feb 17 10:18:50 2012 -0800 +++ b/jaxws/build-defs.xml Wed Feb 22 10:17:57 2012 -0800 @@ -101,7 +101,7 @@ + file="${primary.src.dir}/com/sun/tools/etc/META-INF/services/com.sun.tools.internal.ws.wscompile.Plugin"/> diff -r eab1e4be8495 -r 09f5d262e329 jaxws/jaxws.properties --- a/jaxws/jaxws.properties Fri Feb 17 10:18:50 2012 -0800 +++ b/jaxws/jaxws.properties Wed Feb 22 10:17:57 2012 -0800 @@ -25,8 +25,8 @@ drops.master.copy.base=${drops.dir} -jaxws_src.bundle.name=jdk8-jaxws2_2_4-b01-2011_07_22.zip -jaxws_src.bundle.md5.checksum=f64bedd3c512e6b1ca265fda2feb0905 +jaxws_src.bundle.name=jdk8-jaxws-2_2-SNAPSHOT-2012_01_11-patched.zip +jaxws_src.bundle.md5.checksum=005b93d1a2d6e66438c3c84c49c10b13 jaxws_src.master.bundle.dir=${drops.master.copy.base} jaxws_src.master.bundle.url.base=http://download.java.net/glassfish/components/jax-ws/openjdk/jdk8 diff -r eab1e4be8495 -r 09f5d262e329 jdk/make/com/sun/Makefile --- a/jdk/make/com/sun/Makefile Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/make/com/sun/Makefile Wed Feb 22 10:17:57 2012 -0800 @@ -47,7 +47,6 @@ org rowset net/httpserver SUBDIRS_misc = $(SCRIPT_SUBDIR) tracing servicetag nio demo -# Omit mirror since it's built with the apt tool. SUBDIRS_tools = tools include $(BUILDDIR)/common/Subdirs.gmk diff -r eab1e4be8495 -r 09f5d262e329 jdk/make/com/sun/nio/sctp/Exportedfiles.gmk --- a/jdk/make/com/sun/nio/sctp/Exportedfiles.gmk Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/make/com/sun/nio/sctp/Exportedfiles.gmk Wed Feb 22 10:17:57 2012 -0800 @@ -29,11 +29,11 @@ ifneq ($(PLATFORM), windows) FILES_export = \ - sun/nio/ch/SctpAssocChange.java \ - sun/nio/ch/SctpChannelImpl.java \ - sun/nio/ch/SctpNet.java \ - sun/nio/ch/SctpPeerAddrChange.java \ - sun/nio/ch/SctpResultContainer.java \ - sun/nio/ch/SctpServerChannelImpl.java \ - sun/nio/ch/SctpStdSocketOption.java + sun/nio/ch/sctp/AssociationChange.java \ + sun/nio/ch/sctp/SctpChannelImpl.java \ + sun/nio/ch/sctp/SctpNet.java \ + sun/nio/ch/sctp/PeerAddrChange.java \ + sun/nio/ch/sctp/ResultContainer.java \ + sun/nio/ch/sctp/SctpServerChannelImpl.java \ + sun/nio/ch/sctp/SctpStdSocketOption.java endif diff -r eab1e4be8495 -r 09f5d262e329 jdk/make/com/sun/nio/sctp/FILES_java.gmk --- a/jdk/make/com/sun/nio/sctp/FILES_java.gmk Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/make/com/sun/nio/sctp/FILES_java.gmk Wed Feb 22 10:17:57 2012 -0800 @@ -42,25 +42,25 @@ com/sun/nio/sctp/SendFailedNotification.java \ com/sun/nio/sctp/ShutdownNotification.java \ \ - sun/nio/ch/SctpMessageInfoImpl.java \ - sun/nio/ch/SctpStdSocketOption.java + sun/nio/ch/sctp/MessageInfoImpl.java \ + sun/nio/ch/sctp/SctpStdSocketOption.java ifneq ($(PLATFORM), windows) FILES_java += \ - sun/nio/ch/SctpAssocChange.java \ - sun/nio/ch/SctpAssociationImpl.java \ - sun/nio/ch/SctpChannelImpl.java \ - sun/nio/ch/SctpMultiChannelImpl.java \ - sun/nio/ch/SctpNet.java \ - sun/nio/ch/SctpNotification.java \ - sun/nio/ch/SctpPeerAddrChange.java \ - sun/nio/ch/SctpResultContainer.java \ - sun/nio/ch/SctpSendFailed.java \ - sun/nio/ch/SctpServerChannelImpl.java \ - sun/nio/ch/SctpShutdown.java + sun/nio/ch/sctp/AssociationChange.java \ + sun/nio/ch/sctp/AssociationImpl.java \ + sun/nio/ch/sctp/PeerAddrChange.java \ + sun/nio/ch/sctp/ResultContainer.java \ + sun/nio/ch/sctp/SctpChannelImpl.java \ + sun/nio/ch/sctp/SctpMultiChannelImpl.java \ + sun/nio/ch/sctp/SctpNet.java \ + sun/nio/ch/sctp/SctpNotification.java \ + sun/nio/ch/sctp/SctpServerChannelImpl.java \ + sun/nio/ch/sctp/SendFailed.java \ + sun/nio/ch/sctp/Shutdown.java else FILES_java += \ - sun/nio/ch/SctpChannelImpl.java \ - sun/nio/ch/SctpMultiChannelImpl.java \ - sun/nio/ch/SctpServerChannelImpl.java + sun/nio/ch/sctp/SctpChannelImpl.java \ + sun/nio/ch/sctp/SctpMultiChannelImpl.java \ + sun/nio/ch/sctp/SctpServerChannelImpl.java endif diff -r eab1e4be8495 -r 09f5d262e329 jdk/make/com/sun/nio/sctp/Makefile --- a/jdk/make/com/sun/nio/sctp/Makefile Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/make/com/sun/nio/sctp/Makefile Wed Feb 22 10:17:57 2012 -0800 @@ -47,14 +47,16 @@ # # Find platform-specific C source files # -vpath %.c $(PLATFORM_SRC)/native/sun/nio/ch +vpath %.c $(PLATFORM_SRC)/native/sun/nio/ch/sctp # # Include nio.h, net_util.h, sun_nio_ch_IOStatus.h, etc # OTHER_INCLUDES += \ -I$(SHARE_SRC)/native/sun/nio/ch \ + -I$(SHARE_SRC)/native/sun/nio/ch/sctp \ -I$(SHARE_SRC)/native/java/net \ + -I$(PLATFORM_SRC)/native/sun/nio/ch \ -I$(PLATFORM_SRC)/native/java/net \ -I$(CLASSHDRDIR)/../../../../java/java.nio/nio/CClassHeaders @@ -75,5 +77,5 @@ clean clobber:: $(RM) -r $(CLASSDESTDIR)/com/sun/nio/sctp - $(RM) -r $(CLASSDESTDIR)/sun/nio/ch + $(RM) -r $(CLASSDESTDIR)/sun/nio/ch/sctp diff -r eab1e4be8495 -r 09f5d262e329 jdk/make/com/sun/nio/sctp/mapfile-vers --- a/jdk/make/com/sun/nio/sctp/mapfile-vers Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/make/com/sun/nio/sctp/mapfile-vers Wed Feb 22 10:17:57 2012 -0800 @@ -25,30 +25,30 @@ SUNWprivate_1.1 { global: - Java_sun_nio_ch_SctpNet_init; - Java_sun_nio_ch_SctpNet_socket0; - Java_sun_nio_ch_SctpNet_bindx; - Java_sun_nio_ch_SctpNet_branch0; - Java_sun_nio_ch_SctpNet_listen0; - Java_sun_nio_ch_SctpNet_connect0; - Java_sun_nio_ch_SctpNet_close0; - Java_sun_nio_ch_SctpNet_preClose0; - Java_sun_nio_ch_SctpNet_getLocalAddresses0; - Java_sun_nio_ch_SctpNet_getRemoteAddresses0; - Java_sun_nio_ch_SctpNet_getPrimAddrOption0; - Java_sun_nio_ch_SctpNet_setPrimAddrOption0; - Java_sun_nio_ch_SctpNet_setPeerPrimAddrOption0; - Java_sun_nio_ch_SctpNet_getInitMsgOption0; - Java_sun_nio_ch_SctpNet_setInitMsgOption0; - Java_sun_nio_ch_SctpNet_getIntOption0; - Java_sun_nio_ch_SctpNet_setIntOption0; - Java_sun_nio_ch_SctpNet_shutdown0; - Java_sun_nio_ch_SctpChannelImpl_initIDs; - Java_sun_nio_ch_SctpChannelImpl_checkConnect; - Java_sun_nio_ch_SctpChannelImpl_receive0; - Java_sun_nio_ch_SctpChannelImpl_send0; - Java_sun_nio_ch_SctpServerChannelImpl_initIDs; - Java_sun_nio_ch_SctpServerChannelImpl_accept0; + Java_sun_nio_ch_sctp_SctpNet_init; + Java_sun_nio_ch_sctp_SctpNet_socket0; + Java_sun_nio_ch_sctp_SctpNet_bindx; + Java_sun_nio_ch_sctp_SctpNet_branch0; + Java_sun_nio_ch_sctp_SctpNet_listen0; + Java_sun_nio_ch_sctp_SctpNet_connect0; + Java_sun_nio_ch_sctp_SctpNet_close0; + Java_sun_nio_ch_sctp_SctpNet_preClose0; + Java_sun_nio_ch_sctp_SctpNet_getLocalAddresses0; + Java_sun_nio_ch_sctp_SctpNet_getRemoteAddresses0; + Java_sun_nio_ch_sctp_SctpNet_getPrimAddrOption0; + Java_sun_nio_ch_sctp_SctpNet_setPrimAddrOption0; + Java_sun_nio_ch_sctp_SctpNet_setPeerPrimAddrOption0; + Java_sun_nio_ch_sctp_SctpNet_getInitMsgOption0; + Java_sun_nio_ch_sctp_SctpNet_setInitMsgOption0; + Java_sun_nio_ch_sctp_SctpNet_getIntOption0; + Java_sun_nio_ch_sctp_SctpNet_setIntOption0; + Java_sun_nio_ch_sctp_SctpNet_shutdown0; + Java_sun_nio_ch_sctp_SctpChannelImpl_initIDs; + Java_sun_nio_ch_sctp_SctpChannelImpl_checkConnect; + Java_sun_nio_ch_sctp_SctpChannelImpl_receive0; + Java_sun_nio_ch_sctp_SctpChannelImpl_send0; + Java_sun_nio_ch_sctp_SctpServerChannelImpl_initIDs; + Java_sun_nio_ch_sctp_SctpServerChannelImpl_accept0; JNI_OnLoad; local: *; diff -r eab1e4be8495 -r 09f5d262e329 jdk/make/common/Release.gmk --- a/jdk/make/common/Release.gmk Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/make/common/Release.gmk Wed Feb 22 10:17:57 2012 -0800 @@ -132,7 +132,6 @@ JDK_MAN_PAGES = \ $(JRE_MAN_PAGES) \ appletviewer.1 \ - apt.1 \ extcheck.1 \ idlj.1 \ jar.1 \ @@ -264,7 +263,6 @@ com/sun/java/swing \ com/sun/javadoc \ com/sun/jmx \ - com/sun/mirror \ com/sun/source \ com/sun/naming \ com/sun/security/auth \ @@ -346,7 +344,6 @@ com/sun/javadoc \ com/sun/jdi \ com/sun/jarsigner \ - com/sun/mirror \ com/sun/source \ com/sun/tools/classfile \ com/sun/tools/doclets \ @@ -356,16 +353,16 @@ com/sun/tools/hat \ com/sun/tools/javac \ com/sun/tools/javadoc \ - com/sun/tools/apt \ com/sun/tools/javah \ com/sun/tools/javap \ com/sun/tools/corba \ com/sun/tools/internal/xjc \ com/sun/tools/internal/ws \ - META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory \ - META-INF/services/com.sun.tools.xjc.Plugin \ + META-INF/services/com.sun.tools.internal.ws.wscompile.Plugin \ + META-INF/services/com.sun.tools.internal.xjc.Plugin \ com/sun/istack/internal/tools \ - com/sun/istack/internal/ws \ + com/sun/tools/internal/jxc/ap \ + com/sun/tools/internal/ws/wscompile/plugin/at_generated \ com/sun/codemodel \ com/sun/tools/internal/jxc \ com/sun/xml/internal/rngom \ @@ -438,7 +435,6 @@ java-rmi.cgi \ javac$(EXE_SUFFIX) \ javadoc$(EXE_SUFFIX) \ - apt$(EXE_SUFFIX) \ javah$(EXE_SUFFIX) \ javap$(EXE_SUFFIX) \ jcmd$(EXE_SUFFIX) \ @@ -525,13 +521,10 @@ $(ECHO) "com/sun/javadoc/" >> $@ $(ECHO) "com/sun/jdi/" >> $@ $(ECHO) "com/sun/jarsigner/" >> $@ - $(ECHO) "com/sun/mirror/" >> $@ $(ECHO) "com/sun/source/" >> $@ $(ECHO) "com/sun/istack/internal/tools/" >> $@ - $(ECHO) "com/sun/istack/internal/ws/" >> $@ $(ECHO) "META-INF/services/com.sun.jdi.connect.Connector" >> $@ $(ECHO) "META-INF/services/com.sun.jdi.connect.spi.TransportService" >> $@ - $(ECHO) "META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory" >> $@ $(ECHO) "META-INF/services/com.sun.tools.xjc.Plugin" >> $@ $(ECHO) "com/sun/tools/" >> $@ $(ECHO) "sun/jvmstat/" >> $@ @@ -1000,7 +993,7 @@ @# @# files that might not exist need to be touched. @# - $(TOUCH) $(CLASSBINDIR)/META-INF/services/com.sun.tools.xjc.Plugin + $(TOUCH) $(CLASSBINDIR)/META-INF/services/com.sun.tools.internal.xjc.Plugin @# @# lib/tools.jar @# diff -r eab1e4be8495 -r 09f5d262e329 jdk/make/common/internal/Defs-jaxws.gmk --- a/jdk/make/common/internal/Defs-jaxws.gmk Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/make/common/internal/Defs-jaxws.gmk Wed Feb 22 10:17:57 2012 -0800 @@ -34,7 +34,6 @@ javax/xml/ws \ javax/jws \ javax/annotation \ - com/sun/istack/internal \ com/sun/xml/internal/bind \ com/sun/xml/internal/fastinfoset \ com/sun/xml/internal/messaging \ @@ -42,13 +41,13 @@ com/sun/xml/internal/txw2 \ com/sun/xml/internal/ws \ com/sun/xml/internal/stream/buffer + NOT_USED_PACKAGES += \ com/sun/tools/internal/txw2 IMPORT_TOOLS_PACKAGES += \ com/sun/codemodel \ com/sun/istack/internal/tools \ - com/sun/istack/internal/ws \ com/sun/xml/internal/rngom \ com/sun/xml/internal/xsom \ com/sun/xml/internal/dtdparser \ @@ -56,6 +55,9 @@ com/sun/tools/internal/ws \ com/sun/tools/internal/jxc \ org/relaxng \ - META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory \ - META-INF/services/com.sun.tools.internal.xjc.Plugin + META-INF/services/com.sun.tools.internal.ws.wscompile.Plugin \ + META-INF/services/com.sun.tools.internal.xjc.Plugin \ + com/sun/tools/internal/jxc/ap \ + com/sun/tools/internal/ws/wscompile/plugin/at_generated + diff -r eab1e4be8495 -r 09f5d262e329 jdk/make/common/internal/Defs-langtools.gmk --- a/jdk/make/common/internal/Defs-langtools.gmk Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/make/common/internal/Defs-langtools.gmk Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 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 @@ -32,9 +32,7 @@ IMPORT_TOOLS_PACKAGES += \ com/sun/javadoc \ - com/sun/mirror \ com/sun/source \ - com/sun/tools/apt \ com/sun/tools/classfile \ com/sun/tools/doclets \ com/sun/tools/javac \ diff -r eab1e4be8495 -r 09f5d262e329 jdk/make/docs/Makefile --- a/jdk/make/docs/Makefile Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/make/docs/Makefile Wed Feb 22 10:17:57 2012 -0800 @@ -1,4 +1,4 @@ -# Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 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 @@ -358,64 +358,6 @@ ############################################################# # -# mirrordocs -# - -# Part of langtools -ifdef LANGTOOLS_DIST - ALL_OTHER_TARGETS += mirrordocs -endif - -MIRROR_DOCDIR := $(JDK_API_DOCSDIR)/apt/mirror -MIRROR2COREAPI := ../../$(JDKJRE2COREAPI) -MIRROR_DOCTITLE := Mirror API -MIRROR_WINDOWTITLE := Mirror API -MIRROR_HEADER := Mirror API -MIRROR_BOTTOM := $(call CommonBottom,$(MIRROR_FIRST_COPYRIGHT_YEAR)) -MIRROR_GROUPNAME := Packages -MIRROR_OVERVIEW := $(IMPORTSRCDIR)/com/sun/mirror/overview.html -MIRROR_REGEXP := com.sun.mirror.* -# MIRROR_PKGS is located in NON_CORE_PKGS.gmk - -# The index.html, options, and packages files -MIRROR_INDEX_FILE = $(MIRROR_DOCDIR)/index.html -MIRROR_OPTIONS_FILE = $(DOCSTMPDIR)/mirror.options -MIRROR_PACKAGES_FILE = $(DOCSTMPDIR)/mirror.packages - -mirrordocs: $(MIRROR_INDEX_FILE) - -# Set relative location to core api document root -$(MIRROR_INDEX_FILE): GET2DOCSDIR=$(MIRROR2COREAPI)/.. - -# Run javadoc if the index file is out of date or missing -$(MIRROR_INDEX_FILE): $(MIRROR_OPTIONS_FILE) $(MIRROR_PACKAGES_FILE) - $(prep-javadoc) - $(call JavadocSummary,$(MIRROR_OPTIONS_FILE),$(MIRROR_PACKAGES_FILE)) - $(JAVADOC_CMD) $(JAVADOC_VM_MEMORY_FLAGS) -d $(@D) \ - @$(MIRROR_OPTIONS_FILE) @$(MIRROR_PACKAGES_FILE) - -# Create file with javadoc options in it -$(MIRROR_OPTIONS_FILE): $(MIRROR_OVERVIEW) - $(prep-target) - @($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \ - $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \ - $(call OptionPair,-encoding,ascii) ; \ - $(call OptionPair,-overview,$(MIRROR_OVERVIEW)) ; \ - $(call OptionPair,-doctitle,$(MIRROR_DOCTITLE)) ; \ - $(call OptionPair,-windowtitle,$(MIRROR_WINDOWTITLE) $(DRAFT_WINTITLE));\ - $(call OptionPair,-header,$(MIRROR_HEADER)$(DRAFT_HEADER)) ; \ - $(call OptionPair,-bottom,$(MIRROR_BOTTOM)$(DRAFT_BOTTOM)) ; \ - $(call OptionTrip,-group,$(MIRROR_GROUPNAME),$(MIRROR_REGEXP)); \ - $(call OptionTrip,-linkoffline,$(MIRROR2COREAPI),$(COREAPI_DOCSDIR)); \ - ) >> $@ - -# Create a file with the package names in it -$(MIRROR_PACKAGES_FILE): $(DIRECTORY_CACHE) $(call PackageDependencies,$(MIRROR_PKGS)) - $(prep-target) - $(call PackageFilter,$(MIRROR_PKGS)) - -############################################################# -# # docletapidocs # diff -r eab1e4be8495 -r 09f5d262e329 jdk/make/docs/NON_CORE_PKGS.gmk --- a/jdk/make/docs/NON_CORE_PKGS.gmk Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/make/docs/NON_CORE_PKGS.gmk Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ # -# Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2002, 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 @@ -71,11 +71,6 @@ TAGLETAPI_FILE = com/sun/tools/doclets/Taglet.java -MIRROR_PKGS = com.sun.mirror.apt \ - com.sun.mirror.declaration \ - com.sun.mirror.type \ - com.sun.mirror.util - ATTACH_PKGS = com.sun.tools.attach \ com.sun.tools.attach.spi diff -r eab1e4be8495 -r 09f5d262e329 jdk/make/java/management/mapfile-vers --- a/jdk/make/java/management/mapfile-vers Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/make/java/management/mapfile-vers Wed Feb 22 10:17:57 2012 -0800 @@ -54,9 +54,6 @@ Java_sun_management_GcInfoBuilder_getLastGcInfo0; Java_sun_management_GcInfoBuilder_getNumGcExtAttributes; Java_sun_management_HotSpotDiagnostic_dumpHeap; - Java_sun_management_HotSpotDiagnostic_executeDiagnosticCommand0; - Java_sun_management_HotSpotDiagnostic_getDiagnosticCommandInfo0; - Java_sun_management_HotSpotDiagnostic_getDiagnosticCommands0; Java_sun_management_HotspotThread_getInternalThreadCount; Java_sun_management_HotspotThread_getInternalThreadTimes0; Java_sun_management_MemoryImpl_getMemoryManagers0; diff -r eab1e4be8495 -r 09f5d262e329 jdk/make/launchers/Makefile --- a/jdk/make/launchers/Makefile Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/make/launchers/Makefile Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ # -# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2004, 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 @@ -55,7 +55,6 @@ define make-all-launchers $(make-appletviewer) -$(call make-launcher, apt, com.sun.tools.apt.Main, , ) $(call make-launcher, extcheck, com.sun.tools.extcheck.Main, , ) $(call make-launcher, idlj, com.sun.tools.corba.se.idl.toJavaPortable.Compile, , ) $(call make-launcher, jar, sun.tools.jar.Main, , ) diff -r eab1e4be8495 -r 09f5d262e329 jdk/make/launchers/Makefile.launcher --- a/jdk/make/launchers/Makefile.launcher Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/make/launchers/Makefile.launcher Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ # -# Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2004, 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 @@ -47,10 +47,6 @@ endif # Some tools need the wildcard expansion option -ifeq ($(PROGRAM),apt) - WILDCARDS=true - NEVER_ACT_AS_SERVER_CLASS_MACHINE=true -endif ifeq ($(PROGRAM),javac) WILDCARDS=true MAIN_JAVA_ARGS += -J-Xss4m -J-ea:com.sun.tools... diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/linux/doc/man/apt.1 --- a/jdk/src/linux/doc/man/apt.1 Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,153 +0,0 @@ -." Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. -." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -." -." This code is free software; you can redistribute 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. -." -.TH apt 1 "10 May 2011" - -.LP -.SH "NAME" -.LP -.LP -\f2apt\fP \- annotation processing tool -.LP -.SH "SYNOPSIS" -.LP -.LP -\f2apt [\-classpath \fP\f2classpath\fP] [\-sourcepath \f2sourcepath\fP] [\-d \f2directory\fP] [\-s \f2directory\fP] [\-factorypath \f2path\fP] [\-factory \f2class\fP] [\-print] [\-nocompile] [\-A\f2key\fP[\f2=val\fP] ...] [\f2javac option\fP] sourcefiles [@files] -.LP -.SH "PARAMETERS" -.LP -.LP -Options may be in any order. For a discussion of parameters which apply to a specific option, see OPTIONS below. -.LP -.RS 3 -.TP 3 -sourcefiles -Zero or more source files to be processed. -.TP 3 -@files -One or more files that list source files or other options -.RE - -.LP -.SH "DESCRIPTION" -.LP -.LP -\f3Note\fP: The \f2apt\fP tool and its associated API contained in the package \f2com.sun.mirror\fP have been deprecated since JDK 7 and are planned to be removed in the next major JDK release. Use the options available in the \f2javac(1)\fP tool and the APIs contained in the packages \f2javax.annotation.processing\fP and \f2javax.lang.model\fP to process annotations. -.LP -.LP -The tool \f2apt\fP, annotation processing tool, includes reflective APIs and supporting infrastructure to process program annotations. The \f2apt\fP reflective APIs provide a build\-time, source\-based, read\-only view of program structure. These reflective APIs are designed to cleanly model the Java(TM) programming language's type system after the addition of generics. First, \f2apt\fP runs annotation processors that can produce new source code and other files. Next, \f2apt\fP can cause compilation of both original and generated source files, easing development. The reflective APIs and other APIs used to interact with the tool are subpackages of \f2com.sun.mirror\fP. -.LP -.LP -A fuller discussion of how the tool operates as well as instructions for developing with \f2apt\fP are in -.na -\f4Getting Started with \fP\f4apt\fP. @ -.fi -http://download.oracle.com/javase/7/docs/technotes/guides/apt/GettingStarted.html -.LP -.SH "OPTIONS" -.LP -.SS -apt specific options -.LP -.RS 3 -.TP 3 -\-s dir -Specify the directory root under which processor\-generated source files will be placed; files are placed in subdirectories based on package namespace. -.TP 3 -\-nocompile -Do not compile source files to class files. -.TP 3 -\-print -Print out textual representation of specified types; perform no annotation processing or compilation. -.TP 3 -\-A[key[=val]] -Options to pass to annotation processors \-\- these are not interpreted by \f2apt\fP directly, but are made available for use by individual processors -.TP 3 -\-factorypath path -Specify where to find annotation processor factories; if this option is used, the classpath is \f2not\fP searched for factories. -.TP 3 -\-factory classname -Name of annotation processor factory to use; bypasses default discovery process -.TP 3 -\-version -Print version information. -.TP 3 -\-X -Display information about non\-standard options. -.RE - -.LP -.SS -Options shared with javac -.LP -.RS 3 -.TP 3 -\-d dir -Specify where to place processor and javac generated class files -.TP 3 -\-cp path or \-classpath path -Specify where to find user class files and annotation processor factories. If \f2\-factorypath\fP is given, the classpath is not searched for factories. -.RE - -.LP -.LP -Consult the javac(1) man page for information on \f2javac\fP options. -.LP -.SS -Non\-Standard Options -.LP -.RS 3 -.TP 3 -\-XListAnnotationTypes -List found annotation types. -.TP 3 -\-XListDeclarations -List specified and included declarations. -.TP 3 -\-XPrintAptRounds -Print information about initial and recursive \f2apt\fP rounds. -.TP 3 -\-XPrintFactoryInfo -Print information about which annotations a factory is asked to process. -.TP 3 -\-XclassesAsDecls -Treat both class and source files as declarations to process. -.RE - -.LP -.LP -\f3Note\fP: Because these options are non\-standard, they are subject to change without notice. -.LP -.SH "NOTES" -.LP -.LP -The \f2apt\fP tool and its associated API contained in the package \f2com.sun.mirror\fP have been deprecated since JDK 7 and are planned to be removed in the next major JDK release. Use the options available in the \f2javac(1)\fP tool and the APIs contained in the packages \f2javax.annotation.processing\fP and \f2javax.lang.model\fP to process annotations. -.LP -.SH "SEE ALSO" -.LP -.RS 3 -.TP 2 -o -javac(1), java(1) -.RE - -.LP - diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/linux/doc/man/ja/apt.1 --- a/jdk/src/linux/doc/man/ja/apt.1 Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,153 +0,0 @@ -." Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. -." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -." -." This code is free software; you can redistribute 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. -." -.TH apt 1 "07 May 2011" - -.LP -.SH "NAME" -.LP -.LP -\f2apt\fP \- Ãí¼á½èÍý¥Ä¡¼¥ë -.LP -.SH "·Á¼°" -.LP -.LP -\f2apt [\-classpath \fP\f2classpath\fP] [\-sourcepath \f2sourcepath\fP] [\-d \f2directory\fP] [\-s \f2directory\fP] [\-factorypath \f2path\fP] [\-factory \f2class\fP] [\-print] [\-nocompile] [\-A\f2key\fP[\f2=val\fP] ...] [\f2javac option\fP] sourcefiles [@files] -.LP -.SH "¥Ñ¥é¥á¡¼¥¿" -.LP -.LP -¥ª¥×¥·¥ç¥ó¤Î»ØÄê½ç½ø¤Ë·è¤Þ¤ê¤Ï¤¢¤ê¤Þ¤»¤ó¡£ÆÃÄê¤Î¥ª¥×¥·¥ç¥ó¤ËŬÍѤµ¤ì¤ë¥Ñ¥é¥á¡¼¥¿¤Ë¤Ä¤¤¤Æ¤Ï¡¢²¼µ­¤Î¡Ö¥ª¥×¥·¥ç¥ó¡×¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ -.LP -.RS 3 -.TP 3 -sourcefiles -¥¼¥í¡¢1 ¤Ä¡¢¤Þ¤¿¤ÏÊ£¿ô¤Î½èÍýÂоݤΥ½¡¼¥¹¥Õ¥¡¥¤¥ë -.TP 3 -@files -¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤Þ¤¿¤Ï¾¤Î¥ª¥×¥·¥ç¥ó¤ò°ìÍ÷ɽ¼¨¤¹¤ë 1 ¤Ä¤Þ¤¿¤ÏÊ£¿ô¤Î¥Õ¥¡¥¤¥ë -.RE - -.LP -.SH "ÀâÌÀ" -.LP -.LP -\f3Ãí\fP: \f2apt\fP ¥Ä¡¼¥ë¤È¡¢¥Ñ¥Ã¥±¡¼¥¸ \f2com.sun.mirror\fP ¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë¤½¤ì¤Ë´ØÏ¢¤·¤¿ API ¤Ï¡¢JDK 7 °Ê¹ßÈó¿ä¾©¤Ë¤Ê¤Ã¤Æ¤ª¤ê¡¢JDK ¤Î¼¡¤Î¥á¥¸¥ã¡¼¥ê¥ê¡¼¥¹¤Çºï½ü¤µ¤ì¤ëͽÄê¤Ç¤¹¡£\f2javac(1)\fP ¥Ä¡¼¥ë¤ÇÍøÍѲÄǽ¤Ê¥ª¥×¥·¥ç¥ó¤È¡¢¥Ñ¥Ã¥±¡¼¥¸ \f2javax.annotation.processing\fP ¤ª¤è¤Ó \f2javax.lang.model\fP ¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë API ¤ò»ÈÍѤ·¤Æ¡¢Ãí¼á¤ò½èÍý¤·¤Æ¤¯¤À¤µ¤¤¡£ -.LP -.LP -Ãí¼á½èÍý¥Ä¡¼¥ë \f2apt\fP ¤Ï¡¢¥ê¥Õ¥ì¥¯¥È API ¤È¥µ¥Ý¡¼¥È¥¤¥ó¥Õ¥é¥¹¥È¥é¥¯¥Á¥ã¡¼¤«¤é¹½À®¤µ¤ì¡¢¥×¥í¥°¥é¥àÃí¼á¤ò½èÍý¤·¤Þ¤¹¡£\f2apt\fP ¥ê¥Õ¥ì¥¯¥È API ¤Ï¡¢ ¹½ÃÛ»þ¤Î¥½¡¼¥¹¥Ù¡¼¥¹¤Ç¡¢¥×¥í¥°¥é¥à¹½Â¤¤Ë´Ø¤¹¤ëÆɤ߼è¤êÀìÍѥӥ塼¤òÄ󶡤·¤Þ¤¹¡£¤³¤ì¤é¤Î¥ê¥Õ¥ì¥¯¥È API ¤Ï¡¢Áí¾Î¤òÄɲä·¤¿¸å¤Ë¡¢Java(TM) ¥×¥í¥°¥é¥ß¥ó¥°¸À¸ì¤Î·¿¥·¥¹¥Æ¥à¤òÀµ¤·¤¯¥â¥Ç¥ë²½¤¹¤ë¤è¤¦¤ËÀ߷פµ¤ì¤Æ¤¤¤Þ¤¹¡£ºÇ½é¤Ë¡¢\f2apt\fP ¤Ï¡¢¿·¤·¤¤¥½¡¼¥¹¥³¡¼¥É¤È¾¤Î¥Õ¥¡¥¤¥ë¤òºîÀ®¤¹¤ëÃí¼á¥×¥í¥»¥Ã¥µ¤ò¼Â¹Ô¤·¤Þ¤¹¡£¼¡¤Ë¡¢\f2apt\fP ¤Ï¡¢¸µ¤Î¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤ÈÀ¸À®¤·¤¿¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤ÎξÊý¤ò¥³¥ó¥Ñ¥¤¥ë¤¹¤ë¤¿¤á¡¢³«È¯¤¬³Ú¤Ë¤Ê¤ê¤Þ¤¹¡£¥Ä¡¼¥ë¤È¤Î¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤Ë»ÈÍѤµ¤ì¤ë¥ê¥Õ¥ì¥¯¥È API ¤Ê¤É¤Î API ¤Ï¡¢\f2com.sun.mirror\fP ¤Î¥µ¥Ö¥Ñ¥Ã¥±¡¼¥¸¤Ç¤¹¡£ -.LP -.LP -¥Ä¡¼¥ë¤Îµ¡Ç½¤Ë´Ø¤¹¤ë¾ÜºÙ¤È¡¢\f2apt\fP ¤ò»ÈÍѤ·¤¿³«È¯ÊýË¡¤Ë¤Ä¤¤¤Æ¤Ï¡¢ -.na -\f4¡Öapt ÆþÌç¡×\fP @ -.fi -http://java.sun.com/javase/6/docs/technotes/guides/apt/GettingStarted.html¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ -.LP -.SH "¥ª¥×¥·¥ç¥ó" -.LP -.SS -apt ¸ÇÍ­¤Î¥ª¥×¥·¥ç¥ó -.LP -.RS 3 -.TP 3 -\-s dir -¥×¥í¥»¥Ã¥µ¤ÎÀ¸À®¤¹¤ë¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤òÃÖ¤¯¥Ç¥£¥ì¥¯¥È¥ê¥ë¡¼¥È¤ò»ØÄꤷ¤Þ¤¹¡£ ¥Õ¥¡¥¤¥ë¤Ï¡¢¥Ñ¥Ã¥±¡¼¥¸¤Î̾Á°¶õ´Ö¤Ë´ð¤Å¤¤¤Æ¥µ¥Ö¥Ç¥£¥ì¥¯¥È¥ê¤ËÃÖ¤«¤ì¤Þ¤¹¡£ -.TP 3 -\-nocompile -¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤ò¥¯¥é¥¹¥Õ¥¡¥¤¥ë¤Ë¥³¥ó¥Ñ¥¤¥ë¤·¤Þ¤»¤ó¡£ -.TP 3 -\-print -»ØÄꤷ¤¿¥¿¥¤¥×¤Î¥Æ¥­¥¹¥Èɽ¸½¤ò½ÐÎϤ·¤Þ¤¹¡£ Ãí¼á½èÍý¤Þ¤¿¤Ï¥³¥ó¥Ñ¥¤¥ë¤Ï¹Ô¤¤¤Þ¤»¤ó¡£ -.TP 3 -\-A[key[=val]] -Ãí¼á¥×¥í¥»¥Ã¥µ¤ØÅϤ¹¥ª¥×¥·¥ç¥ó¤Ç¤¹¡£ ¤³¤Î¥ª¥×¥·¥ç¥ó¤Ï¡¢\f2apt\fP ¤¬Ä¾Àܲò¼á¤¹¤ë¤Î¤Ç¤Ï¤Ê¤¯¡¢¤½¤ì¤¾¤ì¤Î¥×¥í¥»¥Ã¥µ¤Ë¤è¤Ã¤Æ»ÈÍѤǤ­¤ë¤è¤¦¤ËÊѤ¨¤é¤ì¤Þ¤¹¡£ -.TP 3 -\-factorypath path -Ãí¼á¥×¥í¥»¥Ã¥µ¥Õ¥¡¥¯¥È¥ê¤ò¸¡º÷¤¹¤ë¾ì½ê¤ò»ØÄꤷ¤Þ¤¹¡£ ¤³¤Î¥ª¥×¥·¥ç¥ó¤ò»ÈÍѤ¹¤ë¾ì¹ç¡¢¥¯¥é¥¹¥Ñ¥¹¤Î¥Õ¥¡¥¯¥È¥ê¤Ï¸¡º÷¤µ¤ì¤Þ¤»¤ó¡£ -.TP 3 -\-factory classname -»ÈÍѤ¹¤ëÃí¼á¥×¥í¥»¥Ã¥µ¥Õ¥¡¥¯¥È¥ê¤Î̾Á°¤Ç¤¹¡£ ¥Ç¥Õ¥©¥ë¥È¤Î¸¡½Ð¥×¥í¥»¥¹¤ò¾Êά¤·¤Þ¤¹¡£ -.TP 3 -\-version -¥Ð¡¼¥¸¥ç¥ó¾ðÊó¤ò½ÐÎϤ·¤Þ¤¹¡£ -.TP 3 -\-X -Èóɸ½à¥ª¥×¥·¥ç¥ó¤Ë´Ø¤¹¤ë¾ðÊó¤òɽ¼¨¤·¤Þ¤¹¡£ -.RE - -.LP -.SS -javac ¤È¶¦ÍѤ¹¤ë¥ª¥×¥·¥ç¥ó -.LP -.RS 3 -.TP 3 -\-d dir -¥×¥í¥»¥Ã¥µ¤È javac À¸À®¤Î¥¯¥é¥¹¥Õ¥¡¥¤¥ë¤òÃÖ¤¯¾ì½ê¤ò»ØÄꤷ¤Þ¤¹¡£ -.TP 3 -\-cp path ¤Þ¤¿¤Ï \-classpath path -¥æ¡¼¥¶¡¼¥¯¥é¥¹¥Õ¥¡¥¤¥ë¤ÈÃí¼á¥×¥í¥»¥Ã¥µ¥Õ¥¡¥¯¥È¥ê¤ò¸¡º÷¤¹¤ë¾ì½ê¤ò»ØÄꤷ¤Þ¤¹¡£\f2\-factorypath\fP ¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢¥¯¥é¥¹¥Ñ¥¹¤Î¥Õ¥¡¥¯¥È¥ê¤Ï¸¡º÷¤µ¤ì¤Þ¤»¤ó¡£ -.RE - -.LP -.LP -\f2javac\fP ¥ª¥×¥·¥ç¥ó¤Î¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¡¢javac(1) ¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£ -.LP -.SS -Èóɸ½à¥ª¥×¥·¥ç¥ó -.LP -.RS 3 -.TP 3 -\-XListAnnotationTypes -Ãí¼á¤Î·¿¤Ë¸¡½Ð¤µ¤ì¤ë¥ê¥¹¥È. -.TP 3 -\-XListDeclarations -»ØÄꤪ¤è¤ÓÀë¸À¤¬¥¤¥ó¥¯¥ë¡¼¥É¤µ¤ì¤ë¥ê¥¹¥È. -.TP 3 -\-XPrintAptRounds -½é´ü¤ª¤è¤ÓºÆµ¢Åª¤Ê \f2apt\fP ¥é¥¦¥ó¥É¤Ë´Ø¤¹¤ë¾ðÊó¤ò½ÐÎϤ¹¤ë. -.TP 3 -\-XPrintFactoryInfo -½èÍý¤òÍ׵᤹¤ë¥Õ¥¡¥¯¥È¥ê¤ÎÃí¼á¤Ë´Ø¤¹¤ë¾ðÊó¤ò½ÐÎϤ¹¤ë. -.TP 3 -\-XclassesAsDecls -¥¯¥é¥¹¥Õ¥¡¥¤¥ë¤È¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤ÎξÊý¤ò¡¢½èÍýÂоݤÎÀë¸À¤È¤·¤Æ½èÍý¤·¤Þ¤¹¡£ -.RE - -.LP -.LP -\f3Ãí\fP: ¤³¤ì¤é¤ÏÈóɸ½à¥ª¥×¥·¥ç¥ó¤Ê¤Î¤Ç¡¢Í½¹ð¤Ê¤¯Êѹ¹¤µ¤ì¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£ -.LP -.SH "Ãí" -.LP -.LP -\f2apt\fP ¥Ä¡¼¥ë¤È¡¢¥Ñ¥Ã¥±¡¼¥¸ \f2com.sun.mirror\fP ¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë¤½¤ì¤Ë´ØÏ¢¤·¤¿ API ¤Ï¡¢JDK 7 °Ê¹ßÈó¿ä¾©¤Ë¤Ê¤Ã¤Æ¤ª¤ê¡¢JDK ¤Î¼¡¤Î¥á¥¸¥ã¡¼¥ê¥ê¡¼¥¹¤Çºï½ü¤µ¤ì¤ëͽÄê¤Ç¤¹¡£\f2javac(1)\fP ¥Ä¡¼¥ë¤ÇÍøÍѲÄǽ¤Ê¥ª¥×¥·¥ç¥ó¤È¡¢¥Ñ¥Ã¥±¡¼¥¸ \f2javax.annotation.processing\fP ¤ª¤è¤Ó \f2javax.lang.model\fP ¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë API ¤ò»ÈÍѤ·¤Æ¡¢Ãí¼á¤ò½èÍý¤·¤Æ¤¯¤À¤µ¤¤¡£ -.LP -.SH "´ØÏ¢¹àÌÜ" -.LP -.RS 3 -.TP 2 -o -javac(1), java(1) -.RE - -.LP - diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/com/sun/crypto/provider/PBEKey.java --- a/jdk/src/share/classes/com/sun/crypto/provider/PBEKey.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/com/sun/crypto/provider/PBEKey.java Wed Feb 22 10:17:57 2012 -0800 @@ -55,9 +55,12 @@ // Should allow an empty password. passwd = new char[0]; } - for (int i=0; i '\u007E')) { - throw new InvalidKeySpecException("Password is not ASCII"); + // Accept "\0" to signify "zero-length password with no terminator". + if (!(passwd.length == 1 && passwd[0] == 0)) { + for (int i=0; i '\u007E')) { + throw new InvalidKeySpecException("Password is not ASCII"); + } } } this.key = new byte[passwd.length]; diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/com/sun/crypto/provider/PKCS12PBECipherCore.java --- a/jdk/src/share/classes/com/sun/crypto/provider/PKCS12PBECipherCore.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/com/sun/crypto/provider/PKCS12PBECipherCore.java Wed Feb 22 10:17:57 2012 -0800 @@ -60,11 +60,16 @@ static byte[] derive(char[] chars, byte[] salt, int ic, int n, int type) { - // Add in trailing NULL terminator. + // Add in trailing NULL terminator. Special case: + // no terminator if password is "\0". int length = chars.length*2; - if (length != 0) { + if (length == 2 && chars[0] == 0) { + chars = new char[0]; + length = 0; + } else { length += 2; } + byte[] passwd = new byte[length]; for (int i = 0, j = 0; i < chars.length; i++, j+=2) { passwd[j] = (byte) ((chars[i] >>> 8) & 0xFF); @@ -133,6 +138,9 @@ } private static void concat(byte[] src, byte[] dst, int start, int len) { + if (src.length == 0) { + return; + } int loop = len / src.length; int off, i; for (i = 0, off = 0; i < loop; i++, off += src.length) diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java --- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java Wed Feb 22 10:17:57 2012 -0800 @@ -137,6 +137,11 @@ g.setColor(progressBar.getForeground()); barRectHeight -= 2; barRectWidth -= 2; + + if (barRectWidth <= 0 || barRectHeight <= 0) { + return; + } + Graphics2D g2 = (Graphics2D)g; g2.setStroke(new BasicStroke((float)(vertical ? barRectWidth : barRectHeight), BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/com/sun/management/DiagnosticCommandArgumentInfo.java --- a/jdk/src/share/classes/com/sun/management/DiagnosticCommandArgumentInfo.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.management; - -import java.beans.ConstructorProperties; - -/** - * Diagnostic Command Argument information. It contains the description - * of one parameter of the diagnostic command. A parameter can either be an - * option or an argument. Options are identified by the option name while - * arguments are identified by their position in the command line. The generic - * syntax of a diagnostic command is: - *
- * <command name> [<option>=<value>] [<argument_value>] - *
- * Example: - *
- * command_name option1=value1 option2=value argumentA argumentB argumentC - *
- * In this command line, the diagnostic command receives five parameters, two - * options named {@code option1} and {@code option2}, and three arguments. - * argumentA's position is 0, argumentB's position is 1 and argumentC's - * position is 2. - * - * @author Frederic Parain - * @since 7u4 - */ - -public class DiagnosticCommandArgumentInfo { - private final String name; - private final String description; - private final String type; - private final String defaultValue; - private final boolean mandatory; - private final boolean option; - private final int position; - - /** - * Returns the argument name - * - * @return the argument name - */ - public String getName() { - return name; - } - - /** - * Returns the argument description - * - * @return the argument description - */ - public String getDescription() { - return description; - } - - /** - * Returns the argument type - * - * @return the argument type - */ - public String getType() { - return type; - } - - /** - * Returns the default value as a String if a default value - * is defined, null otherwise. - * - * @return the default value as a String if a default value - * is defined, null otherwise. - */ - public String getDefault() { - return defaultValue; - } - - /** - * Returns {@code true} if the argument is mandatory, - * {@code false} otherwise - * - * @return {@code true} if the argument is mandatory, - * {@code false} otherwise - */ - public boolean isMandatory() { - return mandatory; - } - - /** - * Returns {@code true} if the argument is an option, - * {@code false} otherwise. Options have to be specified using the - * <key>=<value> syntax on the command line, while other - * arguments are specified with a single <value> field and are - * identified by their position on command line. - * - * @return {@code true} if the argument is an option, - * {@code false} otherwise - */ - public boolean isOption() { - return option; - } - - /** - * Returns the expected position of this argument if it is not an option, - * -1 otherwise. Argument position if defined from left to right, - * starting at zero and ignoring the diagnostic command name and - * options. - * - * @return the expected position of this argument if it is not an option, - * -1 otherwise. - */ - public int getPosition() { - return position; - } - - @ConstructorProperties({"name","description","type","default", - "mandatory","option","position"}) - public DiagnosticCommandArgumentInfo(String name, String description, - String type, String defaultValue, - boolean mandatory, boolean option, - int position) { - this.name = name; - this.description = description; - this.type = type; - this.defaultValue = defaultValue; - this.mandatory = mandatory; - this.option = option; - this.position = position; - } -} diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/com/sun/management/DiagnosticCommandInfo.java --- a/jdk/src/share/classes/com/sun/management/DiagnosticCommandInfo.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.management; - -import java.beans.ConstructorProperties; -import java.util.List; - -/** - * Diagnostic command information. It contains the description of a - * diagnostic command. - * - * @author Frederic Parain - * @since 7u4 - */ - -public class DiagnosticCommandInfo { - private final String name; - private final String description; - private final String impact; - private final boolean enabled; - private final List arguments; - - /** - * Returns the diagnostic command name - * - * @return the diagnostic command name - */ - public String getName() { - return name; - } - - /** - * Returns the diagnostic command description - * - * @return the diagnostic command description - */ - public String getDescription() { - return description; - } - - /** - * Returns the potential impact of the diagnostic command execution - * on the Java virtual machine behavior - * - * @return the potential impact of the diagnostic command execution - * on the Java virtual machine behavior - */ - public String getImpact() { - return impact; - } - - /** - * Returns {@code true} if the diagnostic command is enabled, - * {@code false} otherwise. The enabled/disabled - * status of a diagnostic command can evolve during - * the lifetime of the Java virtual machine. - * - * @return {@code true} if the diagnostic command is enabled, - * {@code false} otherwise - */ - public boolean isEnabled() { - return enabled; - } - - /** - * Returns the list of the diagnostic command arguments description. - * If the diagnostic command has no arguments, it returns an empty list. - * - * @return a list of the diagnostic command arguments description - */ - public List getArgumentsInfo() { - return arguments; - } - - @ConstructorProperties({"name", "description","impact","enabled", - "argumentsInfo"}) - public DiagnosticCommandInfo(String name, String description, - String impact, boolean enabled, - List arguments) - { - this.name = name; - this.description = description; - this.impact = impact; - this.enabled = enabled; - this.arguments = arguments; - } -} diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java --- a/jdk/src/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -31,11 +31,6 @@ /** * Diagnostic management interface for the HotSpot Virtual Machine. * - *

{@linkplain #getDiagnosticCommands Diagnostic commands} - * are actions that can be invoked dynamically and - * executed in a target Java virtual machine, mainly for troubleshooting - * and diagnosis. - * *

The diagnostic MBean is registered to the platform MBeanServer * as are other platform MBeans. * @@ -116,108 +111,4 @@ * ManagementPermission("control"). */ public void setVMOption(String name, String value); - - /** - * Returns the {@linkplain DiagnosticCommandInfo#getName() names} - * of all diagnostic commands. - * A diagnostic command is an action that can be invoked dynamically - * mainly for troubleshooting and diagnosis. The list of diagnostic - * commands may change at runtime. A diagnostic command may be - * {@linkplain DiagnosticCommandInfo#isEnabled disabled} but will - * not be removed from a previously returned list. - * - * @return the names of all diagnostic commands. - * - * @since 7u4 - */ - public List getDiagnosticCommands(); - - /** - * Returns a {@code DiagnosticCommandInfo} object describing the - * diagnostic command of the specified name {@code command} - * - * @param command a diagnostic command name - * @return a {@code DiagnosticCommandInfo} object - * @throws java.lang.IllegalArgumentException if the {@code command} - * doesn't match any diagnostic command registered in the - * targeted Java virtual machine. - * - * @since 7u4 - */ - public DiagnosticCommandInfo getDiagnosticCommandInfo(String command); - - /** - * Returns a list of {@code DiagnosticCommandInfo} object describing - * all diagnostic commands available on the targeted Java virtual machine - * - * @return a list of {@code DiagnosticCommandInfo} objects - * - * @since 7u4 - */ - public List getDiagnosticCommandInfo(); - - /** - * Returns a list of {@code DiagnosticCommandInfo} object describing - * all diagnostic commands specified in the {@code commands} list. - * - * @param commands {@code List} of {@code String} containing diagnostic - * command names - * @return a {@code List} of {@code DiagnosticCommandInfo} objects - * - * @throws java.lang.IllegalArgumentException if at least one - * command specified in the {@code commands } list - * doesn't match any diagnostic command registered in the - * targeted Java virtual machine. - * - * @since 7u4 - */ - public List getDiagnosticCommandInfo(List commands); - - /** - * Executes the command line {@code commandLine}. The command line must - * start with a diagnostic command name, optionally followed by parameters. - * Each command has its own syntax but the generic syntax for a diagnostic - * command line is: - *

- * <command name> [<option>=<value>] [<argument_value>] - *
- * - * @param commandLine command line to execute - * @return a {@code String} object containing the diagnostic command - * output. - * - * @throws java.lang.IllegalArgumentException if the command line doesn't - * match any diagnostic command registered in the virtual machine - * of if the parameters don't match the diagnostic command syntax. - * @throws java.lang.SecurityException - * if a security manager exists and the caller does not have - * ManagementPermission("control"). - * - * @since 7u4 - */ - public String execute(String commandLine); - - /** - * Invokes the diagnostic command named {@code cmd} with the parameters - * specified in {@code args}. Each command has its own syntax but - * the generic syntax for parameters is: - *
- * [<option>=<value>] [<argument_value>] - *
- * - * @param cmd a diagnostic command name - * @param args the command parameters - * @return a {@code String} object containing the diagnostic command - * output. - * - * @throws java.lang.IllegalArgumentException if the command line doesn't - * match any diagnostic command registered in the virtual machine - * of if the parameters don't match the diagnostic command syntax. - * @throws java.lang.SecurityException - * if a security manager exists and the caller does not have - * ManagementPermission("control"). - * - * @since 7u4 - */ - public String execute(String cmd, String... args); } diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/com/sun/nio/sctp/MessageInfo.java --- a/jdk/src/share/classes/com/sun/nio/sctp/MessageInfo.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/com/sun/nio/sctp/MessageInfo.java Wed Feb 22 10:17:57 2012 -0800 @@ -94,7 +94,7 @@ if (streamNumber < 0 || streamNumber > 65536) throw new IllegalArgumentException("Invalid stream number"); - return new sun.nio.ch.SctpMessageInfoImpl(null, address, streamNumber); + return new sun.nio.ch.sctp.MessageInfoImpl(null, address, streamNumber); } /** * Creates a {@code MessageInfo} instance suitable for use when @@ -133,8 +133,8 @@ if (streamNumber < 0 || streamNumber > 65536) throw new IllegalArgumentException("Invalid stream number"); - return new sun.nio.ch.SctpMessageInfoImpl(association, address, - streamNumber); + return new sun.nio.ch.sctp.MessageInfoImpl(association, + address, streamNumber); } /** diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/com/sun/nio/sctp/SctpChannel.java --- a/jdk/src/share/classes/com/sun/nio/sctp/SctpChannel.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/com/sun/nio/sctp/SctpChannel.java Wed Feb 22 10:17:57 2012 -0800 @@ -162,7 +162,7 @@ */ public static SctpChannel open() throws IOException { - return new sun.nio.ch.SctpChannelImpl((SelectorProvider)null); + return new sun.nio.ch.sctp.SctpChannelImpl((SelectorProvider)null); } /** diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/com/sun/nio/sctp/SctpMultiChannel.java --- a/jdk/src/share/classes/com/sun/nio/sctp/SctpMultiChannel.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/com/sun/nio/sctp/SctpMultiChannel.java Wed Feb 22 10:17:57 2012 -0800 @@ -162,7 +162,7 @@ */ public static SctpMultiChannel open() throws IOException { - return new sun.nio.ch.SctpMultiChannelImpl((SelectorProvider)null); + return new sun.nio.ch.sctp.SctpMultiChannelImpl((SelectorProvider)null); } /** diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/com/sun/nio/sctp/SctpServerChannel.java --- a/jdk/src/share/classes/com/sun/nio/sctp/SctpServerChannel.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/com/sun/nio/sctp/SctpServerChannel.java Wed Feb 22 10:17:57 2012 -0800 @@ -98,7 +98,7 @@ */ public static SctpServerChannel open() throws IOException { - return new sun.nio.ch.SctpServerChannelImpl((SelectorProvider)null); + return new sun.nio.ch.sctp.SctpServerChannelImpl((SelectorProvider)null); } /** diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/com/sun/nio/sctp/SctpStandardSocketOptions.java --- a/jdk/src/share/classes/com/sun/nio/sctp/SctpStandardSocketOptions.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/com/sun/nio/sctp/SctpStandardSocketOptions.java Wed Feb 22 10:17:57 2012 -0800 @@ -25,7 +25,7 @@ package com.sun.nio.sctp; import java.net.SocketAddress; -import sun.nio.ch.SctpStdSocketOption; +import sun.nio.ch.sctp.SctpStdSocketOption; /** * SCTP channels supports the socket options defined by this class @@ -50,7 +50,7 @@ */ public static final SctpSocketOption SCTP_DISABLE_FRAGMENTS = new SctpStdSocketOption("SCTP_DISABLE_FRAGMENTS", Boolean.class, - sun.nio.ch.SctpStdSocketOption.SCTP_DISABLE_FRAGMENTS); + sun.nio.ch.sctp.SctpStdSocketOption.SCTP_DISABLE_FRAGMENTS); /** * Enables or disables explicit message completion. @@ -69,7 +69,7 @@ */ public static final SctpSocketOption SCTP_EXPLICIT_COMPLETE = new SctpStdSocketOption("SCTP_EXPLICIT_COMPLETE", Boolean.class, - sun.nio.ch.SctpStdSocketOption.SCTP_EXPLICIT_COMPLETE); + sun.nio.ch.sctp.SctpStdSocketOption.SCTP_EXPLICIT_COMPLETE); /** * Fragmented interleave controls how the presentation of messages occur @@ -120,7 +120,7 @@ public static final SctpSocketOption SCTP_FRAGMENT_INTERLEAVE = new SctpStdSocketOption("SCTP_FRAGMENT_INTERLEAVE", Integer.class, - sun.nio.ch.SctpStdSocketOption.SCTP_FRAGMENT_INTERLEAVE); + sun.nio.ch.sctp.SctpStdSocketOption.SCTP_FRAGMENT_INTERLEAVE); /** * The maximum number of streams requested by the local endpoint during @@ -171,7 +171,7 @@ */ public static final SctpSocketOption SCTP_NODELAY = new SctpStdSocketOption("SCTP_NODELAY", Boolean.class, - sun.nio.ch.SctpStdSocketOption.SCTP_NODELAY); + sun.nio.ch.sctp.SctpStdSocketOption.SCTP_NODELAY); /** * Requests that the local SCTP stack use the given peer address as @@ -246,7 +246,7 @@ */ public static final SctpSocketOption SO_SNDBUF = new SctpStdSocketOption("SO_SNDBUF", Integer.class, - sun.nio.ch.SctpStdSocketOption.SO_SNDBUF); + sun.nio.ch.sctp.SctpStdSocketOption.SO_SNDBUF); /** * The size of the socket receive buffer. @@ -273,7 +273,7 @@ */ public static final SctpSocketOption SO_RCVBUF = new SctpStdSocketOption("SO_RCVBUF", Integer.class, - sun.nio.ch.SctpStdSocketOption.SO_RCVBUF); + sun.nio.ch.sctp.SctpStdSocketOption.SO_RCVBUF); /** * Linger on close if data is present. @@ -304,7 +304,7 @@ */ public static final SctpSocketOption SO_LINGER = new SctpStdSocketOption("SO_LINGER", Integer.class, - sun.nio.ch.SctpStdSocketOption.SO_LINGER); + sun.nio.ch.sctp.SctpStdSocketOption.SO_LINGER); /** * This class is used to set the maximum number of inbound/outbound streams diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/java/awt/List.java --- a/jdk/src/share/classes/java/awt/List.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/java/awt/List.java Wed Feb 22 10:17:57 2012 -0800 @@ -115,7 +115,7 @@ * @see #addItem(String) * @see #getItem(int) */ - Vector items = new Vector(); + Vector items = new Vector<>(); /** * This field will represent the number of visible rows in the @@ -306,7 +306,7 @@ // to insure that it cannot be overridden by client subclasses. // DO NOT INVOKE CLIENT CODE ON THIS THREAD! final String getItemImpl(int index) { - return (String)items.elementAt(index); + return items.elementAt(index); } /** @@ -415,7 +415,7 @@ if (peer != null) { peer.removeAll(); } - items = new Vector(); + items = new Vector<>(); selected = new int[0]; } @@ -490,9 +490,9 @@ public synchronized int[] getSelectedIndexes() { ListPeer peer = (ListPeer)this.peer; if (peer != null) { - selected = ((ListPeer)peer).getSelectedIndexes(); + selected = peer.getSelectedIndexes(); } - return (int[])selected.clone(); + return selected.clone(); } /** @@ -908,7 +908,7 @@ * @since 1.4 */ public synchronized ItemListener[] getItemListeners() { - return (ItemListener[])(getListeners(ItemListener.class)); + return getListeners(ItemListener.class); } /** @@ -975,7 +975,7 @@ * @since 1.4 */ public synchronized ActionListener[] getActionListeners() { - return (ActionListener[])(getListeners(ActionListener.class)); + return getListeners(ActionListener.class); } /** diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/java/awt/Window.java --- a/jdk/src/share/classes/java/awt/Window.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/java/awt/Window.java Wed Feb 22 10:17:57 2012 -0800 @@ -398,10 +398,10 @@ initIDs(); } - String s = (String) java.security.AccessController.doPrivileged( + String s = java.security.AccessController.doPrivileged( new GetPropertyAction("java.awt.syncLWRequests")); systemSyncLWRequests = (s != null && s.equals("true")); - s = (String) java.security.AccessController.doPrivileged( + s = java.security.AccessController.doPrivileged( new GetPropertyAction("java.awt.Window.locationByPlatform")); locationByPlatformProp = (s != null && s.equals("true")); } @@ -1378,7 +1378,7 @@ // make sure the privileged action is only // for getting the property! We don't want the // above checkTopLevelWindow call to always succeed! - warningString = (String) AccessController.doPrivileged( + warningString = AccessController.doPrivileged( new GetPropertyAction("awt.appletWarning", "Java Applet Window")); } diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/java/awt/color/ICC_Profile.java --- a/jdk/src/share/classes/java/awt/color/ICC_Profile.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/java/awt/color/ICC_Profile.java Wed Feb 22 10:17:57 2012 -0800 @@ -921,9 +921,9 @@ */ private static ICC_Profile getStandardProfile(final String name) { - return (ICC_Profile) AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { + return AccessController.doPrivileged( + new PrivilegedAction() { + public ICC_Profile run() { ICC_Profile p = null; try { p = getInstance (name); diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/java/awt/event/InputEvent.java --- a/jdk/src/share/classes/java/awt/event/InputEvent.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/java/awt/event/InputEvent.java Wed Feb 22 10:17:57 2012 -0800 @@ -321,14 +321,15 @@ * @param when a long int that gives the time the event occurred. * Passing negative or zero value * is not recommended - * @param modifiers the modifier keys down during event (e.g. shift, ctrl, - * alt, meta) - * Passing negative parameter is not recommended. - * Zero value means no modifiers. - * Either extended _DOWN_MASK or old _MASK modifiers - * should be used, but both models should not be mixed - * in one event. Use of the extended modifiers is - * preferred + * @param modifiers a modifier mask describing the modifier keys and mouse + * buttons (for example, shift, ctrl, alt, and meta) that + * are down during the event. + * Only extended modifiers are allowed to be used as a + * value for this parameter (see the {@link InputEvent#getModifiersEx} + * class for the description of extended modifiers). + * Passing negative parameter + * is not recommended. + * Zero value means that no modifiers were passed * @throws IllegalArgumentException if source is null * @see #getSource() * @see #getID() @@ -416,9 +417,13 @@ /** * Returns the extended modifier mask for this event. + *

+ * Extended modifiers are the modifiers that ends with the _DOWN_MASK suffix, + * such as ALT_DOWN_MASK, BUTTON1_DOWN_MASK, and others. + *

* Extended modifiers represent the state of all modal keys, * such as ALT, CTRL, META, and the mouse buttons just after - * the event occurred + * the event occurred. *

* For example, if the user presses button 1 followed by * button 2, and then releases them in the same order, diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/java/awt/event/MouseEvent.java --- a/jdk/src/share/classes/java/awt/event/MouseEvent.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/java/awt/event/MouseEvent.java Wed Feb 22 10:17:57 2012 -0800 @@ -488,14 +488,15 @@ * @param when A long integer that gives the time the event occurred. * Passing negative or zero value * is not recommended - * @param modifiers The modifier keys down during event (e.g. shift, ctrl, - * alt, meta) + * @param modifiers a modifier mask describing the modifier keys and mouse + * buttons (for example, shift, ctrl, alt, and meta) that + * are down during the event. + * Only extended modifiers are allowed to be used as a + * value for this parameter (see the {@link InputEvent#getModifiersEx} + * class for the description of extended modifiers). * Passing negative parameter * is not recommended. - * Zero value means that no modifiers were passed. - * Use either an extended _DOWN_MASK or old _MASK modifiers, - * however do not mix models in the one event. - * The extended modifiers are preferred for using + * Zero value means that no modifiers were passed * @param x The horizontal x coordinate for the mouse location. * It is allowed to pass negative values * @param y The vertical y coordinate for the mouse location. @@ -586,14 +587,15 @@ * @param when A long integer that gives the time the event occurred. * Passing negative or zero value * is not recommended - * @param modifiers The modifier keys down during event (e.g. shift, ctrl, - * alt, meta) + * @param modifiers a modifier mask describing the modifier keys and mouse + * buttons (for example, shift, ctrl, alt, and meta) that + * are down during the event. + * Only extended modifiers are allowed to be used as a + * value for this parameter (see the {@link InputEvent#getModifiersEx} + * class for the description of extended modifiers). * Passing negative parameter * is not recommended. - * Zero value means that no modifiers were passed. - * Use either an extended _DOWN_MASK or old _MASK modifiers, - * however do not mix models in the one event. - * The extended modifiers are preferred for using + * Zero value means that no modifiers were passed * @param x The horizontal x coordinate for the mouse location. * It is allowed to pass negative values * @param y The vertical y coordinate for the mouse location. @@ -657,14 +659,15 @@ * @param when A long integer that gives the time the event occurred. * Passing negative or zero value * is not recommended - * @param modifiers The modifier keys down during event (e.g. shift, ctrl, - * alt, meta) + * @param modifiers a modifier mask describing the modifier keys and mouse + * buttons (for example, shift, ctrl, alt, and meta) that + * are down during the event. + * Only extended modifiers are allowed to be used as a + * value for this parameter (see the {@link InputEvent#getModifiersEx} + * class for the description of extended modifiers). * Passing negative parameter * is not recommended. - * Zero value means that no modifiers were passed. - * Use either an extended _DOWN_MASK or old _MASK modifiers, - * however do not mix models in the one event. - * The extended modifiers are preferred for using + * Zero value means that no modifiers were passed * @param x The horizontal x coordinate for the mouse location. * It is allowed to pass negative values * @param y The vertical y coordinate for the mouse location. diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/java/lang/management/ManagementPermission.java --- a/jdk/src/share/classes/java/lang/management/ManagementPermission.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/java/lang/management/ManagementPermission.java Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,12 +46,17 @@ * * control * Ability to control the runtime characteristics of the Java virtual - * machine, for example, setting the -verbose:gc and -verbose:class flag, - * setting the threshold of a memory pool, and enabling and disabling - * the thread contention monitoring support. + * machine, for example, enabling and disabling the verbose output for + * the class loading or memory system, setting the threshold of a memory + * pool, and enabling and disabling the thread contention monitoring + * support. Some actions controlled by this permission can disclose + * information about the running application, like the -verbose:class + * flag. * * This allows an attacker to control the runtime characteristics - * of the Java virtual machine and cause the system to misbehave. + * of the Java virtual machine and cause the system to misbehave. An + * attacker can also access some information related to the running + * application. * * * diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/java/util/jar/Attributes.java --- a/jdk/src/share/classes/java/util/jar/Attributes.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/java/util/jar/Attributes.java Wed Feb 22 10:17:57 2012 -0800 @@ -71,7 +71,7 @@ * @param size the initial number of attributes */ public Attributes(int size) { - map = new HashMap(size); + map = new HashMap<>(size); } /** @@ -81,7 +81,7 @@ * @param attr the specified Attributes */ public Attributes(Attributes attr) { - map = new HashMap(attr); + map = new HashMap<>(attr); } @@ -296,9 +296,9 @@ * XXX Need to handle UTF8 values and break up lines longer than 72 bytes */ void write(DataOutputStream os) throws IOException { - Iterator it = entrySet().iterator(); + Iterator> it = entrySet().iterator(); while (it.hasNext()) { - Map.Entry e = (Map.Entry)it.next(); + Map.Entry e = it.next(); StringBuffer buffer = new StringBuffer( ((Name)e.getKey()).toString()); buffer.append(": "); @@ -340,9 +340,9 @@ // write out all attributes except for the version // we wrote out earlier - Iterator it = entrySet().iterator(); + Iterator> it = entrySet().iterator(); while (it.hasNext()) { - Map.Entry e = (Map.Entry)it.next(); + Map.Entry e = it.next(); String name = ((Name)e.getKey()).toString(); if ((version != null) && ! (name.equalsIgnoreCase(vername))) { @@ -499,7 +499,7 @@ */ public boolean equals(Object o) { if (o instanceof Name) { - Comparator c = ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER; + Comparator c = ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER; return c.compare(name, ((Name)o).name) == 0; } else { return false; diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/java/util/jar/JarOutputStream.java --- a/jdk/src/share/classes/java/util/jar/JarOutputStream.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/java/util/jar/JarOutputStream.java Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -135,7 +135,7 @@ * The bytes are assumed to be in Intel (little-endian) byte order. */ private static int get16(byte[] b, int off) { - return (b[off] & 0xff) | ((b[off+1] & 0xff) << 8); + return Byte.toUnsignedInt(b[off]) | ( Byte.toUnsignedInt(b[off+1]) << 8); } /* diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/java/util/jar/JarVerifier.java --- a/jdk/src/share/classes/java/util/jar/JarVerifier.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/java/util/jar/JarVerifier.java Wed Feb 22 10:17:57 2012 -0800 @@ -48,21 +48,21 @@ /* a table mapping names to code signers, for jar entries that have had their actual hashes verified */ - private Hashtable verifiedSigners; + private Hashtable verifiedSigners; /* a table mapping names to code signers, for jar entries that have passed the .SF/.DSA/.EC -> MANIFEST check */ - private Hashtable sigFileSigners; + private Hashtable sigFileSigners; /* a hash table to hold .SF bytes */ - private Hashtable sigFileData; + private Hashtable sigFileData; /** "queue" of pending PKCS7 blocks that we couldn't parse * until we parsed the .SF file */ - private ArrayList pendingBlocks; + private ArrayList pendingBlocks; /* cache of CodeSigner objects */ - private ArrayList signerCache; + private ArrayList signerCache; /* Are we parsing a block? */ private boolean parsingBlockOrSF = false; @@ -94,10 +94,10 @@ public JarVerifier(byte rawBytes[]) { manifestRawBytes = rawBytes; - sigFileSigners = new Hashtable(); - verifiedSigners = new Hashtable(); - sigFileData = new Hashtable(11); - pendingBlocks = new ArrayList(); + sigFileSigners = new Hashtable<>(); + verifiedSigners = new Hashtable<>(); + sigFileData = new Hashtable<>(11); + pendingBlocks = new ArrayList<>(); baos = new ByteArrayOutputStream(); manifestDigests = new ArrayList<>(); } @@ -248,10 +248,9 @@ sigFileData.put(key, bytes); // check pending blocks, we can now process // anyone waiting for this .SF file - Iterator it = pendingBlocks.iterator(); + Iterator it = pendingBlocks.iterator(); while (it.hasNext()) { - SignatureFileVerifier sfv = - (SignatureFileVerifier) it.next(); + SignatureFileVerifier sfv = it.next(); if (sfv.needSignatureFile(key)) { if (debug != null) { debug.println( @@ -270,7 +269,7 @@ String key = uname.substring(0, uname.lastIndexOf(".")); if (signerCache == null) - signerCache = new ArrayList(); + signerCache = new ArrayList<>(); if (manDig == null) { synchronized(manifestRawBytes) { @@ -287,7 +286,7 @@ if (sfv.needSignatureFileBytes()) { // see if we have already parsed an external .SF file - byte[] bytes = (byte[]) sigFileData.get(key); + byte[] bytes = sigFileData.get(key); if (bytes == null) { // put this block on queue for later processing @@ -343,7 +342,7 @@ */ public CodeSigner[] getCodeSigners(String name) { - return (CodeSigner[])verifiedSigners.get(name); + return verifiedSigners.get(name); } public CodeSigner[] getCodeSigners(JarFile jar, JarEntry entry) @@ -376,15 +375,14 @@ CodeSigner[] signers) { if (signers != null) { - ArrayList certChains = new ArrayList(); + ArrayList certChains = new ArrayList<>(); for (int i = 0; i < signers.length; i++) { certChains.addAll( signers[i].getSignerCertPath().getCertificates()); } // Convert into a Certificate[] - return (java.security.cert.Certificate[]) - certChains.toArray( + return certChains.toArray( new java.security.cert.Certificate[certChains.size()]); } return null; @@ -418,8 +416,8 @@ // MANIFEST.MF is always treated as signed and verified, // move its signers from sigFileSigners to verifiedSigners. if (sigFileSigners.containsKey(JarFile.MANIFEST_NAME)) { - verifiedSigners.put(JarFile.MANIFEST_NAME, - sigFileSigners.remove(JarFile.MANIFEST_NAME)); + CodeSigner[] codeSigners = sigFileSigners.remove(JarFile.MANIFEST_NAME); + verifiedSigners.put(JarFile.MANIFEST_NAME, codeSigners); } } @@ -493,10 +491,10 @@ // Extended JavaUtilJarAccess CodeSource API Support - private Map urlToCodeSourceMap = new HashMap(); - private Map signerToCodeSource = new HashMap(); + private Map> urlToCodeSourceMap = new HashMap<>(); + private Map signerToCodeSource = new HashMap<>(); private URL lastURL; - private Map lastURLMap; + private Map lastURLMap; /* * Create a unique mapping from codeSigner cache entries to CodeSource. @@ -504,19 +502,19 @@ * and shared JAR file although in practice there will be a single URL in use. */ private synchronized CodeSource mapSignersToCodeSource(URL url, CodeSigner[] signers) { - Map map; + Map map; if (url == lastURL) { map = lastURLMap; } else { - map = (Map) urlToCodeSourceMap.get(url); + map = urlToCodeSourceMap.get(url); if (map == null) { - map = new HashMap(); + map = new HashMap<>(); urlToCodeSourceMap.put(url, map); } lastURLMap = map; lastURL = url; } - CodeSource cs = (CodeSource) map.get(signers); + CodeSource cs = map.get(signers); if (cs == null) { cs = new VerifierCodeSource(csdomain, url, signers); signerToCodeSource.put(signers, cs); @@ -524,16 +522,16 @@ return cs; } - private CodeSource[] mapSignersToCodeSources(URL url, List signers, boolean unsigned) { - List sources = new ArrayList(); + private CodeSource[] mapSignersToCodeSources(URL url, List signers, boolean unsigned) { + List sources = new ArrayList<>(); for (int i = 0; i < signers.size(); i++) { - sources.add(mapSignersToCodeSource(url, (CodeSigner[]) signers.get(i))); + sources.add(mapSignersToCodeSource(url, signers.get(i))); } if (unsigned) { sources.add(mapSignersToCodeSource(url, null)); } - return (CodeSource[]) sources.toArray(new CodeSource[sources.size()]); + return sources.toArray(new CodeSource[sources.size()]); } private CodeSigner[] emptySigner = new CodeSigner[0]; @@ -553,7 +551,7 @@ * but this handles a CodeSource of any type, just in case. */ CodeSource[] sources = mapSignersToCodeSources(cs.getLocation(), getJarCodeSigners(), true); - List sourceList = new ArrayList(); + List sourceList = new ArrayList<>(); for (int i = 0; i < sources.length; i++) { sourceList.add(sources[i]); } @@ -574,6 +572,7 @@ * signing data that can be compared by object reference identity. */ private static class VerifierCodeSource extends CodeSource { + private static final long serialVersionUID = -9047366145967768825L; URL vlocation; CodeSigner[] vsigners; @@ -641,16 +640,16 @@ return vcerts; } } - private Map signerMap; + private Map signerMap; - private synchronized Map signerMap() { + private synchronized Map signerMap() { if (signerMap == null) { /* * Snapshot signer state so it doesn't change on us. We care * only about the asserted signatures. Verification of * signature validity happens via the JarEntry apis. */ - signerMap = new HashMap(verifiedSigners.size() + sigFileSigners.size()); + signerMap = new HashMap<>(verifiedSigners.size() + sigFileSigners.size()); signerMap.putAll(verifiedSigners); signerMap.putAll(sigFileSigners); } @@ -658,15 +657,15 @@ } public synchronized Enumeration entryNames(JarFile jar, final CodeSource[] cs) { - final Map map = signerMap(); - final Iterator itor = map.entrySet().iterator(); + final Map map = signerMap(); + final Iterator> itor = map.entrySet().iterator(); boolean matchUnsigned = false; /* * Grab a single copy of the CodeSigner arrays. Check * to see if we can optimize CodeSigner equality test. */ - List req = new ArrayList(cs.length); + List req = new ArrayList<>(cs.length); for (int i = 0; i < cs.length; i++) { CodeSigner[] match = findMatchingSigners(cs[i]); if (match != null) { @@ -678,8 +677,8 @@ } } - final List signersReq = req; - final Enumeration enum2 = (matchUnsigned) ? unsignedEntryNames(jar) : emptyEnumeration; + final List signersReq = req; + final Enumeration enum2 = (matchUnsigned) ? unsignedEntryNames(jar) : emptyEnumeration; return new Enumeration() { @@ -691,14 +690,14 @@ } while (itor.hasNext()) { - Map.Entry e = (Map.Entry) itor.next(); - if (signersReq.contains((CodeSigner[]) e.getValue())) { - name = (String) e.getKey(); + Map.Entry e = itor.next(); + if (signersReq.contains(e.getValue())) { + name = e.getKey(); return true; } } while (enum2.hasMoreElements()) { - name = (String) enum2.nextElement(); + name = enum2.nextElement(); return true; } return false; @@ -719,13 +718,13 @@ * Like entries() but screens out internal JAR mechanism entries * and includes signed entries with no ZIP data. */ - public Enumeration entries2(final JarFile jar, Enumeration e) { - final Map map = new HashMap(); + public Enumeration entries2(final JarFile jar, Enumeration e) { + final Map map = new HashMap<>(); map.putAll(signerMap()); - final Enumeration enum_ = e; + final Enumeration enum_ = e; return new Enumeration() { - Enumeration signers = null; + Enumeration signers = null; JarEntry entry; public boolean hasMoreElements() { @@ -733,7 +732,7 @@ return true; } while (enum_.hasMoreElements()) { - ZipEntry ze = (ZipEntry) enum_.nextElement(); + ZipEntry ze = enum_.nextElement(); if (JarVerifier.isSigningRelated(ze.getName())) { continue; } @@ -744,7 +743,7 @@ signers = Collections.enumeration(map.keySet()); } while (signers.hasMoreElements()) { - String name = (String) signers.nextElement(); + String name = signers.nextElement(); entry = jar.newEntry(new ZipEntry(name)); return true; } @@ -764,7 +763,7 @@ } }; } - private Enumeration emptyEnumeration = new Enumeration() { + private Enumeration emptyEnumeration = new Enumeration() { public boolean hasMoreElements() { return false; @@ -797,8 +796,8 @@ } private Enumeration unsignedEntryNames(JarFile jar) { - final Map map = signerMap(); - final Enumeration entries = jar.entries(); + final Map map = signerMap(); + final Enumeration entries = jar.entries(); return new Enumeration() { String name; @@ -813,7 +812,7 @@ } while (entries.hasMoreElements()) { String value; - ZipEntry e = (ZipEntry) entries.nextElement(); + ZipEntry e = entries.nextElement(); value = e.getName(); if (e.isDirectory() || isSigningRelated(value)) { continue; @@ -836,14 +835,14 @@ } }; } - private List jarCodeSigners; + private List jarCodeSigners; - private synchronized List getJarCodeSigners() { + private synchronized List getJarCodeSigners() { CodeSigner[] signers; if (jarCodeSigners == null) { - HashSet set = new HashSet(); + HashSet set = new HashSet<>(); set.addAll(signerMap().values()); - jarCodeSigners = new ArrayList(); + jarCodeSigners = new ArrayList<>(); jarCodeSigners.addAll(set); } return jarCodeSigners; @@ -858,7 +857,7 @@ public CodeSource getCodeSource(URL url, String name) { CodeSigner[] signers; - signers = (CodeSigner[]) signerMap().get(name); + signers = signerMap().get(name); return mapSignersToCodeSource(url, signers); } diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/java/util/jar/Manifest.java --- a/jdk/src/share/classes/java/util/jar/Manifest.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/java/util/jar/Manifest.java Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -339,7 +339,7 @@ return -1; } } - return buf[pos++] & 0xff; + return Byte.toUnsignedInt(buf[pos++]); } public int read(byte[] b, int off, int len) throws IOException { diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/java/util/zip/InflaterInputStream.java --- a/jdk/src/share/classes/java/util/zip/InflaterInputStream.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/java/util/zip/InflaterInputStream.java Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -119,7 +119,7 @@ */ public int read() throws IOException { ensureOpen(); - return read(singleByteBuf, 0, 1) == -1 ? -1 : singleByteBuf[0] & 0xff; + return read(singleByteBuf, 0, 1) == -1 ? -1 : Byte.toUnsignedInt(singleByteBuf[0]); } /** diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/java/util/zip/ZipInputStream.java --- a/jdk/src/share/classes/java/util/zip/ZipInputStream.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/java/util/zip/ZipInputStream.java Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -435,7 +435,7 @@ * The bytes are assumed to be in Intel (little-endian) byte order. */ private static final int get16(byte b[], int off) { - return (b[off] & 0xff) | ((b[off+1] & 0xff) << 8); + return Byte.toUnsignedInt(b[off]) | (Byte.toUnsignedInt(b[off+1]) << 8); } /* diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/javax/crypto/CipherSpi.java --- a/jdk/src/share/classes/javax/crypto/CipherSpi.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/javax/crypto/CipherSpi.java Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -775,7 +775,7 @@ int outOfs = output.arrayOffset() + outPos; byte[] inArray = new byte[getTempArraySize(inLen)]; int total = 0; - while (inLen > 0) { + do { int chunk = Math.min(inLen, inArray.length); input.get(inArray, 0, chunk); int n; @@ -787,7 +787,7 @@ total += n; outOfs += n; inLen -= chunk; - } + } while (inLen > 0); output.position(outPos + total); return total; } else { // output is not backed by an accessible byte[] @@ -804,7 +804,7 @@ int outSize = outArray.length; int total = 0; boolean resized = false; - while (inLen > 0) { + do { int chunk = Math.min(inLen, outSize); if ((a1 == false) && (resized == false)) { input.get(inArray, 0, chunk); @@ -834,7 +834,7 @@ int newOut = engineGetOutputSize(chunk); outArray = new byte[newOut]; } - } + } while (inLen > 0); input.position(inLimit); return total; } diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/javax/net/ssl/ExtendedSSLSession.java --- a/jdk/src/share/classes/javax/net/ssl/ExtendedSSLSession.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/javax/net/ssl/ExtendedSSLSession.java Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -43,7 +43,7 @@ * The signature algorithm name must be a standard Java Security * name (such as "SHA1withRSA", "SHA256withECDSA", and so on). * See Appendix A in the + * "{@docRoot}/../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * Java Cryptography Architecture API Specification & Reference * for information about standard algorithm names. *

@@ -71,7 +71,7 @@ * The signature algorithm name must be a standard Java Security * name (such as "SHA1withRSA", "SHA256withECDSA", and so on). * See Appendix A in the + * "{@docRoot}/../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * Java Cryptography Architecture API Specification & Reference * for information about standard algorithm names. * diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/javax/net/ssl/SSLParameters.java --- a/jdk/src/share/classes/javax/net/ssl/SSLParameters.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/javax/net/ssl/SSLParameters.java Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -242,7 +242,7 @@ * * @param algorithm The standard string name of the endpoint * identification algorithm (or null). See Appendix A in the + * "{@docRoot}/../technotes/guides/security/crypto/CryptoSpec.html#AppA"> * Java Cryptography Architecture API Specification & Reference * for information about standard algorithm names. * diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/javax/print/attribute/standard/PrinterStateReasons.java --- a/jdk/src/share/classes/javax/print/attribute/standard/PrinterStateReasons.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/javax/print/attribute/standard/PrinterStateReasons.java Wed Feb 22 10:17:57 2012 -0800 @@ -180,8 +180,7 @@ if (severity == null) { throw new NullPointerException("severity is null"); } - return super.put((PrinterStateReason) reason, - (Severity) severity); + return super.put(reason, severity); } /** diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/javax/print/attribute/standard/ReferenceUriSchemesSupported.java --- a/jdk/src/share/classes/javax/print/attribute/standard/ReferenceUriSchemesSupported.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/javax/print/attribute/standard/ReferenceUriSchemesSupported.java Wed Feb 22 10:17:57 2012 -0800 @@ -141,7 +141,7 @@ * Returns the string table for class ReferenceUriSchemesSupported. */ protected String[] getStringTable() { - return (String[])myStringTable.clone(); + return myStringTable.clone(); } /** diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/javax/security/auth/x500/X500Principal.java --- a/jdk/src/share/classes/javax/security/auth/x500/X500Principal.java Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/javax/security/auth/x500/X500Principal.java Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -107,10 +107,17 @@ * defined in RFC 1779 and RFC 2253 * (and listed in {@link #getName(String format) getName(String format)}), * as well as the T, DNQ or DNQUALIFIER, SURNAME, GIVENNAME, INITIALS, - * GENERATION, EMAILADDRESS, and SERIALNUMBER keywords whose OIDs are - * defined in RFC 3280 and its successor. + * GENERATION, EMAILADDRESS, and SERIALNUMBER keywords whose Object + * Identifiers (OIDs) are defined in RFC 3280 and its successor. * Any other attribute type must be specified as an OID. * + *

This implementation enforces a more restrictive OID syntax than + * defined in RFC 1779 and 2253. It uses the more correct syntax defined in + * RFC 4512, which + * specifies that OIDs contain at least 2 digits: + * + *

{@code numericoid = number 1*( DOT number ) } + * * @param name an X.500 distinguished name in RFC 1779 or RFC 2253 format * @exception NullPointerException if the name * is null @@ -135,10 +142,17 @@ * keywords recognized by X500Principal(String). Keywords * MUST be specified in all upper-case, otherwise they will be ignored. * Improperly specified keywords are ignored; however if a keyword in the - * name maps to an improperly specified OID, an + * name maps to an improperly specified Object Identifier (OID), an * IllegalArgumentException is thrown. It is permissible to * have 2 different keywords that map to the same OID. * + *

This implementation enforces a more restrictive OID syntax than + * defined in RFC 1779 and 2253. It uses the more correct syntax defined in + * RFC 4512, which + * specifies that OIDs contain at least 2 digits: + * + *

{@code numericoid = number 1*( DOT number ) } + * * @param name an X.500 distinguished name in RFC 1779 or RFC 2253 format * @param keywordMap an attribute type keyword map, where each key is a * keyword String that maps to a corresponding object identifier in String diff -r eab1e4be8495 -r 09f5d262e329 jdk/src/share/classes/javax/security/auth/x500/package.html --- a/jdk/src/share/classes/javax/security/auth/x500/package.html Fri Feb 17 10:18:50 2012 -0800 +++ b/jdk/src/share/classes/javax/security/auth/x500/package.html Wed Feb 22 10:17:57 2012 -0800 @@ -2,7 +2,7 @@ @@ -657,42 +657,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -967,7 +931,6 @@ - @@ -1005,7 +968,7 @@ samevm="@{samevm}" verbose="@{verbose}" failonerror="false" resultproperty="jtreg.@{name}.result" javacoptions="-g" - vmoptions="${coverage.options} -Xbootclasspath/p:${coverage.classpath}:${build.classes.dir} @{jpda.jvmargs}"> + vmoptions="${coverage.options} -Xbootclasspath/p:${coverage.classpath}${path.separator}${build.classes.dir} @{jpda.jvmargs}"> diff -r eab1e4be8495 -r 09f5d262e329 langtools/make/netbeans/README --- a/langtools/make/netbeans/README Fri Feb 17 10:18:50 2012 -0800 +++ b/langtools/make/netbeans/README Wed Feb 22 10:17:57 2012 -0800 @@ -7,7 +7,7 @@ repository. The repository contains a number of tools: - apt, javac, javadoc and its doclets, javah and javap. + javac, javadoc and its doclets, javah and javap. Build Properties. diff -r eab1e4be8495 -r 09f5d262e329 langtools/make/test/lib/apt.sh --- a/langtools/make/test/lib/apt.sh Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @summary Verify the basic execution of the apt classes in classes.jar. - -TESTSRC=${TESTSRC:-.} -TOPDIR=${TESTSRC}/../../.. -TESTJAVAEXE="${TESTJAVA:+${TESTJAVA}/bin/}java" - -"${TESTJAVAEXE}" -Xbootclasspath/p:${TOPDIR}/dist/lib/classes.jar \ - com.sun.tools.apt.Main \ - -print "${TESTSRC}"/../HelloWorld.java > apt.tmp - -if diff ${TESTSRC}/../HelloWorld.apt.gold.txt apt.tmp ; then - echo "Test passed." -else - echo "Test failed." - exit 1 -fi diff -r eab1e4be8495 -r 09f5d262e329 langtools/make/test/lib/src.gold.txt --- a/langtools/make/test/lib/src.gold.txt Fri Feb 17 10:18:50 2012 -0800 +++ b/langtools/make/test/lib/src.gold.txt Wed Feb 22 10:17:57 2012 -0800 @@ -1,14 +1,4 @@ com/sun/javadoc/package.html -com/sun/mirror/apt/package.html -com/sun/mirror/declaration/package.html -com/sun/mirror/overview.html -com/sun/mirror/type/package.html -com/sun/mirror/util/package.html -com/sun/tools/apt/Main.java -com/sun/tools/apt/main/Main.java -com/sun/tools/apt/resources/apt.properties -com/sun/tools/apt/resources/apt_ja.properties -com/sun/tools/apt/resources/apt_zh_CN.properties com/sun/tools/doclets/formats/html/markup/package.html com/sun/tools/doclets/formats/html/package.html com/sun/tools/doclets/formats/html/resources/standard.properties diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/apt/AnnotationProcessor.java --- a/langtools/src/share/classes/com/sun/mirror/apt/AnnotationProcessor.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.apt; - - -import java.io.IOException; -import java.util.Collection; - - -/** - * An annotation processor, used to examine and process the - * annotations of program elements. An annotation processor may, - * for example, create new source files and XML documents to be used - * in conjunction with the original code. - * - *

An annotation processor is constructed by a - * {@linkplain AnnotationProcessorFactory factory}, which provides it with an - * {@linkplain AnnotationProcessorEnvironment environment} that - * encapsulates the state it needs. - * Messages regarding warnings and errors encountered during processing - * should be directed to the environment's {@link Messager}, - * and new files may be created using the environment's {@link Filer}. - * - *

Each annotation processor is created to process annotations - * of a particular annotation type or set of annotation types. - * It may use its environment to find the program elements with - * annotations of those types. It may freely examine any other program - * elements in the course of its processing. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.annotation.processing.Processor}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface AnnotationProcessor { - - /** - * Process all program elements supported by this annotation processor. - */ - void process(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/apt/AnnotationProcessorEnvironment.java --- a/langtools/src/share/classes/com/sun/mirror/apt/AnnotationProcessorEnvironment.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,182 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.apt; - - -import java.util.Collection; -import java.util.Map; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.*; - - -/** - * The environment encapsulating the state needed by an annotation processor. - * An annotation processing tool makes this environment available - * to all annotation processors. - * - *

When an annotation processing tool is invoked, it is given a - * set of type declarations on which to operate. These - * are refered to as the specified types. - * The type declarations said to be included in this invocation - * consist of the specified types and any types nested within them. - * - *

{@link DeclarationFilter} - * provides a simple way to select just the items of interest - * when a method returns a collection of declarations. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.annotation.processing.ProcessingEnvironment}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface AnnotationProcessorEnvironment { - - /** - * Returns the options passed to the annotation processing tool. - * Options are returned in the form of a map from option name - * (such as "-encoding") to option value. - * For an option with no value (such as "-help"), the - * corresponding value in the map is null. - * - *

Options beginning with "-A" are processor-specific. - * Such options are unrecognized by the tool, but intended to be used by - * some annotation processor. - * - * @return the options passed to the tool - */ - Map getOptions(); - - /** - * Returns the messager used to report errors, warnings, and other - * notices. - * - * @return the messager - */ - Messager getMessager(); - - /** - * Returns the filer used to create new source, class, or auxiliary - * files. - * - * @return the filer - */ - Filer getFiler(); - - - /** - * Returns the declarations of the types specified when the - * annotation processing tool was invoked. - * - * @return the types specified when the tool was invoked, or an - * empty collection if there were none - */ - Collection getSpecifiedTypeDeclarations(); - - /** - * Returns the declaration of a package given its fully qualified name. - * - * @param name fully qualified package name, or "" for the unnamed package - * @return the declaration of the named package, or null if it cannot - * be found - */ - PackageDeclaration getPackage(String name); - - /** - * Returns the declaration of a type given its fully qualified name. - * - * @param name fully qualified type name - * @return the declaration of the named type, or null if it cannot be - * found - */ - TypeDeclaration getTypeDeclaration(String name); - - /** - * A convenience method that returns the declarations of the types - * {@linkplain AnnotationProcessorEnvironment included} - * in this invocation of the annotation processing tool. - * - * @return the declarations of the types included in this invocation - * of the tool, or an empty collection if there are none - */ - Collection getTypeDeclarations(); - - /** - * Returns the declarations annotated with the given annotation type. - * Only declarations of the types - * {@linkplain AnnotationProcessorEnvironment included} - * in this invocation of the annotation processing tool, or - * declarations of members, parameters, or type parameters - * declared within those, are returned. - * - * @param a annotation type being requested - * @return the declarations annotated with the given annotation type, - * or an empty collection if there are none - */ - Collection getDeclarationsAnnotatedWith( - AnnotationTypeDeclaration a); - - /** - * Returns an implementation of some utility methods for - * operating on declarations. - * - * @return declaration utilities - */ - Declarations getDeclarationUtils(); - - /** - * Returns an implementation of some utility methods for - * operating on types. - * - * @return type utilities - */ - Types getTypeUtils(); - - /** - * Add a listener. If the listener is currently registered to listen, - * adding it again will have no effect. - * - * @param listener The listener to add. - * @throws NullPointerException if the listener is null - */ - void addListener(AnnotationProcessorListener listener); - - - /** - * Remove a listener. If the listener is not currently listening, - * the method call does nothing. - * - * @param listener The listener to remove. - * @throws NullPointerException if the listener is null - */ - void removeListener(AnnotationProcessorListener listener); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/apt/AnnotationProcessorFactory.java --- a/langtools/src/share/classes/com/sun/mirror/apt/AnnotationProcessorFactory.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.apt; - - -import java.util.Collection; -import java.util.Set; - -import com.sun.mirror.declaration.AnnotationTypeDeclaration; - - -/** - * A factory for creating annotation processors. - * Each factory is responsible for creating processors for one or more - * annotation types. - * The factory is said to support these types. - * - *

Each implementation of an AnnotationProcessorFactory - * must provide a public no-argument constructor to be used by tools to - * instantiate the factory. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.annotation.processing.Processor}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface AnnotationProcessorFactory { - - /** - * Returns the options recognized by this factory or by any of the - * processors it may create. - * Only {@linkplain AnnotationProcessorEnvironment#getOptions() - * processor-specific} options are included, each of which begins - * with "-A". For example, if this factory recognizes - * options such as -Adebug -Aloglevel=3, it will - * return the strings "-Adebug" and "-Aloglevel". - * - *

A tool might use this information to determine if any - * options provided by a user are unrecognized by any processor, - * in which case it may wish to report an error. - * - * @return the options recognized by this factory or by any of the - * processors it may create, or an empty collection if none - */ - Collection supportedOptions(); - - /** - * Returns the names of the annotation types supported by this factory. - * An element of the result may be the canonical (fully qualified) name - * of a supported annotation type. Alternately it may be of the form - * "name.*" - * representing the set of all annotation types - * with canonical names beginning with "name." - * Finally, "*" by itself represents the set of all - * annotation types. - * - * @return the names of the annotation types supported by this factory - */ - Collection supportedAnnotationTypes(); - - /** - * Returns an annotation processor for a set of annotation - * types. The set will be empty if the factory supports - * "*" and the specified type declarations have - * no annotations. Note that the set of annotation types may be - * empty for other reasons, such as giving the factory an - * opportunity to register a listener. An - * AnnotationProcessorFactory must gracefully handle an - * empty set of annotations; an appropriate response to an empty - * set will often be returning {@link AnnotationProcessors#NO_OP}. - * - * @param atds type declarations of the annotation types to be processed - * @param env environment to use during processing - * @return an annotation processor for the given annotation types, - * or null if the types are not supported or the - * processor cannot be created - */ - AnnotationProcessor getProcessorFor(Set atds, - AnnotationProcessorEnvironment env); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/apt/AnnotationProcessorListener.java --- a/langtools/src/share/classes/com/sun/mirror/apt/AnnotationProcessorListener.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.apt; - -/** - * Superinterface for all annotation processor event listeners. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. This interface has no - * direct analog in the standardized API because the different round - * model renders it unnecessary. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface AnnotationProcessorListener extends java.util.EventListener {} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/apt/AnnotationProcessors.java --- a/langtools/src/share/classes/com/sun/mirror/apt/AnnotationProcessors.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.apt; - -import com.sun.mirror.apt.*; -import java.util.*; - -/** - * Utilities to create specialized annotation processors. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. There is no direct analog - * of the functionality of this class in the standardized API. - * - * @since 1.5 - * @author Joseph D. Darcy - * @author Scott Seligman - */ -@Deprecated -@SuppressWarnings("deprecation") -public class AnnotationProcessors { - static class NoOpAP implements AnnotationProcessor { - NoOpAP() {} - public void process(){} - } - - /** - * Combines multiple annotation processors into a simple composite - * processor. - * The composite processor functions by invoking each of its component - * processors in sequence. - */ - static class CompositeAnnotationProcessor implements AnnotationProcessor { - - private List aps = - new LinkedList(); - - /** - * Constructs a new composite annotation processor. - * @param aps the component annotation processors - */ - public CompositeAnnotationProcessor(Collection aps) { - this.aps.addAll(aps); - } - - /** - * Constructs a new composite annotation processor. - * @param aps the component annotation processors - */ - public CompositeAnnotationProcessor(AnnotationProcessor... aps) { - for(AnnotationProcessor ap: aps) - this.aps.add(ap); - } - - /** - * Invokes the process method of each component processor, - * in the order in which the processors were passed to the constructor. - */ - public void process() { - for(AnnotationProcessor ap: aps) - ap.process(); - } - } - - - /** - * An annotation processor that does nothing and has no state. - * May be used multiple times. - * - * @since 1.5 - */ - public final static AnnotationProcessor NO_OP = new NoOpAP(); - - /** - * Constructs a new composite annotation processor. A composite - * annotation processor combines multiple annotation processors - * into one and functions by invoking each of its component - * processors' process methods in sequence. - * - * @param aps The processors to create a composite of - * @since 1.5 - */ - public static AnnotationProcessor getCompositeAnnotationProcessor(AnnotationProcessor... aps) { - return new CompositeAnnotationProcessor(aps); - } - - /** - * Constructs a new composite annotation processor. A composite - * annotation processor combines multiple annotation processors - * into one and functions by invoking each of its component - * processors' process methods in the sequence the processors are - * returned by the collection's iterator. - * - * @param aps A collection of processors to create a composite of - * @since 1.5 - */ - public static AnnotationProcessor getCompositeAnnotationProcessor(Collection aps) { - return new CompositeAnnotationProcessor(aps); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/apt/Filer.java --- a/langtools/src/share/classes/com/sun/mirror/apt/Filer.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.apt; - - -import java.io.*; - - -/** - * This interface supports the creation of new files by an - * annotation processor. - * Files created in this way will be known to the annotation processing - * tool implementing this interface, better enabling the tool to manage them. - * Four kinds of files are distinguished: - * source files, class files, other text files, and other binary files. - * The latter two are collectively referred to as auxiliary files. - * - *

There are two distinguished locations (subtrees within the - * file system) where newly created files are placed: - * one for new source files, and one for new class files. - * (These might be specified on a tool's command line, for example, - * using flags such as -s and -d.) - * Auxiliary files may be created in either location. - * - *

During each run of an annotation processing tool, a file - * with a given pathname may be created only once. If that file already - * exists before the first attempt to create it, the old contents will - * be deleted. Any subsequent attempt to create the same file during - * a run will fail. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.annotation.processing.Filer}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface Filer { - - /** - * Creates a new source file and returns a writer for it. - * The file's name and path (relative to the root of all newly created - * source files) is based on the type to be declared in that file. - * If more than one type is being declared, the name of the principal - * top-level type (the public one, for example) should be used. - * - *

The {@linkplain java.nio.charset.Charset charset} used to - * encode the file is determined by the implementation. - * An annotation processing tool may have an -encoding - * flag or the like for specifying this. It will typically use - * the platform's default encoding if none is specified. - * - * @param name canonical (fully qualified) name of the principal type - * being declared in this file - * @return a writer for the new file - * @throws IOException if the file cannot be created - */ - PrintWriter createSourceFile(String name) throws IOException; - - /** - * Creates a new class file, and returns a stream for writing to it. - * The file's name and path (relative to the root of all newly created - * class files) is based on the name of the type being written. - * - * @param name canonical (fully qualified) name of the type being written - * @return a stream for writing to the new file - * @throws IOException if the file cannot be created - */ - OutputStream createClassFile(String name) throws IOException; - - /** - * Creates a new text file, and returns a writer for it. - * The file is located along with either the - * newly created source or newly created binary files. It may be - * named relative to some package (as are source and binary files), - * and from there by an arbitrary pathname. In a loose sense, the - * pathname of the new file will be the concatenation of - * loc, pkg, and relPath. - * - *

A {@linkplain java.nio.charset.Charset charset} for - * encoding the file may be provided. If none is given, the - * charset used to encode source files - * (see {@link #createSourceFile(String)}) will be used. - * - * @param loc location of the new file - * @param pkg package relative to which the file should be named, - * or the empty string if none - * @param relPath final pathname components of the file - * @param charsetName the name of the charset to use, or null if none - * is being explicitly specified - * @return a writer for the new file - * @throws IOException if the file cannot be created - */ - PrintWriter createTextFile(Location loc, - String pkg, - File relPath, - String charsetName) throws IOException; - - /** - * Creates a new binary file, and returns a stream for writing to it. - * The file is located along with either the - * newly created source or newly created binary files. It may be - * named relative to some package (as are source and binary files), - * and from there by an arbitrary pathname. In a loose sense, the - * pathname of the new file will be the concatenation of - * loc, pkg, and relPath. - * - * @param loc location of the new file - * @param pkg package relative to which the file should be named, - * or the empty string if none - * @param relPath final pathname components of the file - * @return a stream for writing to the new file - * @throws IOException if the file cannot be created - */ - OutputStream createBinaryFile(Location loc, - String pkg, - File relPath) throws IOException; - - - /** - * Locations (subtrees within the file system) where new files are created. - * - * @deprecated All components of this API have been superseded by - * the standardized annotation processing API. The replacement - * for the functionality of this enum is {@link - * javax.tools.StandardLocation}. - */ - @Deprecated - enum Location { - /** The location of new source files. */ - SOURCE_TREE, - /** The location of new class files. */ - CLASS_TREE - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/apt/Messager.java --- a/langtools/src/share/classes/com/sun/mirror/apt/Messager.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.apt; - -import com.sun.mirror.util.SourcePosition; - -/** - * A Messager provides the way for - * an annotation processor to report error messages, warnings, and - * other notices. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.annotation.processing.Messager}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface Messager { - - /** - * Prints an error message. - * Equivalent to printError(null, msg). - * @param msg the message, or an empty string if none - */ - void printError(String msg); - - /** - * Prints an error message. - * @param pos the position where the error occured, or null if it is - * unknown or not applicable - * @param msg the message, or an empty string if none - */ - void printError(SourcePosition pos, String msg); - - /** - * Prints a warning message. - * Equivalent to printWarning(null, msg). - * @param msg the message, or an empty string if none - */ - void printWarning(String msg); - - /** - * Prints a warning message. - * @param pos the position where the warning occured, or null if it is - * unknown or not applicable - * @param msg the message, or an empty string if none - */ - void printWarning(SourcePosition pos, String msg); - - /** - * Prints a notice. - * Equivalent to printNotice(null, msg). - * @param msg the message, or an empty string if none - */ - void printNotice(String msg); - - /** - * Prints a notice. - * @param pos the position where the noticed occured, or null if it is - * unknown or not applicable - * @param msg the message, or an empty string if none - */ - void printNotice(SourcePosition pos, String msg); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/apt/RoundCompleteEvent.java --- a/langtools/src/share/classes/com/sun/mirror/apt/RoundCompleteEvent.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.apt; - -/** - * Event for the completion of a round of annotation processing. - * - *

While this class extends the serializable EventObject, it - * cannot meaningfully be serialized because all of the annotation - * processing tool's internal state would potentially be needed. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. This class has no direct - * analog in the standardized API because the different round model - * renders it unnecessary. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public abstract class RoundCompleteEvent extends java.util.EventObject { - private RoundState rs; - - /** - * The current AnnotationProcessorEnvironment is regarded - * as the source of events. - * - * @param source The source of events - * @param rs The state of the round - */ - protected RoundCompleteEvent(AnnotationProcessorEnvironment source, - RoundState rs) { - super(source); - this.rs = rs; - } - - /** - * Return round state. - */ - public RoundState getRoundState() { - return rs; - } - - /** - * Return source. - */ - public AnnotationProcessorEnvironment getSource() { - return (AnnotationProcessorEnvironment)super.getSource(); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/apt/RoundCompleteListener.java --- a/langtools/src/share/classes/com/sun/mirror/apt/RoundCompleteListener.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.apt; - -/** - * Listener for the completion of a round of annotation processing. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. This interface has no - * direct analog in the standardized API because the different round - * model renders it unnecessary. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface RoundCompleteListener extends AnnotationProcessorListener { - /** - * Invoked after all processors for a round have run to completion. - * - * @param event An event for round completion - */ - void roundComplete(RoundCompleteEvent event); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/apt/RoundState.java --- a/langtools/src/share/classes/com/sun/mirror/apt/RoundState.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.apt; - -/** - * Represents the status of a completed round of annotation processing. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.annotation.processing.RoundEnvironment}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface RoundState { - /** - * Returns true if this was the last round of annotation - * processing; returns false if there will be a subsequent round. - */ - boolean finalRound(); - - /** - * Returns true if an error was raised in this round of processing; - * returns false otherwise. - */ - boolean errorRaised(); - - /** - * Returns true if new source files were created in this round of - * processing; returns false otherwise. - */ - boolean sourceFilesCreated(); - - /** - * Returns true if new class files were created in this round of - * processing; returns false otherwise. - */ - boolean classFilesCreated(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/apt/package-info.java --- a/langtools/src/share/classes/com/sun/mirror/apt/package-info.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * Classes used to communicate information between {@linkplain - * com.sun.mirror.apt.AnnotationProcessor annotation processors} and - * an annotation processing tool. - * - *

The {@code apt} tool and its associated API have been superseded - * by the standardized annotation processing API. The replacement for - * the functionality in this package is {@link - * javax.annotation.processing}. - * - * @since 1.5 - */ -package com.sun.mirror.apt; diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/declaration/AnnotationMirror.java --- a/langtools/src/share/classes/com/sun/mirror/declaration/AnnotationMirror.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - -import java.util.Map; -import com.sun.mirror.type.AnnotationType; -import com.sun.mirror.util.SourcePosition; - - -/** - * Represents an annotation. An annotation associates a value with - * each element of an annotation type. - * - *

Annotations should not be compared using reference-equality - * ("=="). There is no guarantee that any particular - * annotation will always be represented by the same object. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.element.AnnotationMirror}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface AnnotationMirror { - - /** - * Returns the annotation type of this annotation. - * - * @return the annotation type of this annotation - */ - AnnotationType getAnnotationType(); - - /** - * Returns the source position of the beginning of this annotation. - * Returns null if the position is unknown or not applicable. - * - *

This source position is intended for use in providing diagnostics, - * and indicates only approximately where an annotation begins. - * - * @return the source position of the beginning of this annotation or - * null if the position is unknown or not applicable - */ - SourcePosition getPosition(); - - /** - * Returns this annotation's elements and their values. - * This is returned in the form of a map that associates elements - * with their corresponding values. - * Only those elements and values explicitly present in the - * annotation are included, not those that are implicitly assuming - * their default values. - * The order of the map matches the order in which the - * elements appear in the annotation's source. - * - * @return this annotation's elements and their values, - * or an empty map if there are none - */ - Map getElementValues(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/declaration/AnnotationTypeDeclaration.java --- a/langtools/src/share/classes/com/sun/mirror/declaration/AnnotationTypeDeclaration.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -import java.util.Collection; - - -/** - * Represents the declaration of an annotation type. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.element.TypeElement}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface AnnotationTypeDeclaration extends InterfaceDeclaration { - - /** - * Returns the annotation type elements of this annotation type. - * These are the methods that are directly declared in the type's - * declaration. - * - * @return the annotation type elements of this annotation type, - * or an empty collection if there are none - */ - Collection getMethods(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/declaration/AnnotationTypeElementDeclaration.java --- a/langtools/src/share/classes/com/sun/mirror/declaration/AnnotationTypeElementDeclaration.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -/** - * Represents an element of an annotation type. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.element.ExecutableElement}. - * - * @author Joe Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface AnnotationTypeElementDeclaration extends MethodDeclaration { - - /** - * Returns the default value of this element. - * - * @return the default value of this element, or null if this element - * has no default. - */ - AnnotationValue getDefaultValue(); - - /** - * {@inheritDoc} - */ - AnnotationTypeDeclaration getDeclaringType(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/declaration/AnnotationValue.java --- a/langtools/src/share/classes/com/sun/mirror/declaration/AnnotationValue.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - -import com.sun.mirror.util.SourcePosition; - -/** - * Represents a value of an annotation type element. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.element.AnnotationValue}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface AnnotationValue { - - /** - * Returns the value. - * The result has one of the following types: - *

  • a wrapper class (such as {@link Integer}) for a primitive type - *
  • {@code String} - *
  • {@code TypeMirror} - *
  • {@code EnumConstantDeclaration} - *
  • {@code AnnotationMirror} - *
  • {@code Collection} - * (representing the elements, in order, if the value is an array) - *
- * - * @return the value - */ - Object getValue(); - - /** - * Returns the source position of the beginning of this annotation value. - * Returns null if the position is unknown or not applicable. - * - *

This source position is intended for use in providing diagnostics, - * and indicates only approximately where an annotation value begins. - * - * @return the source position of the beginning of this annotation value or - * null if the position is unknown or not applicable - */ - SourcePosition getPosition(); - - /** - * Returns a string representation of this value. - * This is returned in a form suitable for representing this value - * in the source code of an annotation. - * - * @return a string representation of this value - */ - String toString(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/declaration/ClassDeclaration.java --- a/langtools/src/share/classes/com/sun/mirror/declaration/ClassDeclaration.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -import java.util.Collection; - -import com.sun.mirror.type.ClassType; - - -/** - * Represents the declaration of a class. - * For the declaration of an interface, see {@link InterfaceDeclaration}. - * Provides access to information about the class, its members, and - * its constructors. - * Note that an {@linkplain EnumDeclaration enum} is a kind of class. - * - *

While a ClassDeclaration represents the declaration - * of a class, a {@link ClassType} represents a class type. - * See {@link TypeDeclaration} for more on this distinction. - * - *

{@link com.sun.mirror.util.DeclarationFilter} - * provides a simple way to select just the items of interest - * when a method returns a collection of declarations. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.element.TypeElement}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * - * @see ClassType - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface ClassDeclaration extends TypeDeclaration { - - /** - * Returns the class type directly extended by this class. - * The only class with no superclass is java.lang.Object, - * for which this method returns null. - * - * @return the class type directly extended by this class, or null - * if there is none - */ - ClassType getSuperclass(); - - /** - * Returns the constructors of this class. - * This includes the default constructor if this class has - * no constructors explicitly declared. - * - * @return the constructors of this class - * - * @see com.sun.mirror.util.DeclarationFilter - */ - Collection getConstructors(); - - /** - * {@inheritDoc} - */ - Collection getMethods(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/declaration/ConstructorDeclaration.java --- a/langtools/src/share/classes/com/sun/mirror/declaration/ConstructorDeclaration.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -/** - * Represents a constructor of a class or interface. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.element.ExecutableElement}. - * - * @author Joe Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface ConstructorDeclaration extends ExecutableDeclaration { -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/declaration/Declaration.java --- a/langtools/src/share/classes/com/sun/mirror/declaration/Declaration.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,169 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -import java.lang.annotation.Annotation; -import java.util.Collection; - -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -/** - * Represents the declaration of a program element such as a package, - * class, or method. Each declaration represents a static, language-level - * construct (and not, for example, a runtime construct of the virtual - * machine), and typically corresponds one-to-one with a particular - * fragment of source code. - * - *

Declarations should be compared using the {@link #equals(Object)} - * method. There is no guarantee that any particular declaration will - * always be represented by the same object. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.element.Element}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * - * @see Declarations - * @see TypeMirror - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface Declaration { - - /** - * Tests whether an object represents the same declaration as this. - * - * @param obj the object to be compared with this declaration - * @return true if the specified object represents the same - * declaration as this - */ - boolean equals(Object obj); - - /** - * Returns the text of the documentation ("javadoc") comment of - * this declaration. - * - * @return the documentation comment of this declaration, or null - * if there is none - */ - String getDocComment(); - - /** - * Returns the annotations that are directly present on this declaration. - * - * @return the annotations directly present on this declaration; - * an empty collection if there are none - */ - Collection getAnnotationMirrors(); - - /** - * Returns the annotation of this declaration having the specified - * type. The annotation may be either inherited or directly - * present on this declaration. - * - *

The annotation returned by this method could contain an element - * whose value is of type Class. - * This value cannot be returned directly: information necessary to - * locate and load a class (such as the class loader to use) is - * not available, and the class might not be loadable at all. - * Attempting to read a Class object by invoking the relevant - * method on the returned annotation - * will result in a {@link MirroredTypeException}, - * from which the corresponding {@link TypeMirror} may be extracted. - * Similarly, attempting to read a Class[]-valued element - * will result in a {@link MirroredTypesException}. - * - *

- * Note: This method is unlike - * others in this and related interfaces. It operates on run-time - * reflective information -- representations of annotation types - * currently loaded into the VM -- rather than on the mirrored - * representations defined by and used throughout these - * interfaces. It is intended for callers that are written to - * operate on a known, fixed set of annotation types. - *
- * - * @param the annotation type - * @param annotationType the Class object corresponding to - * the annotation type - * @return the annotation of this declaration having the specified type - * - * @see #getAnnotationMirrors() - */ - A getAnnotation(Class annotationType); - - /** - * Returns the modifiers of this declaration, excluding annotations. - * Implicit modifiers, such as the public and static - * modifiers of interface members, are included. - * - * @return the modifiers of this declaration in undefined order; - * an empty collection if there are none - */ - Collection getModifiers(); - - /** - * Returns the simple (unqualified) name of this declaration. - * The name of a generic type does not include any reference - * to its formal type parameters. - * For example, the simple name of the interface declaration - * {@code java.util.Set} is "Set". - * If this declaration represents the empty package, an empty - * string is returned. - * If it represents a constructor, the simple name of its - * declaring class is returned. - * - * @return the simple name of this declaration - */ - String getSimpleName(); - - /** - * Returns the source position of the beginning of this declaration. - * Returns null if the position is unknown or not applicable. - * - *

This source position is intended for use in providing - * diagnostics, and indicates only approximately where a declaration - * begins. - * - * @return the source position of the beginning of this declaration, - * or null if the position is unknown or not applicable - */ - SourcePosition getPosition(); - - /** - * Applies a visitor to this declaration. - * - * @param v the visitor operating on this declaration - */ - void accept(DeclarationVisitor v); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/declaration/EnumConstantDeclaration.java --- a/langtools/src/share/classes/com/sun/mirror/declaration/EnumConstantDeclaration.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -/** - * Represents an enum constant declaration. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.element.VariableElement}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface EnumConstantDeclaration extends FieldDeclaration { - /** - * {@inheritDoc} - */ - EnumDeclaration getDeclaringType(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/declaration/EnumDeclaration.java --- a/langtools/src/share/classes/com/sun/mirror/declaration/EnumDeclaration.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -import java.util.Collection; - - -/** - * Represents the declaration of an enum type. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.element.TypeElement}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface EnumDeclaration extends ClassDeclaration { - - /** - * Returns the enum constants defined for this enum. - * - * @return the enum constants defined for this enum, - * or an empty collection if there are none - */ - Collection getEnumConstants(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/declaration/ExecutableDeclaration.java --- a/langtools/src/share/classes/com/sun/mirror/declaration/ExecutableDeclaration.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -import java.util.Collection; - -import com.sun.mirror.type.ReferenceType; - - -/** - * Represents a method or constructor of a class or interface. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.element.ExecutableElement}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface ExecutableDeclaration extends MemberDeclaration { - - /** - * Returns true if this method or constructor accepts a variable - * number of arguments. - * - * @return true if this method or constructor accepts a variable - * number of arguments - */ - boolean isVarArgs(); - - /** - * Returns the formal type parameters of this method or constructor. - * They are returned in declaration order. - * - * @return the formal type parameters of this method or constructor, - * or an empty collection if there are none - */ - Collection getFormalTypeParameters(); - - /** - * Returns the formal parameters of this method or constructor. - * They are returned in declaration order. - * - * @return the formal parameters of this method or constructor, - * or an empty collection if there are none - */ - Collection getParameters(); - - /** - * Returns the exceptions and other throwables listed in this - * method or constructor's throws clause. - * - * @return the exceptions and other throwables listed in the - * throws clause, or an empty collection if there are none - */ - Collection getThrownTypes(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/declaration/FieldDeclaration.java --- a/langtools/src/share/classes/com/sun/mirror/declaration/FieldDeclaration.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -import com.sun.mirror.type.TypeMirror; - - -/** - * Represents a field of a type declaration. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.element.VariableElement}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface FieldDeclaration extends MemberDeclaration { - - /** - * Returns the type of this field. - * - * @return the type of this field - */ - TypeMirror getType(); - - /** - * Returns the value of this field if this field is a compile-time - * constant. Returns null otherwise. - * The value will be of a primitive type or String. - * If the value is of a primitive type, it is wrapped in the - * appropriate wrapper class (such as {@link Integer}). - * - * @return the value of this field if this field is a compile-time - * constant, or null otherwise - */ - Object getConstantValue(); - - /** - * Returns the text of a constant expression representing the - * value of this field if this field is a compile-time constant. - * Returns null otherwise. - * The value will be of a primitive type or String. - * The text returned is in a form suitable for representing the value - * in source code. - * - * @return the text of a constant expression if this field is a - * compile-time constant, or null otherwise - */ - String getConstantExpression(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/declaration/InterfaceDeclaration.java --- a/langtools/src/share/classes/com/sun/mirror/declaration/InterfaceDeclaration.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -import com.sun.mirror.type.InterfaceType; - - -/** - * Represents the declaration of an interface. - * Provides access to information about the interface and its members. - * Note that an {@linkplain AnnotationTypeDeclaration annotation type} is - * a kind of interface. - * - *

While an InterfaceDeclaration represents the - * declaration of an interface, an {@link InterfaceType} - * represents an interface type. - * See {@link TypeDeclaration} for more on this distinction. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.element.TypeElement}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * - * @see InterfaceType - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface InterfaceDeclaration extends TypeDeclaration { -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/declaration/MemberDeclaration.java --- a/langtools/src/share/classes/com/sun/mirror/declaration/MemberDeclaration.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -/** - * Represents a declaration that may be a member or constructor of a declared - * type. This includes fields, constructors, methods, and (since they - * may be nested) declared types themselves. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.element.Element}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface MemberDeclaration extends Declaration { - - /** - * Returns the type declaration within which this member or constructor - * is declared. - * If this is the declaration of a top-level type (a non-nested class - * or interface), returns null. - * - * @return the type declaration within which this member or constructor - * is declared, or null if there is none - */ - TypeDeclaration getDeclaringType(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/declaration/MethodDeclaration.java --- a/langtools/src/share/classes/com/sun/mirror/declaration/MethodDeclaration.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -import com.sun.mirror.type.TypeMirror; -import com.sun.mirror.type.VoidType; - - -/** - * Represents a method of a class or interface. - * Note that an - * {@linkplain AnnotationTypeElementDeclaration annotation type element} - * is a kind of method. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.element.ExecutableElement}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface MethodDeclaration extends ExecutableDeclaration { - - /** - * Returns the formal return type of this method. - * Returns {@link VoidType} if this method does not return a value. - * - * @return the formal return type of this method - */ - TypeMirror getReturnType(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/declaration/Modifier.java --- a/langtools/src/share/classes/com/sun/mirror/declaration/Modifier.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -/** - * Represents a modifier on the declaration of a program element such - * as a class, method, or field. - * - *

Not all modifiers are applicable to all kinds of declarations. - * When two or more modifiers appear in the source code of a declaration, - * then it is customary, though not required, that they appear in the same - * order as the constants listed in the detail section below. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this enum is {@link javax.lang.model.element.Modifier}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public enum Modifier { - - // See JLS2 sections 8.1.1, 8.3.1, 8.4.3, 8.8.3, and 9.1.1. - // java.lang.reflect.Modifier includes INTERFACE, but that's a VMism. - - /** The modifier public */ PUBLIC, - /** The modifier protected */ PROTECTED, - /** The modifier private */ PRIVATE, - /** The modifier abstract */ ABSTRACT, - /** The modifier static */ STATIC, - /** The modifier final */ FINAL, - /** The modifier transient */ TRANSIENT, - /** The modifier volatile */ VOLATILE, - /** The modifier synchronized */ SYNCHRONIZED, - /** The modifier native */ NATIVE, - /** The modifier strictfp */ STRICTFP; - - - private String lowercase = null; // modifier name in lowercase - - /** - * Returns this modifier's name in lowercase. - */ - public String toString() { - if (lowercase == null) { - lowercase = name().toLowerCase(java.util.Locale.US); - } - return lowercase; - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/declaration/PackageDeclaration.java --- a/langtools/src/share/classes/com/sun/mirror/declaration/PackageDeclaration.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -import java.util.Collection; - - -/** - * Represents the declaration of a package. Provides access to information - * about the package and its members. - * - *

{@link com.sun.mirror.util.DeclarationFilter} - * provides a simple way to select just the items of interest - * when a method returns a collection of declarations. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.element.PackageElement}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface PackageDeclaration extends Declaration { - - /** - * Returns the fully qualified name of this package. - * This is also known as the package's canonical name. - * - * @return the fully qualified name of this package, or the - * empty string if this is the unnamed package - */ - String getQualifiedName(); - - /** - * Returns the declarations of the top-level classes in this package. - * Interfaces are not included, but enum types are. - * - * @return the declarations of the top-level classes in this package - * - * @see com.sun.mirror.util.DeclarationFilter - */ - Collection getClasses(); - - /** - * Returns the declarations of the top-level enum types in this package. - * - * @return the declarations of the top-level enum types in this package - * - * @see com.sun.mirror.util.DeclarationFilter - */ - Collection getEnums(); - - /** - * Returns the declarations of the top-level interfaces in this package. - * Annotation types are included. - * - * @return the declarations of the top-level interfaces in this package - * - * @see com.sun.mirror.util.DeclarationFilter - */ - Collection getInterfaces(); - - /** - * Returns the declarations of the top-level annotation types in this - * package. - * - * @return the declarations of the top-level annotation types in this - * package - * - * @see com.sun.mirror.util.DeclarationFilter - */ - Collection getAnnotationTypes(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/declaration/ParameterDeclaration.java --- a/langtools/src/share/classes/com/sun/mirror/declaration/ParameterDeclaration.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -import com.sun.mirror.type.TypeMirror; - - -/** - * Represents a formal parameter of a method or constructor. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.element.VariableElement}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface ParameterDeclaration extends Declaration { - - /** - * Returns the type of this parameter. - * - * @return the type of this parameter - */ - TypeMirror getType(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/declaration/TypeDeclaration.java --- a/langtools/src/share/classes/com/sun/mirror/declaration/TypeDeclaration.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -import java.util.Collection; - -import com.sun.mirror.type.*; - - -/** - * Represents the declaration of a class or interface. - * Provides access to information about the type and its members. - * Note that an {@linkplain EnumDeclaration enum} is a kind of class, - * and an {@linkplain AnnotationTypeDeclaration annotation type} is - * a kind of interface. - * - *

- * While a TypeDeclaration represents the declaration - * of a class or interface, a {@link DeclaredType} represents a class - * or interface type, the latter being a use - * (or invocation) of the former. - * The distinction is most apparent with generic types, - * for which a single declaration can define a whole - * family of types. For example, the declaration of - * {@code java.util.Set} corresponds to the parameterized types - * {@code java.util.Set} and {@code java.util.Set} - * (and many others), and to the raw type {@code java.util.Set}. - * - *

{@link com.sun.mirror.util.DeclarationFilter} - * provides a simple way to select just the items of interest - * when a method returns a collection of declarations. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.element.TypeElement}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * - * @see DeclaredType - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface TypeDeclaration extends MemberDeclaration { - - /** - * Returns the package within which this type is declared. - * - * @return the package within which this type is declared - */ - PackageDeclaration getPackage(); - - /** - * Returns the fully qualified name of this class or interface - * declaration. More precisely, it returns the canonical - * name. - * The name of a generic type does not include any reference - * to its formal type parameters. - * For example, the the fully qualified name of the interface declaration - * {@code java.util.Set} is "java.util.Set". - * - * @return the fully qualified name of this class or interface declaration - */ - String getQualifiedName(); - - /** - * Returns the formal type parameters of this class or interface. - * - * @return the formal type parameters, or an empty collection - * if there are none - */ - Collection getFormalTypeParameters(); - - /** - * Returns the interface types directly implemented by this class - * or extended by this interface. - * - * @return the interface types directly implemented by this class - * or extended by this interface, or an empty collection if there are none - * - * @see com.sun.mirror.util.DeclarationFilter - */ - Collection getSuperinterfaces(); - - /** - * Returns the fields that are directly declared by this class or - * interface. Includes enum constants. - * - * @return the fields that are directly declared, - * or an empty collection if there are none - * - * @see com.sun.mirror.util.DeclarationFilter - */ - Collection getFields(); - - /** - * Returns the methods that are directly declared by this class or - * interface. Includes annotation type elements. Excludes - * implicitly declared methods of an interface, such as - * toString, that correspond to the methods of - * java.lang.Object. - * - * @return the methods that are directly declared, - * or an empty collection if there are none - * - * @see com.sun.mirror.util.DeclarationFilter - */ - Collection getMethods(); - - /** - * Returns the declarations of the nested classes and interfaces - * that are directly declared by this class or interface. - * - * @return the declarations of the nested classes and interfaces, - * or an empty collection if there are none - * - * @see com.sun.mirror.util.DeclarationFilter - */ - Collection getNestedTypes(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/declaration/TypeParameterDeclaration.java --- a/langtools/src/share/classes/com/sun/mirror/declaration/TypeParameterDeclaration.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.declaration; - - -import java.util.Collection; - -import com.sun.mirror.type.*; - - -/** - * Represents a formal type parameter of a generic type, method, - * or constructor declaration. - * A type parameter declares a {@link TypeVariable}. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.element.TypeParameterElement}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface TypeParameterDeclaration extends Declaration { - - /** - * Returns the bounds of this type parameter. - * These are the types given by the extends clause. - * If there is no explicit extends clause, then - * java.lang.Object is considered to be the sole bound. - * - * @return the bounds of this type parameter - */ - Collection getBounds(); - - /** - * Returns the type, method, or constructor declaration within which - * this type parameter is declared. - * - * @return the declaration within which this type parameter is declared - */ - Declaration getOwner(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/declaration/package-info.java --- a/langtools/src/share/classes/com/sun/mirror/declaration/package-info.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * Interfaces used to model program element declarations. A - * declaration is represented by the appropriate subinterface of - * {@link com.sun.mirror.declaration.Declaration}, and an annotation - * is represented as an {@link - * com.sun.mirror.declaration.AnnotationMirror}. - * - *

The {@code apt} tool and its associated API have been superseded - * by the standardized annotation processing API. The replacement for - * the functionality in this package is {@link - * javax.lang.model.element}. - * - * @since 1.5 - */ -package com.sun.mirror.declaration; diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/overview.html --- a/langtools/src/share/classes/com/sun/mirror/overview.html Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,111 +0,0 @@ - - - - - - - - -The Mirror API is used to model the semantic structure of a program. -It provides representations of the entities -declared in a program, such as classes, methods, and fields. -Constructs below the method level, such as -individual statements and expressions, are not represented. - -

Also included is support for writing -{@linkplain com.sun.mirror.apt.AnnotationProcessor annotation processors} -to examine and process the annotations -of program elements. An annotation processor may, as an example, create -new source files and XML documents to be used in conjunction with the -original code. - - -

Characteristics of the API

- -A program is represented at the language level, rather than at the -level of the virtual machine. Nested classes, for example, are -handled as first-class constructs, -rather than in the translated form understood by the VM. -Both source code and compiled code (class files) may be modeled -in this way. - -

Programs are modeled in their static, or build-time, form. -This differs from the {@linkplain java.lang.reflect reflection} API, -which provides run-time information about classes and objects. - -

The API does not provide direct support for generating new code. - - -

Declarations and Types

- -The mirror API represents program constructs principally through the -{@link com.sun.mirror.declaration.Declaration} interface -and its hierarchy of subinterfaces in the package {@link -com.sun.mirror.declaration}. A Declaration represents a -program element such as a package, class, or method. -The interface hierarchy is depicted - here. - -

Types are represented by the {@link com.sun.mirror.type.TypeMirror} -interface and its hierarchy of subinterfaces in the -package {@link com.sun.mirror.type}. Types include primitive types, -class and interface types, array types, type variables, and wildcards. -The interface hierarchy is depicted - here. - -

The API makes a clear distinction between declarations and types. -This is most significant for generic types, where a single declaration -can define an infinite family of types. For example, the declaration of -java.util.Set defines the raw type java.util.Set, -the parameterized type {@code java.util.Set}, -and much more. Only the declaration can be annotated, for example, -and only a type can appear in a method signature. - -

A program being modeled may be incomplete, in that -it may depend on an unknown class or interface type. -This may be the result of a processing error such as a missing class file, -or perhaps the missing type is to be created by an annotation processor. -See {@link com.sun.mirror.type.DeclaredType} for information on -how such unknown types are handled. - - -

Utilities and Tool Support

- -The {@link com.sun.mirror.util} package provides -utilities to assist in the processing of declarations and types. -Included is support for using the visitor design pattern when -operating on declaration and type objects. - -

The {@link com.sun.mirror.apt} package supports the writing -of annotation processors. It provides the mechanism for them to -interact with an annotation processing tool. - - -@since 1.5 - - - diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/type/AnnotationType.java --- a/langtools/src/share/classes/com/sun/mirror/type/AnnotationType.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -import com.sun.mirror.declaration.AnnotationTypeDeclaration; - - -/** - * Represents an annotation type. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.type.DeclaredType}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface AnnotationType extends InterfaceType { - - /** - * {@inheritDoc} - */ - AnnotationTypeDeclaration getDeclaration(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/type/ArrayType.java --- a/langtools/src/share/classes/com/sun/mirror/type/ArrayType.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -/** - * Represents an array type. - * A multidimensional array type is represented as an array type - * whose component type is also an array type. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.type.ArrayType}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface ArrayType extends ReferenceType { - - /** - * Returns the component type of this array type. - * - * @return the component type of this array type - */ - TypeMirror getComponentType(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/type/ClassType.java --- a/langtools/src/share/classes/com/sun/mirror/type/ClassType.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -import com.sun.mirror.declaration.*; - - -/** - * Represents a class type. - * Interface types are represented separately by {@link InterfaceType}. - * Note that an {@linkplain EnumType enum} is a kind of class. - * - *

While a {@link ClassDeclaration} represents the declaration - * of a class, a ClassType represents a class type. - * See {@link TypeDeclaration} for more on this distinction. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.type.DeclaredType}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface ClassType extends DeclaredType { - - /** - * {@inheritDoc} - */ - ClassDeclaration getDeclaration(); - - /** - * Returns the class type that is a direct supertype of this one. - * This is the superclass of this type's declaring class, with any - * type arguments substituted in. - * The only class with no superclass is java.lang.Object, - * for which this method returns null. - * - *

For example, the class type extended by - * {@code java.util.TreeSet} is - * {@code java.util.AbstractSet}. - * - * @return the class type that is a direct supertype of this one, - * or null if there is none - */ - ClassType getSuperclass(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/type/DeclaredType.java --- a/langtools/src/share/classes/com/sun/mirror/type/DeclaredType.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -import java.util.Collection; - -import com.sun.mirror.declaration.TypeDeclaration; - - -/** - * Represents a declared type, either a class type or an interface type. - * This includes parameterized types such as {@code java.util.Set} - * as well as raw types. - * - *

While a TypeDeclaration represents the declaration - * of a class or interface, a DeclaredType represents a class - * or interface type, the latter being a use of the former. - * See {@link TypeDeclaration} for more on this distinction. - * - *

A DeclaredType may represent a type - * for which details (declaration, supertypes, etc.) are unknown. - * This may be the result of a processing error, such as a missing class file, - * and is indicated by {@link #getDeclaration()} returning null. - * Other method invocations on such an unknown type will not, in general, - * return meaningful results. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.type.DeclaredType}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface DeclaredType extends ReferenceType { - - /** - * Returns the declaration of this type. - * - *

Returns null if this type's declaration is unknown. This may - * be the result of a processing error, such as a missing class file. - * - * @return the declaration of this type, or null if unknown - */ - TypeDeclaration getDeclaration(); - - /** - * Returns the type that contains this type as a member. - * Returns null if this is a top-level type. - * - *

For example, the containing type of {@code O.I} - * is the type {@code O}, and the containing type of - * {@code O.I} is the type {@code O}. - * - * @return the type that contains this type, - * or null if this is a top-level type - */ - DeclaredType getContainingType(); - - /** - * Returns (in order) the actual type arguments of this type. - * For a generic type nested within another generic type - * (such as {@code Outer.Inner}), only the type - * arguments of the innermost type are included. - * - * @return the actual type arguments of this type, or an empty collection - * if there are none - */ - Collection getActualTypeArguments(); - - /** - * Returns the interface types that are direct supertypes of this type. - * These are the interface types implemented or extended - * by this type's declaration, with any type arguments - * substituted in. - * - *

For example, the interface type extended by - * {@code java.util.Set} is {@code java.util.Collection}. - * - * @return the interface types that are direct supertypes of this type, - * or an empty collection if there are none - */ - Collection getSuperinterfaces(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/type/EnumType.java --- a/langtools/src/share/classes/com/sun/mirror/type/EnumType.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -import com.sun.mirror.declaration.EnumDeclaration; - - -/** - * Represents an enum type. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.type.DeclaredType}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface EnumType extends ClassType { - - /** - * {@inheritDoc} - */ - EnumDeclaration getDeclaration(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/type/InterfaceType.java --- a/langtools/src/share/classes/com/sun/mirror/type/InterfaceType.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -import com.sun.mirror.declaration.*; - - -/** - * Represents an interface type. - * Note that an {@linkplain AnnotationType annotation type} is - * a kind of interface. - * - *

While an {@link InterfaceDeclaration} represents the - * declaration of an interface, an InterfaceType - * represents an interface type. - * See {@link TypeDeclaration} for more on this distinction. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.type.DeclaredType}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface InterfaceType extends DeclaredType { - - /** - * {@inheritDoc} - */ - InterfaceDeclaration getDeclaration(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/type/MirroredTypeException.java --- a/langtools/src/share/classes/com/sun/mirror/type/MirroredTypeException.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -import java.lang.annotation.Annotation; - -import com.sun.mirror.declaration.Declaration; - - -/** - * Thrown when an application attempts to access the {@link Class} object - * corresponding to a {@link TypeMirror}. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this exception is {@link - * javax.lang.model.type.MirroredTypeException}. - * - * @see MirroredTypesException - * @see Declaration#getAnnotation(Class) - */ -@Deprecated -@SuppressWarnings("deprecation") -public class MirroredTypeException extends RuntimeException { - - private static final long serialVersionUID = 1; - - private transient TypeMirror type; // cannot be serialized - private String name; // type's qualified "name" - - /** - * Constructs a new MirroredTypeException for the specified type. - * - * @param type the type being accessed - */ - public MirroredTypeException(TypeMirror type) { - super("Attempt to access Class object for TypeMirror " + type); - this.type = type; - name = type.toString(); - } - - /** - * Returns the type mirror corresponding to the type being accessed. - * The type mirror may be unavailable if this exception has been - * serialized and then read back in. - * - * @return the type mirror, or null if unavailable - */ - public TypeMirror getTypeMirror() { - return type; - } - - /** - * Returns the fully qualified name of the type being accessed. - * More precisely, returns the canonical name of a class, - * interface, array, or primitive, and returns "void" for - * the pseudo-type representing the type of void. - * - * @return the fully qualified name of the type being accessed - */ - public String getQualifiedName() { - return name; - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/type/MirroredTypesException.java --- a/langtools/src/share/classes/com/sun/mirror/type/MirroredTypesException.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; - -import com.sun.mirror.declaration.Declaration; - - -/** - * Thrown when an application attempts to access a sequence of {@link Class} - * objects each corresponding to a {@link TypeMirror}. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this exception is {@link - * javax.lang.model.type.MirroredTypesException}. - * - * @see MirroredTypeException - * @see Declaration#getAnnotation(Class) - */ -@Deprecated -@SuppressWarnings("deprecation") -public class MirroredTypesException extends RuntimeException { - - private static final long serialVersionUID = 1; - - private transient Collection types; // cannot be serialized - private Collection names; // types' qualified "names" - - /** - * Constructs a new MirroredTypesException for the specified types. - * - * @param types an ordered collection of the types being accessed - */ - public MirroredTypesException(Collection types) { - super("Attempt to access Class objects for TypeMirrors " + types); - this.types = types; - names = new ArrayList(); - for (TypeMirror t : types) { - names.add(t.toString()); - } - } - - /** - * Returns the type mirrors corresponding to the types being accessed. - * The type mirrors may be unavailable if this exception has been - * serialized and then read back in. - * - * @return the type mirrors in order, or null if unavailable - */ - public Collection getTypeMirrors() { - return (types != null) - ? Collections.unmodifiableCollection(types) - : null; - } - - /** - * Returns the fully qualified names of the types being accessed. - * More precisely, returns the canonical names of each class, - * interface, array, or primitive, and "void" for - * the pseudo-type representing the type of void. - * - * @return the fully qualified names, in order, of the types being - * accessed - */ - public Collection getQualifiedNames() { - return Collections.unmodifiableCollection(names); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/type/PrimitiveType.java --- a/langtools/src/share/classes/com/sun/mirror/type/PrimitiveType.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -/** - * Represents a primitive type. These include - * boolean, byte, short, int, - * long, char, float, and double. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.type.PrimitiveType}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface PrimitiveType extends TypeMirror { - - /** - * Returns the kind of primitive type that this object represents. - * - * @return the kind of primitive type that this object represents - */ - Kind getKind(); - - /** - * An enumeration of the different kinds of primitive types. - * - * @deprecated All components of this API have been superseded by - * the standardized annotation processing API. The replacement - * for the functionality of this enum is {@link - * javax.lang.model.type.TypeKind}. - */ - @Deprecated - enum Kind { - /** The primitive type boolean */ BOOLEAN, - /** The primitive type byte */ BYTE, - /** The primitive type short */ SHORT, - /** The primitive type int */ INT, - /** The primitive type long */ LONG, - /** The primitive type char */ CHAR, - /** The primitive type float */ FLOAT, - /** The primitive type double */ DOUBLE - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/type/ReferenceType.java --- a/langtools/src/share/classes/com/sun/mirror/type/ReferenceType.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -/** - * Represents a reference type. - * These include class and interface types, array types, and type variables. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.type.ReferenceType}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface ReferenceType extends TypeMirror { -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/type/TypeMirror.java --- a/langtools/src/share/classes/com/sun/mirror/type/TypeMirror.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -import com.sun.mirror.declaration.Declaration; -import com.sun.mirror.util.Types; -import com.sun.mirror.util.TypeVisitor; - - -/** - * Represents a type in the Java programming language. - * Types include primitive types, class and interface types, array - * types, and type variables. Wildcard type arguments, and the - * pseudo-type representing the type of void, are represented - * by type mirrors as well. - * - *

Types may be compared using the utility methods in - * {@link Types}. - * There is no guarantee that any particular type will - * always be represented by the same object. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.type.TypeMirror}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * - * @see Declaration - * @see Types - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface TypeMirror { - - /** - * Returns a string representation of this type. - * Any names embedded in the expression are qualified. - * - * @return a string representation of this type - */ - String toString(); - - /** - * Tests whether two types represent the same type. - * - * @param obj the object to be compared with this type - * @return true if the specified object represents the same - * type as this. - */ - boolean equals(Object obj); - - /** - * Applies a visitor to this type. - * - * @param v the visitor operating on this type - */ - void accept(TypeVisitor v); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/type/TypeVariable.java --- a/langtools/src/share/classes/com/sun/mirror/type/TypeVariable.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -import com.sun.mirror.declaration.*; - - -/** - * Represents a type variable. - * A type variable is declared by a - * {@linkplain TypeParameterDeclaration type parameter} of a - * type, method, or constructor. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.type.TypeVariable}. - * - * @author Joe Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface TypeVariable extends ReferenceType { - - /** - * Returns the type parameter that declared this type variable. - * - * @return the type parameter that declared this type variable - */ - TypeParameterDeclaration getDeclaration(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/type/VoidType.java --- a/langtools/src/share/classes/com/sun/mirror/type/VoidType.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -import com.sun.mirror.declaration.MethodDeclaration; - - -/** - * A pseudo-type representing the type of void. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is included in {@link - * javax.lang.model.type.NoType}. - * - * @see MethodDeclaration#getReturnType() - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface VoidType extends TypeMirror { -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/type/WildcardType.java --- a/langtools/src/share/classes/com/sun/mirror/type/WildcardType.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.type; - - -import java.util.Collection; - - -/** - * Represents a wildcard type argument. - * Examples include:


- *   ?
- *   ? extends Number
- *   ? super T
- * 
- * - *

A wildcard may have its upper bound explicitly set by an - * extends clause, its lower bound explicitly set by a - * super clause, or neither (but not both). - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.type.WildcardType}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface WildcardType extends TypeMirror { - - /** - * Returns the upper bounds of this wildcard. - * If no upper bound is explicitly declared, then - * an empty collection is returned. - * - * @return the upper bounds of this wildcard - */ - Collection getUpperBounds(); - - /** - * Returns the lower bounds of this wildcard. - * If no lower bound is explicitly declared, then - * an empty collection is returned. - * - * @return the lower bounds of this wildcard - */ - Collection getLowerBounds(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/type/package-info.java --- a/langtools/src/share/classes/com/sun/mirror/type/package-info.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * Interfaces used to model types. A type is represented by the - * appropriate subinterface of {@link com.sun.mirror.type.TypeMirror}. - * - *

The {@code apt} tool and its associated API have been - * superseded by the standardized annotation processing API. The - * replacement for the functionality in this package is {@link - * javax.lang.model.type}. - * - * @since 1.5 - */ -package com.sun.mirror.type; diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/util/DeclarationFilter.java --- a/langtools/src/share/classes/com/sun/mirror/util/DeclarationFilter.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,319 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.util; - - -import java.util.ArrayList; -import java.util.Collection; - -import com.sun.mirror.declaration.Declaration; -import com.sun.mirror.declaration.Modifier; - -import static com.sun.mirror.declaration.Modifier.*; - - -/** - * A filter for selecting just the items of interest - * from a collection of declarations. - * The filter is said to select or to match those declarations. - * Filters can be created in several ways: - * by the static methods described below, - * by negating or composing existing filters, - * or by subclasses that implement arbitrary matching rules. - * - *

A subclass can create an arbitrary filter simply by implementing - * the {@link #matches(Declaration)} method. - * - *

Examples. - *

Selecting the public declarations from a collection: - *

- *     result = FILTER_PUBLIC.filter(decls);            
- * Selecting class declarations (including enums): - *
- *     classFilter = DeclarationFilter.getFilter(ClassDeclaration.class);
- *     result = classFilter.filter(decls);              
- * Selecting class declarations but excluding enums: - *
- *     enumFilter = DeclarationFilter.getFilter(EnumDeclaration.class);
- *     compoundFilter = classFilter.and(enumFilter.not());
- *     result = compoundFilter.filter(decls);           
- * Selecting declarations named "Bob": - *
- *     nameFilter = new DeclarationFilter() {
- *                      public boolean matches(Declaration d) {
- *                          return d.getSimpleName().equals("Bob");
- *                      }
- *                  };
- *     result = nameFilter.filter(decls);               
- * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this class is {@link - * javax.lang.model.util.ElementFilter}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public class DeclarationFilter { - - // Predefined filters for convenience. - - /** - * A filter that selects only public declarations. - */ - public static final DeclarationFilter FILTER_PUBLIC = - new AccessFilter(PUBLIC); - - /** - * A filter that selects only protected declarations. - */ - public static final DeclarationFilter FILTER_PROTECTED = - new AccessFilter(PROTECTED); - - /** - * A filter that selects only public or protected - * declarations. - */ - public static final DeclarationFilter FILTER_PUBLIC_OR_PROTECTED = - new AccessFilter(PUBLIC, PROTECTED); - - /** - * A filter that selects only package-private (default) - * declarations. - */ - public static final DeclarationFilter FILTER_PACKAGE = - new AccessFilter(); - - /** - * A filter that selects only private declarations. - */ - public static final DeclarationFilter FILTER_PRIVATE = - new AccessFilter(PRIVATE); - - - /** - * Constructs an identity filter: one that selects all declarations. - */ - public DeclarationFilter() { - } - - - - // Methods to create a filter. - - /** - * Returns a filter that selects declarations containing all of a - * collection of modifiers. - * - * @param mods the modifiers to match (non-null) - * @return a filter that matches declarations containing mods - */ - public static DeclarationFilter getFilter( - final Collection mods) { - return new DeclarationFilter() { - public boolean matches(Declaration d) { - return d.getModifiers().containsAll(mods); - } - }; - } - - /** - * Returns a filter that selects declarations of a particular kind. - * For example, there may be a filter that selects only class - * declarations, or only fields. - * The filter will select declarations of the specified kind, - * and also any subtypes of that kind; for example, a field filter - * will also select enum constants. - * - * @param kind the kind of declarations to select - * @return a filter that selects declarations of a particular kind - */ - public static DeclarationFilter getFilter( - final Class kind) { - return new DeclarationFilter() { - public boolean matches(Declaration d) { - return kind.isInstance(d); - } - }; - } - - /** - * Returns a filter that selects those declarations selected - * by both this filter and another. - * - * @param f filter to be composed with this one - * @return a filter that selects those declarations selected by - * both this filter and another - */ - public DeclarationFilter and(DeclarationFilter f) { - final DeclarationFilter f1 = this; - final DeclarationFilter f2 = f; - return new DeclarationFilter() { - public boolean matches(Declaration d) { - return f1.matches(d) && f2.matches(d); - } - }; - } - - /** - * Returns a filter that selects those declarations selected - * by either this filter or another. - * - * @param f filter to be composed with this one - * @return a filter that selects those declarations selected by - * either this filter or another - */ - public DeclarationFilter or(DeclarationFilter f) { - final DeclarationFilter f1 = this; - final DeclarationFilter f2 = f; - return new DeclarationFilter() { - public boolean matches(Declaration d) { - return f1.matches(d) || f2.matches(d); - } - }; - } - - /** - * Returns a filter that selects those declarations not selected - * by this filter. - * - * @return a filter that selects those declarations not selected - * by this filter - */ - public DeclarationFilter not() { - return new DeclarationFilter() { - public boolean matches(Declaration d) { - return !DeclarationFilter.this.matches(d); - } - }; - } - - - - // Methods to apply a filter. - - /** - * Tests whether this filter matches a given declaration. - * The default implementation always returns true; - * subclasses should override this. - * - * @param decl the declaration to match - * @return true if this filter matches the given declaration - */ - public boolean matches(Declaration decl) { - return true; - } - - /** - * Returns the declarations matched by this filter. - * The result is a collection of the same type as the argument; - * the {@linkplain #filter(Collection, Class) two-parameter version} - * of filter offers control over the result type. - * - * @param type of the declarations being filtered - * @param decls declarations being filtered - * @return the declarations matched by this filter - */ - public Collection filter(Collection decls) { - ArrayList res = new ArrayList(decls.size()); - for (D d : decls) { - if (matches(d)) { - res.add(d); - } - } - return res; - } - - /** - * Returns the declarations matched by this filter, with the result - * being restricted to declarations of a given kind. - * Similar to the simpler - * {@linkplain #filter(Collection) single-parameter version} - * of filter, but the result type is specified explicitly. - * - * @param type of the declarations being returned - * @param decls declarations being filtered - * @param resType type of the declarations being returned -- - * the reflective view of D - * @return the declarations matched by this filter, restricted to those - * of the specified type - */ - public Collection - filter(Collection decls, Class resType) { - ArrayList res = new ArrayList(decls.size()); - for (Declaration d : decls) { - if (resType.isInstance(d) && matches(d)) { - res.add(resType.cast(d)); - } - } - return res; - } - - - - /* - * A filter based on access modifiers. - */ - private static class AccessFilter extends DeclarationFilter { - - // The first access modifier to filter on, or null if we're looking - // for declarations with no access modifiers. - private Modifier mod1 = null; - - // The second access modifier to filter on, or null if none. - private Modifier mod2 = null; - - // Returns a filter that matches declarations with no access - // modifiers. - AccessFilter() { - } - - // Returns a filter that matches m. - AccessFilter(Modifier m) { - mod1 = m; - } - - // Returns a filter that matches either m1 or m2. - AccessFilter(Modifier m1, Modifier m2) { - mod1 = m1; - mod2 = m2; - } - - public boolean matches(Declaration d) { - Collection mods = d.getModifiers(); - if (mod1 == null) { // looking for package private - return !(mods.contains(PUBLIC) || - mods.contains(PROTECTED) || - mods.contains(PRIVATE)); - } - return mods.contains(mod1) && - (mod2 == null || mods.contains(mod2)); - } - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/util/DeclarationScanner.java --- a/langtools/src/share/classes/com/sun/mirror/util/DeclarationScanner.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,267 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.util; - -import com.sun.mirror.declaration.*; - -/** - * A visitor for declarations that scans declarations contained within - * the given declaration. For example, when visiting a class, the - * methods, fields, constructors, and nested types of the class are - * also visited. - * - *

To control the processing done on a declaration, users of this - * class pass in their own visitors for pre and post processing. The - * preprocessing visitor is called before the contained declarations - * are scanned; the postprocessing visitor is called after the - * contained declarations are scanned. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this class is {@link - * javax.lang.model.util.ElementScanner6}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -class DeclarationScanner implements DeclarationVisitor { - protected DeclarationVisitor pre; - protected DeclarationVisitor post; - - DeclarationScanner(DeclarationVisitor pre, DeclarationVisitor post) { - this.pre = pre; - this.post = post; - } - - /** - * Visits a declaration. - * - * @param d the declaration to visit - */ - public void visitDeclaration(Declaration d) { - d.accept(pre); - d.accept(post); - } - - /** - * Visits a package declaration. - * - * @param d the declaration to visit - */ - public void visitPackageDeclaration(PackageDeclaration d) { - d.accept(pre); - - for(ClassDeclaration classDecl: d.getClasses()) { - classDecl.accept(this); - } - - for(InterfaceDeclaration interfaceDecl: d.getInterfaces()) { - interfaceDecl.accept(this); - } - - d.accept(post); - } - - /** - * Visits a member or constructor declaration. - * - * @param d the declaration to visit - */ - public void visitMemberDeclaration(MemberDeclaration d) { - visitDeclaration(d); - } - - /** - * Visits a type declaration. - * - * @param d the declaration to visit - */ - public void visitTypeDeclaration(TypeDeclaration d) { - d.accept(pre); - - for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) { - tpDecl.accept(this); - } - - for(FieldDeclaration fieldDecl: d.getFields()) { - fieldDecl.accept(this); - } - - for(MethodDeclaration methodDecl: d.getMethods()) { - methodDecl.accept(this); - } - - for(TypeDeclaration typeDecl: d.getNestedTypes()) { - typeDecl.accept(this); - } - - d.accept(post); - } - - /** - * Visits a class declaration. - * - * @param d the declaration to visit - */ - public void visitClassDeclaration(ClassDeclaration d) { - d.accept(pre); - - for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) { - tpDecl.accept(this); - } - - for(FieldDeclaration fieldDecl: d.getFields()) { - fieldDecl.accept(this); - } - - for(MethodDeclaration methodDecl: d.getMethods()) { - methodDecl.accept(this); - } - - for(TypeDeclaration typeDecl: d.getNestedTypes()) { - typeDecl.accept(this); - } - - for(ConstructorDeclaration ctorDecl: d.getConstructors()) { - ctorDecl.accept(this); - } - - d.accept(post); - } - - /** - * Visits an enum declaration. - * - * @param d the declaration to visit - */ - public void visitEnumDeclaration(EnumDeclaration d) { - visitClassDeclaration(d); - } - - /** - * Visits an interface declaration. - * - * @param d the declaration to visit - */ - public void visitInterfaceDeclaration(InterfaceDeclaration d) { - visitTypeDeclaration(d); - } - - /** - * Visits an annotation type declaration. - * - * @param d the declaration to visit - */ - public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d) { - visitInterfaceDeclaration(d); - } - - /** - * Visits a field declaration. - * - * @param d the declaration to visit - */ - public void visitFieldDeclaration(FieldDeclaration d) { - visitMemberDeclaration(d); - } - - /** - * Visits an enum constant declaration. - * - * @param d the declaration to visit - */ - public void visitEnumConstantDeclaration(EnumConstantDeclaration d) { - visitFieldDeclaration(d); - } - - /** - * Visits a method or constructor declaration. - * - * @param d the declaration to visit - */ - public void visitExecutableDeclaration(ExecutableDeclaration d) { - d.accept(pre); - - for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) { - tpDecl.accept(this); - } - - for(ParameterDeclaration pDecl: d.getParameters()) { - pDecl.accept(this); - } - - d.accept(post); - } - - /** - * Visits a constructor declaration. - * - * @param d the declaration to visit - */ - public void visitConstructorDeclaration(ConstructorDeclaration d) { - visitExecutableDeclaration(d); - } - - /** - * Visits a method declaration. - * - * @param d the declaration to visit - */ - public void visitMethodDeclaration(MethodDeclaration d) { - visitExecutableDeclaration(d); - } - - /** - * Visits an annotation type element declaration. - * - * @param d the declaration to visit - */ - public void visitAnnotationTypeElementDeclaration( - AnnotationTypeElementDeclaration d) { - visitMethodDeclaration(d); - } - - /** - * Visits a parameter declaration. - * - * @param d the declaration to visit - */ - public void visitParameterDeclaration(ParameterDeclaration d) { - visitDeclaration(d); - } - - /** - * Visits a type parameter declaration. - * - * @param d the declaration to visit - */ - public void visitTypeParameterDeclaration(TypeParameterDeclaration d) { - visitDeclaration(d); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/util/DeclarationVisitor.java --- a/langtools/src/share/classes/com/sun/mirror/util/DeclarationVisitor.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,149 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.util; - -import com.sun.mirror.declaration.*; - - -/** - * A visitor for declarations, in the style of the standard visitor - * design pattern. Classes implementing this interface are used to - * operate on a declaration when the kind of declaration is unknown at - * compile time. When a visitor is passed to a declaration's {@link - * Declaration#accept accept} method, the most specific - * visitXxx method applicable to that declaration is - * invoked. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.element.ElementVisitor}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface DeclarationVisitor { - - /** - * Visits a declaration. - * @param d the declaration to visit - */ - public void visitDeclaration(Declaration d); - - /** - * Visits a package declaration. - * @param d the declaration to visit - */ - public void visitPackageDeclaration(PackageDeclaration d); - - /** - * Visits a member or constructor declaration. - * @param d the declaration to visit - */ - public void visitMemberDeclaration(MemberDeclaration d); - - /** - * Visits a type declaration. - * @param d the declaration to visit - */ - public void visitTypeDeclaration(TypeDeclaration d); - - /** - * Visits a class declaration. - * @param d the declaration to visit - */ - public void visitClassDeclaration(ClassDeclaration d); - - /** - * Visits an enum declaration. - * @param d the declaration to visit - */ - public void visitEnumDeclaration(EnumDeclaration d); - - /** - * Visits an interface declaration. - * @param d the declaration to visit - */ - public void visitInterfaceDeclaration(InterfaceDeclaration d); - - /** - * Visits an annotation type declaration. - * @param d the declaration to visit - */ - public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d); - - /** - * Visits a field declaration. - * @param d the declaration to visit - */ - public void visitFieldDeclaration(FieldDeclaration d); - - /** - * Visits an enum constant declaration. - * @param d the declaration to visit - */ - public void visitEnumConstantDeclaration(EnumConstantDeclaration d); - - /** - * Visits a method or constructor declaration. - * @param d the declaration to visit - */ - public void visitExecutableDeclaration(ExecutableDeclaration d); - - /** - * Visits a constructor declaration. - * @param d the declaration to visit - */ - public void visitConstructorDeclaration(ConstructorDeclaration d); - - /** - * Visits a method declaration. - * @param d the declaration to visit - */ - public void visitMethodDeclaration(MethodDeclaration d); - - /** - * Visits an annotation type element declaration. - * @param d the declaration to visit - */ - public void visitAnnotationTypeElementDeclaration( - AnnotationTypeElementDeclaration d); - - /** - * Visits a parameter declaration. - * @param d the declaration to visit - */ - public void visitParameterDeclaration(ParameterDeclaration d); - - /** - * Visits a type parameter declaration. - * @param d the declaration to visit - */ - public void visitTypeParameterDeclaration(TypeParameterDeclaration d); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/util/DeclarationVisitors.java --- a/langtools/src/share/classes/com/sun/mirror/util/DeclarationVisitors.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.util; - -/** - * Utilities to create specialized DeclarationVisitor instances. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. There is no direct - * replacement for the functionality of this class in the standardized - * API due to that API's different visitor structure. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public class DeclarationVisitors { - private DeclarationVisitors(){} // do not instantiate. - - /** - * A visitor that has no side effects and keeps no state. - */ - public static final DeclarationVisitor NO_OP = new SimpleDeclarationVisitor(); - - /** - * Return a DeclarationVisitor that will scan the - * declaration structure, visiting declarations contained in - * another declaration. For example, when visiting a class, the - * fields, methods, constructors, etc. of the class are also - * visited. The order in which the contained declarations are scanned is - * not specified. - * - *

The pre and post - * DeclarationVisitor parameters specify, - * respectively, the processing the scanner will do before or - * after visiting the contained declarations. If only one of pre - * and post processing is needed, use {@link - * DeclarationVisitors#NO_OP DeclarationVisitors.NO_OP} for the - * other parameter. - * - * @param pre visitor representing processing to do before - * visiting contained declarations. - * - * @param post visitor representing processing to do after - * visiting contained declarations. - */ - public static DeclarationVisitor getDeclarationScanner(DeclarationVisitor pre, - DeclarationVisitor post) { - return new DeclarationScanner(pre, post); - } - - /** - * Return a DeclarationVisitor that will scan the - * declaration structure, visiting declarations contained in - * another declaration in source code order. For example, when - * visiting a class, the fields, methods, constructors, etc. of - * the class are also visited. The order in which the contained - * declarations are visited is as close to source code order as - * possible; declaration mirrors created from class files instead - * of source code will not have source position information. - * - *

The pre and post - * DeclarationVisitor parameters specify, - * respectively, the processing the scanner will do before or - * after visiting the contained declarations. If only one of pre - * and post processing is needed, use {@link - * DeclarationVisitors#NO_OP DeclarationVisitors.NO_OP} for the other parameter. - * - * @param pre visitor representing processing to do before - * visiting contained declarations. - * - * @param post visitor representing processing to do after - * visiting contained declarations. - */ - public static DeclarationVisitor getSourceOrderDeclarationScanner(DeclarationVisitor pre, - DeclarationVisitor post) { - return new SourceOrderDeclScanner(pre, post); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/util/Declarations.java --- a/langtools/src/share/classes/com/sun/mirror/util/Declarations.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.util; - - -import com.sun.mirror.declaration.*; - - -/** - * Utility methods for operating on declarations. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.util.Elements}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface Declarations { - - /** - * Tests whether one type, method, or field declaration hides another. - * - * @param sub the first member - * @param sup the second member - * @return true if and only if the first member hides - * the second - */ - boolean hides(MemberDeclaration sub, MemberDeclaration sup); - - /** - * Tests whether one method overrides another. When a - * non-abstract method overrides an abstract one, the - * former is also said to implement the latter. - * - * @param sub the first method - * @param sup the second method - * @return true if and only if the first method overrides - * the second - */ - boolean overrides(MethodDeclaration sub, MethodDeclaration sup); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/util/SimpleDeclarationVisitor.java --- a/langtools/src/share/classes/com/sun/mirror/util/SimpleDeclarationVisitor.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,216 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.util; - - -import com.sun.mirror.declaration.*; - - -/** - * A simple visitor for declarations. - * - *

The implementations of the methods of this class do nothing but - * delegate up the declaration hierarchy. A subclass should override the - * methods that correspond to the kinds of declarations on which it - * will operate. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this class is {@link - * javax.lang.model.util.SimpleElementVisitor6}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public class SimpleDeclarationVisitor implements DeclarationVisitor { - - /** - * Creates a new SimpleDeclarationVisitor. - */ - public SimpleDeclarationVisitor(){} - - /** - * Visits a declaration. - * The implementation does nothing. - * @param d the declaration to visit - */ - public void visitDeclaration(Declaration d) { - } - - /** - * Visits a package declaration. - * The implementation simply invokes - * {@link #visitDeclaration visitDeclaration}. - * @param d the declaration to visit - */ - public void visitPackageDeclaration(PackageDeclaration d) { - visitDeclaration(d); - } - - /** - * Visits a member or constructor declaration. - * The implementation simply invokes - * {@link #visitDeclaration visitDeclaration}. - * @param d the declaration to visit - */ - public void visitMemberDeclaration(MemberDeclaration d) { - visitDeclaration(d); - } - - /** - * Visits a type declaration. - * The implementation simply invokes - * {@link #visitMemberDeclaration visitMemberDeclaration}. - * @param d the declaration to visit - */ - public void visitTypeDeclaration(TypeDeclaration d) { - visitMemberDeclaration(d); - } - - /** - * Visits a class declaration. - * The implementation simply invokes - * {@link #visitTypeDeclaration visitTypeDeclaration}. - * @param d the declaration to visit - */ - public void visitClassDeclaration(ClassDeclaration d) { - visitTypeDeclaration(d); - } - - /** - * Visits an enum declaration. - * The implementation simply invokes - * {@link #visitClassDeclaration visitClassDeclaration}. - * @param d the declaration to visit - */ - public void visitEnumDeclaration(EnumDeclaration d) { - visitClassDeclaration(d); - } - - /** - * Visits an interface declaration. - * The implementation simply invokes - * {@link #visitTypeDeclaration visitTypeDeclaration}. - * @param d the declaration to visit - */ - public void visitInterfaceDeclaration(InterfaceDeclaration d) { - visitTypeDeclaration(d); - } - - /** - * Visits an annotation type declaration. - * The implementation simply invokes - * {@link #visitInterfaceDeclaration visitInterfaceDeclaration}. - * @param d the declaration to visit - */ - public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d) { - visitInterfaceDeclaration(d); - } - - /** - * Visits a field declaration. - * The implementation simply invokes - * {@link #visitMemberDeclaration visitMemberDeclaration}. - * @param d the declaration to visit - */ - public void visitFieldDeclaration(FieldDeclaration d) { - visitMemberDeclaration(d); - } - - /** - * Visits an enum constant declaration. - * The implementation simply invokes - * {@link #visitFieldDeclaration visitFieldDeclaration}. - * @param d the declaration to visit - */ - public void visitEnumConstantDeclaration(EnumConstantDeclaration d) { - visitFieldDeclaration(d); - } - - /** - * Visits a method or constructor declaration. - * The implementation simply invokes - * {@link #visitMemberDeclaration visitMemberDeclaration}. - * @param d the declaration to visit - */ - public void visitExecutableDeclaration(ExecutableDeclaration d) { - visitMemberDeclaration(d); - } - - /** - * Visits a constructor declaration. - * The implementation simply invokes - * {@link #visitExecutableDeclaration visitExecutableDeclaration}. - * @param d the declaration to visit - */ - public void visitConstructorDeclaration(ConstructorDeclaration d) { - visitExecutableDeclaration(d); - } - - /** - * Visits a method declaration. - * The implementation simply invokes - * {@link #visitExecutableDeclaration visitExecutableDeclaration}. - * @param d the declaration to visit - */ - public void visitMethodDeclaration(MethodDeclaration d) { - visitExecutableDeclaration(d); - } - - /** - * Visits an annotation type element declaration. - * The implementation simply invokes - * {@link #visitMethodDeclaration visitMethodDeclaration}. - * @param d the declaration to visit - */ - public void visitAnnotationTypeElementDeclaration( - AnnotationTypeElementDeclaration d) { - visitMethodDeclaration(d); - } - - /** - * Visits a parameter declaration. - * The implementation simply invokes - * {@link #visitDeclaration visitDeclaration}. - * @param d the declaration to visit - */ - public void visitParameterDeclaration(ParameterDeclaration d) { - visitDeclaration(d); - } - - /** - * Visits a type parameter declaration. - * The implementation simply invokes - * {@link #visitDeclaration visitDeclaration}. - * @param d the declaration to visit - */ - public void visitTypeParameterDeclaration(TypeParameterDeclaration d) { - visitDeclaration(d); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/util/SimpleTypeVisitor.java --- a/langtools/src/share/classes/com/sun/mirror/util/SimpleTypeVisitor.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.util; - - -import com.sun.mirror.type.*; - - -/** - * A simple visitor for types. - * - *

The implementations of the methods of this class do nothing but - * delegate up the type hierarchy. A subclass should override the - * methods that correspond to the kinds of types on which it will - * operate. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this class is {@link - * javax.lang.model.util.SimpleTypeVisitor6}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public class SimpleTypeVisitor implements TypeVisitor { - - /** - * Creates a new SimpleTypeVisitor. - */ - public SimpleTypeVisitor() {} - - /** - * Visits a type mirror. - * The implementation does nothing. - * @param t the type to visit - */ - public void visitTypeMirror(TypeMirror t) { - } - - /** - * Visits a primitive type. - * The implementation simply invokes - * {@link #visitTypeMirror visitTypeMirror}. - * @param t the type to visit - */ - public void visitPrimitiveType(PrimitiveType t) { - visitTypeMirror(t); - } - - /** - * Visits a void type. - * The implementation simply invokes - * {@link #visitTypeMirror visitTypeMirror}. - * @param t the type to visit - */ - public void visitVoidType(VoidType t) { - visitTypeMirror(t); - } - - /** - * Visits a reference type. - * The implementation simply invokes - * {@link #visitTypeMirror visitTypeMirror}. - * @param t the type to visit - */ - public void visitReferenceType(ReferenceType t) { - visitTypeMirror(t); - } - - /** - * Visits a declared type. - * The implementation simply invokes - * {@link #visitReferenceType visitReferenceType}. - * @param t the type to visit - */ - public void visitDeclaredType(DeclaredType t) { - visitReferenceType(t); - } - - /** - * Visits a class type. - * The implementation simply invokes - * {@link #visitDeclaredType visitDeclaredType}. - * @param t the type to visit - */ - public void visitClassType(ClassType t) { - visitDeclaredType(t); - } - - /** - * Visits an enum type. - * The implementation simply invokes - * {@link #visitClassType visitClassType}. - * @param t the type to visit - */ - public void visitEnumType(EnumType t) { - visitClassType(t); - } - - /** - * Visits an interface type. - * The implementation simply invokes - * {@link #visitDeclaredType visitDeclaredType}. - * @param t the type to visit - */ - public void visitInterfaceType(InterfaceType t) { - visitDeclaredType(t); - } - - /** - * Visits an annotation type. - * The implementation simply invokes - * {@link #visitInterfaceType visitInterfaceType}. - * @param t the type to visit - */ - public void visitAnnotationType(AnnotationType t) { - visitInterfaceType(t); - } - - /** - * Visits an array type. - * The implementation simply invokes - * {@link #visitReferenceType visitReferenceType}. - * @param t the type to visit - */ - public void visitArrayType(ArrayType t) { - visitReferenceType(t); - } - - /** - * Visits a type variable. - * The implementation simply invokes - * {@link #visitReferenceType visitReferenceType}. - * @param t the type to visit - */ - public void visitTypeVariable(TypeVariable t) { - visitReferenceType(t); - } - - /** - * Visits a wildcard. - * The implementation simply invokes - * {@link #visitTypeMirror visitTypeMirror}. - * @param t the type to visit - */ - public void visitWildcardType(WildcardType t) { - visitTypeMirror(t); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/util/SourceOrderDeclScanner.java --- a/langtools/src/share/classes/com/sun/mirror/util/SourceOrderDeclScanner.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,258 +0,0 @@ -/* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.util; - -import com.sun.mirror.declaration.*; - -import java.util.SortedSet; -import java.util.TreeSet; - -/** - * A visitor for declarations that scans declarations contained within - * the given declaration in source code order. For example, when - * visiting a class, the methods, fields, constructors, and nested - * types of the class are also visited. - * - * To control the processing done on a declaration, users of this - * class pass in their own visitors for pre and post processing. The - * preprocessing visitor is called before the contained declarations - * are scanned; the postprocessing visitor is called after the - * contained declarations are scanned. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this class is {@link - * javax.lang.model.util.SimpleElementVisitor6}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -class SourceOrderDeclScanner extends DeclarationScanner { - static class SourceOrderComparator implements java.util.Comparator { - SourceOrderComparator(){} - - - static boolean equals(Declaration d1, Declaration d2) { - return d1 == d2 || (d1 != null && d1.equals(d2)); - } - - private static class DeclPartialOrder extends com.sun.mirror.util.SimpleDeclarationVisitor { - private int value = 1000; - private static int staticAdjust(Declaration d) { - return d.getModifiers().contains(Modifier.STATIC)?0:1; - } - - DeclPartialOrder() {} - - public int getValue() { return value; } - - @Override - public void visitTypeParameterDeclaration(TypeParameterDeclaration d) {value = 0;} - - @Override - public void visitEnumConstantDeclaration(EnumConstantDeclaration d) {value = 1;} - - @Override - public void visitClassDeclaration(ClassDeclaration d) {value = 2 + staticAdjust(d);} - - @Override - public void visitInterfaceDeclaration(InterfaceDeclaration d) {value = 4;} - - @Override - public void visitEnumDeclaration(EnumDeclaration d) {value = 6;} - - @Override - public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d) {value = 8;} - - @Override - public void visitFieldDeclaration(FieldDeclaration d) {value = 10 + staticAdjust(d);} - - @Override - public void visitConstructorDeclaration(ConstructorDeclaration d) {value = 12;} - - @Override - public void visitMethodDeclaration(MethodDeclaration d) {value = 14 + staticAdjust(d);} - } - @SuppressWarnings("cast") - private int compareEqualPosition(Declaration d1, Declaration d2) { - assert - (d1.getPosition() == d2.getPosition()) || // Handles two null positions. - (d1.getPosition().file().compareTo(d2.getPosition().file()) == 0 && - d1.getPosition().line() == d2.getPosition().line() && - d1.getPosition().column() == d2.getPosition().column()); - - DeclPartialOrder dpo1 = new DeclPartialOrder(); - DeclPartialOrder dpo2 = new DeclPartialOrder(); - - d1.accept(dpo1); - d2.accept(dpo2); - - int difference = dpo1.getValue() - dpo2.getValue(); - if (difference != 0) - return difference; - else { - int result = d1.getSimpleName().compareTo(d2.getSimpleName()); - if (result != 0) - return result; - return (int)( Long.signum((long)System.identityHashCode(d1) - - (long)System.identityHashCode(d2))); - } - } - - public int compare(Declaration d1, Declaration d2) { - if (equals(d1, d2)) - return 0; - - SourcePosition p1 = d1.getPosition(); - SourcePosition p2 = d2.getPosition(); - - if (p1 == null && p2 != null) - return 1; - else if (p1 != null && p2 == null) - return -1; - else if(p1 == null && p2 == null) - return compareEqualPosition(d1, d2); - else { - assert p1 != null && p2 != null; - int fileComp = p1.file().compareTo(p2.file()) ; - if (fileComp == 0) { - long diff = (long)p1.line() - (long)p2.line(); - if (diff == 0) { - diff = Long.signum((long)p1.column() - (long)p2.column()); - if (diff != 0) - return (int)diff; - else { - // declarations may be two - // compiler-generated members with the - // same source position - return compareEqualPosition(d1, d2); - } - } else - return (diff<0)? -1:1; - } else - return fileComp; - } - } - } - - final static java.util.Comparator comparator = new SourceOrderComparator(); - - SourceOrderDeclScanner(DeclarationVisitor pre, DeclarationVisitor post) { - super(pre, post); - } - - /** - * Visits a type declaration. - * - * @param d the declaration to visit - */ - public void visitTypeDeclaration(TypeDeclaration d) { - d.accept(pre); - - SortedSet decls = new - TreeSet(SourceOrderDeclScanner.comparator) ; - - for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) { - decls.add(tpDecl); - } - - for(FieldDeclaration fieldDecl: d.getFields()) { - decls.add(fieldDecl); - } - - for(MethodDeclaration methodDecl: d.getMethods()) { - decls.add(methodDecl); - } - - for(TypeDeclaration typeDecl: d.getNestedTypes()) { - decls.add(typeDecl); - } - - for(Declaration decl: decls ) - decl.accept(this); - - d.accept(post); - } - - /** - * Visits a class declaration. - * - * @param d the declaration to visit - */ - public void visitClassDeclaration(ClassDeclaration d) { - d.accept(pre); - - SortedSet decls = new - TreeSet(SourceOrderDeclScanner.comparator) ; - - for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) { - decls.add(tpDecl); - } - - for(FieldDeclaration fieldDecl: d.getFields()) { - decls.add(fieldDecl); - } - - for(MethodDeclaration methodDecl: d.getMethods()) { - decls.add(methodDecl); - } - - for(TypeDeclaration typeDecl: d.getNestedTypes()) { - decls.add(typeDecl); - } - - for(ConstructorDeclaration ctorDecl: d.getConstructors()) { - decls.add(ctorDecl); - } - - for(Declaration decl: decls ) - decl.accept(this); - - d.accept(post); - } - - public void visitExecutableDeclaration(ExecutableDeclaration d) { - d.accept(pre); - - SortedSet decls = new - TreeSet(SourceOrderDeclScanner.comparator) ; - - for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) - decls.add(tpDecl); - - for(ParameterDeclaration pDecl: d.getParameters()) - decls.add(pDecl); - - for(Declaration decl: decls ) - decl.accept(this); - - d.accept(post); - } - -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/util/SourcePosition.java --- a/langtools/src/share/classes/com/sun/mirror/util/SourcePosition.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.util; - - -import java.io.File; - - -/** - * Represents a position in a source file. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. There is no direct - * replacement for the functionality of this interface since the - * standardized {@link javax.annotation.processing.Messager Messager} - * API implicitly takes a source position argument via any element, - * annotation mirror, or annotation value passed along with the - * message. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface SourcePosition { - - /** - * Returns the source file containing this position. - * - * @return the source file containing this position; never null - */ - File file(); - - /** - * Returns the line number of this position. Lines are numbered - * starting with 1. - * - * @return the line number of this position, or 0 if the line - * number is unknown or not applicable - */ - int line(); - - /** - * Returns the column number of this position. Columns are numbered - * starting with 1. - * - * @return the column number of this position, or 0 if the column - * number is unknown or not applicable - */ - int column(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/util/TypeVisitor.java --- a/langtools/src/share/classes/com/sun/mirror/util/TypeVisitor.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.util; - - -import com.sun.mirror.type.*; - - -/** - * A visitor for types, in the style of the standard visitor design pattern. - * This is used to operate on a type when the kind - * of type is unknown at compile time. - * When a visitor is passed to a type's - * {@link TypeMirror#accept accept} method, - * the most specific visitXxx method applicable to - * that type is invoked. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.element.TypeVisitor}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface TypeVisitor { - - /** - * Visits a type mirror. - * - * @param t the type to visit - */ - public void visitTypeMirror(TypeMirror t); - - /** - * Visits a primitive type. - - * @param t the type to visit - */ - public void visitPrimitiveType(PrimitiveType t); - - /** - * Visits a void type. - * - * @param t the type to visit - */ - public void visitVoidType(VoidType t); - - /** - * Visits a reference type. - * - * @param t the type to visit - */ - public void visitReferenceType(ReferenceType t); - - /** - * Visits a declared type. - * - * @param t the type to visit - */ - public void visitDeclaredType(DeclaredType t); - - /** - * Visits a class type. - * - * @param t the type to visit - */ - public void visitClassType(ClassType t); - - /** - * Visits an enum type. - * - * @param t the type to visit - */ - public void visitEnumType(EnumType t); - - /** - * Visits an interface type. - * - * @param t the type to visit - */ - public void visitInterfaceType(InterfaceType t); - - /** - * Visits an annotation type. - * - * @param t the type to visit - */ - public void visitAnnotationType(AnnotationType t); - - /** - * Visits an array type. - * - * @param t the type to visit - */ - public void visitArrayType(ArrayType t); - - /** - * Visits a type variable. - * - * @param t the type to visit - */ - public void visitTypeVariable(TypeVariable t); - - /** - * Visits a wildcard. - * - * @param t the type to visit - */ - public void visitWildcardType(WildcardType t); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/util/Types.java --- a/langtools/src/share/classes/com/sun/mirror/util/Types.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,189 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.mirror.util; - - -import java.util.Collection; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; - - -/** - * Utility methods for operating on types. - * - * @deprecated All components of this API have been superseded by the - * standardized annotation processing API. The replacement for the - * functionality of this interface is {@link - * javax.lang.model.util.Types}. - * - * @author Joseph D. Darcy - * @author Scott Seligman - * @since 1.5 - */ -@Deprecated -@SuppressWarnings("deprecation") -public interface Types { - - /** - * Tests whether one type is a subtype of the another. - * Any type is considered to be a subtype of itself. - * - * @param t1 the first type - * @param t2 the second type - * @return true if and only if the first type is a subtype - * of the second - */ - boolean isSubtype(TypeMirror t1, TypeMirror t2); - - /** - * Tests whether one type is assignable to another. - * - * @param t1 the first type - * @param t2 the second type - * @return true if and only if the first type is assignable - * to the second - */ - boolean isAssignable(TypeMirror t1, TypeMirror t2); - - /** - * Returns the erasure of a type. - * - * @param t the type to be erased - * @return the erasure of the given type - */ - TypeMirror getErasure(TypeMirror t); - - /** - * Returns a primitive type. - * - * @param kind the kind of primitive type to return - * @return a primitive type - */ - PrimitiveType getPrimitiveType(PrimitiveType.Kind kind); - - /** - * Returns the pseudo-type representing the type of void. - * - * @return the pseudo-type representing the type of void - */ - VoidType getVoidType(); - - /** - * Returns an array type with the specified component type. - * - * @param componentType the component type - * @return an array type with the specified component type. - * @throws IllegalArgumentException if the component type is not valid for - * an array - */ - ArrayType getArrayType(TypeMirror componentType); - - /** - * Returns the type variable declared by a type parameter. - * - * @param tparam the type parameter - * @return the type variable declared by the type parameter - */ - TypeVariable getTypeVariable(TypeParameterDeclaration tparam); - - /** - * Returns a new wildcard. - * Either the wildcards's upper bounds or lower bounds may be - * specified, or neither, but not both. - * - * @param upperBounds the upper bounds of this wildcard, - * or an empty collection if none - * @param lowerBounds the lower bounds of this wildcard, - * or an empty collection if none - * @return a new wildcard - * @throws IllegalArgumentException if bounds are not valid - */ - WildcardType getWildcardType(Collection upperBounds, - Collection lowerBounds); - - /** - * Returns the type corresponding to a type declaration and - * actual type arguments. - * Given the declaration for String, for example, this - * method may be used to get the String type. It may - * then be invoked a second time, with the declaration for Set, - * to make the parameterized type {@code Set}. - * - *

The number of type arguments must either equal the - * number of the declaration's formal type parameters, or must be - * zero. If zero, and if the declaration is generic, - * then the declaration's raw type is returned. - * - *

If a parameterized type is being returned, its declaration - * must not be contained within a generic outer class. - * The parameterized type {@code Outer.Inner}, - * for example, may be constructed by first using this - * method to get the type {@code Outer}, and then invoking - * {@link #getDeclaredType(DeclaredType, TypeDeclaration, TypeMirror...)}. - * - * @param decl the type declaration - * @param typeArgs the actual type arguments - * @return the type corresponding to the type declaration and - * actual type arguments - * @throws IllegalArgumentException if too many or too few - * type arguments are given, or if an inappropriate type - * argument or declaration is provided - */ - DeclaredType getDeclaredType(TypeDeclaration decl, - TypeMirror... typeArgs); - - /** - * Returns the type corresponding to a type declaration - * and actual arguments, given a - * {@linkplain DeclaredType#getContainingType() containing type} - * of which it is a member. - * The parameterized type {@code Outer.Inner}, - * for example, may be constructed by first using - * {@link #getDeclaredType(TypeDeclaration, TypeMirror...)} - * to get the type {@code Outer}, and then invoking - * this method. - * - *

If the containing type is a parameterized type, - * the number of type arguments must equal the - * number of the declaration's formal type parameters. - * If it is not parameterized or if it is null, this method is - * equivalent to getDeclaredType(decl, typeArgs). - * - * @param containing the containing type, or null if none - * @param decl the type declaration - * @param typeArgs the actual type arguments - * @return the type corresponding to the type declaration and - * actual type arguments, - * contained within the given type - * @throws IllegalArgumentException if too many or too few - * type arguments are given, or if an inappropriate type - * argument, declaration, or containing type is provided - */ - DeclaredType getDeclaredType(DeclaredType containing, - TypeDeclaration decl, - TypeMirror... typeArgs); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/mirror/util/package-info.java --- a/langtools/src/share/classes/com/sun/mirror/util/package-info.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * Utilities to assist in the processing of {@linkplain - * com.sun.mirror.declaration declarations} and {@linkplain - * com.sun.mirror.type types}. - * - *

The {@code apt} tool and its associated API have been superseded - * by the standardized annotation processing API. The replacement for - * the functionality in this package is {@link javax.lang.model.util}. - * - * @since 1.5 - */ -package com.sun.mirror.util; diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/Main.java --- a/langtools/src/share/classes/com/sun/tools/apt/Main.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt; - -import java.io.PrintWriter; -import com.sun.mirror.apt.AnnotationProcessorFactory; - -/** - * The main program for the command-line tool apt. - * - *

Nothing described in this source file is part of any supported - * API. If you write code that depends on this, you do so at your own - * risk. This code and its internal interfaces are subject to change - * or deletion without notice. - */ -public class Main { - - static { - ClassLoader loader = Main.class.getClassLoader(); - if (loader != null) - loader.setPackageAssertionStatus("com.sun.tools.apt", true); - } - - /** Command line interface. If args is null, a - * NullPointerException is thrown. - * @param args The command line parameters. - */ - public static void main(String... args) { - System.exit(process(args)); - } - - /** Programatic interface. If args is null, a - * NullPointerException is thrown. - * Output is directed to System.err. - * @param args The command line parameters. - */ - public static int process(String... args) { - return processing(null, null, args); - } - - /** Programmatic interface. If any argument - * is null, a NullPointerException is thrown. - * @param args The command line parameters. - * @param out Where the tool's output is directed. - */ - public static int process(PrintWriter out, String... args) { - if (out == null) - throw new NullPointerException("Parameter out cannot be null."); - return processing(null, out, args); - } - - /** Programmatic interface. If factory or args - * is null, a NullPointerException is thrown. - * The "-factory" and "-factorypath" - * command line parameters are ignored by this entry point. - * Output is directed to System.err. - * - * @param factory The annotation processor factory to use - * @param args The command line parameters. - */ - public static int process(AnnotationProcessorFactory factory, String... args) { - return process(factory, new PrintWriter(System.err, true), args); - } - - /** Programmatic interface. If any argument - * is null, a NullPointerException is thrown. - * The "-factory" and "-factorypath" - * command line parameters are ignored by this entry point. - * - * @param factory The annotation processor factory to use - * @param args The command line parameters. - * @param out Where the tool's output is directed. - */ - public static int process(AnnotationProcessorFactory factory, PrintWriter out, - String... args) { - if (out == null) - throw new NullPointerException("Parameter out cannot be null."); - if (factory == null) - throw new NullPointerException("Parameter factory cannot be null"); - return processing(factory, out, args); - } - - private static int processing(AnnotationProcessorFactory factory, - PrintWriter out, - String... args) { - if (out == null) - out = new PrintWriter(System.err, true); - com.sun.tools.apt.main.Main compiler = - new com.sun.tools.apt.main.Main("apt", out); - return compiler.compile(args, factory); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/comp/AnnotationProcessingError.java --- a/langtools/src/share/classes/com/sun/tools/apt/comp/AnnotationProcessingError.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.comp; - -public class AnnotationProcessingError extends Error { - private static final long serialVersionUID = 3279196183341719287L; - AnnotationProcessingError(Throwable cause) { - super(cause); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/comp/Apt.java --- a/langtools/src/share/classes/com/sun/tools/apt/comp/Apt.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,509 +0,0 @@ -/* - * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.comp; - -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.comp.*; -import com.sun.tools.javac.tree.*; -import com.sun.tools.javac.util.*; -import com.sun.tools.javac.tree.TreeScanner; -import com.sun.tools.javac.util.Context; -import com.sun.tools.apt.util.Bark; -import com.sun.tools.javac.util.Position; - -import java.util.*; -import java.util.regex.*; -import java.lang.reflect.*; -import java.lang.reflect.InvocationTargetException; -import java.io.IOException; - -import com.sun.tools.apt.*; -import com.sun.tools.apt.comp.*; -import com.sun.tools.javac.code.Symbol.*; - -import com.sun.mirror.declaration.TypeDeclaration; -import com.sun.mirror.declaration.AnnotationTypeDeclaration; -import com.sun.mirror.apt.*; -// import com.sun.mirror.apt.AnnotationProcessorFactory; -import com.sun.mirror.apt.AnnotationProcessors; - -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.apt.mirror.apt.FilerImpl; -import com.sun.tools.apt.mirror.apt.AnnotationProcessorEnvironmentImpl; - - -import static com.sun.tools.apt.mirror.declaration.DeclarationMaker.isJavaIdentifier; - -/** - * Apt compiler phase. - * - *

This is NOT part of any supported API. - * If you write code that depends on this, you do so at your own - * risk. This code and its internal interfaces are subject to change - * or deletion without notice. - */ -@SuppressWarnings("deprecation") -public class Apt extends ListBuffer> { - java.util.Set genSourceFileNames = new java.util.LinkedHashSet(); - public java.util.Set getSourceFileNames() { - return genSourceFileNames; - } - - /** List of names of generated class files. - */ - java.util.Set genClassFileNames = new java.util.LinkedHashSet(); - public java.util.Set getClassFileNames() { - return genClassFileNames; - } - - /* AptEnvironment */ - AptEnv aptenv; - - private Context context; - - /** The context key for the todo list. */ - - protected static final Context.Key aptKey = - new Context.Key(); - - /** Get the Apt instance for this context. */ - public static Apt instance(Context context) { - Apt instance = context.get(aptKey); - if (instance == null) - instance = new Apt(context); - return instance; - } - - /** Create a new apt list. */ - protected Apt(Context context) { - this.context = context; - - context.put(aptKey, this); - aptenv = AptEnv.instance(context); - } - - /** - * Used to scan javac trees to build data structures needed for - * bootstrapping the apt environment. In particular: - * - *

    - * - *
  • Generate list of canonical names of annotation types that - * appear in source files given on the command line - * - *
  • Collect list of javac symbols representing source files - * given on the command line - * - *
- */ - static class AptTreeScanner extends TreeScanner { - - // Set of fully qualified names of annotation types present in - // examined source - private Set annotationSet; - - // Symbols to build bootstrapping declaration list - private Collection specifiedDeclCollection; - private Collection declCollection; - - public Set getAnnotationSet() { - return annotationSet; - } - - public AptTreeScanner() { - annotationSet = new LinkedHashSet(); - specifiedDeclCollection = new LinkedHashSet(); - declCollection = new LinkedHashSet(); - } - - public void visitTopLevel(JCTree.JCCompilationUnit tree) { - super.visitTopLevel(tree); - // Print out contents -- what are we dealing with? - - for(JCTree d: tree.defs) { - if (d instanceof JCTree.JCClassDecl) - specifiedDeclCollection.add(((JCTree.JCClassDecl) d).sym); - } - - } - - public void visitBlock(JCTree.JCBlock tree) { - ; // Do nothing. - } - - - // should add nested classes to packages, etc. - public void visitClassDef(JCTree.JCClassDecl tree) { - if (tree.sym == null) { - // could be an anon class w/in an initializer - return; - } - - super.visitClassDef(tree); - - declCollection.add(tree.sym); - } - - public void visitMethodDef(JCTree.JCMethodDecl tree) { - super.visitMethodDef(tree); - } - - public void visitVarDef(JCTree.JCVariableDecl tree) { - super.visitVarDef(tree); - } - - public void visitAnnotation(JCTree.JCAnnotation tree) { - super.visitAnnotation(tree); - annotationSet.add(tree.type.tsym.toString()); - } - } - - Set computeAnnotationSet(Collection classSymbols) { - Set annotationSet = new HashSet(); - - for(ClassSymbol classSymbol: classSymbols) { - computeAnnotationSet(classSymbol, annotationSet); - } - return annotationSet; - } - - void computeAnnotationSet(Symbol symbol, Set annotationSet) { - if (symbol != null ) { - if (symbol.getAnnotationMirrors() != null) - for(Attribute.Compound compound: symbol.getAnnotationMirrors()) - annotationSet.add(compound.type.tsym.toString()); // should fullName be used instead of toString? - - if (symbol instanceof Symbol.MethodSymbol) // add parameter annotations - for(Symbol param: ((MethodSymbol) symbol).params()) - computeAnnotationSet(param, annotationSet); - - if (symbol.members() != null) { - for(Scope.Entry e = symbol.members().elems; e != null; e = e.sibling) - computeAnnotationSet(e.sym, annotationSet); - } - } - } - - public void main(com.sun.tools.javac.util.List treeList, - ListBuffer classes, - Map origOptions, - ClassLoader aptCL, - AnnotationProcessorFactory providedFactory, - java.util.Set > productiveFactories) { - Bark bark = Bark.instance(context); - java.io.PrintWriter out = bark.getWriter(Log.WriterKind.WARNING); - Options options = Options.instance(context); - - Collection spectypedecls = new LinkedHashSet(); - Collection typedecls = new LinkedHashSet(); - Set unmatchedAnnotations = new LinkedHashSet(); - Set emptyATDS = Collections.emptySet(); - Set > currentRoundFactories = - new LinkedHashSet >(); - - // Determine what annotations are present on the input source - // files, create collections of specified type declarations, - // and type declarations. - AptTreeScanner ats = new AptTreeScanner(); - for(JCTree t: treeList) { - t.accept(ats); - } - - // Turn collection of ClassSymbols into Collection of apt decls - for (ClassSymbol cs : ats.specifiedDeclCollection) { - TypeDeclaration decl = aptenv.declMaker.getTypeDeclaration(cs); - spectypedecls.add(decl); - } - - for (ClassSymbol cs : ats.declCollection) { - TypeDeclaration decl = aptenv.declMaker.getTypeDeclaration(cs); - typedecls.add(decl); - } - - unmatchedAnnotations.addAll(ats.getAnnotationSet()); - - // Process input class files - for(ClassSymbol cs : classes) { - TypeDeclaration decl = aptenv.declMaker.getTypeDeclaration(cs); - // System.out.println("Adding a class to spectypedecls"); - spectypedecls.add(decl); - typedecls.add(decl); - computeAnnotationSet(cs, unmatchedAnnotations); - } - - if (options.get("-XListAnnotationTypes") != null) { - out.println("Set of annotations found:" + - (new TreeSet(unmatchedAnnotations)).toString()); - } - - AnnotationProcessorEnvironmentImpl trivAPE = - new AnnotationProcessorEnvironmentImpl(spectypedecls, typedecls, origOptions, context); - - if (options.get("-XListDeclarations") != null) { - out.println("Set of Specified Declarations:" + - spectypedecls); - - out.println("Set of Included Declarations: " + - typedecls); - } - - if (options.get("-print") != null) { - if (spectypedecls.size() == 0 ) - throw new UsageMessageNeededException(); - - // Run the printing processor - AnnotationProcessor proc = (new BootstrapAPF()).getProcessorFor(new HashSet(), - trivAPE); - proc.process(); - } else { - // Discovery process - - // List of annotation processory factory instances - java.util.Iterator providers = null; - { - /* - * If a factory is provided by the user, the - * "-factory" and "-factorypath" options are not used. - * - * Otherwise, if the "-factory" option is used, search - * the appropriate path for the named class. - * Otherwise, use sun.misc.Service to implement the - * default discovery policy. - */ - - java.util.List list = - new LinkedList(); - String factoryName = options.get("-factory"); - - if (providedFactory != null) { - list.add(providedFactory); - providers = list.iterator(); - } else if (factoryName != null) { - try { - AnnotationProcessorFactory factory = - (AnnotationProcessorFactory) (aptCL.loadClass(factoryName).newInstance()); - list.add(factory); - } catch (ClassNotFoundException cnfe) { - bark.aptWarning("FactoryNotFound", factoryName); - } catch (ClassCastException cce) { - bark.aptWarning("FactoryWrongType", factoryName); - } catch (Exception e ) { - bark.aptWarning("FactoryCantInstantiate", factoryName); - } catch(Throwable t) { - throw new AnnotationProcessingError(t); - } - - providers = list.iterator(); - } else { - @SuppressWarnings("unchecked") - Iterator iter = - sun.misc.Service.providers(AnnotationProcessorFactory.class, aptCL); - providers = iter; - - } - } - - java.util.Map> factoryToAnnotation = - new LinkedHashMap>(); - - if (!providers.hasNext() && productiveFactories.size() == 0) { - if (unmatchedAnnotations.size() > 0) - bark.aptWarning("NoAnnotationProcessors"); - if (spectypedecls.size() == 0) - throw new UsageMessageNeededException(); - return; // no processors; nothing else to do - } else { - // If there are no annotations, still give - // processors that match everything a chance to - // run. - - if(unmatchedAnnotations.size() == 0) - unmatchedAnnotations.add(""); - - Set emptyStringSet = new HashSet(); - emptyStringSet.add(""); - emptyStringSet = Collections.unmodifiableSet(emptyStringSet); - - while (providers.hasNext() ) { - Object provider = providers.next(); - try { - Set matchedStrings = new HashSet(); - - AnnotationProcessorFactory apf = (AnnotationProcessorFactory) provider; - Collection supportedTypes = apf.supportedAnnotationTypes(); - - Collection supportedTypePatterns = new LinkedList(); - for(String s: supportedTypes) - supportedTypePatterns.add(importStringToPattern(s)); - - for(String s: unmatchedAnnotations) { - for(Pattern p: supportedTypePatterns) { - if (p.matcher(s).matches()) { - matchedStrings.add(s); - break; - } - } - } - - unmatchedAnnotations.removeAll(matchedStrings); - - if (options.get("-XPrintFactoryInfo") != null) { - out.println("Factory " + apf.getClass().getName() + - " matches " + - ((matchedStrings.size() == 0)? - "nothing.": matchedStrings)); - } - - if (matchedStrings.size() > 0) { - // convert annotation names to annotation - // type decls - Set atds = new HashSet(); - - // If a "*" processor is called on the - // empty string, pass in an empty set of - // annotation type declarations. - if (!matchedStrings.equals(emptyStringSet)) { - for(String s: matchedStrings) { - TypeDeclaration decl = aptenv.declMaker.getTypeDeclaration(s); - AnnotationTypeDeclaration annotdecl; - if (decl == null) { - bark.aptError("DeclarationCreation", s); - } else { - try { - annotdecl = (AnnotationTypeDeclaration)decl; - atds.add(annotdecl); - - } catch (ClassCastException cce) { - bark.aptError("BadDeclaration", s); - } - } - } - } - - currentRoundFactories.add(apf.getClass()); - productiveFactories.add(apf.getClass()); - factoryToAnnotation.put(apf, atds); - } else if (productiveFactories.contains(apf.getClass())) { - // If a factory provided a processor in a - // previous round but doesn't match any - // annotations this round, call it with an - // empty set of declarations. - currentRoundFactories.add(apf.getClass()); - factoryToAnnotation.put(apf, emptyATDS ); - } - - if (unmatchedAnnotations.size() == 0) - break; - - } catch (ClassCastException cce) { - bark.aptWarning("BadFactory", cce); - } - } - - unmatchedAnnotations.remove(""); - } - - // If the set difference of productiveFactories and - // currentRoundFactories is non-empty, call the remaining - // productive factories with an empty set of declarations. - { - java.util.Set > neglectedFactories = - new LinkedHashSet>(productiveFactories); - neglectedFactories.removeAll(currentRoundFactories); - for(Class working : neglectedFactories) { - try { - AnnotationProcessorFactory factory = working.newInstance(); - factoryToAnnotation.put(factory, emptyATDS); - } catch (Exception e ) { - bark.aptWarning("FactoryCantInstantiate", working.getName()); - } catch(Throwable t) { - throw new AnnotationProcessingError(t); - } - } - } - - if (unmatchedAnnotations.size() > 0) - bark.aptWarning("AnnotationsWithoutProcessors", unmatchedAnnotations); - - Set processors = new LinkedHashSet(); - - // If there were no source files AND no factory matching "*", - // make sure the usage message is printed - if (spectypedecls.size() == 0 && - factoryToAnnotation.keySet().size() == 0 ) - throw new UsageMessageNeededException(); - - try { - for(Map.Entry> entry : - factoryToAnnotation.entrySet()) { - AnnotationProcessorFactory apFactory = entry.getKey(); - AnnotationProcessor processor = apFactory.getProcessorFor(entry.getValue(), - trivAPE); - if (processor != null) - processors.add(processor); - else - bark.aptWarning("NullProcessor", apFactory.getClass().getName()); - } - } catch(Throwable t) { - throw new AnnotationProcessingError(t); - } - - LinkedList temp = new LinkedList(); - temp.addAll(processors); - - AnnotationProcessor proc = AnnotationProcessors.getCompositeAnnotationProcessor(temp); - - try { - proc.process(); - } catch (Throwable t) { - throw new AnnotationProcessingError(t); - } - - // Invoke listener callback mechanism - trivAPE.roundComplete(); - - FilerImpl filerimpl = (FilerImpl)trivAPE.getFiler(); - genSourceFileNames = filerimpl.getSourceFileNames(); - genClassFileNames = filerimpl.getClassFileNames(); - filerimpl.flush(); // Make sure new files are written out - } - } - - /** - * Convert import-style string to regex matching that string. If - * the string is a valid import-style string, return a regex that - * won't match anything. - */ - Pattern importStringToPattern(String s) { - if (com.sun.tools.javac.processing.JavacProcessingEnvironment.isValidImportString(s)) { - return com.sun.tools.javac.processing.JavacProcessingEnvironment.validImportStringToPattern(s); - } else { - Bark bark = Bark.instance(context); - bark.aptWarning("MalformedSupportedString", s); - return com.sun.tools.javac.processing.JavacProcessingEnvironment.noMatches; - } - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/comp/BootstrapAPF.java --- a/langtools/src/share/classes/com/sun/tools/apt/comp/BootstrapAPF.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.comp; - -import java.util.*; -import com.sun.mirror.apt.*; -import com.sun.mirror.declaration.AnnotationTypeDeclaration; - -@SuppressWarnings("deprecation") -public class BootstrapAPF implements AnnotationProcessorFactory { - - static final Collection supportedOptions = - Collections.unmodifiableSet(new HashSet()); - - static Collection supportedAnnotations; - static { - Collection c = new HashSet(); - c.add("*"); - supportedAnnotations = Collections.unmodifiableCollection(c); - } - - public BootstrapAPF(){} - - public Collection supportedOptions() { - return BootstrapAPF.supportedOptions; - } - - public Collection supportedAnnotationTypes() { - return supportedAnnotations; - } - - public AnnotationProcessor getProcessorFor(Set atds, - AnnotationProcessorEnvironment env) { - return new PrintAP(env); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/comp/PrintAP.java --- a/langtools/src/share/classes/com/sun/tools/apt/comp/PrintAP.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,467 +0,0 @@ -/* - * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.comp; - -import com.sun.mirror.declaration.*; -import static com.sun.mirror.declaration.Modifier.*; -import com.sun.mirror.type.*; -import com.sun.mirror.apt.*; - -import java.util.*; -import com.sun.mirror.util.*; - -/** - * Class used to implement "-print" option. - */ -@SuppressWarnings("deprecation") -public class PrintAP implements AnnotationProcessor { - - - static class PrintingVisitors { - int indentation = 0; // Indentation level; - AnnotationProcessorEnvironment env; - Messager out; - Declaration java_lang_Object; - Declaration java_lang_annotation_Annotation; - - static Set EMPTY_ELIDES = Collections.emptySet(); - static Set INTERFACE_ELIDES = EnumSet.of(ABSTRACT); - static Set ENUM_ELIDES = EnumSet.of(FINAL, ABSTRACT); - static Set INTERFACE_MEMBER_ELIDES = EnumSet.of(ABSTRACT, PUBLIC, STATIC, FINAL); - - PrintingVisitors(AnnotationProcessorEnvironment env) { - this.env = env; - this.out = env.getMessager(); - this.java_lang_Object = env.getTypeDeclaration("java.lang.Object"); - this.java_lang_annotation_Annotation = env.getTypeDeclaration("java.lang.annotation.Annotation"); - } - - - static String [] spaces = { - "", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " ", - " " - }; - - - String indent(){ - int indentation = this.indentation; - if (indentation < 0) - return ""; - else if (indentation <= 10) - return spaces[indentation]; - else { - StringBuilder sb = new StringBuilder(); - while (indentation > 10) { - sb.append(spaces[indentation]); - indentation -= 10; - } - sb.append(spaces[indentation]); - return sb.toString(); - } - } - - - class PrePrinting extends SimpleDeclarationVisitor { - Map enumCardinality = new HashMap(); - Map enumConstVisited = new HashMap(); - - PrePrinting(){} - - public void visitClassDeclaration(ClassDeclaration d) { - System.out.println(); - printDocComment(d); - printModifiers(d, EMPTY_ELIDES); - System.out.print("class " + d.getSimpleName()); - printFormalTypeParameters(d); - - // Elide "extends Object" - ClassType Super = d.getSuperclass(); - if (Super != null && !java_lang_Object.equals(Super.getDeclaration()) ) - System.out.print(" extends " + Super.toString()); - - printInterfaces(d); - - System.out.println(" {"); - - PrintingVisitors.this.indentation++; - } - - public void visitEnumDeclaration(EnumDeclaration d) { - enumCardinality.put(d, d.getEnumConstants().size()); - enumConstVisited.put(d, 1); - - System.out.println(); - printDocComment(d); - printModifiers(d, ENUM_ELIDES); - - System.out.print("enum " + d.getSimpleName()); - printFormalTypeParameters(d); - printInterfaces(d); - - System.out.println(" {"); - - PrintingVisitors.this.indentation++; - } - - - public void visitInterfaceDeclaration(InterfaceDeclaration d) { - System.out.println(); - printDocComment(d); - printModifiers(d, INTERFACE_ELIDES); - System.out.print("interface " + d.getSimpleName()); - - printFormalTypeParameters(d); - printInterfaces(d); - - System.out.println(" {"); - - PrintingVisitors.this.indentation++; - } - - public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d) { - System.out.println(); - printDocComment(d); - printModifiers(d, INTERFACE_ELIDES); - System.out.print("@interface " + d.getSimpleName()); - printFormalTypeParameters(d); - - printInterfaces(d); - - System.out.println(" {"); - - PrintingVisitors.this.indentation++; - } - - public void visitFieldDeclaration(FieldDeclaration d) { - System.out.println(); - printDocComment(d); - printModifiers(d, - (d.getDeclaringType() instanceof InterfaceDeclaration)? - INTERFACE_MEMBER_ELIDES : EMPTY_ELIDES); - System.out.print(d.getType().toString() + " " + - d.getSimpleName() ); - String constantExpr = d.getConstantExpression(); - if (constantExpr != null) { - System.out.print(" = " + constantExpr); - } - System.out.println(";" ); - } - - public void visitEnumConstantDeclaration(EnumConstantDeclaration d) { - EnumDeclaration ed = d.getDeclaringType(); - int enumCard = enumCardinality.get(ed); - int enumVisit = enumConstVisited.get(ed); - - System.out.println(); - printDocComment(d); - System.out.print(PrintingVisitors.this.indent()); - System.out.print(d.getSimpleName() ); - System.out.println((enumVisit < enumCard )? ",":";" ); - - enumConstVisited.put(ed, enumVisit+1); - } - - public void visitMethodDeclaration(MethodDeclaration d) { - System.out.println(); - printDocComment(d); - printModifiers(d, - (d.getDeclaringType() instanceof InterfaceDeclaration)? - INTERFACE_MEMBER_ELIDES : EMPTY_ELIDES); - printFormalTypeParameters(d); - System.out.print(d.getReturnType().toString() + " "); - System.out.print(d.getSimpleName() + "("); - printParameters(d); - System.out.print(")"); - printThrows(d); - System.out.println(";"); - } - - public void visitConstructorDeclaration(ConstructorDeclaration d) { - System.out.println(); - printDocComment(d); - printModifiers(d, EMPTY_ELIDES); - printFormalTypeParameters(d); - System.out.print(d.getSimpleName() + "("); - printParameters(d); - System.out.print(")"); - printThrows(d); - System.out.println(";"); - } - - - } - - class PostPrinting extends SimpleDeclarationVisitor { - PostPrinting(){} - - public void visitTypeDeclaration(TypeDeclaration d) { - PrintingVisitors.this.indentation--; - - System.out.print(PrintingVisitors.this.indent()); - System.out.println("}"); - } - } - - private void printAnnotations(Collection annots) { - - for(AnnotationMirror annot: annots) { - System.out.print(this.indent()); - System.out.print(annot.toString()); - System.out.println(); - } - } - - private void printAnnotationsInline(Collection annots) { - - for(AnnotationMirror annot: annots) { - System.out.print(annot); - System.out.print(" "); - } - } - - - private void printParameters(ExecutableDeclaration ex) { - - Collection parameters = ex.getParameters(); - int size = parameters.size(); - - switch (size) { - case 0: - break; - - case 1: - for(ParameterDeclaration parameter: parameters) { - printModifiers(parameter, EMPTY_ELIDES); - - if (ex.isVarArgs() ) { - System.out.print(((ArrayType)parameter.getType()).getComponentType() ); - System.out.print("..."); - } else - System.out.print(parameter.getType()); - System.out.print(" " + parameter.getSimpleName()); - } - break; - - default: - { - int i = 1; - for(ParameterDeclaration parameter: parameters) { - if (i == 2) - PrintingVisitors.this.indentation++; - - if (i > 1) - System.out.print(PrintingVisitors.this.indent()); - - printModifiers(parameter, EMPTY_ELIDES); - - if (i == size && ex.isVarArgs() ) { - System.out.print(((ArrayType)parameter.getType()).getComponentType() ); - System.out.print("..."); - } else - System.out.print(parameter.getType()); - System.out.print(" " + parameter.getSimpleName()); - - if (i < size) - System.out.println(","); - - i++; - } - - if (parameters.size() >= 2) - PrintingVisitors.this.indentation--; - } - break; - } - } - - private void printDocComment(Declaration d) { - String docComment = d.getDocComment(); - - if (docComment != null) { - // Break comment into lines - java.util.StringTokenizer st = new StringTokenizer(docComment, - "\n\r"); - System.out.print(PrintingVisitors.this.indent()); - System.out.println("/**"); - - while(st.hasMoreTokens()) { - System.out.print(PrintingVisitors.this.indent()); - System.out.print(" *"); - System.out.println(st.nextToken()); - } - - System.out.print(PrintingVisitors.this.indent()); - System.out.println(" */"); - } - } - - private void printModifiers(Declaration d, Collection elides) { - printAnnotations(d.getAnnotationMirrors()); - - System.out.print(PrintingVisitors.this.indent()); - - for(Modifier m: adjustModifiers(d.getModifiers(), elides) ){ - System.out.print(m.toString() + " "); - } - } - - private void printModifiers(ParameterDeclaration d, Collection elides) { - printAnnotationsInline(d.getAnnotationMirrors()); - - for(Modifier m: adjustModifiers(d.getModifiers(), elides) ) { - System.out.print(m.toString() + " "); - } - } - - private Collection adjustModifiers(Collection mods, - Collection elides) { - if (elides.isEmpty()) - return mods; - else { - Collection newMods = new LinkedHashSet(); - newMods.addAll(mods); - newMods.removeAll(elides); - return newMods; - } - } - - private void printFormalTypeParameters(ExecutableDeclaration e) { - printFormalTypeParameterSet(e.getFormalTypeParameters(), true); - } - - private void printFormalTypeParameters(TypeDeclaration d) { - printFormalTypeParameterSet(d.getFormalTypeParameters(), false); - } - - private void printFormalTypeParameterSet(Collection typeParams, boolean pad) { - if (typeParams.size() != 0) { - System.out.print("<"); - - boolean first = true; - for(TypeParameterDeclaration tpd: typeParams) { - if (!first) - System.out.print(", "); - System.out.print(tpd.toString()); - } - - System.out.print(">"); - if (pad) - System.out.print(" "); - - } - } - - private void printInterfaceSet(Collection interfaces, - boolean classNotInterface) { - if (interfaces.size() != 0) { - System.out.print((classNotInterface?" implements" : " extends")); - - boolean first = true; - for(InterfaceType interType: interfaces) { - if (!first) - System.out.print(","); - System.out.print(" "); - System.out.print(interType.toString()); - first = false; - } - } - } - - private void printInterfaces(TypeDeclaration d) { - printInterfaceSet(d.getSuperinterfaces(), d instanceof ClassDeclaration); - } - - private void printInterfaces(AnnotationTypeDeclaration d) { - Collection interfaces = new HashSet(d.getSuperinterfaces()); - - for(InterfaceType interType: interfaces) { - if (java_lang_annotation_Annotation.equals(interType.getDeclaration()) ) - interfaces.remove(interType); - } - - printInterfaceSet(interfaces, d instanceof ClassDeclaration); - } - - private void printThrows(ExecutableDeclaration d) { - Collection thrownTypes = d.getThrownTypes(); - final int size = thrownTypes.size(); - if (size != 0) { - System.out.print(" throws"); - - int i = 1; - for(ReferenceType thrownType: thrownTypes) { - if (i == 1) { - System.out.print(" "); - } - - if (i == 2) - PrintingVisitors.this.indentation++; - - if (i >= 2) - System.out.print(PrintingVisitors.this.indent()); - - System.out.print(thrownType.toString()); - - - if (i != size) { - System.out.println(", "); - } - i++; - } - - if (size >= 2) - PrintingVisitors.this.indentation--; - } - } - - DeclarationVisitor getPrintingVisitor() { - return DeclarationVisitors.getSourceOrderDeclarationScanner(new PrePrinting(), - new PostPrinting()); - } - } - - AnnotationProcessorEnvironment env; - PrintAP(AnnotationProcessorEnvironment env) { - this.env = env; - } - - - public void process() { - Collection typedecls = env.getSpecifiedTypeDeclarations(); - - for (TypeDeclaration td: typedecls) - td.accept((new PrintingVisitors(env)).getPrintingVisitor()); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/comp/UsageMessageNeededException.java --- a/langtools/src/share/classes/com/sun/tools/apt/comp/UsageMessageNeededException.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.comp; - - -public class UsageMessageNeededException extends RuntimeException { - private static final long serialVersionUID = -3265159608992825840L; -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/main/AptJavaCompiler.java --- a/langtools/src/share/classes/com/sun/tools/apt/main/AptJavaCompiler.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,291 +0,0 @@ -/* - * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.main; - -import java.io.*; -import java.util.Map; - -import javax.tools.JavaFileManager; -import javax.tools.JavaFileObject; - -import com.sun.tools.javac.file.JavacFileManager; -import com.sun.tools.javac.util.*; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.jvm.*; - -import com.sun.tools.javac.code.Symbol.*; -import com.sun.tools.javac.tree.JCTree.*; - -import com.sun.tools.apt.comp.*; -import com.sun.tools.apt.util.Bark; -import com.sun.mirror.apt.AnnotationProcessorFactory; - -/** - *

This is NOT part of any supported API. - * If you write code that depends on this, you do so at your own - * risk. This code and its internal interfaces are subject to change - * or deletion without notice. - */ -@SuppressWarnings("deprecation") -public class AptJavaCompiler extends com.sun.tools.javac.main.JavaCompiler { - /** The context key for the compiler. */ - protected static final Context.Key compilerKey = - new Context.Key(); - - /** Get the JavaCompiler instance for this context. */ - public static AptJavaCompiler instance(Context context) { - AptJavaCompiler instance = context.get(compilerKey); - if (instance == null) - instance = new AptJavaCompiler(context); - return instance; - } - - - java.util.Set genSourceFileNames; - java.util.Set genClassFileNames; - - public java.util.Set getSourceFileNames() { - return genSourceFileNames; - } - - /** List of names of generated class files. - */ - public java.util.Set getClassFileNames() { - return genClassFileNames; - } - - java.util.Set aggregateGenFiles = java.util.Collections.emptySet(); - - public java.util.Set getAggregateGenFiles() { - return aggregateGenFiles; - } - - /** The bark to be used for error reporting. - */ - Bark bark; - - /** The log to be used for error reporting. - */ - Log log; - - /** The annotation framework - */ - Apt apt; - - private static Context preRegister(Context context) { - Bark.preRegister(context); - - if (context.get(JavaFileManager.class) == null) - JavacFileManager.preRegister(context); - - return context; - } - - /** Construct a new compiler from a shared context. - */ - public AptJavaCompiler(Context context) { - super(preRegister(context)); - - context.put(compilerKey, this); - apt = Apt.instance(context); - - ClassReader classReader = ClassReader.instance(context); - classReader.preferSource = true; - - // TEMPORARY NOTE: bark==log, but while refactoring, we maintain their - // original identities, to remember the original intent. - log = Log.instance(context); - bark = Bark.instance(context); - - Options options = Options.instance(context); - classOutput = options.get("-retrofit") == null; - nocompile = options.get("-nocompile") != null; - print = options.get("-print") != null; - classesAsDecls= options.get("-XclassesAsDecls") != null; - - genSourceFileNames = new java.util.LinkedHashSet(); - genClassFileNames = new java.util.LinkedHashSet(); - - // this forces a copy of the line map to be kept in the tree, - // for use by com.sun.mirror.util.SourcePosition. - lineDebugInfo = true; - } - - /* Switches: - */ - - /** Emit class files. This switch is always set, except for the first - * phase of retrofitting, where signatures are parsed. - */ - public boolean classOutput; - - /** The internal printing annotation processor should be used. - */ - public boolean print; - - /** Compilation should not be done after annotation processing. - */ - public boolean nocompile; - - /** Are class files being treated as declarations - */ - public boolean classesAsDecls; - - /** Try to open input stream with given name. - * Report an error if this fails. - * @param filename The file name of the input stream to be opened. - */ - // PROVIDED FOR EXTREME BACKWARDS COMPATIBILITY - // There are some very obscure errors that can arise while translating - // the contents of a file from bytes to characters. In Tiger, these - // diagnostics were ignored. This method provides compatibility with - // that behavior. It would be better to honor those diagnostics, in which - // case, this method can be deleted. - @Override - public CharSequence readSource(JavaFileObject filename) { - try { - inputFiles.add(filename); - boolean prev = bark.setDiagnosticsIgnored(true); - try { - return filename.getCharContent(false); - } - finally { - bark.setDiagnosticsIgnored(prev); - } - } catch (IOException e) { - bark.error(Position.NOPOS, "cant.read.file", filename); - return null; - } - } - - /** Parse contents of input stream. - * @param filename The name of the file from which input stream comes. - * @param input The input stream to be parsed. - */ - // PROVIDED FOR BACKWARDS COMPATIBILITY - // In Tiger, diagnostics from the scanner and parser were ignored. - // This method provides compatibility with that behavior. - // It would be better to honor those diagnostics, in which - // case, this method can be deleted. - @Override - protected JCCompilationUnit parse(JavaFileObject filename, CharSequence content) { - boolean prev = bark.setDiagnosticsIgnored(true); - try { - return super.parse(filename, content); - } - finally { - bark.setDiagnosticsIgnored(prev); - } - } - - @Override - protected boolean keepComments() { - return true; // make doc comments available to mirror API impl. - } - - /** Track when the JavaCompiler has been used to compile something. */ - private boolean hasBeenUsed = false; - - /** Main method: compile a list of files, return all compiled classes - * @param filenames The names of all files to be compiled. - */ - public List compile(List filenames, - Map origOptions, - ClassLoader aptCL, - AnnotationProcessorFactory providedFactory, - java.util.Set > productiveFactories, - java.util.Set aggregateGenFiles) - throws Throwable { - // as a JavaCompiler can only be used once, throw an exception if - // it has been used before. - assert !hasBeenUsed : "attempt to reuse JavaCompiler"; - hasBeenUsed = true; - - this.aggregateGenFiles = aggregateGenFiles; - - long msec = System.currentTimeMillis(); - - ListBuffer classes = new ListBuffer(); - try { - JavacFileManager fm = (JavacFileManager)fileManager; - //parse all files - ListBuffer trees = new ListBuffer(); - for (List l = filenames; l.nonEmpty(); l = l.tail) { - if (classesAsDecls) { - if (! l.head.endsWith(".java") ) { // process as class file - ClassSymbol cs = reader.enterClass(names.fromString(l.head)); - try { - cs.complete(); - } catch(Symbol.CompletionFailure cf) { - bark.aptError("CantFindClass", l); - continue; - } - - classes.append(cs); // add to list of classes - continue; - } - } - JavaFileObject fo = fm.getJavaFileObjectsFromStrings(List.of(l.head)).iterator().next(); - trees.append(parse(fo)); - } - - //enter symbols for all files - List roots = trees.toList(); - - if (errorCount() == 0) { - boolean prev = bark.setDiagnosticsIgnored(true); - try { - enter.main(roots); - } - finally { - bark.setDiagnosticsIgnored(prev); - } - } - - if (errorCount() == 0) { - apt.main(roots, - classes, - origOptions, aptCL, - providedFactory, - productiveFactories); - genSourceFileNames.addAll(apt.getSourceFileNames()); - genClassFileNames.addAll(apt.getClassFileNames()); - } - - } catch (Abort ex) { - } - - if (verbose) - log.printVerbose("total", Long.toString(System.currentTimeMillis() - msec)); - - chk.reportDeferredDiagnostics(); - - printCount("error", errorCount()); - printCount("warn", warningCount()); - - return classes.toList(); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/main/CommandLine.java --- a/langtools/src/share/classes/com/sun/tools/apt/main/CommandLine.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.main; - -import java.io.IOException; -import java.io.Reader; -import java.io.FileReader; -import java.io.BufferedReader; -import java.io.StreamTokenizer; -import com.sun.tools.javac.util.ListBuffer; - -/** - * Various utility methods for processing Java tool command line arguments. - * - *

This is NOT part of any supported API. - * If you write code that depends on this, you do so at your own risk. - * This code and its internal interfaces are subject to change or - * deletion without notice. - */ -public class CommandLine { - /** - * Process Win32-style command files for the specified command line - * arguments and return the resulting arguments. A command file argument - * is of the form '@file' where 'file' is the name of the file whose - * contents are to be parsed for additional arguments. The contents of - * the command file are parsed using StreamTokenizer and the original - * '@file' argument replaced with the resulting tokens. Recursive command - * files are not supported. The '@' character itself can be quoted with - * the sequence '@@'. - */ - public static String[] parse(String[] args) - throws IOException - { - ListBuffer newArgs = new ListBuffer(); - for (int i = 0; i < args.length; i++) { - String arg = args[i]; - if (arg.length() > 1 && arg.charAt(0) == '@') { - arg = arg.substring(1); - if (arg.charAt(0) == '@') { - newArgs.append(arg); - } else { - loadCmdFile(arg, newArgs); - } - } else { - newArgs.append(arg); - } - } - return newArgs.toList().toArray(new String[newArgs.length()]); - } - - private static void loadCmdFile(String name, ListBuffer args) - throws IOException - { - Reader r = new BufferedReader(new FileReader(name)); - StreamTokenizer st = new StreamTokenizer(r); - st.resetSyntax(); - st.wordChars(' ', 255); - st.whitespaceChars(0, ' '); - st.commentChar('#'); - st.quoteChar('"'); - st.quoteChar('\''); - while (st.nextToken() != StreamTokenizer.TT_EOF) { - args.append(st.sval); - } - r.close(); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/main/Main.java --- a/langtools/src/share/classes/com/sun/tools/apt/main/Main.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1281 +0,0 @@ -/* - * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.main; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.text.MessageFormat; -import java.util.ResourceBundle; -import java.util.MissingResourceException; -import java.util.StringTokenizer; -import java.util.Map; -import java.util.HashMap; -import java.util.Collections; - -import java.net.URLClassLoader; -import java.net.URL; -import java.net.MalformedURLException; - -import javax.tools.JavaFileManager; -import javax.tools.StandardLocation; - -import com.sun.tools.javac.file.JavacFileManager; -import com.sun.tools.javac.code.Source; -import com.sun.tools.javac.code.Symbol; -import com.sun.tools.javac.code.Type; -import com.sun.tools.javac.jvm.Target; -import com.sun.tools.javac.util.*; - -import com.sun.tools.apt.comp.AnnotationProcessingError; -import com.sun.tools.apt.comp.UsageMessageNeededException; -import com.sun.tools.apt.util.Bark; -import com.sun.mirror.apt.AnnotationProcessorFactory; - -import static com.sun.tools.javac.file.Locations.pathToURLs; - -/** This class provides a commandline interface to the apt build-time - * tool. - * - *

This is NOT part of any supported API. - * If you write code that depends on this, you do so at your own - * risk. This code and its internal interfaces are subject to change - * or deletion without notice. - */ -@SuppressWarnings("deprecation") -public class Main { - - /** For testing: enter any options you want to be set implicitly - * here. - */ - static String[] forcedOpts = { - // Preserve parameter names from class files if the class was - // compiled with debug enabled - "-XDsave-parameter-names" - }; - - /** The name of the compiler, for use in diagnostics. - */ - String ownName; - - /** The writer to use for diagnostic output. - */ - PrintWriter out; - - - /** Instantiated factory to use in lieu of discovery process. - */ - AnnotationProcessorFactory providedFactory = null; - - /** Map representing original command-line arguments. - */ - Map origOptions = new HashMap(); - - /** Classloader to use for finding factories. - */ - ClassLoader aptCL = null; - - /** Result codes. - */ - static final int - EXIT_OK = 0, // Compilation completed with no errors. - EXIT_ERROR = 1, // Completed but reported errors. - EXIT_CMDERR = 2, // Bad command-line arguments - EXIT_SYSERR = 3, // System error or resource exhaustion. - EXIT_ABNORMAL = 4; // Compiler terminated abnormally - - /** This class represents an option recognized by the main program - */ - private class Option { - /** Whether or not the option is used only aptOnly. - */ - boolean aptOnly = false; - - /** Option string. - */ - String name; - - /** Documentation key for arguments. - */ - String argsNameKey; - - /** Documentation key for description. - */ - String descrKey; - - /** Suffix option (-foo=bar or -foo:bar) - */ - boolean hasSuffix; - - Option(String name, String argsNameKey, String descrKey) { - this.name = name; - this.argsNameKey = argsNameKey; - this.descrKey = descrKey; - char lastChar = name.charAt(name.length()-1); - hasSuffix = lastChar == ':' || lastChar == '='; - } - Option(String name, String descrKey) { - this(name, null, descrKey); - } - - public String toString() { - return name; - } - - /** Does this option take a (separate) operand? - */ - boolean hasArg() { - return argsNameKey != null && !hasSuffix; - } - - /** Does argument string match option pattern? - * @param arg The command line argument string. - */ - boolean matches(String arg) { - return hasSuffix ? arg.startsWith(name) : arg.equals(name); - } - - /** For javac-only options, print nothing. - */ - void help() { - } - - String helpSynopsis() { - return name + - (argsNameKey == null ? "" : - ((hasSuffix ? "" : " ") + - getLocalizedString(argsNameKey))); - } - - /** Print a line of documentation describing this option, if non-standard. - */ - void xhelp() {} - - /** Process the option (with arg). Return true if error detected. - */ - boolean process(String option, String arg) { - options.put(option, arg); - return false; - } - - /** Process the option (without arg). Return true if error detected. - */ - boolean process(String option) { - if (hasSuffix) - return process(name, option.substring(name.length())); - else - return process(option, option); - } - }; - - private class SharedOption extends Option { - SharedOption(String name, String argsNameKey, String descrKey) { - super(name, argsNameKey, descrKey); - } - - SharedOption(String name, String descrKey) { - super(name, descrKey); - } - - void help() { - String s = " " + helpSynopsis(); - out.print(s); - for (int j = s.length(); j < 29; j++) out.print(" "); - Bark.printRawLines(out, getLocalizedString(descrKey)); - } - - } - - private class AptOption extends Option { - AptOption(String name, String argsNameKey, String descrKey) { - super(name, argsNameKey, descrKey); - aptOnly = true; - } - - AptOption(String name, String descrKey) { - super(name, descrKey); - aptOnly = true; - } - - /** Print a line of documentation describing this option, if standard. - */ - void help() { - String s = " " + helpSynopsis(); - out.print(s); - for (int j = s.length(); j < 29; j++) out.print(" "); - Bark.printRawLines(out, getLocalizedString(descrKey)); - } - - } - - /** A nonstandard or extended (-X) option - */ - private class XOption extends Option { - XOption(String name, String argsNameKey, String descrKey) { - super(name, argsNameKey, descrKey); - } - XOption(String name, String descrKey) { - this(name, null, descrKey); - } - void help() {} - void xhelp() {} - }; - - /** A nonstandard or extended (-X) option - */ - private class AptXOption extends Option { - AptXOption(String name, String argsNameKey, String descrKey) { - super(name, argsNameKey, descrKey); - aptOnly = true; - } - AptXOption(String name, String descrKey) { - this(name, null, descrKey); - } - void xhelp() { - String s = " " + helpSynopsis(); - out.print(s); - for (int j = s.length(); j < 29; j++) out.print(" "); - Log.printRawLines(out, getLocalizedString(descrKey)); - } - }; - - /** A hidden (implementor) option - */ - private class HiddenOption extends Option { - HiddenOption(String name) { - super(name, null, null); - } - HiddenOption(String name, String argsNameKey) { - super(name, argsNameKey, null); - } - void help() {} - void xhelp() {} - }; - - private class AptHiddenOption extends HiddenOption { - AptHiddenOption(String name) { - super(name); - aptOnly = true; - } - AptHiddenOption(String name, String argsNameKey) { - super(name, argsNameKey); - aptOnly = true; - } - } - - private Option[] recognizedOptions = { - new Option("-g", "opt.g"), - new Option("-g:none", "opt.g.none") { - boolean process(String option) { - options.put("-g:", "none"); - return false; - } - }, - - new Option("-g:{lines,vars,source}", "opt.g.lines.vars.source") { - boolean matches(String s) { - return s.startsWith("-g:"); - } - boolean process(String option) { - String suboptions = option.substring(3); - options.put("-g:", suboptions); - // enter all the -g suboptions as "-g:suboption" - for (StringTokenizer t = new StringTokenizer(suboptions, ","); t.hasMoreTokens(); ) { - String tok = t.nextToken(); - String opt = "-g:" + tok; - options.put(opt, opt); - } - return false; - } - }, - - new XOption("-Xlint", "opt.Xlint"), - new XOption("-Xlint:{" - + "all," - + "cast,deprecation,divzero,empty,unchecked,fallthrough,path,serial,finally,overrides," - + "-cast,-deprecation,-divzero,-empty,-unchecked,-fallthrough,-path,-serial,-finally,-overrides," - + "none}", - "opt.Xlint.suboptlist") { - boolean matches(String s) { - return s.startsWith("-Xlint:"); - } - boolean process(String option) { - String suboptions = option.substring(7); - options.put("-Xlint:", suboptions); - // enter all the -Xlint suboptions as "-Xlint:suboption" - for (StringTokenizer t = new StringTokenizer(suboptions, ","); t.hasMoreTokens(); ) { - String tok = t.nextToken(); - String opt = "-Xlint:" + tok; - options.put(opt, opt); - } - return false; - } - }, - - new Option("-nowarn", "opt.nowarn"), - new Option("-verbose", "opt.verbose"), - - // -deprecation is retained for command-line backward compatibility - new Option("-deprecation", "opt.deprecation") { - boolean process(String option) { - options.put("-Xlint:deprecation", option); - return false; - } - }, - - new SharedOption("-classpath", "opt.arg.path", "opt.classpath"), - new SharedOption("-cp", "opt.arg.path", "opt.classpath") { - boolean process(String option, String arg) { - return super.process("-classpath", arg); - } - }, - new Option("-sourcepath", "opt.arg.path", "opt.sourcepath"), - new Option("-bootclasspath", "opt.arg.path", "opt.bootclasspath") { - boolean process(String option, String arg) { - options.remove("-Xbootclasspath/p:"); - options.remove("-Xbootclasspath/a:"); - return super.process(option, arg); - } - }, - new XOption("-Xbootclasspath/p:", "opt.arg.path", "opt.Xbootclasspath.p"), - new XOption("-Xbootclasspath/a:", "opt.arg.path", "opt.Xbootclasspath.a"), - new XOption("-Xbootclasspath:", "opt.arg.path", "opt.bootclasspath") { - boolean process(String option, String arg) { - options.remove("-Xbootclasspath/p:"); - options.remove("-Xbootclasspath/a:"); - return super.process("-bootclasspath", arg); - } - }, - new Option("-extdirs", "opt.arg.dirs", "opt.extdirs"), - new XOption("-Djava.ext.dirs=", "opt.arg.dirs", "opt.extdirs") { - boolean process(String option, String arg) { - return super.process("-extdirs", arg); - } - }, - new Option("-endorseddirs", "opt.arg.dirs", "opt.endorseddirs"), - new XOption("-Djava.endorsed.dirs=","opt.arg.dirs", "opt.endorseddirs") { - boolean process(String option, String arg) { - return super.process("-endorseddirs", arg); - } - }, - new Option("-proc:{none, only}", "opt.proc.none.only") { - public boolean matches(String s) { - return s.equals("-proc:none") || s.equals("-proc:only"); - } - }, - new Option("-processor", "opt.arg.class", "opt.processor"), - new Option("-processorpath", "opt.arg.path", "opt.processorpath"), - - new SharedOption("-d", "opt.arg.path", "opt.d"), - new SharedOption("-s", "opt.arg.path", "opt.s"), - new Option("-encoding", "opt.arg.encoding", "opt.encoding"), - new SharedOption("-source", "opt.arg.release", "opt.source") { - boolean process(String option, String operand) { - Source source = Source.lookup(operand); - if (source == null) { - error("err.invalid.source", operand); - return true; - } else if (source.compareTo(Source.JDK1_5) > 0) { - error("err.unsupported.source.version", operand); - return true; - } - return super.process(option, operand); - } - }, - new Option("-target", "opt.arg.release", "opt.target") { - boolean process(String option, String operand) { - Target target = Target.lookup(operand); - if (target == null) { - error("err.invalid.target", operand); - return true; - } else if (target.compareTo(Target.JDK1_5) > 0) { - error("err.unsupported.target.version", operand); - return true; - } - return super.process(option, operand); - } - }, - new AptOption("-version", "opt.version") { - boolean process(String option) { - Bark.printRawLines(out, ownName + " " + AptJavaCompiler.version()); - return super.process(option); - } - }, - new HiddenOption("-fullversion"), - new AptOption("-help", "opt.help") { - boolean process(String option) { - Main.this.help(); - return super.process(option); - } - }, - new SharedOption("-X", "opt.X") { - boolean process(String option) { - Main.this.xhelp(); - return super.process(option); - } - }, - - // This option exists only for the purpose of documenting itself. - // It's actually implemented by the launcher. - new AptOption("-J", "opt.arg.flag", "opt.J") { - String helpSynopsis() { - hasSuffix = true; - return super.helpSynopsis(); - } - boolean process(String option) { - throw new AssertionError - ("the -J flag should be caught by the launcher."); - } - }, - - - new SharedOption("-A", "opt.proc.flag", "opt.A") { - String helpSynopsis() { - hasSuffix = true; - return super.helpSynopsis(); - } - - boolean matches(String arg) { - return arg.startsWith("-A"); - } - - boolean hasArg() { - return false; - } - - boolean process(String option) { - return process(option, option); - } - }, - - new AptOption("-nocompile", "opt.nocompile"), - - new AptOption("-print", "opt.print"), - - new AptOption("-factorypath", "opt.arg.path", "opt.factorypath"), - - new AptOption("-factory", "opt.arg.class", "opt.factory"), - - new AptXOption("-XListAnnotationTypes", "opt.XListAnnotationTypes"), - - new AptXOption("-XListDeclarations", "opt.XListDeclarations"), - - new AptXOption("-XPrintAptRounds", "opt.XPrintAptRounds"), - - new AptXOption("-XPrintFactoryInfo", "opt.XPrintFactoryInfo"), - - /* - * Option to treat both classes and source files as - * declarations that can be given on the command line and - * processed as the result of an apt round. - */ - new AptXOption("-XclassesAsDecls", "opt.XClassesAsDecls"), - - // new Option("-moreinfo", "opt.moreinfo") { - new HiddenOption("-moreinfo") { - boolean process(String option) { - Type.moreInfo = true; - return super.process(option); - } - }, - - // treat warnings as errors - new HiddenOption("-Werror"), - - // use complex inference from context in the position of a method call argument - new HiddenOption("-complexinference"), - - // prompt after each error - // new Option("-prompt", "opt.prompt"), - new HiddenOption("-prompt"), - - // dump stack on error - new HiddenOption("-doe"), - - // display warnings for generic unchecked and unsafe operations - new HiddenOption("-warnunchecked") { - boolean process(String option) { - options.put("-Xlint:unchecked", option); - return false; - } - }, - - new HiddenOption("-Xswitchcheck") { - boolean process(String option) { - options.put("-Xlint:switchcheck", option); - return false; - } - }, - - // generate trace output for subtyping operations - new HiddenOption("-debugsubtyping"), - - new XOption("-Xmaxerrs", "opt.arg.number", "opt.maxerrs"), - new XOption("-Xmaxwarns", "opt.arg.number", "opt.maxwarns"), - new XOption("-Xstdout", "opt.arg.file", "opt.Xstdout") { - boolean process(String option, String arg) { - try { - out = new PrintWriter(new FileWriter(arg), true); - } catch (java.io.IOException e) { - error("err.error.writing.file", arg, e); - return true; - } - return super.process(option, arg); - } - }, - - new XOption("-Xprint", "opt.print"), - - new XOption("-XprintRounds", "opt.printRounds"), - - new XOption("-XprintProcessorInfo", "opt.printProcessorInfo"), - - - /* -O is a no-op, accepted for backward compatibility. */ - new HiddenOption("-O"), - - /* -Xjcov produces tables to support the code coverage tool jcov. */ - new HiddenOption("-Xjcov"), - - /* This is a back door to the compiler's option table. - * -Dx=y sets the option x to the value y. - * -Dx sets the option x to the value x. - */ - new HiddenOption("-XD") { - String s; - boolean matches(String s) { - this.s = s; - return s.startsWith(name); - } - boolean process(String option) { - s = s.substring(name.length()); - int eq = s.indexOf('='); - String key = (eq < 0) ? s : s.substring(0, eq); - String value = (eq < 0) ? s : s.substring(eq+1); - options.put(key, value); - return false; - } - }, - - new HiddenOption("sourcefile") { - String s; - boolean matches(String s) { - this.s = s; - return s.endsWith(".java") || - (options.get("-XclassesAsDecls") != null); - } - boolean process(String option) { - if (s.endsWith(".java")) { - if (!sourceFileNames.contains(s)) - sourceFileNames.add(s); - } else if (options.get("-XclassesAsDecls") != null) { - classFileNames.add(s); - } - return false; - } - }, - }; - - /** - * Construct a compiler instance. - */ - public Main(String name) { - this(name, new PrintWriter(System.err, true)); - } - - /** - * Construct a compiler instance. - */ - public Main(String name, PrintWriter out) { - this.ownName = name; - this.out = out; - } - - /** A table of all options that's passed to the JavaCompiler constructor. */ - private Options options = null; - - /** The list of source files to process - */ - java.util.List sourceFileNames = new java.util.LinkedList(); - - /** The list of class files to process - */ - java.util.List classFileNames = new java.util.LinkedList(); - - /** List of top level names of generated source files from most recent apt round. - */ - java.util.Set genSourceFileNames = new java.util.LinkedHashSet(); - - /** List of names of generated class files from most recent apt round. - */ - java.util.Set genClassFileNames = new java.util.LinkedHashSet(); - - /** - * List of all the generated source file names across all apt rounds. - */ - java.util.Set aggregateGenSourceFileNames = new java.util.LinkedHashSet(); - - /** - * List of all the generated class file names across all apt rounds. - */ - java.util.Set aggregateGenClassFileNames = new java.util.LinkedHashSet(); - - /** - * List of all the generated file names across all apt rounds. - */ - java.util.Set aggregateGenFiles = new java.util.LinkedHashSet(); - - /** - * Set of all factories that have provided a processor on some apt round. - */ - java.util.Set > productiveFactories = - new java.util.LinkedHashSet >(); - - - - /** Print a string that explains usage. - */ - void help() { - Bark.printRawLines(out, getLocalizedString("msg.usage.header", ownName)); - for (int i=0; i < recognizedOptions.length; i++) { - recognizedOptions[i].help(); - } - Bark.printRawLines(out, getLocalizedString("msg.usage.footer")); - out.println(); - } - - /** Print a string that explains usage for X options. - */ - void xhelp() { - for (int i=0; i processArgs(String[] flags) { - int ac = 0; - while (ac < flags.length) { - String flag = flags[ac]; - ac++; - - int j; - for (j=0; j < recognizedOptions.length; j++) - if (recognizedOptions[j].matches(flag)) - break; - - if (j == recognizedOptions.length) { - error("err.invalid.flag", flag); - return null; - } - - Option option = recognizedOptions[j]; - if (option.hasArg()) { - if (ac == flags.length) { - error("err.req.arg", flag); - return null; - } - String operand = flags[ac]; - ac++; - if (option.process(flag, operand)) - return null; - } else { - if (option.process(flag)) - return null; - } - } - - String sourceString = options.get("-source"); - Source source = (sourceString != null) - ? Source.lookup(sourceString) - : Source.JDK1_5; // JDK 5 is the latest supported source version - String targetString = options.get("-target"); - Target target = (targetString != null) - ? Target.lookup(targetString) - : Target.JDK1_5; // JDK 5 is the latest supported source version - // We don't check source/target consistency for CLDC, as J2ME - // profiles are not aligned with J2SE targets; moreover, a - // single CLDC target may have many profiles. In addition, - // this is needed for the continued functioning of the JSR14 - // prototype. - if (Character.isDigit(target.name.charAt(0)) && - target.compareTo(source.requiredTarget()) < 0) { - if (targetString != null) { - if (sourceString == null) { - warning("warn.target.default.source.conflict", - targetString, - source.requiredTarget().name); - } else { - warning("warn.source.target.conflict", - sourceString, - source.requiredTarget().name); - } - return null; - } else { - options.put("-target", source.requiredTarget().name); - } - } - return sourceFileNames; - } - - /** Programmatic interface for main function. - * @param args The command line parameters. - */ - public int compile(String[] args, AnnotationProcessorFactory factory) { - int returnCode = 0; - providedFactory = factory; - - Context context = new Context(); - JavacFileManager.preRegister(context); - options = Options.instance(context); - Bark bark; - - /* - * Process the command line options to create the intial - * options data. This processing is at least partially reused - * by any recursive apt calls. - */ - - // For testing: assume all arguments in forcedOpts are - // prefixed to command line arguments. - processArgs(forcedOpts); - - /* - * A run of apt only gets passed the most recently generated - * files; the initial run of apt gets passed the files from - * the command line. - */ - - java.util.List origFilenames; - try { - // assign args the result of parse to capture results of - // '@file' expansion - origFilenames = processArgs((args=CommandLine.parse(args))); - - if (options.get("suppress-tool-api-removal-message") == null) { - Bark.printRawLines(out, getLocalizedString("misc.Deprecation")); - } - - if (origFilenames == null) { - return EXIT_CMDERR; - } else if (origFilenames.size() == 0) { - // it is allowed to compile nothing if just asking for help - if (options.get("-help") != null || - options.get("-X") != null) - return EXIT_OK; - } - } catch (java.io.FileNotFoundException e) { - Bark.printRawLines(out, ownName + ": " + - getLocalizedString("err.file.not.found", - e.getMessage())); - return EXIT_SYSERR; - } catch (IOException ex) { - ioMessage(ex); - return EXIT_SYSERR; - } catch (OutOfMemoryError ex) { - resourceMessage(ex); - return EXIT_SYSERR; - } catch (StackOverflowError ex) { - resourceMessage(ex); - return EXIT_SYSERR; - } catch (FatalError ex) { - feMessage(ex); - return EXIT_SYSERR; - } catch (sun.misc.ServiceConfigurationError sce) { - sceMessage(sce); - return EXIT_ABNORMAL; - } catch (Throwable ex) { - bugMessage(ex); - return EXIT_ABNORMAL; - } - - - boolean firstRound = true; - boolean needSourcePath = false; - boolean needClassPath = false; - boolean classesAsDecls = options.get("-XclassesAsDecls") != null; - - /* - * Create augumented classpath and sourcepath values. - * - * If any of the prior apt rounds generated any new source - * files, the n'th apt round (and any javac invocation) has the - * source destination path ("-s path") as the last element of - * the "-sourcepath" to the n'th call. - * - * If any of the prior apt rounds generated any new class files, - * the n'th apt round (and any javac invocation) has the class - * destination path ("-d path") as the last element of the - * "-classpath" to the n'th call. - */ - String augmentedSourcePath = ""; - String augmentedClassPath = ""; - String baseClassPath = ""; - - try { - /* - * Record original options for future annotation processor - * invocations. - */ - origOptions = new HashMap(options.size()); - for(String s: options.keySet()) { - String value; - if (s.equals(value = options.get(s))) - origOptions.put(s, (String)null); - else - origOptions.put(s, value); - } - origOptions = Collections.unmodifiableMap(origOptions); - - JavacFileManager fm = (JavacFileManager) context.get(JavaFileManager.class); - { - // Note: it might be necessary to check for an empty - // component ("") of the source path or class path - - String sourceDest = options.get("-s"); - if (fm.hasLocation(StandardLocation.SOURCE_PATH)) { - for(File f: fm.getLocation(StandardLocation.SOURCE_PATH)) - augmentedSourcePath += (f + File.pathSeparator); - augmentedSourcePath += (sourceDest == null)?".":sourceDest; - } else { - augmentedSourcePath = "."; - - if (sourceDest != null) - augmentedSourcePath += (File.pathSeparator + sourceDest); - } - - String classDest = options.get("-d"); - if (fm.hasLocation(StandardLocation.CLASS_PATH)) { - for(File f: fm.getLocation(StandardLocation.CLASS_PATH)) - baseClassPath += (f + File.pathSeparator); - // put baseClassPath into map to handle any - // value needed for the classloader - options.put("-classpath", baseClassPath); - - augmentedClassPath = baseClassPath + ((classDest == null)?".":classDest); - } else { - baseClassPath = "."; - if (classDest != null) - augmentedClassPath = baseClassPath + (File.pathSeparator + classDest); - } - assert options.get("-classpath") != null; - } - - /* - * Create base and augmented class loaders - */ - ClassLoader augmentedAptCL = null; - { - /* - * Use a url class loader to look for classes on the - * user-specified class path. Prepend computed bootclass - * path, which includes extdirs, to the URLClassLoader apt - * uses. - */ - String aptclasspath = ""; - String bcp = ""; - Iterable bootclasspath = fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH); - - if (bootclasspath != null) { - for(File f: bootclasspath) - bcp += (f + File.pathSeparator); - } - - // If the factory path is set, use that path - if (providedFactory == null) - aptclasspath = options.get("-factorypath"); - if (aptclasspath == null) - aptclasspath = options.get("-classpath"); - - assert aptclasspath != null; - aptclasspath = (bcp + aptclasspath); - aptCL = new URLClassLoader(pathToURLs(aptclasspath)); - - if (providedFactory == null && - options.get("-factorypath") != null) // same CL even if new class files written - augmentedAptCL = aptCL; - else { - // Create class loader in case new class files are - // written - augmentedAptCL = new URLClassLoader(pathToURLs(augmentedClassPath. - substring(baseClassPath.length())), - aptCL); - } - } - - int round = 0; // For -XPrintAptRounds - do { - round++; - - Context newContext = new Context(); - Options newOptions = Options.instance(newContext); // creates a new context - newOptions.putAll(options); - - // populate with old options... don't bother reparsing command line, etc. - - // if genSource files, must add destination to source path - if (genSourceFileNames.size() > 0 && !firstRound) { - newOptions.put("-sourcepath", augmentedSourcePath); - needSourcePath = true; - } - aggregateGenSourceFileNames.addAll(genSourceFileNames); - sourceFileNames.addAll(genSourceFileNames); - genSourceFileNames.clear(); - - // Don't really need to track this; just have to add -d - // "foo" to class path if any class files are generated - if (genClassFileNames.size() > 0) { - newOptions.put("-classpath", augmentedClassPath); - aptCL = augmentedAptCL; - needClassPath = true; - } - aggregateGenClassFileNames.addAll(genClassFileNames); - classFileNames.addAll(genClassFileNames); - genClassFileNames.clear(); - - options = newOptions; - - if (options.get("-XPrintAptRounds") != null) { - out.println("apt Round : " + round); - out.println("filenames: " + sourceFileNames); - if (classesAsDecls) - out.println("classnames: " + classFileNames); - out.println("options: " + options); - } - - returnCode = compile(args, newContext); - firstRound = false; - - // Check for reported errors before continuing - bark = Bark.instance(newContext); - } while(((genSourceFileNames.size() != 0 ) || - (classesAsDecls && genClassFileNames.size() != 0)) && - bark.nerrors == 0); - } catch (UsageMessageNeededException umne) { - help(); - return EXIT_CMDERR; // will cause usage message to be printed - } - - /* - * Do not compile if a processor has reported an error or if - * there are no source files to process. A more sophisticated - * test would also fail for syntax errors caught by javac. - */ - if (options.get("-nocompile") == null && - options.get("-print") == null && - bark.nerrors == 0 && - (origFilenames.size() > 0 || aggregateGenSourceFileNames.size() > 0 )) { - /* - * Need to create new argument string for calling javac: - * 1. apt specific arguments (e.g. -factory) must be stripped out - * 2. proper settings for sourcepath and classpath must be used - * 3. generated class names must be added - * 4. class file names as declarations must be removed - */ - - int newArgsLength = args.length + - (needSourcePath?1:0) + - (needClassPath?1:0) + - aggregateGenSourceFileNames.size(); - - // Null out apt-specific options and don't copy over into - // newArgs. This loop should be a lot faster; the options - // array should be replaced with a better data structure - // which includes a map from strings to options. - // - // If treating classes as declarations, must strip out - // class names from the javac argument list - argLoop: - for(int i = 0; i < args.length; i++) { - int matchPosition = -1; - - // "-A" by itself is recognized by apt but not javac - if (args[i] != null && args[i].equals("-A")) { - newArgsLength--; - args[i] = null; - continue argLoop; - } else { - optionLoop: - for(int j = 0; j < recognizedOptions.length; j++) { - if (args[i] != null && recognizedOptions[j].matches(args[i])) { - matchPosition = j; - break optionLoop; - } - } - - if (matchPosition != -1) { - Option op = recognizedOptions[matchPosition]; - if (op.aptOnly) { - newArgsLength--; - args[i] = null; - if (op.hasArg()) { - newArgsLength--; - args[i+1] = null; - } - } else { - if (op.hasArg()) { // skip over next string - i++; - continue argLoop; - } - - if ((options.get("-XclassesAsDecls") != null) && - (matchPosition == (recognizedOptions.length-1)) ){ - // Remove class file names from - // consideration by javac. - if (! args[i].endsWith(".java")) { - newArgsLength--; - args[i] = null; - } - } - } - } - } - } - - String newArgs[] = new String[newArgsLength]; - - int j = 0; - for(int i=0; i < args.length; i++) { - if (args[i] != null) - newArgs[j++] = args[i]; - } - - if (needClassPath) - newArgs[j++] = "-XD-classpath=" + augmentedClassPath; - - if (needSourcePath) { - newArgs[j++] = "-XD-sourcepath=" + augmentedSourcePath; - - for(String s: aggregateGenSourceFileNames) - newArgs[j++] = s; - } - - returnCode = com.sun.tools.javac.Main.compile(newArgs); - } - - return returnCode; - } - - /** Programmatic interface for main function. - * @param args The command line parameters. - */ - int compile(String[] args, Context context) { - boolean assertionsEnabled = false; - assert assertionsEnabled = true; - if (!assertionsEnabled) { - // Bark.printLines(out, "fatal error: assertions must be enabled when running javac"); - // return EXIT_ABNORMAL; - } - int exitCode = EXIT_OK; - - AptJavaCompiler comp = null; - try { - context.put(Bark.outKey, out); - - comp = AptJavaCompiler.instance(context); - if (comp == null) - return EXIT_SYSERR; - - java.util.List nameList = new java.util.LinkedList(); - nameList.addAll(sourceFileNames); - if (options.get("-XclassesAsDecls") != null) - nameList.addAll(classFileNames); - - List cs - = comp.compile(List.from(nameList.toArray(new String[0])), - origOptions, - aptCL, - providedFactory, - productiveFactories, - aggregateGenFiles); - - /* - * If there aren't new source files, we shouldn't bother - * running javac if there were errors. - * - * If there are new files, we should try running javac in - * case there were typing errors. - * - */ - - if (comp.errorCount() != 0 || - options.get("-Werror") != null && comp.warningCount() != 0) - return EXIT_ERROR; - } catch (IOException ex) { - ioMessage(ex); - return EXIT_SYSERR; - } catch (OutOfMemoryError ex) { - resourceMessage(ex); - return EXIT_SYSERR; - } catch (StackOverflowError ex) { - resourceMessage(ex); - return EXIT_SYSERR; - } catch (FatalError ex) { - feMessage(ex); - return EXIT_SYSERR; - } catch (UsageMessageNeededException umne) { - help(); - return EXIT_CMDERR; // will cause usage message to be printed - } catch (AnnotationProcessingError ex) { - apMessage(ex); - return EXIT_ABNORMAL; - } catch (sun.misc.ServiceConfigurationError sce) { - sceMessage(sce); - return EXIT_ABNORMAL; - } catch (Throwable ex) { - bugMessage(ex); - return EXIT_ABNORMAL; - } finally { - if (comp != null) { - comp.close(); - genSourceFileNames.addAll(comp.getSourceFileNames()); - genClassFileNames.addAll(comp.getClassFileNames()); - } - sourceFileNames = new java.util.LinkedList(); - classFileNames = new java.util.LinkedList(); - } - return exitCode; - } - - /** Print a message reporting an internal error. - */ - void bugMessage(Throwable ex) { - Bark.printRawLines(out, getLocalizedString("msg.bug", - AptJavaCompiler.version())); - ex.printStackTrace(out); - } - - /** Print a message reporting an fatal error. - */ - void apMessage(AnnotationProcessingError ex) { - Bark.printRawLines(out, getLocalizedString("misc.Problem")); - ex.getCause().printStackTrace(out); - } - - /** Print a message about sun.misc.Service problem. - */ - void sceMessage(sun.misc.ServiceConfigurationError ex) { - Bark.printRawLines(out, getLocalizedString("misc.SunMiscService")); - ex.printStackTrace(out); - } - - /** Print a message reporting an fatal error. - */ - void feMessage(Throwable ex) { - Bark.printRawLines(out, ex.toString()); - } - - /** Print a message reporting an input/output error. - */ - void ioMessage(Throwable ex) { - Bark.printRawLines(out, getLocalizedString("msg.io")); - ex.printStackTrace(out); - } - - /** Print a message reporting an out-of-resources error. - */ - void resourceMessage(Throwable ex) { - Bark.printRawLines(out, getLocalizedString("msg.resource")); - ex.printStackTrace(out); - } - - /* ************************************************************************ - * Internationalization - *************************************************************************/ - - /** Find a localized string in the resource bundle. - * @param key The key for the localized string. - */ - private static String getLocalizedString(String key, Object... args) { - return getText(key, args); - } - - private static final String javacRB = - "com.sun.tools.javac.resources.javac"; - - private static final String aptRB = - "com.sun.tools.apt.resources.apt"; - - private static ResourceBundle messageRBjavac; - private static ResourceBundle messageRBapt; - - /** Initialize ResourceBundle. - */ - private static void initResource() { - try { - messageRBapt = ResourceBundle.getBundle(aptRB); - messageRBjavac = ResourceBundle.getBundle(javacRB); - } catch (MissingResourceException e) { - Error x = new FatalError("Fatal Error: Resource for apt or javac is missing"); - x.initCause(e); - throw x; - } - } - - /** Get and format message string from resource. - */ - private static String getText(String key, Object... _args) { - String[] args = new String[_args.length]; - for (int i=0; i<_args.length; i++) { - args[i] = "" + _args[i]; - } - if (messageRBapt == null || messageRBjavac == null ) - initResource(); - try { - return MessageFormat.format(messageRBapt.getString("apt." + key), - (Object[]) args); - } catch (MissingResourceException e) { - try { - return MessageFormat.format(messageRBjavac.getString("javac." + key), - (Object[]) args); - } catch (MissingResourceException f) { - String msg = "apt or javac message file broken: key={0} " - + "arguments={1}, {2}"; - return MessageFormat.format(msg, (Object[]) args); - } - } - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/AptEnv.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/AptEnv.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror; - - -import com.sun.tools.apt.mirror.declaration.DeclarationMaker; -import com.sun.tools.apt.mirror.type.TypeMaker; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.CompletionFailure; -import com.sun.tools.javac.comp.Attr; -import com.sun.tools.javac.comp.Enter; -import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.Names; - - -/** - * The environment for a run of apt. - */ -@SuppressWarnings("deprecation") -public class AptEnv { - - public Names names; // javac's name table - public Symtab symtab; // javac's predefined symbols - public Types jctypes; // javac's type utilities - public Enter enter; // javac's enter phase - public Attr attr; // javac's attr phase (to evaluate - // constant initializers) - public TypeMaker typeMaker; // apt's internal type utilities - public DeclarationMaker declMaker; // apt's internal declaration utilities - - - private static final Context.Key aptEnvKey = - new Context.Key(); - - public static AptEnv instance(Context context) { - AptEnv instance = context.get(aptEnvKey); - if (instance == null) { - instance = new AptEnv(context); - } - return instance; - } - - private AptEnv(Context context) { - context.put(aptEnvKey, this); - - names = Names.instance(context); - symtab = Symtab.instance(context); - jctypes = Types.instance(context); - enter = Enter.instance(context); - attr = Attr.instance(context); - typeMaker = TypeMaker.instance(context); - declMaker = DeclarationMaker.instance(context); - } - - - /** - * Does a symbol have a given flag? Forces symbol completion. - */ - public static boolean hasFlag(Symbol sym, long flag) { - return (getFlags(sym) & flag) != 0; - } - - /** - * Returns a symbol's flags. Forces completion. - */ - public static long getFlags(Symbol sym) { - complete(sym); - return sym.flags(); - } - - /** - * Completes a symbol, ignoring completion failures. - */ - private static void complete(Symbol sym) { - while (true) { - try { - sym.complete(); - return; - } catch (CompletionFailure e) { - // Should never see two in a row, but loop just to be sure. - } - } - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/apt/AnnotationProcessorEnvironmentImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/apt/AnnotationProcessorEnvironmentImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,185 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.apt; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.*; -import com.sun.mirror.apt.*; -import com.sun.tools.apt.mirror.apt.*; -import com.sun.tools.apt.mirror.declaration.DeclarationMaker; -import com.sun.tools.apt.mirror.util.*; -import com.sun.tools.apt.util.Bark; -import com.sun.tools.javac.util.Context; - -import com.sun.tools.apt.mirror.apt.FilerImpl; -import com.sun.tools.apt.mirror.apt.MessagerImpl; -import com.sun.tools.apt.mirror.apt.RoundStateImpl; -import com.sun.tools.apt.mirror.apt.RoundCompleteEventImpl; - -import com.sun.tools.javac.util.Context; - -import java.util.*; -import static com.sun.mirror.util.DeclarationVisitors.*; - -/* - * Annotation Processor Environment implementation. - */ -@SuppressWarnings("deprecation") -public class AnnotationProcessorEnvironmentImpl implements AnnotationProcessorEnvironment { - - Collection spectypedecls; - Collection typedecls; - Map origOptions; - DeclarationMaker declMaker; - Declarations declUtils; - Types typeUtils; - Messager messager; - FilerImpl filer; - Bark bark; - Set roundCompleteListeners; - - public AnnotationProcessorEnvironmentImpl(Collection spectypedecls, - Collection typedecls, - Map origOptions, - Context context) { - // Safer to copy collections before applying unmodifiable - // wrapper. - this.spectypedecls = Collections.unmodifiableCollection(spectypedecls); - this.typedecls = Collections.unmodifiableCollection(typedecls); - this.origOptions = Collections.unmodifiableMap(origOptions); - - declMaker = DeclarationMaker.instance(context); - declUtils = DeclarationsImpl.instance(context); - typeUtils = TypesImpl.instance(context); - messager = MessagerImpl.instance(context); - filer = FilerImpl.instance(context); - bark = Bark.instance(context); - roundCompleteListeners = new LinkedHashSet(); - } - - public Map getOptions() { - return origOptions; - } - - public Messager getMessager() { - return messager; - } - - public Filer getFiler() { - return filer; - } - - public Collection getSpecifiedTypeDeclarations() { - return spectypedecls; - } - - public PackageDeclaration getPackage(String name) { - return declMaker.getPackageDeclaration(name); - } - - public TypeDeclaration getTypeDeclaration(String name) { - return declMaker.getTypeDeclaration(name); - } - - public Collection getTypeDeclarations() { - return typedecls; - } - - public Collection getDeclarationsAnnotatedWith( - AnnotationTypeDeclaration a) { - /* - * create collection of Declarations annotated with a given - * annotation. - */ - - CollectingAP proc = new CollectingAP(this, a); - proc.process(); - return proc.decls; - } - - private static class CollectingAP implements AnnotationProcessor { - AnnotationProcessorEnvironment env; - Collection decls; - AnnotationTypeDeclaration atd; - CollectingAP(AnnotationProcessorEnvironment env, - AnnotationTypeDeclaration atd) { - this.env = env; - this.atd = atd; - decls = new HashSet(); - } - - private class CollectingVisitor extends SimpleDeclarationVisitor { - public void visitDeclaration(Declaration d) { - for(AnnotationMirror am: d.getAnnotationMirrors()) { - if (am.getAnnotationType().getDeclaration().equals(CollectingAP.this.atd)) - CollectingAP.this.decls.add(d); - } - } - } - - public void process() { - for(TypeDeclaration d: env.getSpecifiedTypeDeclarations()) - d.accept(getSourceOrderDeclarationScanner(new CollectingVisitor(), - NO_OP)); - } - } - - public Declarations getDeclarationUtils() { - return declUtils; - } - - public Types getTypeUtils() { - return typeUtils; - } - - public void addListener(AnnotationProcessorListener listener) { - if (listener == null) - throw new NullPointerException(); - else { - if (listener instanceof RoundCompleteListener) - roundCompleteListeners.add((RoundCompleteListener)listener); - } - } - - public void removeListener(AnnotationProcessorListener listener) { - if (listener == null) - throw new NullPointerException(); - else - roundCompleteListeners.remove(listener); - } - - public void roundComplete() { - RoundState roundState = new RoundStateImpl(bark.nerrors > 0, - filer.getSourceFileNames().size() > 0, - filer.getClassFileNames().size() > 0, - origOptions); - RoundCompleteEvent roundCompleteEvent = new RoundCompleteEventImpl(this, roundState); - - filer.roundOver(); - for(RoundCompleteListener rcl: roundCompleteListeners) - rcl.roundComplete(roundCompleteEvent); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/apt/FilerImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/apt/FilerImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,354 +0,0 @@ -/* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.apt; - - -import java.io.*; -import java.util.Collection; -import java.util.EnumMap; -import java.util.HashSet; -import java.util.Set; - -import com.sun.mirror.apt.Filer; -import com.sun.tools.apt.mirror.declaration.DeclarationMaker; -import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.Options; -import com.sun.tools.javac.util.Position; -import com.sun.tools.apt.util.Bark; - -import static com.sun.mirror.apt.Filer.Location.*; - - -/** - * Implementation of Filer. - */ -@SuppressWarnings("deprecation") -public class FilerImpl implements Filer { - /* - * The Filer class must maintain a number of constraints. First, - * multiple attempts to open the same path within the same - * invocation of apt results in an IOException being thrown. For - * example, trying to open the same source file twice: - * - * createSourceFile("foo.Bar") - * ... - * createSourceFile("foo.Bar") - * - * is disallowed as is opening a text file that happens to have - * the same name as a source file: - * - * createSourceFile("foo.Bar") - * ... - * createTextFile(SOURCE_TREE, "foo", new File("Bar"), null) - * - * Additionally, creating a source file that corresponds to an - * already created class file (or vice versa) generates at least a - * warning. This is an error if -XclassesAsDecls is being used - * since you can't create the same type twice. However, if the - * Filer is used to create a text file named *.java that happens - * to correspond to an existing class file, a warning is *not* - * generated. Similarly, a warning is not generated for a binary - * file named *.class and an existing source file. - * - * The reason for this difference is that source files and class - * files are registered with apt and can get passed on as - * declarations to the next round of processing. Files that are - * just named *.java and *.class are not processed in that manner; - * although having extra source files and class files on the - * source path and class path can alter the behavior of the tool - * and any final compile. - */ - - private enum FileKind { - SOURCE { - void register(File file, String name, FilerImpl that) throws IOException { - // Check for corresponding class file - if (that.filesCreated.contains(new File(that.locations.get(CLASS_TREE), - that.nameToPath(name, ".class")))) { - - that.bark.aptWarning("CorrespondingClassFile", name); - if (that.opts.get("-XclassesAsDecls") != null) - throw new IOException(); - } - that.sourceFileNames.add(file.getPath()); - } - }, - - CLASS { - void register(File file, String name, FilerImpl that) throws IOException { - if (that.filesCreated.contains(new File(that.locations.get(SOURCE_TREE), - that.nameToPath(name, ".java")))) { - that.bark.aptWarning("CorrespondingSourceFile", name); - if (that.opts.get("-XclassesAsDecls") != null) - throw new IOException(); - } - // Track the binary name instead of the filesystem location - that.classFileNames.add(name); - } - }, - - OTHER { - // Nothing special to do - void register(File file, String name, FilerImpl that) throws IOException {} - }; - - abstract void register(File file, String name, FilerImpl that) throws IOException; - } - - private final Options opts; - private final DeclarationMaker declMaker; - private final com.sun.tools.apt.main.AptJavaCompiler comp; - - // Platform's default encoding - private final static String DEFAULT_ENCODING = - new OutputStreamWriter(new ByteArrayOutputStream()).getEncoding(); - - private String encoding; // name of charset used for source files - - private final EnumMap locations; // where new files go - - - private static final Context.Key filerKey = - new Context.Key(); - - // Set of files opened. - private Collection wc; - - private Bark bark; - - // All created files. - private final Set filesCreated; - - // Names of newly created source files - private HashSet sourceFileNames = new HashSet(); - - // Names of newly created class files - private HashSet classFileNames = new HashSet(); - - private boolean roundOver; - - public static FilerImpl instance(Context context) { - FilerImpl instance = context.get(filerKey); - if (instance == null) { - instance = new FilerImpl(context); - } - return instance; - } - - // flush all output streams; - public void flush() { - for(Flushable opendedFile: wc) { - try { - opendedFile.flush(); - if (opendedFile instanceof FileOutputStream) { - try { - ((FileOutputStream) opendedFile).getFD().sync() ; - } catch (java.io.SyncFailedException sfe) {} - } - } catch (IOException e) { } - } - } - - private FilerImpl(Context context) { - context.put(filerKey, this); - opts = Options.instance(context); - declMaker = DeclarationMaker.instance(context); - bark = Bark.instance(context); - comp = com.sun.tools.apt.main.AptJavaCompiler.instance(context); - roundOver = false; - this.filesCreated = comp.getAggregateGenFiles(); - - // Encoding - encoding = opts.get("-encoding"); - if (encoding == null) { - encoding = DEFAULT_ENCODING; - } - - wc = new HashSet(); - - // Locations - locations = new EnumMap(Location.class); - String s = opts.get("-s"); // location for new source files - String d = opts.get("-d"); // location for new class files - locations.put(SOURCE_TREE, new File(s != null ? s : ".")); - locations.put(CLASS_TREE, new File(d != null ? d : ".")); - } - - - /** - * {@inheritDoc} - */ - public PrintWriter createSourceFile(String name) throws IOException { - String pathname = nameToPath(name, ".java"); - File file = new File(locations.get(SOURCE_TREE), - pathname); - PrintWriter pw = getPrintWriter(file, encoding, name, FileKind.SOURCE); - return pw; - } - - /** - * {@inheritDoc} - */ - public OutputStream createClassFile(String name) throws IOException { - String pathname = nameToPath(name, ".class"); - File file = new File(locations.get(CLASS_TREE), - pathname); - OutputStream os = getOutputStream(file, name, FileKind.CLASS); - return os; - } - - /** - * {@inheritDoc} - */ - public PrintWriter createTextFile(Location loc, - String pkg, - File relPath, - String charsetName) throws IOException { - File file = (pkg.length() == 0) - ? relPath - : new File(nameToPath(pkg), relPath.getPath()); - if (charsetName == null) { - charsetName = encoding; - } - return getPrintWriter(loc, file.getPath(), charsetName, null, FileKind.OTHER); - } - - /** - * {@inheritDoc} - */ - public OutputStream createBinaryFile(Location loc, - String pkg, - File relPath) throws IOException { - File file = (pkg.length() == 0) - ? relPath - : new File(nameToPath(pkg), relPath.getPath()); - return getOutputStream(loc, file.getPath(), null, FileKind.OTHER); - } - - - /** - * Converts the canonical name of a top-level type or package to a - * pathname. Suffix is ".java" or ".class" or "". - */ - private String nameToPath(String name, String suffix) throws IOException { - if (!DeclarationMaker.isJavaIdentifier(name.replace('.', '_'))) { - bark.aptWarning("IllegalFileName", name); - throw new IOException(); - } - return name.replace('.', File.separatorChar) + suffix; - } - - private String nameToPath(String name) throws IOException { - return nameToPath(name, ""); - } - - /** - * Returns a writer for a text file given its location, its - * pathname relative to that location, and its encoding. - */ - private PrintWriter getPrintWriter(Location loc, String pathname, - String encoding, String name, FileKind kind) throws IOException { - File file = new File(locations.get(loc), pathname); - return getPrintWriter(file, encoding, name, kind); - } - - /** - * Returns a writer for a text file given its encoding. - */ - private PrintWriter getPrintWriter(File file, - String encoding, String name, FileKind kind) throws IOException { - prepareFile(file, name, kind); - PrintWriter pw = - new PrintWriter( - new BufferedWriter( - new OutputStreamWriter(new FileOutputStream(file), - encoding))); - wc.add(pw); - return pw; - } - - /** - * Returns an output stream for a binary file given its location - * and its pathname relative to that location. - */ - private OutputStream getOutputStream(Location loc, String pathname, String name, FileKind kind) - throws IOException { - File file = new File(locations.get(loc), pathname); - return getOutputStream(file, name, kind); - } - - private OutputStream getOutputStream(File file, String name, FileKind kind) throws IOException { - prepareFile(file, name, kind); - OutputStream os = new FileOutputStream(file); - wc.add(os); - return os; - - } - - public Set getSourceFileNames() { - return sourceFileNames; - } - - public Set getClassFileNames() { - return classFileNames; - } - - public void roundOver() { - roundOver = true; - } - - /** - * Checks that the file has not already been created during this - * invocation. If not, creates intermediate directories, and - * deletes the file if it already exists. - */ - private void prepareFile(File file, String name, FileKind kind) throws IOException { - if (roundOver) { - bark.aptWarning("NoNewFilesAfterRound", file.toString()); - throw new IOException(); - } - - if (filesCreated.contains(file)) { - bark.aptWarning("FileReopening", file.toString()); - throw new IOException(); - } else { - if (file.exists()) { - file.delete(); - } else { - File parent = file.getParentFile(); - if (parent != null && !parent.exists()) { - if(!parent.mkdirs()) { - bark.aptWarning("BadParentDirectory", file.toString()); - throw new IOException(); - } - } - } - - kind.register(file, name, this); - filesCreated.add(file); - } - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/apt/MessagerImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/apt/MessagerImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.apt; - -import javax.tools.JavaFileObject; -import com.sun.mirror.apt.Messager; -import com.sun.tools.apt.mirror.util.SourcePositionImpl; -import com.sun.mirror.util.SourcePosition; -import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.Name; -import com.sun.tools.javac.util.Position; -import com.sun.tools.apt.util.Bark; - - -/** - * Implementation of Messager. - */ -@SuppressWarnings("deprecation") -public class MessagerImpl implements Messager { - private final Bark bark; - - private static final Context.Key messagerKey = - new Context.Key(); - - public static MessagerImpl instance(Context context) { - MessagerImpl instance = context.get(messagerKey); - if (instance == null) { - instance = new MessagerImpl(context); - } - return instance; - } - - private MessagerImpl(Context context) { - context.put(messagerKey, this); - bark = Bark.instance(context); - } - - - /** - * {@inheritDoc} - */ - public void printError(String msg) { - bark.aptError("Messager", msg); - } - - /** - * {@inheritDoc} - */ - public void printError(SourcePosition pos, String msg) { - if (pos instanceof SourcePositionImpl) { - SourcePositionImpl posImpl = (SourcePositionImpl) pos; - JavaFileObject prev = bark.useSource(posImpl.getSource()); - bark.aptError(posImpl.getJavacPosition(), "Messager", msg); - bark.useSource(prev); - } else - printError(msg); - } - - /** - * {@inheritDoc} - */ - public void printWarning(String msg) { - bark.aptWarning("Messager", msg); - } - - /** - * {@inheritDoc} - */ - public void printWarning(SourcePosition pos, String msg) { - if (pos instanceof SourcePositionImpl) { - SourcePositionImpl posImpl = (SourcePositionImpl) pos; - JavaFileObject prev = bark.useSource(posImpl.getSource()); - bark.aptWarning(posImpl.getJavacPosition(), "Messager", msg); - bark.useSource(prev); - } else - printWarning(msg); - } - - /** - * {@inheritDoc} - */ - public void printNotice(String msg) { - bark.aptNote("Messager", msg); - } - - /** - * {@inheritDoc} - */ - public void printNotice(SourcePosition pos, String msg) { - if (pos instanceof SourcePositionImpl) { - SourcePositionImpl posImpl = (SourcePositionImpl) pos; - JavaFileObject prev = bark.useSource(posImpl.getSource()); - bark.aptNote(posImpl.getJavacPosition(), "Messager", msg); - bark.useSource(prev); - } else - printNotice(msg); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/apt/RoundCompleteEventImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/apt/RoundCompleteEventImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.apt; - -import com.sun.mirror.apt.AnnotationProcessorEnvironment; -import com.sun.mirror.apt.RoundCompleteEvent; -import com.sun.mirror.apt.RoundState; - -@SuppressWarnings("deprecation") -public class RoundCompleteEventImpl extends RoundCompleteEvent { - private static final long serialVersionUID = 7067621446720784300L; - - public RoundCompleteEventImpl(AnnotationProcessorEnvironment source, - RoundState rs) { - super(source, rs); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/apt/RoundStateImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/apt/RoundStateImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.apt; - -import com.sun.mirror.apt.RoundState; -import java.util.Map; - -@SuppressWarnings("deprecation") -public class RoundStateImpl implements RoundState { - private final boolean finalRound; - private final boolean errorRaised; - private final boolean sourceFilesCreated; - private final boolean classFilesCreated; - - public RoundStateImpl(boolean errorRaised, - boolean sourceFilesCreated, - boolean classFilesCreated, - Map options) { - /* - * In the default mode of operation, this round is the final - * round if an error was raised OR there were no new source - * files generated. If classes are being treated as - * declarations, this is the final round if an error was - * raised OR neither new source files nor new class files were - * generated. - */ - this.finalRound = - errorRaised || - (!sourceFilesCreated && - !(classFilesCreated && options.keySet().contains("-XclassesAsDecls")) ); - this.errorRaised = errorRaised; - this.sourceFilesCreated = sourceFilesCreated; - this.classFilesCreated = classFilesCreated; - } - - public boolean finalRound() { - return finalRound; - } - - public boolean errorRaised() { - return errorRaised; - } - - public boolean sourceFilesCreated() { - return sourceFilesCreated; - } - - public boolean classFilesCreated() { - return classFilesCreated; - } - - public String toString() { - return - "[final round: " + finalRound + - ", error raised: " + errorRaised + - ", source files created: " + sourceFilesCreated + - ", class files created: " + classFilesCreated + "]"; - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationMirrorImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationMirrorImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.LinkedHashMap; -import java.util.Map; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.AnnotationType; -import com.sun.mirror.util.SourcePosition; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Attribute; -import com.sun.tools.javac.code.Symbol.*; -import com.sun.tools.javac.util.Name; -import com.sun.tools.javac.util.Pair; - - -/** - * Implementation of AnnotationMirror - */ -@SuppressWarnings("deprecation") -public class AnnotationMirrorImpl implements AnnotationMirror { - - protected final AptEnv env; - protected final Attribute.Compound anno; - protected final Declaration decl; - - - AnnotationMirrorImpl(AptEnv env, Attribute.Compound anno, Declaration decl) { - this.env = env; - this.anno = anno; - this.decl = decl; - } - - - /** - * Returns a string representation of this annotation. - * String is of one of the forms: - * @com.example.foo(name1=val1, name2=val2) - * @com.example.foo(val) - * @com.example.foo - * Omit parens for marker annotations, and omit "value=" when allowed. - */ - public String toString() { - StringBuilder sb = new StringBuilder("@"); - Constants.Formatter fmtr = Constants.getFormatter(sb); - - fmtr.append(anno.type.tsym); - - int len = anno.values.length(); - if (len > 0) { // omit parens for marker annotations - sb.append('('); - boolean first = true; - for (Pair val : anno.values) { - if (!first) { - sb.append(", "); - } - first = false; - - Name name = val.fst.name; - if (len > 1 || name != env.names.value) { - fmtr.append(name); - sb.append('='); - } - sb.append(new AnnotationValueImpl(env, val.snd, this)); - } - sb.append(')'); - } - return fmtr.toString(); - } - - /** - * {@inheritDoc} - */ - public AnnotationType getAnnotationType() { - return (AnnotationType) env.typeMaker.getType(anno.type); - } - - /** - * {@inheritDoc} - */ - public Map - getElementValues() { - Map res = - new LinkedHashMap(); // whew! - for (Pair val : anno.values) { - res.put(getElement(val.fst), - new AnnotationValueImpl(env, val.snd, this)); - } - return res; - } - - public SourcePosition getPosition() { - // Return position of the declaration on which this annotation - // appears. - return (decl == null) ? null : decl.getPosition(); - - } - - public Declaration getDeclaration() { - return this.decl; - } - - /** - * Returns the annotation type element for a symbol. - */ - private AnnotationTypeElementDeclaration getElement(MethodSymbol m) { - return (AnnotationTypeElementDeclaration) - env.declMaker.getExecutableDeclaration(m); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationProxyMaker.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationProxyMaker.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,355 +0,0 @@ -/* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.lang.annotation.*; -import java.lang.reflect.Array; -import java.lang.reflect.Method; -import java.util.*; -import sun.reflect.annotation.*; - -import com.sun.mirror.type.TypeMirror; -import com.sun.mirror.type.MirroredTypeException; -import com.sun.mirror.type.MirroredTypesException; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.*; -import com.sun.tools.javac.util.Name; -import com.sun.tools.javac.util.Pair; - - -/** - * A generator of dynamic proxy implementations of - * java.lang.annotation.Annotation. - * - *

The "dynamic proxy return form" of an attribute element value is - * the form used by sun.reflect.annotation.AnnotationInvocationHandler. - */ -@SuppressWarnings("deprecation") -class AnnotationProxyMaker { - - private final AptEnv env; - private final Attribute.Compound attrs; - private final Class annoType; - - - private AnnotationProxyMaker(AptEnv env, - Attribute.Compound attrs, - Class annoType) { - this.env = env; - this.attrs = attrs; - this.annoType = annoType; - } - - - /** - * Returns a dynamic proxy for an annotation mirror. - */ - public static A generateAnnotation( - AptEnv env, Attribute.Compound attrs, Class annoType) { - AnnotationProxyMaker apm = new AnnotationProxyMaker(env, attrs, annoType); - return annoType.cast(apm.generateAnnotation()); - } - - - /** - * Returns a dynamic proxy for an annotation mirror. - */ - private Annotation generateAnnotation() { - return AnnotationParser.annotationForMap(annoType, - getAllReflectedValues()); - } - - /** - * Returns a map from element names to their values in "dynamic - * proxy return form". Includes all elements, whether explicit or - * defaulted. - */ - private Map getAllReflectedValues() { - Map res = new LinkedHashMap(); - - for (Map.Entry entry : - getAllValues().entrySet()) { - MethodSymbol meth = entry.getKey(); - Object value = generateValue(meth, entry.getValue()); - if (value != null) { - res.put(meth.name.toString(), value); - } else { - // Ignore this element. May lead to - // IncompleteAnnotationException somewhere down the line. - } - } - return res; - } - - /** - * Returns a map from element symbols to their values. - * Includes all elements, whether explicit or defaulted. - */ - private Map getAllValues() { - Map res = - new LinkedHashMap(); - - // First find the default values. - ClassSymbol sym = (ClassSymbol) attrs.type.tsym; - for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) { - if (e.sym.kind == Kinds.MTH) { - MethodSymbol m = (MethodSymbol) e.sym; - Attribute def = m.defaultValue; - if (def != null) { - res.put(m, def); - } - } - } - // Next find the explicit values, possibly overriding defaults. - for (Pair p : attrs.values) { - res.put(p.fst, p.snd); - } - return res; - } - - /** - * Converts an element value to its "dynamic proxy return form". - * Returns an exception proxy on some errors, but may return null if - * a useful exception cannot or should not be generated at this point. - */ - private Object generateValue(MethodSymbol meth, Attribute attr) { - ValueVisitor vv = new ValueVisitor(meth); - return vv.getValue(attr); - } - - - private class ValueVisitor implements Attribute.Visitor { - - private MethodSymbol meth; // annotation element being visited - private Class runtimeType; // runtime type of annotation element - private Object value; // value in "dynamic proxy return form" - - ValueVisitor(MethodSymbol meth) { - this.meth = meth; - } - - Object getValue(Attribute attr) { - Method method; // runtime method of annotation element - try { - method = annoType.getMethod(meth.name.toString()); - } catch (NoSuchMethodException e) { - return null; - } - runtimeType = method.getReturnType(); - attr.accept(this); - if (!(value instanceof ExceptionProxy) && - !AnnotationType.invocationHandlerReturnType(runtimeType) - .isInstance(value)) { - typeMismatch(method, attr); - } - return value; - } - - - public void visitConstant(Attribute.Constant c) { - value = Constants.decodeConstant(c.value, c.type); - } - - public void visitClass(Attribute.Class c) { - value = new MirroredTypeExceptionProxy( - env.typeMaker.getType(c.type)); - } - - public void visitArray(Attribute.Array a) { - Type elemtype = env.jctypes.elemtype(a.type); - - if (elemtype.tsym == env.symtab.classType.tsym) { // Class[] - // Construct a proxy for a MirroredTypesException - ArrayList elems = new ArrayList(); - for (int i = 0; i < a.values.length; i++) { - Type elem = ((Attribute.Class) a.values[i]).type; - elems.add(env.typeMaker.getType(elem)); - } - value = new MirroredTypesExceptionProxy(elems); - - } else { - int len = a.values.length; - Class runtimeTypeSaved = runtimeType; - runtimeType = runtimeType.getComponentType(); - try { - Object res = Array.newInstance(runtimeType, len); - for (int i = 0; i < len; i++) { - a.values[i].accept(this); - if (value == null || value instanceof ExceptionProxy) { - return; - } - try { - Array.set(res, i, value); - } catch (IllegalArgumentException e) { - value = null; // indicates a type mismatch - return; - } - } - value = res; - } finally { - runtimeType = runtimeTypeSaved; - } - } - } - - @SuppressWarnings({"unchecked", "rawtypes"}) - public void visitEnum(Attribute.Enum e) { - if (runtimeType.isEnum()) { - String constName = e.value.toString(); - try { - value = Enum.valueOf((Class)runtimeType, constName); - } catch (IllegalArgumentException ex) { - value = new EnumConstantNotPresentExceptionProxy( - (Class>)runtimeType, constName); - } - } else { - value = null; // indicates a type mismatch - } - } - - public void visitCompound(Attribute.Compound c) { - try { - Class nested = - runtimeType.asSubclass(Annotation.class); - value = generateAnnotation(env, c, nested); - } catch (ClassCastException ex) { - value = null; // indicates a type mismatch - } - } - - public void visitError(Attribute.Error e) { - value = null; // indicates a type mismatch - } - - - /** - * Sets "value" to an ExceptionProxy indicating a type mismatch. - */ - private void typeMismatch(Method method, final Attribute attr) { - class AnnotationTypeMismatchExceptionProxy extends ExceptionProxy { - private static final long serialVersionUID = 8473323277815075163L; - transient final Method method; - AnnotationTypeMismatchExceptionProxy(Method method) { - this.method = method; - } - public String toString() { - return ""; // eg: @Anno(value=) - } - protected RuntimeException generateException() { - return new AnnotationTypeMismatchException(method, - attr.type.toString()); - } - } - value = new AnnotationTypeMismatchExceptionProxy(method); - } - } - - - /** - * ExceptionProxy for MirroredTypeException. - * The toString, hashCode, and equals methods foward to the underlying - * type. - */ - private static final class MirroredTypeExceptionProxy extends ExceptionProxy { - private static final long serialVersionUID = 6662035281599933545L; - - private MirroredTypeException ex; - - MirroredTypeExceptionProxy(TypeMirror t) { - // It would be safer if we could construct the exception in - // generateException(), but there would be no way to do - // that properly following deserialization. - ex = new MirroredTypeException(t); - } - - public String toString() { - return ex.getQualifiedName(); - } - - public int hashCode() { - TypeMirror t = ex.getTypeMirror(); - return (t != null) - ? t.hashCode() - : ex.getQualifiedName().hashCode(); - } - - public boolean equals(Object obj) { - TypeMirror t = ex.getTypeMirror(); - return t != null && - obj instanceof MirroredTypeExceptionProxy && - t.equals( - ((MirroredTypeExceptionProxy) obj).ex.getTypeMirror()); - } - - protected RuntimeException generateException() { - return (RuntimeException) ex.fillInStackTrace(); - } - } - - - /** - * ExceptionProxy for MirroredTypesException. - * The toString, hashCode, and equals methods foward to the underlying - * types. - */ - private static final class MirroredTypesExceptionProxy extends ExceptionProxy { - private static final long serialVersionUID = -6670822532616693951L; - - private MirroredTypesException ex; - - MirroredTypesExceptionProxy(Collection ts) { - // It would be safer if we could construct the exception in - // generateException(), but there would be no way to do - // that properly following deserialization. - ex = new MirroredTypesException(ts); - } - - public String toString() { - return ex.getQualifiedNames().toString(); - } - - public int hashCode() { - Collection ts = ex.getTypeMirrors(); - return (ts != null) - ? ts.hashCode() - : ex.getQualifiedNames().hashCode(); - } - - public boolean equals(Object obj) { - Collection ts = ex.getTypeMirrors(); - return ts != null && - obj instanceof MirroredTypesExceptionProxy && - ts.equals( - ((MirroredTypesExceptionProxy) obj).ex.getTypeMirrors()); - } - - protected RuntimeException generateException() { - return (RuntimeException) ex.fillInStackTrace(); - } - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationTypeDeclarationImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationTypeDeclarationImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.Collection; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.DeclarationVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Symbol.*; - - -/** - * Implementation of AnnotationTypeDeclaration - */ -@SuppressWarnings("deprecation") -public class AnnotationTypeDeclarationImpl extends InterfaceDeclarationImpl - implements AnnotationTypeDeclaration -{ - AnnotationTypeDeclarationImpl(AptEnv env, ClassSymbol sym) { - super(env, sym); - } - - - /** - * {@inheritDoc} - */ - public Collection getMethods() { - return identityFilter.filter(super.getMethods(), - AnnotationTypeElementDeclaration.class); - } - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitAnnotationTypeDeclaration(this); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationTypeElementDeclarationImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationTypeElementDeclarationImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.DeclarationVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Symbol.MethodSymbol; - - -/** - * Implementation of AnnotationTypeElementDeclaration - */ -@SuppressWarnings("deprecation") -public class AnnotationTypeElementDeclarationImpl extends MethodDeclarationImpl - implements AnnotationTypeElementDeclaration { - - AnnotationTypeElementDeclarationImpl(AptEnv env, MethodSymbol sym) { - super(env, sym); - } - - /** - * {@inheritDoc} - */ - public AnnotationTypeDeclaration getDeclaringType() { - return (AnnotationTypeDeclaration) super.getDeclaringType(); - } - - /** - * {@inheritDoc} - */ - public AnnotationValue getDefaultValue() { - return (sym.defaultValue == null) - ? null - : new AnnotationValueImpl(env, sym.defaultValue, null); - } - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitAnnotationTypeElementDeclaration(this); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationValueImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationValueImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.Collection; -import java.util.ArrayList; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.SourcePosition; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Attribute; -import com.sun.tools.javac.code.Symbol.*; -import com.sun.tools.javac.code.TypeTags; - - -/** - * Implementation of AnnotationValue - */ -@SuppressWarnings("deprecation") -public class AnnotationValueImpl implements AnnotationValue { - - protected final AptEnv env; - protected final Attribute attr; - protected final AnnotationMirrorImpl annotation; - - AnnotationValueImpl(AptEnv env, Attribute attr, AnnotationMirrorImpl annotation) { - this.env = env; - this.attr = attr; - this.annotation = annotation; - } - - - /** - * {@inheritDoc} - */ - public String toString() { - StringBuilder sb = new StringBuilder(); - Constants.Formatter fmtr = Constants.getFormatter(sb); - - fmtr.append(getValue()); - return fmtr.toString(); - } - - /** - * {@inheritDoc} - */ - public Object getValue() { - ValueVisitor vv = new ValueVisitor(); - attr.accept(vv); - return vv.value; - } - - - public SourcePosition getPosition() { - // Imprecise implementation; just return position of enclosing - // annotation. - return (annotation == null) ? null : annotation.getPosition(); - } - - private class ValueVisitor implements Attribute.Visitor { - - public Object value; - - public void visitConstant(Attribute.Constant c) { - value = Constants.decodeConstant(c.value, c.type); - } - - public void visitClass(Attribute.Class c) { - value = env.typeMaker.getType( - env.jctypes.erasure(c.type)); - } - - public void visitEnum(Attribute.Enum e) { - value = env.declMaker.getFieldDeclaration(e.value); - } - - public void visitCompound(Attribute.Compound c) { - value = new AnnotationMirrorImpl(env, c, - (annotation == null) ? - null : - annotation.getDeclaration()); - } - - public void visitArray(Attribute.Array a) { - ArrayList vals = - new ArrayList(a.values.length); - for (Attribute elem : a.values) { - vals.add(new AnnotationValueImpl(env, elem, annotation)); - } - value = vals; - } - - public void visitError(Attribute.Error e) { - value = ""; // javac will already have logged an error msg - } - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/ClassDeclarationImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/ClassDeclarationImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.lang.annotation.Annotation; -import java.lang.annotation.Inherited; -import java.util.ArrayList; -import java.util.Collection; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.ClassType; -import com.sun.mirror.util.DeclarationVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.*; - - -/** - * Implementation of ClassDeclaration - */ -@SuppressWarnings("deprecation") -public class ClassDeclarationImpl extends TypeDeclarationImpl - implements ClassDeclaration { - - ClassDeclarationImpl(AptEnv env, ClassSymbol sym) { - super(env, sym); - } - - - /** - * {@inheritDoc} - * Overridden here to handle @Inherited. - */ - public A getAnnotation(Class annoType) { - - boolean inherited = annoType.isAnnotationPresent(Inherited.class); - for (Type t = sym.type; - t.tsym != env.symtab.objectType.tsym && !t.isErroneous(); - t = env.jctypes.supertype(t)) { - - A result = getAnnotation(annoType, t.tsym); - if (result != null || !inherited) { - return result; - } - } - return null; - } - - /** - * {@inheritDoc} - */ - public ClassType getSuperclass() { - // java.lang.Object has no superclass - if (sym == env.symtab.objectType.tsym) { - return null; - } - Type t = env.jctypes.supertype(sym.type); - return (ClassType) env.typeMaker.getType(t); - } - - /** - * {@inheritDoc} - */ - public Collection getConstructors() { - ArrayList res = - new ArrayList(); - for (Symbol s : getMembers(true)) { - if (s.isConstructor()) { - MethodSymbol m = (MethodSymbol) s; - res.add((ConstructorDeclaration) - env.declMaker.getExecutableDeclaration(m)); - } - } - return res; - } - - /** - * {@inheritDoc} - */ - public Collection getMethods() { - return identityFilter.filter(super.getMethods(), - MethodDeclaration.class); - } - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitClassDeclaration(this); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/Constants.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/Constants.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,294 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.Collection; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.TypeMirror; -import com.sun.tools.apt.mirror.type.TypeMirrorImpl; -import com.sun.tools.javac.code.Type; - -import static com.sun.tools.javac.code.TypeTags.*; - - -/** - * Utility class for operating on constant expressions. - */ -@SuppressWarnings("deprecation") -class Constants { - - /** - * Converts a constant in javac's internal representation (in which - * boolean, char, byte, short, and int are each represented by an Integer) - * into standard representation. Other values (including null) are - * returned unchanged. - */ - static Object decodeConstant(Object value, Type type) { - if (value instanceof Integer) { - int i = ((Integer) value).intValue(); - switch (type.tag) { - case BOOLEAN: return Boolean.valueOf(i != 0); - case CHAR: return Character.valueOf((char) i); - case BYTE: return Byte.valueOf((byte) i); - case SHORT: return Short.valueOf((short) i); - } - } - return value; - } - - /** - * Returns a formatter for generating the text of constant - * expressions. Equivalent to - * getFormatter(new StringBuilder()). - */ - static Formatter getFormatter() { - return new Formatter(new StringBuilder()); - } - - /** - * Returns a formatter for generating the text of constant - * expressions. Also generates the text of constant - * "pseudo-expressions" for annotations and array-valued - * annotation elements. - * - * @param buf where the expression is written - */ - static Formatter getFormatter(StringBuilder buf) { - return new Formatter(buf); - } - - - /** - * Utility class used to generate the text of constant - * expressions. Also generates the text of constant - * "pseudo-expressions" for annotations and array-valued - * annotation elements. - */ - static class Formatter { - - private StringBuilder buf; // where the output goes - - private Formatter(StringBuilder buf) { - this.buf = buf; - } - - - public String toString() { - return buf.toString(); - } - - /** - * Appends a constant whose type is not statically known - * by dispatching to the appropriate overloaded append method. - */ - void append(Object val) { - if (val instanceof String) { - append((String) val); - } else if (val instanceof Character) { - append((Character) val); - } else if (val instanceof Boolean) { - append((Boolean) val); - } else if (val instanceof Byte) { - append((Byte) val); - } else if (val instanceof Short) { - append((Short) val); - } else if (val instanceof Integer) { - append((Integer) val); - } else if (val instanceof Long) { - append((Long) val); - } else if (val instanceof Float) { - append((Float) val); - } else if (val instanceof Double) { - append((Double) val); - } else if (val instanceof TypeMirror) { - append((TypeMirrorImpl) val); - } else if (val instanceof EnumConstantDeclaration) { - append((EnumConstantDeclarationImpl) val); - } else if (val instanceof AnnotationMirror) { - append((AnnotationMirrorImpl) val); - } else if (val instanceof Collection) { - append((Collection) val); - } else { - appendUnquoted(val.toString()); - } - } - - /** - * Appends a string, escaped (as needed) and quoted. - */ - void append(String val) { - buf.append('"'); - appendUnquoted(val); - buf.append('"'); - } - - /** - * Appends a Character, escaped (as needed) and quoted. - */ - void append(Character val) { - buf.append('\''); - appendUnquoted(val.charValue()); - buf.append('\''); - } - - void append(Boolean val) { - buf.append(val); - } - - void append(Byte val) { - buf.append(String.format("0x%02x", val)); - } - - void append(Short val) { - buf.append(val); - } - - void append(Integer val) { - buf.append(val); - } - - void append(Long val) { - buf.append(val).append('L'); - } - - void append(Float val) { - if (val.isNaN()) { - buf.append("0.0f/0.0f"); - } else if (val.isInfinite()) { - if (val.floatValue() < 0) { - buf.append('-'); - } - buf.append("1.0f/0.0f"); - } else { - buf.append(val).append('f'); - } - } - - void append(Double val) { - if (val.isNaN()) { - buf.append("0.0/0.0"); - } else if (val.isInfinite()) { - if (val.doubleValue() < 0) { - buf.append('-'); - } - buf.append("1.0/0.0"); - } else { - buf.append(val); - } - } - - /** - * Appends the class literal corresponding to a type. Should - * only be invoked for types that have an associated literal. - * e.g: "java.lang.String.class" - * "boolean.class" - * "int[].class" - */ - void append(TypeMirrorImpl t) { - appendUnquoted(t.type.toString()); - buf.append(".class"); - } - - /** - * Appends the fully qualified name of an enum constant. - * e.g: "java.math.RoundingMode.UP" - */ - void append(EnumConstantDeclarationImpl e) { - appendUnquoted(e.sym.enclClass() + "." + e); - } - - /** - * Appends the text of an annotation pseudo-expression. - * e.g: "@pkg.Format(linesep='\n')" - */ - void append(AnnotationMirrorImpl anno) { - appendUnquoted(anno.toString()); - } - - /** - * Appends the elements of a collection, enclosed within braces - * and separated by ", ". Useful for array-valued annotation - * elements. - */ - void append(Collection vals) { - buf.append('{'); - boolean first = true; - for (Object val : vals) { - if (first) { - first = false; - } else { - buf.append(", "); - } - append(((AnnotationValue) val).getValue()); - } - buf.append('}'); - } - - - /** - * For each char of a string, append using appendUnquoted(char). - */ - private void appendUnquoted(String s) { - for (char c : s.toCharArray()) { - appendUnquoted(c); - } - } - - /** - * Appends a char (unquoted), using escapes for those that are not - * printable ASCII. We don't know what is actually printable in - * the locale in which this result will be used, so ASCII is our - * best guess as to the least common denominator. - */ - private void appendUnquoted(char c) { - switch (c) { - case '\b': buf.append("\\b"); break; - case '\t': buf.append("\\t"); break; - case '\n': buf.append("\\n"); break; - case '\f': buf.append("\\f"); break; - case '\r': buf.append("\\r"); break; - case '\"': buf.append("\\\""); break; - case '\'': buf.append("\\\'"); break; - case '\\': buf.append("\\\\"); break; - default: - if (isPrintableAscii(c)) { - buf.append(c); - } else { - buf.append(String.format("\\u%04x", (int) c)); - } - } - } - - /** - * Is c a printable ASCII character? - */ - private static boolean isPrintableAscii(char c) { - return c >= ' ' && c <= '~'; - } - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/ConstructorDeclarationImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/ConstructorDeclarationImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.ArrayList; -import java.util.Collection; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.DeclarationVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Flags; -import com.sun.tools.javac.code.Symbol.MethodSymbol; - - -/** - * Implementation of ConstructorDeclaration - */ -@SuppressWarnings("deprecation") -public class ConstructorDeclarationImpl extends ExecutableDeclarationImpl - implements ConstructorDeclaration { - - ConstructorDeclarationImpl(AptEnv env, MethodSymbol sym) { - super(env, sym); - } - - - /** - * {@inheritDoc} - * Returns the simple name of the declaring class. - */ - public String getSimpleName() { - return sym.enclClass().name.toString(); - } - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitConstructorDeclaration(this); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/DeclarationImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/DeclarationImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,254 +0,0 @@ -/* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.Collection; -import java.util.EnumSet; -import javax.tools.JavaFileObject; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.*; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.apt.mirror.util.SourcePositionImpl; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.*; -import com.sun.tools.javac.comp.AttrContext; -import com.sun.tools.javac.comp.Env; -import com.sun.tools.javac.tree.*; -import com.sun.tools.javac.util.Name; -import com.sun.tools.javac.util.Position; - -import static com.sun.mirror.declaration.Modifier.*; -import static com.sun.tools.javac.code.Kinds.*; - - -/** - * Implementation of Declaration - */ -@SuppressWarnings("deprecation") -public abstract class DeclarationImpl implements Declaration { - - protected final AptEnv env; - public final Symbol sym; - - protected static final DeclarationFilter identityFilter = - new DeclarationFilter(); - - - /** - * "sym" should be completed before this constructor is called. - */ - protected DeclarationImpl(AptEnv env, Symbol sym) { - this.env = env; - this.sym = sym; - } - - - /** - * {@inheritDoc} - *

ParameterDeclarationImpl overrides this implementation. - */ - public boolean equals(Object obj) { - if (obj instanceof DeclarationImpl) { - DeclarationImpl that = (DeclarationImpl) obj; - return sym == that.sym && env == that.env; - } else { - return false; - } - } - - /** - * {@inheritDoc} - *

ParameterDeclarationImpl overrides this implementation. - */ - public int hashCode() { - return sym.hashCode() + env.hashCode(); - } - - /** - * {@inheritDoc} - */ - public String getDocComment() { - // Our doc comment is contained in a map in our toplevel, - // indexed by our tree. Find our enter environment, which gives - // us our toplevel. It also gives us a tree that contains our - // tree: walk it to find our tree. This is painful. - Env enterEnv = getEnterEnv(); - if (enterEnv == null) - return null; - JCTree tree = TreeInfo.declarationFor(sym, enterEnv.tree); - return enterEnv.toplevel.docComments.get(tree); - } - - /** - * {@inheritDoc} - */ - public Collection getAnnotationMirrors() { - Collection res = - new ArrayList(); - for (Attribute.Compound a : sym.getAnnotationMirrors()) { - res.add(env.declMaker.getAnnotationMirror(a, this)); - } - return res; - } - - /** - * {@inheritDoc} - * Overridden by ClassDeclarationImpl to handle @Inherited. - */ - public A getAnnotation(Class annoType) { - return getAnnotation(annoType, sym); - } - - protected A getAnnotation(Class annoType, - Symbol annotated) { - if (!annoType.isAnnotation()) { - throw new IllegalArgumentException( - "Not an annotation type: " + annoType); - } - String name = annoType.getName(); - for (Attribute.Compound attr : annotated.getAnnotationMirrors()) { - if (name.equals(attr.type.tsym.flatName().toString())) { - return AnnotationProxyMaker.generateAnnotation(env, attr, - annoType); - } - } - return null; - } - - // Cache for modifiers. - private EnumSet modifiers = null; - - /** - * {@inheritDoc} - */ - public Collection getModifiers() { - if (modifiers == null) { - modifiers = EnumSet.noneOf(Modifier.class); - long flags = AptEnv.getFlags(sym); - - if (0 != (flags & Flags.PUBLIC)) modifiers.add(PUBLIC); - if (0 != (flags & Flags.PROTECTED)) modifiers.add(PROTECTED); - if (0 != (flags & Flags.PRIVATE)) modifiers.add(PRIVATE); - if (0 != (flags & Flags.ABSTRACT)) modifiers.add(ABSTRACT); - if (0 != (flags & Flags.STATIC)) modifiers.add(STATIC); - if (0 != (flags & Flags.FINAL)) modifiers.add(FINAL); - if (0 != (flags & Flags.TRANSIENT)) modifiers.add(TRANSIENT); - if (0 != (flags & Flags.VOLATILE)) modifiers.add(VOLATILE); - if (0 != (flags & Flags.SYNCHRONIZED)) modifiers.add(SYNCHRONIZED); - if (0 != (flags & Flags.NATIVE)) modifiers.add(NATIVE); - if (0 != (flags & Flags.STRICTFP)) modifiers.add(STRICTFP); - } - return modifiers; - } - - /** - * {@inheritDoc} - * Overridden in some subclasses. - */ - public String getSimpleName() { - return sym.name.toString(); - } - - /** - * {@inheritDoc} - */ - public SourcePosition getPosition() { - // Find the toplevel. From there use a tree-walking utility - // that finds the tree for our symbol, and with it the position. - Env enterEnv = getEnterEnv(); - if (enterEnv == null) - return null; - JCTree.JCCompilationUnit toplevel = enterEnv.toplevel; - JavaFileObject sourcefile = toplevel.sourcefile; - if (sourcefile == null) - return null; - int pos = TreeInfo.positionFor(sym, toplevel); - - return new SourcePositionImpl(sourcefile, pos, toplevel.lineMap); - } - - /** - * Applies a visitor to this declaration. - * - * @param v the visitor operating on this declaration - */ - public void accept(DeclarationVisitor v) { - v.visitDeclaration(this); - } - - - private Collection members = null; // cache for getMembers() - - /** - * Returns the symbols of type or package members (and constructors) - * that are not synthetic or otherwise unwanted. - * Caches the result if "cache" is true. - */ - protected Collection getMembers(boolean cache) { - if (members != null) { - return members; - } - LinkedList res = new LinkedList(); - for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) { - if (e.sym != null && !unwanted(e.sym)) { - res.addFirst(e.sym); - } - } - return cache ? (members = res) : res; - } - - /** - * Tests whether this is a symbol that should never be seen by clients, - * such as a synthetic class. - * Note that a class synthesized by the compiler may not be flagged as - * synthetic: see bugid 4959932. - */ - private static boolean unwanted(Symbol s) { - return AptEnv.hasFlag(s, Flags.SYNTHETIC) || - (s.kind == TYP && - !DeclarationMaker.isJavaIdentifier(s.name.toString())); - } - - /** - * Returns this declaration's enter environment, or null if it - * has none. - */ - private Env getEnterEnv() { - // Get enclosing class of sym, or sym itself if it is a class - // or package. - TypeSymbol ts = (sym.kind != PCK) - ? sym.enclClass() - : (PackageSymbol) sym; - return (ts != null) - ? env.enter.getEnv(ts) - : null; - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/DeclarationMaker.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/DeclarationMaker.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,270 +0,0 @@ -/* - * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.HashMap; -import java.util.Map; - -import com.sun.mirror.declaration.*; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.*; -import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.Name; -import com.sun.tools.javac.main.JavaCompiler; - -/** - * Utilities for constructing and caching declarations. - */ -@SuppressWarnings("deprecation") -public class DeclarationMaker { - - private AptEnv env; - private Context context; - private JavaCompiler javacompiler; - private static final Context.Key declarationMakerKey = - new Context.Key(); - - public static DeclarationMaker instance(Context context) { - DeclarationMaker instance = context.get(declarationMakerKey); - if (instance == null) { - instance = new DeclarationMaker(context); - } - return instance; - } - - private DeclarationMaker(Context context) { - context.put(declarationMakerKey, this); - env = AptEnv.instance(context); - this.context = context; - this.javacompiler = JavaCompiler.instance(context); - } - - - - // Cache of package declarations - private Map packageDecls = - new HashMap(); - - /** - * Returns the package declaration for a package symbol. - */ - public PackageDeclaration getPackageDeclaration(PackageSymbol p) { - PackageDeclaration res = packageDecls.get(p); - if (res == null) { - res = new PackageDeclarationImpl(env, p); - packageDecls.put(p, res); - } - return res; - } - - /** - * Returns the package declaration for the package with the given name. - * Name is fully-qualified, or "" for the unnamed package. - * Returns null if package declaration not found. - */ - public PackageDeclaration getPackageDeclaration(String name) { - PackageSymbol p = null; - if (name.equals("") ) - p = env.symtab.unnamedPackage; - else { - if (!isJavaName(name)) - return null; - Symbol s = nameToSymbol(name, false); - if (s instanceof PackageSymbol) { - p = (PackageSymbol) s; - if (!p.exists()) - return null; - } else - return null; - } - return getPackageDeclaration(p); - } - - // Cache of type declarations - private Map typeDecls = - new HashMap(); - - /** - * Returns the type declaration for a class symbol. - * Forces completion, and returns null on error. - */ - public TypeDeclaration getTypeDeclaration(ClassSymbol c) { - long flags = AptEnv.getFlags(c); // forces symbol completion - if (c.kind == Kinds.ERR) { - return null; - } - TypeDeclaration res = typeDecls.get(c); - if (res == null) { - if ((flags & Flags.ANNOTATION) != 0) { - res = new AnnotationTypeDeclarationImpl(env, c); - } else if ((flags & Flags.INTERFACE) != 0) { - res = new InterfaceDeclarationImpl(env, c); - } else if ((flags & Flags.ENUM) != 0) { - res = new EnumDeclarationImpl(env, c); - } else { - res = new ClassDeclarationImpl(env, c); - } - typeDecls.put(c, res); - } - return res; - } - - /** - * Returns the type declaration for the type with the given canonical name. - * Returns null if type declaration not found. - */ - public TypeDeclaration getTypeDeclaration(String name) { - if (!isJavaName(name)) - return null; - Symbol s = nameToSymbol(name, true); - if (s instanceof ClassSymbol) { - ClassSymbol c = (ClassSymbol) s; - return getTypeDeclaration(c); - } else - return null; - } - - /** - * Returns a symbol given the type's or packages's canonical name, - * or null if the name isn't found. - */ - private Symbol nameToSymbol(String name, boolean classCache) { - Symbol s = null; - Name nameName = env.names.fromString(name); - if (classCache) - s = env.symtab.classes.get(nameName); - else - s = env.symtab.packages.get(nameName); - - if (s != null && s.exists()) - return s; - - s = javacompiler.resolveIdent(name); - if (s.kind == Kinds.ERR ) - return null; - - if (s.kind == Kinds.PCK) - s.complete(); - - return s; - } - - // Cache of method and constructor declarations - private Map executableDecls = - new HashMap(); - - /** - * Returns the method or constructor declaration for a method symbol. - */ - ExecutableDeclaration getExecutableDeclaration(MethodSymbol m) { - ExecutableDeclaration res = executableDecls.get(m); - if (res == null) { - if (m.isConstructor()) { - res = new ConstructorDeclarationImpl(env, m); - } else if (isAnnotationTypeElement(m)) { - res = new AnnotationTypeElementDeclarationImpl(env, m); - } else { - res = new MethodDeclarationImpl(env, m); - } - executableDecls.put(m, res); - } - return res; - } - - // Cache of field declarations - private Map fieldDecls = - new HashMap(); - - /** - * Returns the field declaration for a var symbol. - */ - FieldDeclaration getFieldDeclaration(VarSymbol v) { - FieldDeclaration res = fieldDecls.get(v); - if (res == null) { - if (hasFlag(v, Flags.ENUM)) { - res = new EnumConstantDeclarationImpl(env, v); - } else { - res = new FieldDeclarationImpl(env, v); - } - fieldDecls.put(v, res); - } - return res; - } - - /** - * Returns a parameter declaration. - */ - ParameterDeclaration getParameterDeclaration(VarSymbol v) { - return new ParameterDeclarationImpl(env, v); - } - - /** - * Returns a type parameter declaration. - */ - public TypeParameterDeclaration getTypeParameterDeclaration(TypeSymbol t) { - return new TypeParameterDeclarationImpl(env, t); - } - - /** - * Returns an annotation. - */ - AnnotationMirror getAnnotationMirror(Attribute.Compound a, Declaration decl) { - return new AnnotationMirrorImpl(env, a, decl); - } - - - /** - * Is a string a valid Java identifier? - */ - public static boolean isJavaIdentifier(String id) { - return javax.lang.model.SourceVersion.isIdentifier(id); - } - - public static boolean isJavaName(String name) { - for(String id: name.split("\\.")) { - if (! isJavaIdentifier(id)) - return false; - } - return true; - } - - /** - * Is a method an annotation type element? - * It is if it's declared in an annotation type. - */ - private static boolean isAnnotationTypeElement(MethodSymbol m) { - return hasFlag(m.enclClass(), Flags.ANNOTATION); - } - - /** - * Does a symbol have a given flag? - */ - private static boolean hasFlag(Symbol s, long flag) { - return AptEnv.hasFlag(s, flag); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/EnumConstantDeclarationImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/EnumConstantDeclarationImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.DeclarationVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Symbol.VarSymbol; - - -/** - * Implementation of EnumConstantDeclaration - */ -@SuppressWarnings("deprecation") -public class EnumConstantDeclarationImpl extends FieldDeclarationImpl - implements EnumConstantDeclaration { - - EnumConstantDeclarationImpl(AptEnv env, VarSymbol sym) { - super(env, sym); - } - - /** - * {@inheritDoc} - */ - public EnumDeclaration getDeclaringType() { - return (EnumDeclaration) super.getDeclaringType(); - } - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitEnumConstantDeclaration(this); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/EnumDeclarationImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/EnumDeclarationImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.Collection; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.*; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Symbol.*; - - -/** - * Implementation of EnumDeclaration - */ -@SuppressWarnings("deprecation") -public class EnumDeclarationImpl extends ClassDeclarationImpl - implements EnumDeclaration { - - EnumDeclarationImpl(AptEnv env, ClassSymbol sym) { - super(env, sym); - } - - - /** - * {@inheritDoc} - */ - public Collection getEnumConstants() { - return identityFilter.filter(getFields(), - EnumConstantDeclaration.class); - } - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitEnumDeclaration(this); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/ExecutableDeclarationImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/ExecutableDeclarationImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.Collection; -import java.util.ArrayList; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.ReferenceType; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.*; - - -/** - * Implementation of ExecutableDeclaration - */ -@SuppressWarnings("deprecation") -public abstract class ExecutableDeclarationImpl extends MemberDeclarationImpl - implements ExecutableDeclaration { - public MethodSymbol sym; - - protected ExecutableDeclarationImpl(AptEnv env, MethodSymbol sym) { - super(env, sym); - this.sym = sym; - } - - - /** - * Returns type parameters (if any), method name, and signature - * (value parameter types). - */ - public String toString() { - return sym.toString(); - } - - /** - * {@inheritDoc} - */ - public boolean isVarArgs() { - return AptEnv.hasFlag(sym, Flags.VARARGS); - } - - /** - * {@inheritDoc} - */ - public Collection getParameters() { - Collection res = - new ArrayList(); - for (VarSymbol param : sym.params()) - res.add(env.declMaker.getParameterDeclaration(param)); - return res; - } - - /** - * {@inheritDoc} - */ - public Collection getThrownTypes() { - ArrayList res = new ArrayList(); - for (Type t : sym.type.getThrownTypes()) { - res.add((ReferenceType) env.typeMaker.getType(t)); - } - return res; - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/FieldDeclarationImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/FieldDeclarationImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.Collection; -import java.util.ArrayList; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.TypeMirror; -import com.sun.mirror.util.DeclarationVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Symbol.*; -import com.sun.tools.javac.code.TypeTags; - - -/** - * Implementation of FieldDeclaration - */ -@SuppressWarnings("deprecation") -class FieldDeclarationImpl extends MemberDeclarationImpl - implements FieldDeclaration { - - protected VarSymbol sym; - - FieldDeclarationImpl(AptEnv env, VarSymbol sym) { - super(env, sym); - this.sym = sym; - } - - - /** - * Returns the field's name. - */ - public String toString() { - return getSimpleName(); - } - - /** - * {@inheritDoc} - */ - public TypeMirror getType() { - return env.typeMaker.getType(sym.type); - } - - /** - * {@inheritDoc} - */ - public Object getConstantValue() { - Object val = sym.getConstValue(); - // val may be null, indicating that this is not a constant. - - return Constants.decodeConstant(val, sym.type); - } - - /** - * {@inheritDoc} - */ - public String getConstantExpression() { - Object val = getConstantValue(); - if (val == null) { - return null; - } - Constants.Formatter fmtr = Constants.getFormatter(); - fmtr.append(val); - return fmtr.toString(); - } - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitFieldDeclaration(this); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/InterfaceDeclarationImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/InterfaceDeclarationImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.DeclarationVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Symbol.*; - - -/** - * Implementation of InterfaceDeclaration - */ -@SuppressWarnings("deprecation") -public class InterfaceDeclarationImpl extends TypeDeclarationImpl - implements InterfaceDeclaration { - - InterfaceDeclarationImpl(AptEnv env, ClassSymbol sym) { - super(env, sym); - } - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitInterfaceDeclaration(this); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/MemberDeclarationImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/MemberDeclarationImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.Collection; -import java.util.ArrayList; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.DeclarationVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Symbol; -import com.sun.tools.javac.code.Symbol.ClassSymbol; -import com.sun.tools.javac.code.Type; - - -/** - * Implementation of MemberDeclaration - */ -@SuppressWarnings("deprecation") -public abstract class MemberDeclarationImpl extends DeclarationImpl - implements MemberDeclaration { - - protected MemberDeclarationImpl(AptEnv env, Symbol sym) { - super(env, sym); - } - - - /** - * {@inheritDoc} - */ - public TypeDeclaration getDeclaringType() { - ClassSymbol c = getDeclaringClassSymbol(); - return (c == null) - ? null - : env.declMaker.getTypeDeclaration(c); - } - - /** - * {@inheritDoc} - * For methods, constructors, and types. - */ - public Collection getFormalTypeParameters() { - ArrayList res = - new ArrayList(); - for (Type t : sym.type.getTypeArguments()) { - res.add(env.declMaker.getTypeParameterDeclaration(t.tsym)); - } - return res; - } - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitMemberDeclaration(this); - } - - - /** - * Returns the ClassSymbol of the declaring type, - * or null if this is a top-level type. - */ - private ClassSymbol getDeclaringClassSymbol() { - return sym.owner.enclClass(); - } - - /** - * Returns the formal type parameters of a type, member or constructor - * as an angle-bracketed string. Each parameter consists of the simple - * type variable name and any bounds (with no implicit "extends Object" - * clause added). Type names are qualified. - * Returns "" if there are no type parameters. - */ - protected static String typeParamsToString(AptEnv env, Symbol sym) { - if (sym.type.getTypeArguments().isEmpty()) { - return ""; - } - StringBuilder s = new StringBuilder(); - for (Type t : sym.type.getTypeArguments()) { - Type.TypeVar tv = (Type.TypeVar) t; - s.append(s.length() == 0 ? "<" : ", ") - .append(TypeParameterDeclarationImpl.toString(env, tv)); - } - s.append(">"); - return s.toString(); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/MethodDeclarationImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/MethodDeclarationImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.DeclarationVisitor; -import com.sun.mirror.type.TypeMirror; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Symbol.MethodSymbol; - - -/** - * Implementation of MethodDeclaration - */ -@SuppressWarnings("deprecation") -public class MethodDeclarationImpl extends ExecutableDeclarationImpl - implements MethodDeclaration { - - MethodDeclarationImpl(AptEnv env, MethodSymbol sym) { - super(env, sym); - } - - - /** - * {@inheritDoc} - */ - public TypeMirror getReturnType() { - return env.typeMaker.getType(sym.type.getReturnType()); - } - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitMethodDeclaration(this); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/PackageDeclarationImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/PackageDeclarationImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.ArrayList; -import java.util.Collection; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.*; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.*; - - -/** - * Implementation of PackageDeclaration. - */ -@SuppressWarnings("deprecation") -public class PackageDeclarationImpl extends DeclarationImpl - implements PackageDeclaration { - - private PackageSymbol sym; - - - public PackageDeclarationImpl(AptEnv env, PackageSymbol sym) { - super(env, sym); - this.sym = sym; - } - - - /** - * Returns the qualified name. - */ - public String toString() { - return getQualifiedName(); - } - - /** - * {@inheritDoc} - */ - public String getQualifiedName() { - return sym.getQualifiedName().toString(); - } - - /** - * {@inheritDoc} - */ - public Collection getClasses() { - return identityFilter.filter(getAllTypes(), - ClassDeclaration.class); - } - - /** - * {@inheritDoc} - */ - public Collection getEnums() { - return identityFilter.filter(getAllTypes(), - EnumDeclaration.class); - } - - /** - * {@inheritDoc} - */ - public Collection getInterfaces() { - return identityFilter.filter(getAllTypes(), - InterfaceDeclaration.class); - } - - /** - * {@inheritDoc} - */ - public Collection getAnnotationTypes() { - return identityFilter.filter(getAllTypes(), - AnnotationTypeDeclaration.class); - } - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitPackageDeclaration(this); - } - - - // Cache of all top-level type declarations in this package. - private Collection allTypes = null; - - /** - * Caches and returns all top-level type declarations in this package. - * Omits synthetic types. - */ - private Collection getAllTypes() { - if (allTypes != null) { - return allTypes; - } - allTypes = new ArrayList(); - for (Symbol s : getMembers(false)) { - allTypes.add(env.declMaker.getTypeDeclaration((ClassSymbol) s)); - } - return allTypes; - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/ParameterDeclarationImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/ParameterDeclarationImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.Collection; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.TypeMirror; -import com.sun.mirror.util.DeclarationVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.VarSymbol; - - -/** - * Implementation of ParameterDeclaration - */ -@SuppressWarnings("deprecation") -public class ParameterDeclarationImpl extends DeclarationImpl - implements ParameterDeclaration -{ - protected VarSymbol sym; - - - ParameterDeclarationImpl(AptEnv env, VarSymbol sym) { - super(env, sym); - this.sym = sym; - } - - - /** - * Returns the simple name of the parameter. - */ - public String toString() { - return getType() + " " + sym.name; - } - - /** - * {@inheritDoc} - */ - public boolean equals(Object obj) { - // Neither ParameterDeclarationImpl objects nor their symbols - // are cached by the current implementation, so check symbol - // owners and names. - - if (obj instanceof ParameterDeclarationImpl) { - ParameterDeclarationImpl that = (ParameterDeclarationImpl) obj; - return sym.owner == that.sym.owner && - sym.name == that.sym.name && - env == that.env; - } else { - return false; - } - } - - /** - * {@inheritDoc} - */ - public int hashCode() { - return sym.owner.hashCode() + sym.name.hashCode() + env.hashCode(); - } - - /** - * {@inheritDoc} - */ - public TypeMirror getType() { - return env.typeMaker.getType(sym.type); - } - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitParameterDeclaration(this); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/TypeDeclarationImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/TypeDeclarationImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.Collection; -import java.util.ArrayList; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.DeclarationVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.*; -import com.sun.tools.javac.util.Name; - -/** - * Implementation of TypeDeclaration - */ -@SuppressWarnings("deprecation") -public class TypeDeclarationImpl extends MemberDeclarationImpl - implements TypeDeclaration { - - public ClassSymbol sym; - - - /** - * "sym" should be completed before this constructor is called. - */ - protected TypeDeclarationImpl(AptEnv env, ClassSymbol sym) { - super(env, sym); - this.sym = sym; - } - - - /** - * Returns the type's name, with any type parameters (including those - * of outer classes). Type names are qualified. - */ - public String toString() { - return toString(env, sym); - } - - /** - * {@inheritDoc} - */ - public PackageDeclaration getPackage() { - return env.declMaker.getPackageDeclaration(sym.packge()); - } - - /** - * {@inheritDoc} - */ - public String getQualifiedName() { - return sym.toString(); - } - - /** - * {@inheritDoc} - */ - public Collection getSuperinterfaces() { - return env.typeMaker.getTypes(env.jctypes.interfaces(sym.type), - InterfaceType.class); - } - - /** - * {@inheritDoc} - */ - public Collection getFields() { - ArrayList res = new ArrayList(); - for (Symbol s : getMembers(true)) { - if (s.kind == Kinds.VAR) { - res.add(env.declMaker.getFieldDeclaration((VarSymbol) s)); - } - } - return res; - } - - /** - * {@inheritDoc} - */ - public Collection getMethods() { - ArrayList res = new ArrayList(); - for (Symbol s : getMembers(true)) { - if (s.kind == Kinds.MTH && !s.isConstructor() && - !env.names.clinit.equals(s.name) ) { // screen out static initializers - MethodSymbol m = (MethodSymbol) s; - res.add((MethodDeclaration) - env.declMaker.getExecutableDeclaration(m)); - } - } - return res; - } - - /** - * {@inheritDoc} - */ - public Collection getNestedTypes() { - ArrayList res = new ArrayList(); - for (Symbol s : getMembers(true)) { - if (s.kind == Kinds.TYP) { - res.add(env.declMaker.getTypeDeclaration((ClassSymbol) s)); - } - } - return res; - } - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitTypeDeclaration(this); - } - - - /** - * Returns a type's name, with any type parameters (including those - * of outer classes). Type names are qualified. - */ - static String toString(AptEnv env, ClassSymbol c) { - StringBuilder sb = new StringBuilder(); - if (c.isInner()) { - // c is an inner class, so include type params of outer. - ClassSymbol enclosing = c.owner.enclClass(); - sb.append(toString(env, enclosing)) - .append('.') - .append(c.name); - } else { - sb.append(c); - } - sb.append(typeParamsToString(env, c)); - return sb.toString(); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/TypeParameterDeclarationImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/TypeParameterDeclarationImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.declaration; - - -import java.util.Collection; -import java.util.ArrayList; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.ReferenceType; -import com.sun.mirror.util.DeclarationVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.*; - - -/** - * Implementation of TypeParameterDeclaration - */ -@SuppressWarnings("deprecation") -public class TypeParameterDeclarationImpl extends DeclarationImpl - implements TypeParameterDeclaration -{ - protected TypeSymbol sym; - - - TypeParameterDeclarationImpl(AptEnv env, TypeSymbol sym) { - super(env, sym); - this.sym = sym; - } - - - /** - * Returns the type parameter's name along with any "extends" clause. - * Class names are qualified. No implicit "extends Object" is added. - */ - public String toString() { - return toString(env, (Type.TypeVar) sym.type); - } - - /** - * {@inheritDoc} - */ - public Collection getBounds() { - ArrayList res = new ArrayList(); - for (Type t : env.jctypes.getBounds((Type.TypeVar) sym.type)) { - res.add((ReferenceType) env.typeMaker.getType(t)); - } - return res; - } - - /** - * {@inheritDoc} - */ - public Declaration getOwner() { - Symbol owner = sym.owner; - return ((owner.kind & Kinds.TYP) != 0) - ? env.declMaker.getTypeDeclaration((ClassSymbol) owner) - : env.declMaker.getExecutableDeclaration((MethodSymbol) owner); - } - - - - /** - * {@inheritDoc} - */ - public void accept(DeclarationVisitor v) { - v.visitTypeParameterDeclaration(this); - } - - - /** - * Returns the type parameter's name along with any "extends" clause. - * See {@link #toString()} for details. - */ - static String toString(AptEnv env, Type.TypeVar tv) { - StringBuilder s = new StringBuilder(); - s.append(tv); - boolean first = true; - for (Type bound : getExtendsBounds(env, tv)) { - s.append(first ? " extends " : " & "); - s.append(env.typeMaker.typeToString(bound)); - first = false; - } - return s.toString(); - } - - /** - * Returns the bounds of a type variable, eliding java.lang.Object - * if it appears alone. - */ - private static Iterable getExtendsBounds(AptEnv env, - Type.TypeVar tv) { - return (tv.getUpperBound().tsym == env.symtab.objectType.tsym) - ? com.sun.tools.javac.util.List.nil() - : env.jctypes.getBounds(tv); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/type/AnnotationTypeImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/type/AnnotationTypeImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.type; - - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.TypeVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Type; - - -/** - * Implementation of AnnotationType - */ -@SuppressWarnings("deprecation") -public class AnnotationTypeImpl extends InterfaceTypeImpl - implements AnnotationType { - - AnnotationTypeImpl(AptEnv env, Type.ClassType type) { - super(env, type); - } - - - /** - * {@inheritDoc} - */ - public AnnotationTypeDeclaration getDeclaration() { - return (AnnotationTypeDeclaration) super.getDeclaration(); - } - - /** - * {@inheritDoc} - */ - public void accept(TypeVisitor v) { - v.visitAnnotationType(this); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/type/ArrayTypeImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/type/ArrayTypeImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.type; - - -import com.sun.mirror.type.*; -import com.sun.mirror.util.TypeVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Type; - - -/** - * Implementation of ArrayType - */ -@SuppressWarnings("deprecation") -public class ArrayTypeImpl extends TypeMirrorImpl implements ArrayType { - - protected Type.ArrayType type; - - - ArrayTypeImpl(AptEnv env, Type.ArrayType type) { - super(env, type); - this.type = type; - } - - - /** - * {@inheritDoc} - */ - public TypeMirror getComponentType() { - return env.typeMaker.getType(type.elemtype); - } - - /** - * {@inheritDoc} - */ - public void accept(TypeVisitor v) { - v.visitArrayType(this); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/type/ClassTypeImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/type/ClassTypeImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.type; - - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.TypeVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Type; - - -/** - * Implementation of ClassType - */ -@SuppressWarnings("deprecation") -public class ClassTypeImpl extends DeclaredTypeImpl implements ClassType { - - ClassTypeImpl(AptEnv env, Type.ClassType type) { - super(env, type); - } - - - /** - * {@inheritDoc} - */ - public ClassDeclaration getDeclaration() { - return (ClassDeclaration) super.getDeclaration(); - } - - /** - * {@inheritDoc} - */ - public ClassType getSuperclass() { - // java.lang.Object has no superclass - if (type.tsym == env.symtab.objectType.tsym) { - return null; - } - Type sup = env.jctypes.supertype(type); - return (ClassType) env.typeMaker.getType(sup); - } - - /** - * {@inheritDoc} - */ - public void accept(TypeVisitor v) { - v.visitClassType(this); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/type/DeclaredTypeImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/type/DeclaredTypeImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.type; - - -import java.util.Collection; - -import com.sun.mirror.declaration.TypeDeclaration; -import com.sun.mirror.type.*; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.ClassSymbol; - - -/** - * Implementation of DeclaredType - */ -@SuppressWarnings("deprecation") -abstract class DeclaredTypeImpl extends TypeMirrorImpl - implements DeclaredType { - - protected Type.ClassType type; - - - protected DeclaredTypeImpl(AptEnv env, Type.ClassType type) { - super(env, type); - this.type = type; - } - - - /** - * Returns a string representation of this declared type. - * This includes the type's name and any actual type arguments. - * Type names are qualified. - */ - public String toString() { - return toString(env, type); - } - - /** - * {@inheritDoc} - */ - public TypeDeclaration getDeclaration() { - return env.declMaker.getTypeDeclaration((ClassSymbol) type.tsym); - } - - /** - * {@inheritDoc} - */ - public DeclaredType getContainingType() { - if (type.getEnclosingType().tag == TypeTags.CLASS) { - // This is the type of an inner class. - return (DeclaredType) env.typeMaker.getType(type.getEnclosingType()); - } - ClassSymbol enclosing = type.tsym.owner.enclClass(); - if (enclosing != null) { - // Nested but not inner. Return the raw type of the enclosing - // class or interface. - // See java.lang.reflect.ParameterizedType.getOwnerType(). - return (DeclaredType) env.typeMaker.getType( - env.jctypes.erasure(enclosing.type)); - } - return null; - } - - /** - * {@inheritDoc} - */ - public Collection getActualTypeArguments() { - return env.typeMaker.getTypes(type.getTypeArguments()); - } - - /** - * {@inheritDoc} - */ - public Collection getSuperinterfaces() { - return env.typeMaker.getTypes(env.jctypes.interfaces(type), - InterfaceType.class); - } - - - /** - * Returns a string representation of this declared type. - * See {@link #toString()} for details. - */ - static String toString(AptEnv env, Type.ClassType c) { - return c.toString(); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/type/EnumTypeImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/type/EnumTypeImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.type; - - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.TypeVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Type; - - -/** - * Implementation of EnumType - */ -@SuppressWarnings("deprecation") -public class EnumTypeImpl extends ClassTypeImpl implements EnumType { - - EnumTypeImpl(AptEnv env, Type.ClassType type) { - super(env, type); - } - - - /** - * {@inheritDoc} - */ - public EnumDeclaration getDeclaration() { - return (EnumDeclaration) super.getDeclaration(); - } - - /** - * {@inheritDoc} - */ - public void accept(TypeVisitor v) { - v.visitEnumType(this); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/type/InterfaceTypeImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/type/InterfaceTypeImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.type; - - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.TypeVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Type; - - -/** - * Implementation of InterfaceType - */ -@SuppressWarnings("deprecation") -public class InterfaceTypeImpl extends DeclaredTypeImpl - implements InterfaceType { - - InterfaceTypeImpl(AptEnv env, Type.ClassType type) { - super(env, type); - } - - - /** - * {@inheritDoc} - */ - public InterfaceDeclaration getDeclaration() { - return (InterfaceDeclaration) super.getDeclaration(); - } - - /** - * {@inheritDoc} - */ - public void accept(TypeVisitor v) { - v.visitInterfaceType(this); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/type/PrimitiveTypeImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/type/PrimitiveTypeImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.type; - - - -import com.sun.mirror.type.PrimitiveType; -import com.sun.mirror.util.TypeVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Type; - -import static com.sun.mirror.type.PrimitiveType.Kind.*; - - -/** - * Implementation of PrimitiveType. - */ -@SuppressWarnings("deprecation") -class PrimitiveTypeImpl extends TypeMirrorImpl implements PrimitiveType { - - private final Kind kind; // the kind of primitive - - - PrimitiveTypeImpl(AptEnv env, Kind kind) { - super(env, getType(env, kind)); - this.kind = kind; - } - - - /** - * {@inheritDoc} - */ - public Kind getKind() { - return kind; - } - - /** - * {@inheritDoc} - */ - public void accept(TypeVisitor v) { - v.visitPrimitiveType(this); - } - - - /** - * Returns the javac type corresponding to a kind of primitive type. - */ - private static Type getType(AptEnv env, Kind kind) { - switch (kind) { - case BOOLEAN: return env.symtab.booleanType; - case BYTE: return env.symtab.byteType; - case SHORT: return env.symtab.shortType; - case INT: return env.symtab.intType; - case LONG: return env.symtab.longType; - case CHAR: return env.symtab.charType; - case FLOAT: return env.symtab.floatType; - case DOUBLE: return env.symtab.doubleType; - default: throw new AssertionError(); - } - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/type/TypeMaker.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/type/TypeMaker.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,160 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.type; - - -import java.util.Collection; -import java.util.ArrayList; - -import com.sun.mirror.type.*; -import com.sun.mirror.type.PrimitiveType.Kind; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.util.Context; - -import static com.sun.tools.javac.code.TypeTags.*; - - -/** - * Utilities for constructing type objects. - */ -@SuppressWarnings("deprecation") -public class TypeMaker { - - private final AptEnv env; - private final VoidType voidType; - private PrimitiveType[] primTypes = new PrimitiveType[VOID]; - // VOID is past all prim types - - - private static final Context.Key typeMakerKey = - new Context.Key(); - - public static TypeMaker instance(Context context) { - TypeMaker instance = context.get(typeMakerKey); - if (instance == null) { - instance = new TypeMaker(context); - } - return instance; - } - - private TypeMaker(Context context) { - context.put(typeMakerKey, this); - env = AptEnv.instance(context); - - voidType = new VoidTypeImpl(env); - primTypes[BOOLEAN] = new PrimitiveTypeImpl(env, Kind.BOOLEAN); - primTypes[BYTE] = new PrimitiveTypeImpl(env, Kind.BYTE); - primTypes[SHORT] = new PrimitiveTypeImpl(env, Kind.SHORT); - primTypes[INT] = new PrimitiveTypeImpl(env, Kind.INT); - primTypes[LONG] = new PrimitiveTypeImpl(env, Kind.LONG); - primTypes[CHAR] = new PrimitiveTypeImpl(env, Kind.CHAR); - primTypes[FLOAT] = new PrimitiveTypeImpl(env, Kind.FLOAT); - primTypes[DOUBLE] = new PrimitiveTypeImpl(env, Kind.DOUBLE); - } - - - /** - * Returns the TypeMirror corresponding to a javac Type object. - */ - public TypeMirror getType(Type t) { - if (t.isPrimitive()) { - return primTypes[t.tag]; - } - switch (t.tag) { - case ERROR: // fall through - case CLASS: return getDeclaredType((Type.ClassType) t); - case WILDCARD: return new WildcardTypeImpl(env, (Type.WildcardType) t); - case TYPEVAR: return new TypeVariableImpl(env, (Type.TypeVar) t); - case ARRAY: return new ArrayTypeImpl(env, (Type.ArrayType) t); - case VOID: return voidType; - default: throw new AssertionError(); - } - } - - /** - * Returns the declared type corresponding to a given ClassType. - */ - public DeclaredType getDeclaredType(Type.ClassType t) { - return - hasFlag(t.tsym, Flags.ANNOTATION) ? new AnnotationTypeImpl(env, t) : - hasFlag(t.tsym, Flags.INTERFACE) ? new InterfaceTypeImpl(env, t) : - hasFlag(t.tsym, Flags.ENUM) ? new EnumTypeImpl(env, t) : - new ClassTypeImpl(env, t); - } - - /** - * Returns a collection of types corresponding to a list of javac Type - * objects. - */ - public Collection getTypes(Iterable types) { - return getTypes(types, TypeMirror.class); - } - - /** - * Returns a collection of types corresponding to a list of javac Type - * objects. The element type of the result is specified explicitly. - */ - public Collection getTypes(Iterable types, - Class resType) { - ArrayList res = new ArrayList(); - for (Type t : types) { - TypeMirror mir = getType(t); - if (resType.isInstance(mir)) { - res.add(resType.cast(mir)); - } - } - return res; - } - - /** - * Returns the string representation of a type. - * Bounds of type variables are not included; bounds of wildcard types are. - * Type names are qualified. - */ - public String typeToString(Type t) { - switch (t.tag) { - case ARRAY: - return typeToString(env.jctypes.elemtype(t)) + "[]"; - case CLASS: - Type.ClassType c = (Type.ClassType) t; - return DeclaredTypeImpl.toString(env, c); - case WILDCARD: - Type.WildcardType a = (Type.WildcardType) t; - return WildcardTypeImpl.toString(env, a); - default: - return t.tsym.toString(); - } - } - - - /** - * Does a symbol have a given flag? - */ - private static boolean hasFlag(Symbol s, long flag) { - return AptEnv.hasFlag(s, flag); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/type/TypeMirrorImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/type/TypeMirrorImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.type; - - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.*; - - -/** - * Implementation of TypeMirror - */ -@SuppressWarnings("deprecation") -public abstract class TypeMirrorImpl implements TypeMirror { - - protected final AptEnv env; - public final Type type; - - - protected TypeMirrorImpl(AptEnv env, Type type) { - this.env = env; - this.type = type; - } - - - /** - * {@inheritDoc} - */ - public String toString() { - return type.toString(); - } - - /** - * {@inheritDoc} - */ - public boolean equals(Object obj) { - if (obj instanceof TypeMirrorImpl) { - TypeMirrorImpl that = (TypeMirrorImpl) obj; - return env.jctypes.isSameType(this.type, that.type); - } else { - return false; - } - } - - /** - * {@inheritDoc} - */ - public int hashCode() { - return Types.hashCode(type); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/type/TypeVariableImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/type/TypeVariableImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.type; - - -import java.util.Collection; -import java.util.ArrayList; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.TypeVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.Symbol.TypeSymbol; -import com.sun.tools.javac.code.Type; - - -/** - * Implementation of TypeVariable - */ -@SuppressWarnings("deprecation") -public class TypeVariableImpl extends TypeMirrorImpl implements TypeVariable { - - protected Type.TypeVar type; - - - TypeVariableImpl(AptEnv env, Type.TypeVar type) { - super(env, type); - this.type = type; - } - - - /** - * Returns the simple name of this type variable. Bounds are - * not included. - */ - public String toString() { - return type.tsym.name.toString(); - } - - /** - * {@inheritDoc} - */ - public TypeParameterDeclaration getDeclaration() { - TypeSymbol sym = type.tsym; - return env.declMaker.getTypeParameterDeclaration(sym); - } - - /** - * {@inheritDoc} - */ - public void accept(TypeVisitor v) { - v.visitTypeVariable(this); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/type/VoidTypeImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/type/VoidTypeImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.type; - - -import com.sun.mirror.type.VoidType; -import com.sun.mirror.util.TypeVisitor; -import com.sun.tools.apt.mirror.AptEnv; - - -/** - * Implementation of VoidType. - */ -@SuppressWarnings("deprecation") -class VoidTypeImpl extends TypeMirrorImpl implements VoidType { - - VoidTypeImpl(AptEnv env) { - super(env, env.symtab.voidType); - } - - /** - * {@inheritDoc} - */ - public void accept(TypeVisitor v) { - v.visitVoidType(this); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/type/WildcardTypeImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/type/WildcardTypeImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.type; - - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.TypeVisitor; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.*; - - -/** - * Implementation of WildcardType - */ -@SuppressWarnings("deprecation") -public class WildcardTypeImpl extends TypeMirrorImpl implements WildcardType { - - protected Type.WildcardType type; - - WildcardTypeImpl(AptEnv env, Type.WildcardType type) { - super(env, type); - this.type = type; - } - - - /** - * Returns the string form of a wildcard type, consisting of "?" - * and any "extends" or "super" clause. - * Delimiting brackets are not included. Class names are qualified. - */ - public String toString() { - return toString(env, type); - } - - /** - * {@inheritDoc} - */ - public Collection getUpperBounds() { - return type.isSuperBound() - ? Collections.emptyList() - : typeToCollection(type.type); - } - - /** - * {@inheritDoc} - */ - public Collection getLowerBounds() { - return type.isExtendsBound() - ? Collections.emptyList() - : typeToCollection(type.type); - } - - /** - * Gets the ReferenceType for a javac Type object, and returns - * it in a singleton collection. If type is null, returns an empty - * collection. - */ - private Collection typeToCollection(Type type) { - ArrayList res = new ArrayList(1); - if (type != null) { - res.add((ReferenceType) env.typeMaker.getType(type)); - } - return res; - } - - /** - * {@inheritDoc} - */ - public void accept(TypeVisitor v) { - v.visitWildcardType(this); - } - - - /** - * Returns the string form of a wildcard type, consisting of "?" - * and any "extends" or "super" clause. - * See {@link #toString()} for details. - */ - static String toString(AptEnv env, Type.WildcardType wildThing) { - return wildThing.toString(); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/util/DeclarationsImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/util/DeclarationsImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.util; - - -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.Declarations; -import com.sun.tools.apt.mirror.declaration.DeclarationImpl; -import com.sun.tools.apt.mirror.declaration.MethodDeclarationImpl; -import com.sun.tools.apt.mirror.util.DeclarationsImpl; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Symbol.*; -import com.sun.tools.javac.util.Context; - -import static com.sun.tools.javac.code.Kinds.*; - - -/** - * Implementation of Declarations utility methods for annotation processors - */ -@SuppressWarnings("deprecation") -public class DeclarationsImpl implements Declarations { - - private final AptEnv env; - - - private static final Context.Key declarationsKey = - new Context.Key(); - - public static Declarations instance(Context context) { - Declarations instance = context.get(declarationsKey); - if (instance == null) { - instance = new DeclarationsImpl(context); - } - return instance; - } - - private DeclarationsImpl(Context context) { - context.put(declarationsKey, this); - env = AptEnv.instance(context); - } - - - /** - * {@inheritDoc} - * See sections 8.3 and 8.4.6 of - * The Java™ Language Specification - */ - public boolean hides(MemberDeclaration sub, MemberDeclaration sup) { - Symbol hider = ((DeclarationImpl) sub).sym; - Symbol hidee = ((DeclarationImpl) sup).sym; - - // Fields only hide fields; methods only methods; types only types. - // Names must match. Nothing hides itself (just try it). - if (hider == hidee || - hider.kind != hidee.kind || - hider.name != hidee.name) { - return false; - } - - // Only static methods can hide other methods. - // Methods only hide methods with matching signatures. - if (hider.kind == MTH) { - if ((hider.flags() & Flags.STATIC) == 0 || - !env.jctypes.isSubSignature(hider.type, hidee.type)) { - return false; - } - } - - // Hider must be in a subclass of hidee's class. - // Note that if M1 hides M2, and M2 hides M3, and M3 is accessible - // in M1's class, then M1 and M2 both hide M3. - ClassSymbol hiderClass = hider.owner.enclClass(); - ClassSymbol hideeClass = hidee.owner.enclClass(); - if (hiderClass == null || hideeClass == null || - !hiderClass.isSubClass(hideeClass, env.jctypes)) { - return false; - } - - // Hidee must be accessible in hider's class. - // The method isInheritedIn is poorly named: it checks only access. - return hidee.isInheritedIn(hiderClass, env.jctypes); - } - - /** - * {@inheritDoc} - * See section 8.4.6.1 of - * The Java™ Language Specification - */ - public boolean overrides(MethodDeclaration sub, MethodDeclaration sup) { - MethodSymbol overrider = ((MethodDeclarationImpl) sub).sym; - MethodSymbol overridee = ((MethodDeclarationImpl) sup).sym; - ClassSymbol origin = (ClassSymbol) overrider.owner; - - return overrider.name == overridee.name && - - // not reflexive as per JLS - overrider != overridee && - - // we don't care if overridee is static, though that wouldn't - // compile - !overrider.isStatic() && - - // overrider, whose declaring type is the origin, must be - // in a subtype of overridee's type - env.jctypes.asSuper(origin.type, overridee.owner) != null && - - // check access and signatures; don't check return types - overrider.overrides(overridee, origin, env.jctypes, false); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/util/SourcePositionImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/util/SourcePositionImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.util; - - -import java.io.File; -import javax.tools.JavaFileObject; - -import com.sun.mirror.util.SourcePosition; -import com.sun.tools.javac.util.Position; - - -/** - * Implementation of SourcePosition - */ -@SuppressWarnings("deprecation") -public class SourcePositionImpl implements SourcePosition { - - private JavaFileObject sourcefile; - private int pos; // file position, in javac's internal format - private Position.LineMap linemap; - - - public SourcePositionImpl(JavaFileObject sourcefile, int pos, Position.LineMap linemap) { - this.sourcefile = sourcefile; - this.pos = pos; - this.linemap = linemap; - assert sourcefile != null; - assert linemap != null; - } - - public int getJavacPosition() { - return pos; - } - - public JavaFileObject getSource() { - return sourcefile; - } - - /** - * Returns a string representation of this position in the - * form "sourcefile:line", or "sourcefile" if no line number is available. - */ - public String toString() { - int ln = line(); - return (ln == Position.NOPOS) - ? sourcefile.getName() - : sourcefile.getName() + ":" + ln; - } - - /** - * {@inheritDoc} - */ - public File file() { - return new File(sourcefile.toUri()); - } - - /** - * {@inheritDoc} - */ - public int line() { - return linemap.getLineNumber(pos); - } - - /** - * {@inheritDoc} - */ - public int column() { - return linemap.getColumnNumber(pos); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/mirror/util/TypesImpl.java --- a/langtools/src/share/classes/com/sun/tools/apt/mirror/util/TypesImpl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,229 +0,0 @@ -/* - * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.mirror.util; - - -import java.util.Collection; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.Types; -import com.sun.tools.apt.mirror.AptEnv; -import com.sun.tools.apt.mirror.declaration.*; -import com.sun.tools.apt.mirror.type.TypeMirrorImpl; -import com.sun.tools.javac.code.BoundKind; -import com.sun.tools.javac.code.Type; -import com.sun.tools.javac.code.Symbol.ClassSymbol; -import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.ListBuffer; - - -/** - * Implementation of Types utility methods for annotation processors - */ -@SuppressWarnings("deprecation") -public class TypesImpl implements Types { - - private final AptEnv env; - - - private static final Context.Key typesKey = - new Context.Key(); - - public static Types instance(Context context) { - Types instance = context.get(typesKey); - if (instance == null) { - instance = new TypesImpl(context); - } - return instance; - } - - private TypesImpl(Context context) { - context.put(typesKey, this); - env = AptEnv.instance(context); - } - - - /** - * {@inheritDoc} - */ - public boolean isSubtype(TypeMirror t1, TypeMirror t2) { - return env.jctypes.isSubtype(((TypeMirrorImpl) t1).type, - ((TypeMirrorImpl) t2).type); - } - - /** - * {@inheritDoc} - */ - public boolean isAssignable(TypeMirror t1, TypeMirror t2) { - return env.jctypes.isAssignable(((TypeMirrorImpl) t1).type, - ((TypeMirrorImpl) t2).type); - } - - /** - * {@inheritDoc} - */ - public TypeMirror getErasure(TypeMirror t) { - return env.typeMaker.getType( - env.jctypes.erasure(((TypeMirrorImpl) t).type)); - } - - /** - * {@inheritDoc} - */ - public PrimitiveType getPrimitiveType(PrimitiveType.Kind kind) { - Type prim = null; - switch (kind) { - case BOOLEAN: prim = env.symtab.booleanType; break; - case BYTE: prim = env.symtab.byteType; break; - case SHORT: prim = env.symtab.shortType; break; - case INT: prim = env.symtab.intType; break; - case LONG: prim = env.symtab.longType; break; - case CHAR: prim = env.symtab.charType; break; - case FLOAT: prim = env.symtab.floatType; break; - case DOUBLE: prim = env.symtab.doubleType; break; - default: assert false; - } - return (PrimitiveType) env.typeMaker.getType(prim); - } - - /** - * {@inheritDoc} - */ - public VoidType getVoidType() { - return (VoidType) env.typeMaker.getType(env.symtab.voidType); - } - - /** - * {@inheritDoc} - */ - public ArrayType getArrayType(TypeMirror componentType) { - if (componentType instanceof VoidType) { - throw new IllegalArgumentException("void"); - } - return (ArrayType) env.typeMaker.getType( - new Type.ArrayType(((TypeMirrorImpl) componentType).type, - env.symtab.arrayClass)); - } - - /** - * {@inheritDoc} - */ - public TypeVariable getTypeVariable(TypeParameterDeclaration tparam) { - return (TypeVariable) env.typeMaker.getType( - ((DeclarationImpl) tparam).sym.type); - } - - /** - * {@inheritDoc} - */ - public WildcardType getWildcardType(Collection upperBounds, - Collection lowerBounds) { - BoundKind kind; - Type bound; - int uppers = upperBounds.size(); - int downers = lowerBounds.size(); - - if (uppers + downers > 1) { - throw new IllegalArgumentException("Multiple bounds not allowed"); - - } else if (uppers + downers == 0) { - kind = BoundKind.UNBOUND; - bound = env.symtab.objectType; - - } else if (uppers == 1) { - assert downers == 0; - kind = BoundKind.EXTENDS; - bound = ((TypeMirrorImpl) upperBounds.iterator().next()).type; - - } else { - assert uppers == 0 && downers == 1; - kind = BoundKind.SUPER; - bound = ((TypeMirrorImpl) lowerBounds.iterator().next()).type; - } - - if (bound instanceof Type.WildcardType) - throw new IllegalArgumentException(bound.toString()); - - return (WildcardType) env.typeMaker.getType( - new Type.WildcardType(bound, kind, env.symtab.boundClass)); - } - - /** - * {@inheritDoc} - */ - public DeclaredType getDeclaredType(TypeDeclaration decl, - TypeMirror... typeArgs) { - ClassSymbol sym = ((TypeDeclarationImpl) decl).sym; - - if (typeArgs.length == 0) - return (DeclaredType) env.typeMaker.getType( - env.jctypes.erasure(sym.type)); - if (sym.type.getEnclosingType().isParameterized()) - throw new IllegalArgumentException(decl.toString()); - - return getDeclaredType(sym.type.getEnclosingType(), sym, typeArgs); - } - - /** - * {@inheritDoc} - */ - public DeclaredType getDeclaredType(DeclaredType containing, - TypeDeclaration decl, - TypeMirror... typeArgs) { - if (containing == null) - return getDeclaredType(decl, typeArgs); - - ClassSymbol sym = ((TypeDeclarationImpl) decl).sym; - Type outer = ((TypeMirrorImpl) containing).type; - - if (outer.tsym != sym.owner.enclClass()) - throw new IllegalArgumentException(containing.toString()); - if (!outer.isParameterized()) - return getDeclaredType(decl, typeArgs); - - return getDeclaredType(outer, sym, typeArgs); - } - - private DeclaredType getDeclaredType(Type outer, - ClassSymbol sym, - TypeMirror... typeArgs) { - if (typeArgs.length != sym.type.getTypeArguments().length()) - throw new IllegalArgumentException( - "Incorrect number of type arguments"); - - ListBuffer targs = new ListBuffer(); - for (TypeMirror t : typeArgs) { - if (!(t instanceof ReferenceType || t instanceof WildcardType)) - throw new IllegalArgumentException(t.toString()); - targs.append(((TypeMirrorImpl) t).type); - } - //### Need a way to check that type args match formals. - - return (DeclaredType) env.typeMaker.getType( - new Type.ClassType(outer, targs.toList(), sym)); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/resources/apt.properties --- a/langtools/src/share/classes/com/sun/tools/apt/resources/apt.properties Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,184 +0,0 @@ -# -# Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -apt.msg.usage.header=\ -Usage: {0} \n\ -where apt options include: - -apt.msg.usage.footer=\ -See javac -help for information on javac options. - -apt.msg.usage.nonstandard.footer=\ -These options are non-standard and subject to change without notice, \nas is the format of their output. - -apt.msg.bug=\ -An exception has occurred in apt ({0}). \ -Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) \ -after checking the Bug Parade for duplicates. \ -Include your program and the following diagnostic in your report. Thank you. - -## apt options - -apt.opt.A=\ - Options to pass to annotation processors -apt.opt.arg.class=\ - -apt.opt.arg.directory=\ - Specify where to place processor and javac generated class files -apt.opt.classpath=\ - Specify where to find user class files and annotation processor factories -apt.opt.d=\ - Specify where to place processor and javac generated class files -apt.opt.factory=\ - Name of AnnotationProcessorFactory to use; bypasses default discovery process -apt.opt.factorypath=\ - Specify where to find annotation processor factories -apt.opt.s=\ - Specify where to place processor generated source files -apt.opt.help=\ - Print a synopsis of standard options; use javac -help for more options -apt.opt.print=\ - Print out textual representation of specified types -apt.opt.nocompile=\ - Do not compile source files to class files -apt.opt.proc.flag=\ - [key[=value]] -apt.opt.version=\ - Version information -apt.opt.XListAnnotationTypes=\ - List found annotation types -apt.opt.XListDeclarations=\ - List specified and included declarations -apt.opt.XPrintAptRounds=\ - Print information about initial and recursive apt rounds -apt.opt.XPrintFactoryInfo=\ - Print information about which annotations a factory is asked to process -apt.opt.XClassesAsDecls=\ - Treat both class and source files as declarations to process - -## -## errors -## - -## All errors which do not refer to a particular line in the source code are -## preceded by this string. - -apt.err.error=\ - error:\u0020 - -apt.err.unsupported.source.version=\ - Source release {0} is not supported; use release 5 or earlier - -apt.err.unsupported.target.version=\ - Target release {0} is not supported; use release 5 or earlier - -apt.err.BadDeclaration=\ - Bad declaration created for annotation type {0} - -apt.err.CantFindClass=\ - Could not find class file for {0} - -apt.err.DeclarationCreation=\ - Could not create declaration for annotation type {0} - -# Print an error from the Messager -apt.err.Messager=\ - {0} - -## -## miscellaneous strings -## - -apt.misc.Deprecation=\ - \nwarning:\u0020The apt tool and its associated API are planned to be\n\ - removed in the next major JDK release. These features have been\n\ - superseded by javac and the standardized annotation processing API,\n\ - javax.annotation.processing and javax.lang.model. Users are\n\ - recommended to migrate to the annotation processing features of\n\ - javac; see the javac man page for more information.\n - -apt.misc.Problem=\ - Problem encountered during annotation processing; \nsee stacktrace below for more information. - -apt.misc.SunMiscService=\ - Error finding annotation processor factories; \ncheck META-INF/services information. - -# Print a notice from the Messager -apt.note.Messager=\ - {0} - -## -## warnings -## - -## All warning messages are preceded by the following string. -apt.warn.warning=\ - warning:\u0020 - -apt.warn.AnnotationsWithoutProcessors=\ - Annotation types without processors: {0} - -apt.warn.BadFactory=\ - Bad annotation processor factory: {0} - -apt.warn.BadParentDirectory=\ - Failed to create some parent directory of {0} - -apt.warn.FactoryCantInstantiate=\ - Could not instantiate an instance of factory ''{0}''. - -apt.warn.FactoryWrongType=\ - Specified factory, ''{0}'', is not an AnnotationProcessorFactory. - -apt.warn.FactoryNotFound=\ - Specified AnnotationProcessorFactory, ''{0}'', not found on search path. - -apt.warn.FileReopening=\ - Attempt to create ''{0}'' multiple times - -apt.warn.IllegalFileName=\ - Cannot create file for illegal name ''{0}''. - -apt.warn.MalformedSupportedString=\ - Malformed string for annotation support, ''{0}'', returned by factory. - -apt.warn.NoNewFilesAfterRound=\ - Cannot create file ''{0}'' after a round has ended. - -# Print a warning from the Messager -apt.warn.Messager=\ - {0} - -apt.warn.NoAnnotationProcessors=\ - No annotation processors found but annotations present. - -apt.warn.NullProcessor=\ - Factory {0} returned null for an annotation processor. - -apt.warn.CorrespondingClassFile=\ - A class file corresponding to source file ''{0}'' has already been created. - -apt.warn.CorrespondingSourceFile=\ - A source file corresponding to class file ''{0}'' has already been created. diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/resources/apt_ja.properties --- a/langtools/src/share/classes/com/sun/tools/apt/resources/apt_ja.properties Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -# -# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -apt.msg.usage.header=\u4F7F\u7528\u65B9\u6CD5: {0} \n\u6B21\u306Eapt\u30AA\u30D7\u30B7\u30E7\u30F3\u304C\u3042\u308A\u307E\u3059: - -apt.msg.usage.footer=javac\u30AA\u30D7\u30B7\u30E7\u30F3\u306B\u3064\u3044\u3066\u306F\u3001javac -help\u3092\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\u3002 - -apt.msg.usage.nonstandard.footer=\u3053\u308C\u3089\u306F\u975E\u6A19\u6E96\u30AA\u30D7\u30B7\u30E7\u30F3\u3067\u3042\u308A\u3001\u8868\u793A\u5F62\u5F0F\u4E88\u544A\u306A\u3057\u306B\u5909\u66F4\u3055\u308C\u308B\n\u3053\u3068\u304C\u3042\u308A\u307E\u3059\u3002 - -apt.msg.bug=\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u3067\u4F8B\u5916\u304C\u767A\u751F\u3057\u307E\u3057\u305F({0})\u3002Bug Parade\u306B\u540C\u3058\u30D0\u30B0\u304C\u767B\u9332\u3055\u308C\u3066\u3044\u306A\u3044\u3053\u3068\u3092\u3054\u78BA\u8A8D\u306E\u4E0A\u3001Java Developer Connection(http://java.sun.com/webapps/bugreport)\u3067\u30D0\u30B0\u306E\u767B\u9332\u3092\u304A\u9858\u3044\u3044\u305F\u3057\u307E\u3059\u3002\u30EC\u30DD\u30FC\u30C8\u306B\u306F\u3001\u305D\u306E\u30D7\u30ED\u30B0\u30E9\u30E0\u3068\u4E0B\u8A18\u306E\u8A3A\u65AD\u5185\u5BB9\u3092\u542B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u3054\u5354\u529B\u3042\u308A\u304C\u3068\u3046\u3054\u3056\u3044\u307E\u3059\u3002 - -## apt options - -apt.opt.A=\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u306B\u6E21\u3055\u308C\u308B\u30AA\u30D7\u30B7\u30E7\u30F3 -apt.opt.arg.class= -apt.opt.arg.directory=\u30D7\u30ED\u30BB\u30C3\u30B5\u304A\u3088\u3073javac\u304C\u751F\u6210\u3057\u305F\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u7F6E\u304F\u4F4D\u7F6E\u3092\u6307\u5B9A\u3059\u308B -apt.opt.classpath=\u30E6\u30FC\u30B6\u30FC\u30FB\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u304A\u3088\u3073\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u30FB\u30D5\u30A1\u30AF\u30C8\u30EA\u3092\u691C\u7D22\u3059\u308B\u4F4D\u7F6E\u3092\u6307\u5B9A\u3059\u308B -apt.opt.d=\u30D7\u30ED\u30BB\u30C3\u30B5\u304A\u3088\u3073javac\u304C\u751F\u6210\u3057\u305F\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u7F6E\u304F\u4F4D\u7F6E\u3092\u6307\u5B9A\u3059\u308B -apt.opt.factory=\u4F7F\u7528\u3059\u308BAnnotationProcessorFactory\u306E\u540D\u524D\u3002\u30C7\u30D5\u30A9\u30EB\u30C8\u306E\u691C\u51FA\u51E6\u7406\u3092\u30D0\u30A4\u30D1\u30B9 -apt.opt.factorypath=\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u30FB\u30D5\u30A1\u30AF\u30C8\u30EA\u306E\u691C\u7D22\u5834\u6240\u3092\u6307\u5B9A\u3059\u308B -apt.opt.s=\u30D7\u30ED\u30BB\u30C3\u30B5\u304C\u751F\u6210\u3057\u305F\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u7F6E\u304F\u4F4D\u7F6E\u3092\u6307\u5B9A\u3059\u308B -apt.opt.help=\u6A19\u6E96\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u6982\u8981\u3092\u51FA\u529B\u3059\u308B\u3002\u8A73\u7D30\u30AA\u30D7\u30B7\u30E7\u30F3\u306B\u3064\u3044\u3066\u306Fjavac -help\u3092\u53C2\u7167 -apt.opt.print=\u6307\u5B9A\u3057\u305F\u578B\u306E\u30C6\u30AD\u30B9\u30C8\u8868\u793A\u3092\u51FA\u529B\u3059\u308B -apt.opt.nocompile=\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306B\u30B3\u30F3\u30D1\u30A4\u30EB\u3057\u306A\u3044 -apt.opt.proc.flag=[key[=value]] -apt.opt.version=\u30D0\u30FC\u30B8\u30E7\u30F3\u60C5\u5831 -apt.opt.XListAnnotationTypes=\u898B\u3064\u304B\u3063\u305F\u6CE8\u91C8\u578B\u3092\u30EA\u30B9\u30C8\u3059\u308B -apt.opt.XListDeclarations=\u6307\u5B9A\u3055\u308C\u305F\u5BA3\u8A00\u304A\u3088\u3073\u30A4\u30F3\u30AF\u30EB\u30FC\u30C9\u3055\u308C\u305F\u5BA3\u8A00\u3092\u30EA\u30B9\u30C8\u3059\u308B -apt.opt.XPrintAptRounds=\u521D\u671F\u304A\u3088\u3073\u518D\u5E30apt\u5F80\u5FA9\u306B\u3064\u3044\u3066\u306E\u60C5\u5831\u3092\u5370\u5237\u3059\u308B -apt.opt.XPrintFactoryInfo=\u30D5\u30A1\u30AF\u30C8\u30EA\u304C\u51E6\u7406\u3092\u4F9D\u983C\u3055\u308C\u308B\u6CE8\u91C8\u306B\u3064\u3044\u3066\u306E\u60C5\u5831\u3092\u5370\u5237\u3059\u308B -apt.opt.XClassesAsDecls=\u30AF\u30E9\u30B9\u3068\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u4E21\u65B9\u3068\u3082\u51E6\u7406\u3059\u308B\u5BA3\u8A00\u3068\u3057\u3066\u51E6\u7406 - -## -## errors -## - -## All errors which do not refer to a particular line in the source code are -## preceded by this string. - -apt.err.error=\u30A8\u30E9\u30FC:\u0020 - -apt.err.unsupported.source.version=\u30BD\u30FC\u30B9\u30FB\u30EA\u30EA\u30FC\u30B9{0}\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002\u30EA\u30EA\u30FC\u30B95\u4EE5\u524D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044 - -apt.err.unsupported.target.version=\u30BF\u30FC\u30B2\u30C3\u30C8\u30FB\u30EA\u30EA\u30FC\u30B9{0}\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002\u30EA\u30EA\u30FC\u30B95\u4EE5\u524D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044 - -apt.err.BadDeclaration=\u6CE8\u91C8\u578B{0}\u7528\u306B\u4F5C\u6210\u3055\u308C\u305F\u7121\u52B9\u306A\u5BA3\u8A00\u3067\u3059 - -apt.err.CantFindClass={0}\u306E\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093 - -apt.err.DeclarationCreation=\u6CE8\u91C8\u578B{0}\u7528\u306B\u5BA3\u8A00\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F - -# Print an error from the Messager -apt.err.Messager={0} - -## -## miscellaneous strings -## - -apt.misc.Deprecation=\n\u8B66\u544A: apt\u30C4\u30FC\u30EB\u3068\u30C4\u30FC\u30EB\u306B\u95A2\u9023\u4ED8\u3051\u3089\u308C\u305FAPI\u306F\u3001\u6B21\u56DE\u306EJDK\n\u30E1\u30B8\u30E3\u30FC\u30FB\u30EA\u30EA\u30FC\u30B9\u3067\u524A\u9664\u3055\u308C\u308B\u4E88\u5B9A\u3067\u3059\u3002\u3053\u308C\u3089\u306E\u6A5F\u80FD\u306Fjavac\u304A\u3088\u3073\n\u6A19\u6E96\u5316\u3055\u308C\u305F\u6CE8\u91C8\u51E6\u7406API\u306Ejavax.annotation.processing\u304A\u3088\u3073javax.lang.model\n\u306B\u3088\u3063\u3066\u7F6E\u304D\u63DB\u3048\u3089\u308C\u307E\u3057\u305F\u3002\u30E6\u30FC\u30B6\u30FC\u306Fjavac\u306E\u6CE8\u91C8\u51E6\u7406\u6A5F\u80FD\u306B\n\u79FB\u884C\u3059\u308B\u3053\u3068\u3092\u304A\u85A6\u3081\u3057\u307E\u3059\u3002\n\u8A73\u7D30\u306F\u3001javac man\u30DA\u30FC\u30B8\u3092\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n - -apt.misc.Problem=\u6CE8\u91C8\u51E6\u7406\u4E2D\u306B\u554F\u984C\u304C\u691C\u51FA\u3055\u308C\u307E\u3057\u305F\u3002\n\u8A73\u7D30\u306F\u3001\u4E0B\u8A18\u306E\u30B9\u30BF\u30C3\u30AF\u30FB\u30C8\u30EC\u30FC\u30B9\u3092\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\u3002 - -apt.misc.SunMiscService=\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u30FB\u30D5\u30A1\u30AF\u30C8\u30EA\u306E\u691C\u7D22\u30A8\u30E9\u30FC\u3067\u3059\u3002\nMETA-INF/services\u5185\u306E\u60C5\u5831\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002 - -# Print a notice from the Messager -apt.note.Messager={0} - -## -## warnings -## - -## All warning messages are preceded by the following string. -apt.warn.warning=\u8B66\u544A: - -apt.warn.AnnotationsWithoutProcessors=\u30D7\u30ED\u30BB\u30C3\u30B5\u306A\u3057\u306E\u6CE8\u91C8\u578B\u3067\u3059: {0} - -apt.warn.BadFactory=\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u30FB\u30D5\u30A1\u30AF\u30C8\u30EA\u304C\u7121\u52B9\u3067\u3059: {0} - -apt.warn.BadParentDirectory={0}\u306E\u3044\u304F\u3064\u304B\u306E\u89AA\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E\u4F5C\u6210\u306B\u5931\u6557\u3057\u307E\u3057\u305F - -apt.warn.FactoryCantInstantiate=\u30D5\u30A1\u30AF\u30C8\u30EA''{0}''\u306E\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u3092\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u5316\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002 - -apt.warn.FactoryWrongType=\u6307\u5B9A\u3057\u305F\u30D5\u30A1\u30AF\u30C8\u30EA''{0}''\u306FAnnotationProcessorFactory\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002 - -apt.warn.FactoryNotFound=\u6307\u5B9A\u3057\u305FAnnotationProcessorFactory ''{0}''\u306F\u691C\u7D22\u30D1\u30B9\u3067\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u3002 - -apt.warn.FileReopening=''{0}''\u3092\u8907\u6570\u56DE\u4F5C\u6210\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u307E\u3059 - -apt.warn.IllegalFileName=\u7121\u52B9\u306A\u540D\u524D''{0}''\u306E\u30D5\u30A1\u30A4\u30EB\u306F\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093\u3002 - -apt.warn.MalformedSupportedString=\u30D5\u30A1\u30AF\u30C8\u30EA\u304C\u8FD4\u3057\u305F\u6CE8\u91C8\u30B5\u30DD\u30FC\u30C8''{0}''\u306E\u6587\u5B57\u5217\u304C\u4E0D\u6B63\u3067\u3059\u3002 - -apt.warn.NoNewFilesAfterRound=\u5F80\u5FA9\u306E\u7D42\u4E86\u5F8C\u306B\u30D5\u30A1\u30A4\u30EB''{0}''\u3092\u4F5C\u6210\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002 - -# Print a warning from the Messager -apt.warn.Messager={0} - -apt.warn.NoAnnotationProcessors=\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u306F\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u304C\u3001\u6CE8\u91C8\u306F\u5B58\u5728\u3057\u307E\u3059\u3002 - -apt.warn.NullProcessor=\u30D5\u30A1\u30AF\u30C8\u30EA{0}\u304C\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u306Bnull\u3092\u8FD4\u3057\u307E\u3057\u305F\u3002 - -apt.warn.CorrespondingClassFile=\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB''{0}''\u306B\u5BFE\u5FDC\u3059\u308B\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306F\u3059\u3067\u306B\u4F5C\u6210\u3055\u308C\u3066\u3044\u307E\u3059\u3002 - -apt.warn.CorrespondingSourceFile=\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB''{0}''\u306B\u5BFE\u5FDC\u3059\u308B\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306F\u3059\u3067\u306B\u4F5C\u6210\u3055\u308C\u3066\u3044\u307E\u3059\u3002 diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/resources/apt_zh_CN.properties --- a/langtools/src/share/classes/com/sun/tools/apt/resources/apt_zh_CN.properties Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -# -# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -apt.msg.usage.header=\u7528\u6CD5: {0} \n\u5176\u4E2D, apt \u9009\u9879\u5305\u62EC: - -apt.msg.usage.footer=\u6709\u5173 javac \u9009\u9879\u7684\u4FE1\u606F, \u8BF7\u53C2\u9605 javac -help\u3002 - -apt.msg.usage.nonstandard.footer=\u8FD9\u4E9B\u9009\u9879\u53CA\u5176\u8F93\u51FA\u683C\u5F0F\u90FD\u4E0D\u662F\u6807\u51C6\u7684, \n\u5982\u6709\u66F4\u6539, \u6055\u4E0D\u53E6\u884C\u901A\u77E5\u3002 - -apt.msg.bug=apt ({0}) \u4E2D\u51FA\u73B0\u5F02\u5E38\u9519\u8BEF\u3002 \u5982\u679C\u5728 Bug Parade \u4E2D\u6CA1\u6709\u627E\u5230\u8BE5\u9519\u8BEF, \u8BF7\u5728 Java Developer Connection (http://java.sun.com/webapps/bugreport) \u4E2D\u5EFA\u7ACB Bug\u3002\u8BF7\u5728\u62A5\u544A\u4E2D\u9644\u4E0A\u60A8\u7684\u7A0B\u5E8F\u548C\u4EE5\u4E0B\u8BCA\u65AD\u4FE1\u606F\u3002\u8C22\u8C22\u3002 - -## apt options - -apt.opt.A=\u4F20\u9012\u7ED9\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F\u7684\u9009\u9879 -apt.opt.arg.class=<\u7C7B> -apt.opt.arg.directory=\u6307\u5B9A\u653E\u7F6E\u5904\u7406\u7A0B\u5E8F\u548C javac \u751F\u6210\u7684\u7C7B\u6587\u4EF6\u7684\u4F4D\u7F6E -apt.opt.classpath=\u6307\u5B9A\u67E5\u627E\u7528\u6237\u7C7B\u6587\u4EF6\u548C\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F\u5DE5\u5382\u7684\u4F4D\u7F6E -apt.opt.d=\u6307\u5B9A\u653E\u7F6E\u5904\u7406\u7A0B\u5E8F\u548C javac \u751F\u6210\u7684\u7C7B\u6587\u4EF6\u7684\u4F4D\u7F6E -apt.opt.factory=\u8981\u4F7F\u7528\u7684 AnnotationProcessorFactory \u7684\u540D\u79F0; \u7ED5\u8FC7\u9ED8\u8BA4\u7684\u641C\u7D22\u8FDB\u7A0B -apt.opt.factorypath=\u6307\u5B9A\u67E5\u627E\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F\u5DE5\u5382\u7684\u4F4D\u7F6E -apt.opt.s=\u6307\u5B9A\u653E\u7F6E\u5904\u7406\u7A0B\u5E8F\u751F\u6210\u7684\u6E90\u6587\u4EF6\u7684\u4F4D\u7F6E -apt.opt.help=\u8F93\u51FA\u6807\u51C6\u9009\u9879\u7684\u63D0\u8981; \u4F7F\u7528 javac -help \u53EF\u4EE5\u5F97\u5230\u66F4\u591A\u9009\u9879 -apt.opt.print=\u8F93\u51FA\u6307\u5B9A\u7C7B\u578B\u7684\u6587\u672C\u8868\u793A -apt.opt.nocompile=\u8BF7\u52FF\u5C06\u6E90\u6587\u4EF6\u7F16\u8BD1\u4E3A\u7C7B\u6587\u4EF6 -apt.opt.proc.flag=[\u5173\u952E\u5B57[=\u503C]] -apt.opt.version=\u7248\u672C\u4FE1\u606F -apt.opt.XListAnnotationTypes=\u5217\u51FA\u627E\u5230\u7684\u6CE8\u91CA\u7C7B\u578B -apt.opt.XListDeclarations=\u5217\u51FA\u6307\u5B9A\u548C\u5305\u542B\u7684\u58F0\u660E -apt.opt.XPrintAptRounds=\u8F93\u51FA\u6709\u5173\u521D\u59CB\u548C\u9012\u5F52 apt \u5FAA\u73AF\u7684\u4FE1\u606F -apt.opt.XPrintFactoryInfo=\u8F93\u51FA\u6709\u5173\u8BF7\u6C42\u5DE5\u5382\u5904\u7406\u54EA\u4E9B\u6CE8\u91CA\u7684\u4FE1\u606F -apt.opt.XClassesAsDecls=\u5C06\u7C7B\u6587\u4EF6\u548C\u6E90\u6587\u4EF6\u90FD\u89C6\u4E3A\u8981\u5904\u7406\u7684\u58F0\u660E - -## -## errors -## - -## All errors which do not refer to a particular line in the source code are -## preceded by this string. - -apt.err.error=\u9519\u8BEF:\u0020 - -apt.err.unsupported.source.version=\u4E0D\u652F\u6301\u6E90\u53D1\u884C\u7248 {0}; \u8BF7\u4F7F\u7528\u53D1\u884C\u7248 5 \u6216\u65E9\u671F\u53D1\u884C\u7248 - -apt.err.unsupported.target.version=\u4E0D\u652F\u6301\u76EE\u6807\u53D1\u884C\u7248 {0}; \u8BF7\u4F7F\u7528\u53D1\u884C\u7248 5 \u6216\u65E9\u671F\u53D1\u884C\u7248 - -apt.err.BadDeclaration=\u4E3A\u6CE8\u91CA\u7C7B\u578B{0}\u521B\u5EFA\u7684\u58F0\u660E\u51FA\u73B0\u9519\u8BEF - -apt.err.CantFindClass=\u627E\u4E0D\u5230{0}\u7684\u7C7B\u6587\u4EF6 - -apt.err.DeclarationCreation=\u65E0\u6CD5\u4E3A\u6CE8\u91CA\u7C7B\u578B{0}\u521B\u5EFA\u58F0\u660E - -# Print an error from the Messager -apt.err.Messager={0} - -## -## miscellaneous strings -## - -apt.misc.Deprecation=\n\u8B66\u544A:\u0020\u5DF2\u8BA1\u5212\u5728\u4E0B\u4E00\u4E2A JDK \u4E3B\u53D1\u884C\u7248\u4E2D\n\u5220\u9664 apt \u5DE5\u5177\u53CA\u5176\u5173\u8054\u7684 API\u3002\u8FD9\u4E9B\u529F\u80FD\n\u5DF2\u88AB javac \u548C\u6807\u51C6\u6CE8\u91CA\u5904\u7406 API,\njavax.annotation.processing \u548C javax.lang.model \u53D6\u4EE3\u3002\u5EFA\u8BAE\u7528\u6237\n\u79FB\u690D\u5230 javac \u7684\u6CE8\u91CA\u5904\u7406\u529F\u80FD;\n\u6709\u5173\u8BE6\u7EC6\u4FE1\u606F, \u8BF7\u53C2\u9605 javac \u5E2E\u52A9\u9875\u3002\n - -apt.misc.Problem=\u6CE8\u91CA\u5904\u7406\u8FC7\u7A0B\u4E2D\u9047\u5230\u95EE\u9898; \n\u6709\u5173\u8BE6\u7EC6\u4FE1\u606F, \u8BF7\u53C2\u9605\u4E0B\u9762\u7684\u5806\u6808\u8DDF\u8E2A\u3002 - -apt.misc.SunMiscService=\u67E5\u627E\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F\u5DE5\u5382\u65F6\u51FA\u9519; \n\u8BF7\u67E5\u770B META-INF/\u670D\u52A1\u4FE1\u606F\u3002 - -# Print a notice from the Messager -apt.note.Messager={0} - -## -## warnings -## - -## All warning messages are preceded by the following string. -apt.warn.warning=\u8B66\u544A:\u0020 - -apt.warn.AnnotationsWithoutProcessors=\u4E0D\u5E26\u5904\u7406\u7A0B\u5E8F\u7684\u6CE8\u91CA\u7C7B\u578B: {0} - -apt.warn.BadFactory=\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F\u5DE5\u5382\u51FA\u73B0\u9519\u8BEF: {0} - -apt.warn.BadParentDirectory=\u65E0\u6CD5\u521B\u5EFA{0}\u7684\u67D0\u4E9B\u7236\u76EE\u5F55 - -apt.warn.FactoryCantInstantiate=\u65E0\u6CD5\u5B9E\u4F8B\u5316\u5DE5\u5382 ''{0}'' \u7684\u5B9E\u4F8B\u3002 - -apt.warn.FactoryWrongType=\u6307\u5B9A\u7684\u5DE5\u5382 ''{0}'' \u4E0D\u662F AnnotationProcessorFactory\u3002 - -apt.warn.FactoryNotFound=\u5728\u641C\u7D22\u8DEF\u5F84\u4E2D\u627E\u4E0D\u5230\u6307\u5B9A\u7684 AnnotationProcessorFactory ''{0}''\u3002 - -apt.warn.FileReopening=\u5C1D\u8BD5\u591A\u6B21\u521B\u5EFA ''{0}'' - -apt.warn.IllegalFileName=\u65E0\u6CD5\u521B\u5EFA\u5E26\u6709\u975E\u6CD5\u540D\u79F0 ''{0}'' \u7684\u6587\u4EF6\u3002 - -apt.warn.MalformedSupportedString=\u5DE5\u5382\u8FD4\u56DE\u683C\u5F0F\u9519\u8BEF\u7684\u6CE8\u91CA\u652F\u6301\u5B57\u7B26\u4E32 ''{0}''\u3002 - -apt.warn.NoNewFilesAfterRound=\u5FAA\u73AF\u7ED3\u675F\u540E\u65E0\u6CD5\u521B\u5EFA\u6587\u4EF6 ''{0}''\u3002 - -# Print a warning from the Messager -apt.warn.Messager={0} - -apt.warn.NoAnnotationProcessors=\u627E\u4E0D\u5230\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F, \u4F46\u5B58\u5728\u6CE8\u91CA\u3002 - -apt.warn.NullProcessor=\u5BF9\u4E8E\u67D0\u4E2A\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F, \u5DE5\u5382{0}\u8FD4\u56DE\u7684\u503C\u4E3A\u7A7A\u503C\u3002 - -apt.warn.CorrespondingClassFile=\u5DF2\u521B\u5EFA\u4E0E\u6E90\u6587\u4EF6 ''{0}'' \u76F8\u5BF9\u5E94\u7684\u7C7B\u6587\u4EF6\u3002 - -apt.warn.CorrespondingSourceFile=\u5DF2\u521B\u5EFA\u4E0E\u7C7B\u6587\u4EF6 ''{0}'' \u76F8\u5BF9\u5E94\u7684\u6E90\u6587\u4EF6\u3002 diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/apt/util/Bark.java --- a/langtools/src/share/classes/com/sun/tools/apt/util/Bark.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,174 +0,0 @@ -/* - * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.apt.util; - -import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.JCDiagnostic; -import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition; -import com.sun.tools.javac.util.Log; -import com.sun.tools.javac.util.JavacMessages; -import com.sun.tools.javac.util.Position; - -/** A subtype of Log for use in APT. - * - *

This is NOT part of any supported API. - * If you write code that depends on this, you do so at your own risk. - * This code and its internal interfaces are subject to change or - * deletion without notice. - */ -public class Bark extends Log { - /** The context key for the bark. */ - protected static final Context.Key barkKey = - new Context.Key(); - - /** - * Preregisters factories to create and use a Bark object for use as - * both a Log and a Bark. - */ - public static void preRegister(Context context) { - context.put(barkKey, new Context.Factory() { - public Bark make(Context c) { - return new Bark(c); - } - }); - context.put(Log.logKey, new Context.Factory() { - public Log make(Context c) { - return Bark.instance(c); - } - }); - } - - /** Get the Bark instance for this context. */ - public static Bark instance(Context context) { - Bark instance = context.get(barkKey); - if (instance == null) - instance = new Bark(context); - return instance; - } - - /** Specifies whether or not to ignore any diagnostics that are reported. - */ - private boolean ignoreDiagnostics; - - /** - * Factory for APT-specific diagnostics. - */ - private JCDiagnostic.Factory aptDiags; - - - /** - * Creates a Bark. - */ - protected Bark(Context context) { - super(context); // will register this object in context with Log.logKey - context.put(barkKey, this); - - // register additional resource bundle for APT messages. - JavacMessages aptMessages = JavacMessages.instance(context); - aptMessages.add("com.sun.tools.apt.resources.apt"); - aptDiags = new JCDiagnostic.Factory(aptMessages, "apt"); - - multipleErrors = true; - } - - /** - * Sets a flag indicating whether or not to ignore all diagnostics. - * When ignored, they are not reported to the output writers, not are they - * counted in the various counters. - * @param b If true, subsequent diagnostics will be ignored. - * @return the previous state of the flag - */ - public boolean setDiagnosticsIgnored(boolean b) { - boolean prev = ignoreDiagnostics; - ignoreDiagnostics = b; - return prev; - } - - /** - * Report a diagnostic if they are not currently being ignored. - */ - @Override - public void report(JCDiagnostic diagnostic) { - if (ignoreDiagnostics) - return; - - super.report(diagnostic); - } - - /** Report an error. - * @param key The key for the localized error message. - * @param args Fields of the error message. - */ - public void aptError(String key, Object... args) { - aptError(Position.NOPOS, key, args); - } - - /** Report an error, unless another error was already reported at same - * source position. - * @param pos The source position at which to report the error. - * @param key The key for the localized error message. - * @param args Fields of the error message. - */ - public void aptError(int pos, String key, Object ... args) { - report(aptDiags.error(source, new SimpleDiagnosticPosition(pos), key, args)); - } - - /** Report a warning, unless suppressed by the -nowarn option or the - * maximum number of warnings has been reached. - * @param key The key for the localized warning message. - * @param args Fields of the warning message. - */ - public void aptWarning(String key, Object... args) { - aptWarning(Position.NOPOS, key, args); - } - - /** Report a warning, unless suppressed by the -nowarn option or the - * maximum number of warnings has been reached. - * @param pos The source position at which to report the warning. - * @param key The key for the localized warning message. - * @param args Fields of the warning message. - */ - public void aptWarning(int pos, String key, Object ... args) { - report(aptDiags.warning(source, new SimpleDiagnosticPosition(pos), key, args)); - } - - /** Report a note, unless suppressed by the -nowarn option. - * @param key The key for the localized note message. - * @param args Fields of the note message. - */ - public void aptNote(String key, Object... args) { - aptNote(Position.NOPOS, key, args); - } - - /** Report a note, unless suppressed by the -nowarn option. - * @param pos The source position at which to report the note. - * @param key The key for the localized note message. - * @param args Fields of the note message. - */ - public void aptNote(int pos, String key, Object ... args) { - report(aptDiags.note(source, new SimpleDiagnosticPosition(pos), key, args)); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/javac/comp/Check.java --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Feb 17 10:18:50 2012 -0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Wed Feb 22 10:17:57 2012 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -2114,25 +2114,26 @@ */ void checkOverrideClashes(DiagnosticPosition pos, Type site, MethodSymbol sym) { ClashFilter cf = new ClashFilter(site); - //for each method m1 that is a member of 'site'... - for (Symbol s1 : types.membersClosure(site, false).getElementsByName(sym.name, cf)) { - //...find another method m2 that is overridden (directly or indirectly) - //by method 'sym' in 'site' - for (Symbol s2 : types.membersClosure(site, false).getElementsByName(sym.name, cf)) { - if (s1 == s2 || !sym.overrides(s2, site.tsym, types, false)) continue; + //for each method m1 that is overridden (directly or indirectly) + //by method 'sym' in 'site'... + for (Symbol m1 : types.membersClosure(site, false).getElementsByName(sym.name, cf)) { + if (!sym.overrides(m1, site.tsym, types, false)) continue; + //...check each method m2 that is a member of 'site' + for (Symbol m2 : types.membersClosure(site, false).getElementsByName(sym.name, cf)) { + if (m2 == m1) continue; //if (i) the signature of 'sym' is not a subsignature of m1 (seen as //a member of 'site') and (ii) m1 has the same erasure as m2, issue an error - if (!types.isSubSignature(sym.type, types.memberType(site, s1), false) && - types.hasSameArgs(s1.erasure(types), s2.erasure(types))) { + if (!types.isSubSignature(sym.type, types.memberType(site, m2), false) && + types.hasSameArgs(m2.erasure(types), m1.erasure(types))) { sym.flags_field |= CLASH; - String key = s2 == sym ? + String key = m1 == sym ? "name.clash.same.erasure.no.override" : "name.clash.same.erasure.no.override.1"; log.error(pos, key, sym, sym.location(), - s1, s1.location(), - s2, s2.location()); + m2, m2.location(), + m1, m1.location()); return; } } diff -r eab1e4be8495 -r 09f5d262e329 langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java --- a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Fri Feb 17 10:18:50 2012 -0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Wed Feb 22 10:17:57 2012 -0800 @@ -1077,7 +1077,9 @@ boolean errors = false; for (String nameStr : classnames) { Symbol sym = resolveBinaryNameOrIdent(nameStr); - if (sym == null || (sym.kind == Kinds.PCK && !processPcks)) { + if (sym == null || + (sym.kind == Kinds.PCK && !processPcks) || + sym.kind == Kinds.ABSENT_TYP) { log.error("proc.cant.find.class", nameStr); errors = true; continue; diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/Aggregate.java --- a/langtools/test/tools/apt/Basics/Aggregate.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -public class Aggregate { - static { - System.out.println("xxyzzy"); - } - - private Aggregate() {} - - private static double hypot(double Berkeley, double SantaCruz) { - return 0.0; - } - - public int hashcode() {return 42;} - public boolean equals(Aggregate a) {return this == a;} - - public static void main(String[] argv) { - System.out.println("Hello World."); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/ClassAnnotations.java --- a/langtools/test/tools/apt/Basics/ClassAnnotations.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 annot.*; -import annot.annot2.*; - -@MySimple("value") @MyMarker -@AnnotMarker @AnnotSimple("foo") -@AnnotMarker2 @AnnotSimple2("bar") -public class ClassAnnotations { - static double d; - - public void foo() { - return; - } - - private double bar(int baz) { - @AnnotShangri_la - int local = 0; - return (double) baz; - } - - static class NestedClass { - protected int field; - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/FreshnessApf.java --- a/langtools/test/tools/apt/Basics/FreshnessApf.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 com.sun.mirror.apt.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - -import java.util.Collection; -import java.util.Set; -import java.util.Arrays; - -import static java.util.Collections.*; -import static com.sun.mirror.util.DeclarationVisitors.*; - -/* - * Indirect test of whether source or class files are used to provide - * declaration information. - */ -public class FreshnessApf implements AnnotationProcessorFactory { - // Process any set of annotations - private static final Collection supportedAnnotations - = unmodifiableCollection(Arrays.asList("*")); - - // No supported options - private static final Collection supportedOptions = emptySet(); - - public Collection supportedAnnotationTypes() { - return supportedAnnotations; - } - - public Collection supportedOptions() { - return supportedOptions; - } - - public AnnotationProcessor getProcessorFor( - Set atds, - AnnotationProcessorEnvironment env) { - return new FreshnessAp(env); - } - - private static class FreshnessAp implements AnnotationProcessor { - private final AnnotationProcessorEnvironment env; - FreshnessAp(AnnotationProcessorEnvironment env) { - this.env = env; - } - - public void process() { - System.out.println("Testing for freshness."); - boolean empty = true; - for (TypeDeclaration typeDecl : env.getSpecifiedTypeDeclarations()) { - for (FieldDeclaration fieldDecl: typeDecl.getFields() ) { - empty = false; - System.out.println(typeDecl.getQualifiedName() + - "." + fieldDecl.getSimpleName()); - - // Verify the declaration for the type of the - // field is a class with an annotation. - System.out.println(((DeclaredType) fieldDecl.getType()).getDeclaration().getAnnotationMirrors()); - if (((DeclaredType) fieldDecl.getType()).getDeclaration().getAnnotationMirrors().size() == 0) - env.getMessager().printError("Expected an annotation."); - } - } - - if (empty) - env.getMessager().printError("No fields encountered."); - } - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/GenClass.java --- a/langtools/test/tools/apt/Basics/GenClass.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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. - */ - - -/* - * A trivial generic class to test the fix for 5018369. - */ - -class GenClass { -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/Indirect.java --- a/langtools/test/tools/apt/Basics/Indirect.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -/* - * Class that is used to provide a pointer to another class - * declaration. - */ -public class Indirect { - Milk skim = null; -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/Lacuna.java --- a/langtools/test/tools/apt/Basics/Lacuna.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -class Lacuna extends Missing {} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/MethodAnnotations.java --- a/langtools/test/tools/apt/Basics/MethodAnnotations.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 annot.*; -import annot.annot2.*; - -public class MethodAnnotations { - static double d; - - @MySimple("value") @MyMarker - @AnnotMarker @AnnotSimple("foo") - @AnnotMarker2 @AnnotSimple2("bar") - public void foo() { - return; - } - - private double bar(int baz) { - @AnnotShangri_la - int local = 0; - return (double) baz; - } - - static class NestedClass { - protected int field; - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/Milk.java --- a/langtools/test/tools/apt/Basics/Milk.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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.lang.annotation.*; - -@Fresh -public class Milk { - // Moo. -} - -@Retention(RetentionPolicy.SOURCE) -@interface Fresh { -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/MisMatch.java --- a/langtools/test/tools/apt/Basics/MisMatch.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - - -/** - * Class that uses constructs whose language and vm interpretation - * differ. - */ -public class MisMatch { - static final int constant = 3; - static int notConstant = 4; - private static strictfp class NestedClass { - } - - protected abstract class AbstractNestedClass { - /** - * Another doc comment. - * - * This one has multiple lines. - */ - void myMethod() throws RuntimeException , Error {} - - abstract void myAbstractMethod(); - } - - void VarArgsMethod1(Number... num) { - ; - } - - void VarArgsMethod2(float f, double d, Number... num) { - ; - } -} - -@interface Colors { -} - -interface Inter { - void interfaceMethod(); -} - -enum MyEnum { - RED, - GREEN, - BLUE; -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/Misc.java --- a/langtools/test/tools/apt/Basics/Misc.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -/* - * Class with miscellaneous structures to exercise printing. - */ - -import java.util.Collection; - -public final class Misc implements Marker2, Marker3 { - private static final long longConstant = Long.MAX_VALUE; - - private static final String asciispecials = "\t\n\u0007"; - - public void covar(Collection s) {return;} - - public void contravar(Collection s) {return;} - - public S varUse(int i) {return null;} - - Object o = (new Object() {}); // verify fix for 5019108 -} - -interface Marker1 {} - -interface Marker2 extends Marker1 {} - -interface Marker3 {} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/MyMarker.java --- a/langtools/test/tools/apt/Basics/MyMarker.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - - -public @interface MyMarker { -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/MySimple.java --- a/langtools/test/tools/apt/Basics/MySimple.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - - -public @interface MySimple { - String value() default "default"; -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/NestedClassAnnotations.java --- a/langtools/test/tools/apt/Basics/NestedClassAnnotations.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 annot.*; -import annot.annot2.*; - -public class NestedClassAnnotations { - static double d; - - public void foo() { - return; - } - - public static void baz() { - } - - private double bar(int baz) { - @AnnotShangri_la - int local = 0; - return (double) baz; - } - - @MySimple("value") @MyMarker - @AnnotMarker @AnnotSimple("foo") - @AnnotMarker2 @AnnotSimple2("bar") - static class NestedClass { - protected int field; - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/ParameterAnnotations.java --- a/langtools/test/tools/apt/Basics/ParameterAnnotations.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 annot.*; -import annot.annot2.*; - -public class ParameterAnnotations { - static double d; - - public void foo() { - return; - } - - private double bar(@MySimple("value") @MyMarker - @AnnotMarker @AnnotSimple("foo") - @AnnotMarker2 @AnnotSimple2("bar") - int baz) { - @AnnotShangri_la - int local = 0; - return (double) baz; - } - - static class NestedClass { - protected int field; - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/StaticFieldAnnotations.java --- a/langtools/test/tools/apt/Basics/StaticFieldAnnotations.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 annot.*; -import annot.annot2.*; - -public class StaticFieldAnnotations { - @MySimple("value") @MyMarker - @AnnotMarker @AnnotSimple("foo") - @AnnotMarker2 @AnnotSimple2("bar") - static double d; - - public void foo() { - return; - } - - private double bar(int baz) { - @AnnotShangri_la - int local = 0; - return (double) baz; - } - - static class NestedClass { - protected int field; - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/StaticMethodAnnotations.java --- a/langtools/test/tools/apt/Basics/StaticMethodAnnotations.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 annot.*; -import annot.annot2.*; - -public class StaticMethodAnnotations { - static double d; - - public void foo() { - return; - } - - @MySimple("value") @MyMarker - @AnnotMarker @AnnotSimple("foo") - @AnnotMarker2 @AnnotSimple2("bar") - public static void baz() { - } - - private double bar(int baz) { - @AnnotShangri_la - int local = 0; - return (double) baz; - } - - static class NestedClass { - protected int field; - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/TestGetPackageApf.java --- a/langtools/test/tools/apt/Basics/TestGetPackageApf.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 com.sun.mirror.apt.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - -import java.util.Collection; -import java.util.Set; -import java.util.Arrays; - -import static java.util.Collections.*; -import static com.sun.mirror.util.DeclarationVisitors.*; - -/* - * This class is used to test getPackage on classes that are - * not already loaded. - */ -public class TestGetPackageApf implements AnnotationProcessorFactory { - // Process any set of annotations - private static final Collection supportedAnnotations - = unmodifiableCollection(Arrays.asList("*")); - - // No supported options - private static final Collection supportedOptions = emptySet(); - - public Collection supportedAnnotationTypes() { - return supportedAnnotations; - } - - public Collection supportedOptions() { - return supportedOptions; - } - - public AnnotationProcessor getProcessorFor( - Set atds, - AnnotationProcessorEnvironment env) { - return new TestGetPackageAp(env); - } - - private static class TestGetPackageAp implements AnnotationProcessor { - private final AnnotationProcessorEnvironment env; - TestGetPackageAp(AnnotationProcessorEnvironment env) { - this.env = env; - } - - public void process() { - boolean failed = false; - String packageNames[] = { - "", // unnamed package - "java.lang.annotation", - "java.lang", - "java.util", - "java.awt.image.renderable", - "foo.bar", - "foo", - "p1", - // "p1.p2", // class p1.p2 obscures package p1.p2 - }; - - for(String packageName: packageNames) { - PackageDeclaration p = env.getPackage(packageName); - if (p == null) { - failed = true; - System.err.println("ERROR: No declaration found for ``" + packageName + "''."); - } - else if (!packageName.equals(p.getQualifiedName())) { - failed = true; - System.err.println("ERROR: Unexpected package name; expected " + packageName + - "got " + p.getQualifiedName()); - } - } - - String notPackageNames[] = { - "XXYZZY", - "java.lang.String", - "1", - "1.2", - "3.14159", - "To be or not to be is a tautology", - "1+2=3", - }; - - for(String notPackageName: notPackageNames) { - PackageDeclaration p = env.getPackage(notPackageName); - if (p != null) { - failed = true; - System.err.println("ERROR: Unexpected declaration: ``" + p + "''."); - } - } - - if (failed) - throw new RuntimeException("Errors found testing getPackage."); - } - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/TestGetTypeDeclarationApf.java --- a/langtools/test/tools/apt/Basics/TestGetTypeDeclarationApf.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 com.sun.mirror.apt.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - -import java.util.Collection; -import java.util.Set; -import java.util.Arrays; - -import static java.util.Collections.*; -import static com.sun.mirror.util.DeclarationVisitors.*; - -/* - * This class is used to test getTypeDeclaration on classes that are - * not already loaded. - */ -public class TestGetTypeDeclarationApf implements AnnotationProcessorFactory { - // Process any set of annotations - private static final Collection supportedAnnotations - = unmodifiableCollection(Arrays.asList("*")); - - // No supported options - private static final Collection supportedOptions = emptySet(); - - public Collection supportedAnnotationTypes() { - return supportedAnnotations; - } - - public Collection supportedOptions() { - return supportedOptions; - } - - public AnnotationProcessor getProcessorFor( - Set atds, - AnnotationProcessorEnvironment env) { - return new TestGetTypeDeclarationAp(env); - } - - private static class TestGetTypeDeclarationAp implements AnnotationProcessor { - private final AnnotationProcessorEnvironment env; - TestGetTypeDeclarationAp(AnnotationProcessorEnvironment env) { - this.env = env; - } - - public void process() { - String classNames[] = { - "java.lang.String", // should be already available - "java.lang.Thread.State", // should be already available - "java.util.Collection", - "java.util.Map.Entry", - "foo.bar.Baz.Xxyzzy.Wombat", - "foo.bar.Baz.Xxyzzy", - "foo.bar.Baz", - "foo.bar.Quux", - "foo.bar.Quux.Xxyzzy", - "foo.bar.Quux.Xxyzzy.Wombat", - "NestedClassAnnotations", - "NestedClassAnnotations.NestedClass", - }; - - for(String className: classNames) { - TypeDeclaration t = env.getTypeDeclaration(className); - if (t == null) - throw new RuntimeException("No declaration found for " + className); - if (! t.getQualifiedName().equals(className)) - throw new RuntimeException("Class with wrong name found for " + className); - } - - // Test obscuring behavior; i.e. nested class C1 in class - // p1 where p1 is member of package p2 should be favored - // over class C1 in package p1.p2. - String nonuniqueCanonicalNames[] = { - "p1.p2.C1", - }; - for(String className: nonuniqueCanonicalNames) { - ClassDeclaration c1 = (ClassDeclaration) env.getTypeDeclaration(className); - ClassDeclaration c2 = (ClassDeclaration) c1.getDeclaringType(); - PackageDeclaration p = env.getPackage("p1"); - - if (!p.equals(c1.getPackage()) || - c2 == null || - !"C1".equals(c1.getSimpleName())) { - throw new RuntimeException("Bad class declaration"); - } - } - - String notClassNames[] = { - "", - "XXYZZY", - "java", - "java.lang", - "java.lang.Bogogogous", - "1", - "1.2", - "3.14159", - "To be or not to be is a tautology", - "1+2=3", - "foo+.x", - "foo+x", - "+", - "?", - "***", - "java.*", - }; - - for(String notClassName: notClassNames) { - Declaration t = env.getTypeDeclaration(notClassName); - if (t != null) { - System.err.println("Unexpected declaration:" + t); - throw new RuntimeException("Declaration found for ``" + notClassName + "''."); - } - } - - } - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/annot/AnnotMarker.java --- a/langtools/test/tools/apt/Basics/annot/AnnotMarker.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 annot; - -public @interface AnnotMarker { -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/annot/AnnotShangri_la.java --- a/langtools/test/tools/apt/Basics/annot/AnnotShangri_la.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 annot; - -/* - * This annotation is used by the tests only to annotate local - * variables; therefore, this annotation should not affect the - * discovery process and should not appear in the list printed by - * -XListAnnotationTypes. - */ -public @interface AnnotShangri_la { -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/annot/AnnotSimple.java --- a/langtools/test/tools/apt/Basics/annot/AnnotSimple.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 annot; - -public @interface AnnotSimple { - String value() default "default"; -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/annot/annot2/AnnotMarker2.java --- a/langtools/test/tools/apt/Basics/annot/annot2/AnnotMarker2.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 annot.annot2; - -public @interface AnnotMarker2 { -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/annot/annot2/AnnotSimple2.java --- a/langtools/test/tools/apt/Basics/annot/annot2/AnnotSimple2.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 annot.annot2; - -public @interface AnnotSimple2 { - String value() default "default"; -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/apt.sh --- a/langtools/test/tools/apt/Basics/apt.sh Fri Feb 17 10:18:50 2012 -0800 +++ b/langtools/test/tools/apt/Basics/apt.sh Wed Feb 22 10:17:57 2012 -0800 @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2004, 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 @@ -24,11 +24,10 @@ # # @test -# @bug 4908512 5024825 4957203 4993280 4996963 6174696 6177059 +# @bug 4908512 5024825 4957203 4993280 4996963 6174696 6177059 7041249 # @run shell ../verifyVariables.sh -# @build Milk MethodAnnotations NestedClassAnnotations StaticFieldAnnotations StaticMethodAnnotations ParameterAnnotations # @run shell apt.sh -# @summary test consistency of annotation discovery +# @summary Make sure apt is removed and doesn't come back # @author Joseph D. Darcy OS=`uname -s`; @@ -41,136 +40,24 @@ ;; esac -# Construct path to apt executable -APT="${TESTJAVA}/bin/apt ${TESTTOOLVMOPTS} -XDsuppress-tool-api-removal-message " - -printf "%s\n" "-classpath ${TESTCLASSES}" > options -printf "%s\n" "-factorypath ./nullap.jar" >> options -printf "%s\n" "-sourcepath ${TESTSRC} " >> options -printf "%s\n" "-nocompile" >> options -printf "%s\n" "-XListAnnotationTypes" >> options - -printf "%s\n" "-classpath ${TESTCLASSES}" > options1 -printf "%s\n" "-factorypath ./nullap.jar" >> options1 -printf "%s\n" "-sourcepath ${TESTSRC} " >> options1 -printf "%s\n" "-nocompile" >> options1 -printf "%s\n" "-XListAnnotationTypes" >> options1 -printf "%s\n" "-XclassesAsDecls" >> options1 - +# Verify apt executable does not exist +if [ -f "${TESTJAVA}/bin/apt" -o -f "${TESTJAVA}/bin/apt.exe" ];then + echo "apt executable should not exist." + exit 1 +fi # Construct path to javac executable JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TESTJAVA}/lib/tools.jar -d . " -JAR="${TESTJAVA}/bin/jar " -$JAVAC ${TESTSRC}/NullAPF.java \ -${TESTSRC}/FreshnessApf.java \ -${TESTSRC}/TestGetTypeDeclarationApf.java \ -${TESTSRC}/TestGetPackageApf.java +$JAVAC ${TESTSRC}/NullAPF.java RESULT=$? case "${RESULT}" in 0 ) - ;; + echo "Compilation of apt-using source passed improperly." + exit 1 + ;; * ) - echo "Compilation failed." - exit 1 + ;; esac - -echo "Making services directory and copying services information." -mkdir -p META-INF/services -cp ${TESTSRC}/com.sun.mirror.apt.AnnotationProcessorFactory ./META-INF/services -$JAR cvf0 nullap.jar NullAPF*.class META-INF - -ANNOTATION_FILES="${TESTSRC}/ClassAnnotations.java \ -${TESTSRC}/MethodAnnotations.java \ -${TESTSRC}/NestedClassAnnotations.java \ -${TESTSRC}/StaticFieldAnnotations.java \ -${TESTSRC}/StaticMethodAnnotations.java \ -${TESTSRC}/ParameterAnnotations.java" - -for i in ${ANNOTATION_FILES} -do - printf "%s\n" "Testing annotations on source file ${i}" - ${APT} @options ${i} 2> result.txt - diff ${DIFFOPTS} ${TESTSRC}/golden.txt result.txt - - RESULT=$? - case "$RESULT" in - 0 ) - ;; - - * ) - echo "Unexpected set of annotations on source files found." - exit 1 - esac - - CLASS=`basename ${i} .java` - printf "%s\n" "Testing annotations on class file ${CLASS}" - ${APT} @options1 ${CLASS} 2> result2.txt - diff ${DIFFOPTS} ${TESTSRC}/golden.txt result2.txt - - RESULT=$? - case "$RESULT" in - 0 ) - ;; - - * ) - echo "Unexpected set of annotations on class files found." - exit 1 - esac -done - -# Verify source files are favored over class files - -printf "%s\n" "-factorypath ." > options2 -printf "%s\n" "-factory FreshnessApf" >> options2 -printf "%s\n" "-sourcepath ${TESTSRC}" >> options2 -printf "%s\n" "-classpath ${TESTCLASSES}" >> options2 -printf "%s\n" "-nocompile" >> options2 - -${APT} @options2 ${TESTSRC}/Indirect.java - -RESULT=$? -case "$RESULT" in - 0 ) - ;; - - * ) - exit 1 -esac - -# Verify new classes can be loaded by getTypeDeclaration - -printf "%s\n" "-factorypath ." > options3 -printf "%s\n" "-factory TestGetTypeDeclarationApf" >> options3 -printf "%s\n" "-sourcepath ${TESTSRC}" >> options3 - -# ${APT} @options3 - -RESULT=$? -case "$RESULT" in - 0 ) - ;; - - * ) - exit 1 -esac - -# Verify packages can be loaded by getPackage - -printf "%s\n" "-factorypath ." > options4 -printf "%s\n" "-factory TestGetPackageApf" >> options4 -printf "%s\n" "-sourcepath ${TESTSRC}" >> options4 - -${APT} @options4 - -RESULT=$? -case "$RESULT" in - 0 ) - ;; - - * ) - exit 1 -esac -exit 0 diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/com.sun.mirror.apt.AnnotationProcessorFactory --- a/langtools/test/tools/apt/Basics/com.sun.mirror.apt.AnnotationProcessorFactory Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -NullAPF diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/foo/bar/Baz.java --- a/langtools/test/tools/apt/Basics/foo/bar/Baz.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 foo.bar; - -public class Baz { - public class Xxyzzy { - public class Wombat { - } - } - -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/foo/bar/Quux.java --- a/langtools/test/tools/apt/Basics/foo/bar/Quux.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 foo.bar; - -public class Quux { - public class Xxyzzy { - public class Wombat { - } - } - -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/golden.txt --- a/langtools/test/tools/apt/Basics/golden.txt Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -Set of annotations found:[MyMarker, MySimple, annot.AnnotMarker, annot.AnnotSimple, annot.annot2.AnnotMarker2, annot.annot2.AnnotSimple2] diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/goldenAggregate.txt --- a/langtools/test/tools/apt/Basics/goldenAggregate.txt Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ - -public class Aggregate { - - private Aggregate(); - - private static double hypot(double arg0, - double arg1); - - public static void main(java.lang.String[] arg0); - - public boolean equals(Aggregate arg0); - - public int hashcode(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/p1/p2.java --- a/langtools/test/tools/apt/Basics/p1/p2.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 p1; - -public class p2 { - public static class C1 {} -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/p1/p2/C1.java --- a/langtools/test/tools/apt/Basics/p1/p2/C1.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 p1.p2; - -public class C1 { -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Basics/print.sh --- a/langtools/test/tools/apt/Basics/print.sh Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute 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 5008759 4998341 5018369 5032476 5060121 5096932 5096931 -# @run shell ../verifyVariables.sh -# @run shell print.sh -# @summary test availabilty of print option -# @author Joseph D. Darcy - -OS=`uname -s`; -case "${OS}" in - CYGWIN* ) - DIFFOPTS="--strip-trailing-cr" - ;; - - * ) - ;; -esac - -# Compile file directly, without TESTJAVACOPTS -# Don't use @build or @compile as these implicitly use jtreg -javacoption values -# and it is important that this file be compiled as expected, for later comparison -# against a golden file. -"${TESTJAVA}/bin/javac" ${TESTTOOLVMOPTS} -d ${TESTCLASSES} ${TESTSRC}/Aggregate.java - -# Construct path to apt executable -APT="${TESTJAVA}/bin/apt ${TESTTOOLVMOPTS} \ --print " - -printf "%s\n" "APT = ${APT}" - -PRINT_FILES="${TESTSRC}/MisMatch.java \ -${TESTSRC}/GenClass.java \ -${TESTSRC}/Misc.java \ -${TESTSRC}/Lacuna.java" - -for i in ${PRINT_FILES} -do - # Delete any existing class file - FILENAME=`basename $i .java` - rm -f ${FILENAME}.class - - printf "%s\n" "Printing ${i}" - ${APT} ${i} - - RESULT=$? - case "$RESULT" in - 0 ) - ;; - - * ) - echo "Problem printing file ${i}." - exit 1 - esac - - # Verify compilation did not occur - if [ -f ${FILENAME}.class ]; then - printf "Improper compilation occured for %s.\n" ${i} - exit 1 - fi - -done - -# check for mutliple methods and no static initializer - -${APT} -XclassesAsDecls -cp ${TESTCLASSES} -print Aggregate > aggregate.txt -diff ${DIFFOPTS} aggregate.txt ${TESTSRC}/goldenAggregate.txt - -RESULT=$? -case "$RESULT" in - 0 ) - ;; - - * ) - echo "Expected output not received" - exit 1 -esac - -exit 0 diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Compile/ClassDeclApf.java --- a/langtools/test/tools/apt/Compile/ClassDeclApf.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 com.sun.mirror.apt.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - -import java.util.Collection; -import java.util.Set; -import java.util.Arrays; - -import java.io.*; - -import static java.util.Collections.*; - -/* - * This class is used to test the ability to store static state across - * apt rounds. - */ -public class ClassDeclApf implements AnnotationProcessorFactory { - static int round = -1; - - // Process any set of annotations - private static final Collection supportedAnnotations - = unmodifiableCollection(Arrays.asList("*")); - - // No supported options - private static final Collection supportedOptions = emptySet(); - - public Collection supportedAnnotationTypes() { - return supportedAnnotations; - } - - public Collection supportedOptions() { - return supportedOptions; - } - - public AnnotationProcessor getProcessorFor(Set atds, - AnnotationProcessorEnvironment env) { - return new ClassDeclAp(env); - } - - private static class ClassDeclAp implements AnnotationProcessor { - private final AnnotationProcessorEnvironment env; - ClassDeclAp(AnnotationProcessorEnvironment env) { - this.env = env; - } - - // Simple inefficient drain - void drain(InputStream is, OutputStream os) { - try { - while (is.available() > 0 ) - os.write(is.read()); - } catch (java.io.IOException ioe) { - throw new RuntimeException(ioe); - } - - } - - public void process() { - int size = env.getSpecifiedTypeDeclarations().size(); - - try { - round++; - switch (size) { - case 0: - if (round == 0) { - drain(new FileInputStream("./tmp/classes/Round1Class.class"), - env.getFiler().createClassFile("Round1Class")); - } else - throw new RuntimeException("Got " + size + " decl's in round " + round); - break; - - case 1: - if (round == 1) { - drain(new FileInputStream("./tmp/classes/AhOneClass.class"), - env.getFiler().createClassFile("AhOneClass")); - - drain(new FileInputStream("./tmp/classes/AndAhTwoClass.class"), - env.getFiler().createClassFile("AndAhTwoClass")); - } else - throw new RuntimeException("Got " + size + " decl's in round " + round); - break; - case 2: - if (round != 2) { - throw new RuntimeException("Got " + size + " decl's in round " + round); - } - break; - } - - } catch (java.io.IOException ioe) { - throw new RuntimeException(); - } - - } - - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Compile/ClassDeclApf2.java --- a/langtools/test/tools/apt/Compile/ClassDeclApf2.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 com.sun.mirror.apt.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - -import java.util.Collection; -import java.util.Set; -import java.util.Arrays; - -import java.io.*; - -import static java.util.Collections.*; - -/* - * This class is used to test the the interaction of -XclassesAsDecls - * with command line options handling. - */ -public class ClassDeclApf2 implements AnnotationProcessorFactory { - static int round = -1; - - // Process any set of annotations - private static final Collection supportedAnnotations - = unmodifiableCollection(Arrays.asList("*")); - - // No supported options - private static final Collection supportedOptions = emptySet(); - - public Collection supportedAnnotationTypes() { - return supportedAnnotations; - } - - public Collection supportedOptions() { - return supportedOptions; - } - - public AnnotationProcessor getProcessorFor(Set atds, - AnnotationProcessorEnvironment env) { - return new ClassDeclAp(env); - } - - private static class ClassDeclAp implements AnnotationProcessor { - private final AnnotationProcessorEnvironment env; - ClassDeclAp(AnnotationProcessorEnvironment env) { - this.env = env; - } - - // Simple inefficient drain - void drain(InputStream is, OutputStream os) { - try { - while (is.available() > 0 ) - os.write(is.read()); - } catch (java.io.IOException ioe) { - throw new RuntimeException(ioe); - } - } - - public void process() { - int size = env.getSpecifiedTypeDeclarations().size(); - Filer f = env.getFiler(); - - try { - round++; - switch (size) { - case 3: - if (round == 0) { - drain(new FileInputStream("./tmp/classes/Round1Class.class"), - f.createClassFile("Round1Class")); - } else - throw new RuntimeException("Got " + size + " decl's in round " + round); - break; - - case 1: - if (round == 1) { - f.createSourceFile("AhOne").println("public class AhOne {}"); - System.out.println("Before writing AndAhTwoClass"); - drain(new FileInputStream("./tmp/classes/AndAhTwoClass.class"), - f.createClassFile("AndAhTwoClass")); - System.out.println("After writing AndAhTwoClass"); - } else - throw new RuntimeException("Got " + size + " decl's in round " + round); - break; - - case 2: - if (round != 2) { - throw new RuntimeException("Got " + size + " decl's in round " + round); - } - break; - default: - throw new RuntimeException("Unexpected number of declarations:" + size + - "\n Specified:" + env.getSpecifiedTypeDeclarations() + - "\n Included:" + env.getTypeDeclarations() ); - } - - } catch (java.io.IOException ioe) { - throw new RuntimeException(ioe); - } - } - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Compile/Dummy1.java --- a/langtools/test/tools/apt/Compile/Dummy1.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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. - */ - - -@Round1 class Dummy1{} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Compile/ErrorAPF.java --- a/langtools/test/tools/apt/Compile/ErrorAPF.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 com.sun.mirror.apt.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - -import java.util.Collection; -import java.util.Set; -import java.util.Arrays; - - -import static java.util.Collections.*; -import static com.sun.mirror.util.DeclarationVisitors.*; - -/* - * Construct a processor that does nothing but report an error. - */ -public class ErrorAPF implements AnnotationProcessorFactory { - static class ErrorAP implements AnnotationProcessor { - AnnotationProcessorEnvironment env; - ErrorAP(AnnotationProcessorEnvironment env) { - this.env = env; - } - - public void process() { - Messager messager = env.getMessager(); - messager.printError("It's a mad, mad, mad, mad world"); - messager.printError("Something wicked this way comes"); - - for(TypeDeclaration typeDecl : env.getSpecifiedTypeDeclarations()) - messager.printError(typeDecl.getPosition(), "Boring class name"); - } - } - - static Collection supportedTypes; - static { - String types[] = {"*"}; - supportedTypes = unmodifiableCollection(Arrays.asList(types)); - } - - static Collection supportedOptions; - static { - String options[] = {""}; - supportedOptions = unmodifiableCollection(Arrays.asList(options)); - } - - public Collection supportedOptions() { - return supportedOptions; - } - - public Collection supportedAnnotationTypes() { - return supportedTypes; - } - - public AnnotationProcessor getProcessorFor(Set atds, - AnnotationProcessorEnvironment env) { - return new ErrorAP(env); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Compile/HelloAnnotation.java --- a/langtools/test/tools/apt/Compile/HelloAnnotation.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -/* /nodynamiccopyright/ */ -import java.lang.annotation.*; -@Target(ElementType.ANNOTATION_TYPE) -@Retention(RetentionPolicy.RUNTIME) -@HelloAnnotation -@interface HelloAnnotation { - Target value() default @Target(ElementType.METHOD); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Compile/HelloWorld.java --- a/langtools/test/tools/apt/Compile/HelloWorld.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -/* /nodynamiccopyright/ */ -public class HelloWorld { - public static void main(String argv[]) { - System.out.println("Hello World."); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Compile/Round1Apf.java --- a/langtools/test/tools/apt/Compile/Round1Apf.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 com.sun.mirror.apt.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - -import java.util.Collection; -import java.util.Set; -import java.util.Arrays; - -import java.io.File; - -import static java.util.Collections.*; -import static com.sun.mirror.util.DeclarationVisitors.*; - -/* - * Factory to help test updated discovery policy. - */ -public class Round1Apf implements AnnotationProcessorFactory { - // Process @Round1 - private static final Collection supportedAnnotations - = unmodifiableCollection(Arrays.asList("Round1")); - - // No supported options - private static final Collection supportedOptions = emptySet(); - - public Collection supportedAnnotationTypes() { - return supportedAnnotations; - } - - public Collection supportedOptions() { - return supportedOptions; - } - - private static int round = 0; - - public AnnotationProcessor getProcessorFor( - Set atds, - AnnotationProcessorEnvironment env) { - return new Round1Ap(env, atds.size() == 0); - } - - private static class Round1Ap implements AnnotationProcessor, RoundCompleteListener { - private final AnnotationProcessorEnvironment env; - private final boolean empty; - - Round1Ap(AnnotationProcessorEnvironment env, boolean empty) { - this.env = env; - this.empty = empty; - } - - public void process() { - Round1Apf.round++; - try { - if (!empty) { - Filer f = env.getFiler(); - f.createSourceFile("Dummy2").println("@Round2 class Dummy2{}"); - f.createTextFile(Filer.Location.SOURCE_TREE, - "", - new File("foo.txt"), - null).println("xxyzzy"); - f.createClassFile("Vacant"); - f.createBinaryFile(Filer.Location.CLASS_TREE, - "", - new File("onezero")); - } - } catch (java.io.IOException ioe) { - throw new RuntimeException(ioe); - } - - System.out.println("Round1Apf: " + round); - env.addListener(this); - } - - public void roundComplete(RoundCompleteEvent event) { - RoundState rs = event.getRoundState(); - - if (event.getSource() != this.env) - throw new RuntimeException("Wrong source!"); - - Filer f = env.getFiler(); - try { - f.createSourceFile("AfterTheBell").println("@Round2 class AfterTheBell{}"); - throw new RuntimeException("Inappropriate source file creation."); - } catch (java.io.IOException ioe) {} - - - System.out.printf("\t[final round: %b, error raised: %b, "+ - "source files created: %b, class files created: %b]%n", - rs.finalRound(), - rs.errorRaised(), - rs.sourceFilesCreated(), - rs.classFilesCreated()); - - System.out.println("Round1Apf: " + round + " complete"); - } - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Compile/Round2Apf.java --- a/langtools/test/tools/apt/Compile/Round2Apf.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 com.sun.mirror.apt.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - -import java.util.Collection; -import java.util.Set; -import java.util.Arrays; - -import java.io.IOException; -import java.io.File; - -import static java.util.Collections.*; -import static com.sun.mirror.util.DeclarationVisitors.*; - -/* - * Factory to help test updated discovery policy. - */ -public class Round2Apf implements AnnotationProcessorFactory { - // Process @Round2 - private static final Collection supportedAnnotations - = unmodifiableCollection(Arrays.asList("Round2")); - - // No supported options - private static final Collection supportedOptions = emptySet(); - - public Collection supportedAnnotationTypes() { - return supportedAnnotations; - } - - public Collection supportedOptions() { - return supportedOptions; - } - - private static int round = 0; - - public AnnotationProcessor getProcessorFor( - Set atds, - AnnotationProcessorEnvironment env) { - return new Round2Ap(env, atds.size() == 0); - } - - private static class Round2Ap implements AnnotationProcessor { - private final AnnotationProcessorEnvironment env; - private final boolean empty; - - Round2Ap(AnnotationProcessorEnvironment env, boolean empty) { - this.env = env; - this.empty = empty; - } - - public void process() { - Round2Apf.round++; - Filer f = env.getFiler(); - try { - f.createSourceFile("Dummy2").println("@Round2 class Dummy2{}"); - throw new RuntimeException("Duplicate file creation allowed"); - } catch (IOException io) {} - - try { - f.createTextFile(Filer.Location.SOURCE_TREE, - "", - new File("foo.txt"), - null).println("xxyzzy"); - throw new RuntimeException("Duplicate file creation allowed"); - } catch (IOException io) {} - - try { - f.createClassFile("Vacant"); - throw new RuntimeException("Duplicate file creation allowed"); - } catch (IOException io) {} - - try { - f.createBinaryFile(Filer.Location.CLASS_TREE, - "", - new File("onezero")); - throw new RuntimeException("Duplicate file creation allowed"); - } catch (IOException io) {} - - - - try { - if (!empty) { - // Create corresponding files of opposite kind to - // the files created by Round1Apf; these should - // only generate warnings - f.createClassFile("Dummy2"); - f.createSourceFile("Vacant").println("class Vacant{}"); - - f.createSourceFile("Dummy3").println("@Round3 class Dummy3{}"); - - // This should generated a warning too - f.createClassFile("Dummy3"); - } - } catch (java.io.IOException ioe) { - throw new RuntimeException(ioe); - } - - System.out.println("Round2Apf: " + round); - } - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Compile/Round3Apf.java --- a/langtools/test/tools/apt/Compile/Round3Apf.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 com.sun.mirror.apt.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - -import java.util.Collection; -import java.util.Set; -import java.util.Arrays; - -import static java.util.Collections.*; -import static com.sun.mirror.util.DeclarationVisitors.*; - -/* - * Factory to help test updated discovery policy. - */ -public class Round3Apf implements AnnotationProcessorFactory { - // Process @Round3 - private static final Collection supportedAnnotations - = unmodifiableCollection(Arrays.asList("Round3")); - - // No supported options - private static final Collection supportedOptions = emptySet(); - - public Collection supportedAnnotationTypes() { - return supportedAnnotations; - } - - public Collection supportedOptions() { - return supportedOptions; - } - - private static int round = 0; - - public AnnotationProcessor getProcessorFor( - Set atds, - AnnotationProcessorEnvironment env) { - return new Round3Ap(env, atds.size() == 0); - } - - private static class Round3Ap implements AnnotationProcessor { - private final AnnotationProcessorEnvironment env; - private final boolean empty; - - Round3Ap(AnnotationProcessorEnvironment env, boolean empty) { - this.env = env; - this.empty = empty; - } - - public void process() { - Round3Apf.round++; - try { - if (!empty) - env.getFiler().createSourceFile("Dummy4").println("@Round4 class Dummy4{}"); - } catch (java.io.IOException ioe) { - throw new RuntimeException(ioe); - } - - System.out.println("Round3Apf: " + round); - } - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Compile/Round4Apf.java --- a/langtools/test/tools/apt/Compile/Round4Apf.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 com.sun.mirror.apt.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - -import java.util.Collection; -import java.util.Set; -import java.util.Arrays; - -import static java.util.Collections.*; -import static com.sun.mirror.util.DeclarationVisitors.*; - -/* - * Factory to help test updated discovery policy. - */ -public class Round4Apf implements AnnotationProcessorFactory { - // Process @Round4 - private static final Collection supportedAnnotations - = unmodifiableCollection(Arrays.asList("Round4")); - - // No supported options - private static final Collection supportedOptions = emptySet(); - - public Collection supportedAnnotationTypes() { - return supportedAnnotations; - } - - public Collection supportedOptions() { - return supportedOptions; - } - - private static int round = 0; - - public AnnotationProcessor getProcessorFor( - Set atds, - AnnotationProcessorEnvironment env) { - return new Round4Ap(env, atds.size() == 0); - } - - private static class Round4Ap implements AnnotationProcessor, RoundCompleteListener { - private final AnnotationProcessorEnvironment env; - private final boolean empty; - - Round4Ap(AnnotationProcessorEnvironment env, boolean empty) { - this.env = env; - this.empty = empty; - } - - public void process() { - Round4Apf.round++; - try { - if (!empty) - env.getFiler().createSourceFile("Dummy5").println("@Round5 class Dummy5{}"); - } catch (java.io.IOException ioe) { - throw new RuntimeException(ioe); - } - - System.out.println("Round4Apf: " + round); - env.addListener(this); - } - - public void roundComplete(RoundCompleteEvent event) { - RoundState rs = event.getRoundState(); - - System.out.println("\t" + rs.toString()); - - System.out.println("Round4Apf: " + round + " complete"); - - if (rs.finalRound()) { - System.out.println("Valediction"); - } - } - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Compile/Rounds.java --- a/langtools/test/tools/apt/Compile/Rounds.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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. - */ - - -@interface Round1{} - -@interface Round2{} - -@interface Round3{} - -@interface Round4{} - -@interface Round5{} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Compile/StaticApf.java --- a/langtools/test/tools/apt/Compile/StaticApf.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 com.sun.mirror.apt.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - -import java.util.Collection; -import java.util.Set; -import java.util.Arrays; - -import static java.util.Collections.*; - -/* - * This class is used to test the ability to store static state across - * apt rounds. - */ -public class StaticApf implements AnnotationProcessorFactory { - static int round = -1; - - // Process any set of annotations - private static final Collection supportedAnnotations - = unmodifiableCollection(Arrays.asList("*")); - - // No supported options - private static final Collection supportedOptions = emptySet(); - - public Collection supportedAnnotationTypes() { - return supportedAnnotations; - } - - public Collection supportedOptions() { - return supportedOptions; - } - - public AnnotationProcessor getProcessorFor(Set atds, - AnnotationProcessorEnvironment env) { - return new StaticAp(env); - } - - private static class StaticAp implements AnnotationProcessor { - private final AnnotationProcessorEnvironment env; - StaticAp(AnnotationProcessorEnvironment env) { - this.env = env; - } - - public void process() { - int size = env.getSpecifiedTypeDeclarations().size(); - - try { - round++; - switch (size) { - case 0: - if (round == 0) { - env.getFiler().createSourceFile("Round1").print("class Round1 {}"); - } else - throw new RuntimeException("Got " + size + " decl's in round " + round); - break; - - case 1: - if (round == 1) { - env.getFiler().createSourceFile("AhOne").print("class AhOne {}"); - env.getFiler().createSourceFile("AndAhTwo").print("class AndAhTwo {}"); - env.getFiler().createClassFile("Foo"); - } else - throw new RuntimeException("Got " + size + " decl's in round " + round); - break; - case 2: - if (round != 2) { - throw new RuntimeException("Got " + size + " decl's in round " + round); - } - break; - } - - } catch (java.io.IOException ioe) { - throw new RuntimeException(); - } - - } - - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Compile/WarnAPF.java --- a/langtools/test/tools/apt/Compile/WarnAPF.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 com.sun.mirror.apt.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - -import java.util.Collection; -import java.util.Set; -import java.util.Map; -import java.util.Arrays; - - -import static java.util.Collections.*; -import static com.sun.mirror.util.DeclarationVisitors.*; - -/* - * Construct a processor that does nothing but report a warning. - */ -public class WarnAPF implements AnnotationProcessorFactory { - static class WarnAP implements AnnotationProcessor { - AnnotationProcessorEnvironment env; - WarnAP(AnnotationProcessorEnvironment env) { - this.env = env; - } - - public void process() { - Messager messager = env.getMessager(); - messager.printWarning("Beware the ides of March!"); - - for(TypeDeclaration typeDecl : env.getSpecifiedTypeDeclarations()) { - messager.printNotice(typeDecl.getPosition(), "You are about to be warned"); - messager.printWarning(typeDecl.getPosition(), "Strange class name"); - - for(AnnotationMirror annotMirror : typeDecl.getAnnotationMirrors()) { - messager.printNotice("MIRROR " + annotMirror.getPosition().toString()); - - Map map = - annotMirror.getElementValues(); - if (map.keySet().size() > 0) - for(AnnotationTypeElementDeclaration key : map.keySet() ) { - AnnotationValue annotValue = map.get(key); - Object o = annotValue.getValue(); - // asserting getPosition is non-null - messager.printNotice("VALUE " + annotValue.getPosition().toString()); - } - else { - Collection ateds = - annotMirror.getAnnotationType().getDeclaration().getMethods(); - for(AnnotationTypeElementDeclaration ated : ateds ) { - AnnotationValue annotValue = ated.getDefaultValue(); - Object o = annotValue.getValue(); - messager.printNotice("VALUE " + "HelloAnnotation.java:5"); - } - } - } - } - } - } - - static final Collection supportedTypes; - static { - String types[] = {"*"}; - supportedTypes = unmodifiableCollection(Arrays.asList(types)); - } - public Collection supportedAnnotationTypes() {return supportedTypes;} - - static final Collection supportedOptions; - static { - String options[] = {""}; - supportedOptions = unmodifiableCollection(Arrays.asList(options)); - } - public Collection supportedOptions() {return supportedOptions;} - - public AnnotationProcessor getProcessorFor(Set atds, - AnnotationProcessorEnvironment env) { - return new WarnAP(env); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Compile/WrappedStaticApf.java --- a/langtools/test/tools/apt/Compile/WrappedStaticApf.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 com.sun.mirror.apt.AnnotationProcessorFactory; - -/* - * Pass an instantiated StaticApf object to the - * com.sun.tools.apt.Main.process entry point. - */ -public class WrappedStaticApf { - public static void main(String argv[]) { - AnnotationProcessorFactory factory = new StaticApf(); - System.exit(com.sun.tools.apt.Main.process(factory, argv)); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Compile/compile.sh --- a/langtools/test/tools/apt/Compile/compile.sh Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,533 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute 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 5033855 4990902 5023880 5043516 5048534 5048535 5041279 5048539 5067261 5068145 5023881 4996963 5095716 6191667 6433634 -# @run shell ../verifyVariables.sh -# @build ErrorAPF -# @build WarnAPF -# @build StaticApf -# @build ClassDeclApf -# @build ClassDeclApf2 -# @build Rounds -# @build Round1Apf Round2Apf Round3Apf Round4Apf -# @build WrappedStaticApf -# @run shell compile.sh -# @summary Test simple usages of apt, including delegating to javac -# @author Joseph D. Darcy - -# If the file *does* exist, exit with an error -TestNoFile() { - if [ -f ${1} ]; then - printf "%s\n" "File ${1} found." - exit 1 - fi -} - -# If the file does not exist, exit with an error -TestFile() { - if [ ! -f ${1} ]; then - printf "%s\n" "File ${1} not found." - exit 1 - fi -} - - -OS=`uname -s`; -case "${OS}" in - Windows* ) - SEP=";" - ;; - - CYGWIN* ) - DIFFOPTS="--strip-trailing-cr" - SEP=";" - ;; - - * ) - SEP=":" - ;; -esac - - -APT="${TESTJAVA}/bin/apt ${TESTTOOLVMOPTS} -XDsuppress-tool-api-removal-message " -JAVA="${TESTJAVA}/bin/java ${TESTVMOPTS} " -JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} " - -unset CLASSPATH - - -# --------------------------------------------------------------- -echo "Verify that source 1.6 is not supported -rm -f HelloWorld.class - -printf "%s\n" "-source 1.6" > options0 -printf "%s\n" "${TESTSRC}/HelloWorld.java" >> options0 -${APT} @options0 - -RESULT=$? -case "$RESULT" in - 0 ) - echo "FAILED: accepted source 1.6" - exit 1 - ;; -esac - -TestNoFile "HelloWorld.class" - -# --------------------------------------------------------------- - -echo "Verify that target 1.6 is not supported -rm -f HelloWorld.class - -printf "%s\n" "-target 1.6" > options00 -printf "%s\n" "${TESTSRC}/HelloWorld.java" >> options00 -${APT} @options00 - -RESULT=$? -case "$RESULT" in - 0 ) - echo "FAILED: accepted target 1.6" - exit 1 - ;; -esac - -TestNoFile "HelloWorld.class" - -# --------------------------------------------------------------- - -echo "Testing javac pass-through with -A in options file" -rm -f HelloWorld.class - -printf "%s\n" "-A" > options1 -printf "%s\n" "-d ." >> options1 -printf "%s\n" "${TESTSRC}/HelloWorld.java" >> options1 -${APT} @options1 - -RESULT=$? -case "$RESULT" in - 0 ) - ;; - - * ) - echo "FAILED: javac with -A in options file did not compile" - exit 1 -esac -TestFile "HelloWorld.class" - - -# --------------------------------------------------------------- - -echo "Verifying reporting an error will prevent compilation" -rm -f HelloWorld.class -if [ ! -f HelloWorld.java ]; then - cp ${TESTSRC}/HelloWorld.java . -fi - - -printf "%s\n" "-factory ErrorAPF" > options2 -printf "%s\n" "-d ." >> options2 -printf "%s\n" "-cp ${TESTCLASSES}" >> options2 -printf "%s\n" "HelloWorld.java" >> options2 -${APT} @options2 2> output - -TestNoFile "HelloWorld.class" - -diff ${DIFFOPTS} output ${TESTSRC}/golden.txt - -RESULT=$? -case "$RESULT" in - 0 ) - ;; - - * ) - echo "FAILED: did not record expected error messages" - exit 1 -esac - - - -# --------------------------------------------------------------- - -echo "Verifying reporting a warning *won't* prevent compilation" - -rm -f HelloAnnotation.class -if [ ! -f HelloAnnotation.java ]; then - cp ${TESTSRC}/HelloAnnotation.java . -fi - - -printf "%s\n" "-factory WarnAPF" > options3 -printf "%s\n" "-d ." >> options3 -printf "%s\n" "-cp ${TESTCLASSES}" >> options3 -printf "%s\n" "HelloAnnotation.java" >> options3 -${APT} @options3 2> output - -diff ${DIFFOPTS} output ${TESTSRC}/goldenWarn.txt - -RESULT=$? -case "$RESULT" in - 0 ) - ;; - - * ) - echo "FAILED: did not record expected warning messages" - exit 1 -esac - -TestFile "HelloAnnotation.class" - -# --------------------------------------------------------------- - -echo "Verifying static state is available across apt rounds; -factory, -cp" - -mkdir -p ./src -mkdir -p ./class - -rm -Rf ./src/* -rm -Rf ./class/* - -printf "%s\n" "-factory StaticApf" > options4 -printf "%s\n" "-s ./src" >> options4 -printf "%s\n" "-d ./class" >> options4 -printf "%s\n" "-cp ${TESTCLASSES}" >> options4 -# printf "%s\n" "-XPrintAptRounds" >> options4 -${APT} @options4 - -TestFile "./class/AndAhTwo.class" - -# --------------------------------------------------------------- - -echo "Verifying static state is available across apt rounds; -factory, -factorypath" - -rm -Rf ./src/* -rm -Rf ./class/* - -printf "%s\n" "-factory StaticApf" > options5 -printf "%s\n" "-s ./src" >> options5 -printf "%s\n" "-d ./class" >> options5 -printf "%s\n" "-factorypath ${TESTCLASSES}" >> options5 -# printf "%s\n" "-XPrintAptRounds" >> options5 -${APT} @options5 - -TestFile "./class/AndAhTwo.class" - -# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -# Create jar file for StaticApf -JAR="${TESTJAVA}/bin/jar " -mkdir -p META-INF/services -cp ${TESTSRC}/servicesStaticApf META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory -cp ${TESTCLASSES}/StaticApf*.class . -${JAR} cf0 staticApf.jar StaticApf*.class META-INF - -# --------------------------------------------------------------- - -echo "Verifying static state is available across apt rounds; -cp" - -rm -Rf ./src/* -rm -Rf ./class/* - -printf "%s\n" "-cp staticApf.jar" > options6 -printf "%s\n" "-s ./src" >> options6 -printf "%s\n" "-d ./class" >> options6 -printf "%s\n" "-XPrintAptRounds" >> options6 -${APT} @options6 - -TestFile "./class/AndAhTwo.class" - -# --------------------------------------------------------------- - -echo "Verifying static state is available across apt rounds; -factorypath" - -rm -Rf ./src/* -rm -Rf ./class/* - -printf "%s\n" "-factorypath staticApf.jar" > options7 -printf "%s\n" "-s ./src" >> options7 -printf "%s\n" "-d ./class" >> options7 -printf "%s\n" "-XPrintAptRounds" >> options7 -${APT} @options7 - -TestFile "./class/AndAhTwo.class" - -# --------------------------------------------------------------- - -echo "Verifying -XclassesAsDecls handles class files properly" - -rm -Rf ./src/* -rm -Rf ./class/* - -mkdir -p ./tmp/classes - -${JAVAC} -d ./tmp/classes ${TESTSRC}/src/Round1Class.java ${TESTSRC}/src/AhOneClass.java ${TESTSRC}/src/AndAhTwoClass.java - -RESULT=$? -case "$RESULT" in - 0 ) - ;; - - * ) - echo "FAILED: javac failed to succesfully compile." - exit 1 -esac - -printf "%s\n" "-factorypath ${TESTCLASSES}" > options7a -printf "%s\n" "-factory ClassDeclApf" >> options7a -printf "%s\n" "-s ./src" >> options7a -printf "%s\n" "-d ./class" >> options7a -printf "%s\n" "-XPrintAptRounds" >> options7a -printf "%s\n" "-XclassesAsDecls" >> options7a -${APT} @options7a - -TestFile "./class/AndAhTwoClass.class" - -# --------------------------------------------------------------- - -echo "Verifying -XclassesAsDecls works with command-line arguments" - -rm -Rf ./src/* -rm -Rf ./class/* -rm -Rf ./tmp/classes - -mkdir -p ./tmp/classes - -${JAVAC} -d ./tmp/classes ${TESTSRC}/src/Round1Class.java ${TESTSRC}/src/AndAhTwoClass.java - -RESULT=$? -case "$RESULT" in - 0 ) - ;; - - * ) - echo "FAILED: javac failed to succesfully compile." - exit 1 -esac - -printf "%s\n" "-factorypath ${TESTCLASSES}" > options7b -printf "%s\n" "-factory ClassDeclApf2" >> options7b -printf "%s\n" "-XPrintAptRounds" >> options7b -printf "%s\n" "-XclassesAsDecls" >> options7b -printf "%s\n" "-cp ${TESTCLASSES}" >> options7b -printf "%s\n" "ErrorAPF" >> options7b -printf "%s\n" "WarnAPF" >> options7b -printf "%s\n" "-s ./src" >> options7b -printf "%s\n" "-d ./class" >> options7b -printf "%s\n" "ClassDeclApf" >> options7b -${APT} @options7b - -RESULT=$? -case "$RESULT" in - 0 ) - ;; - - * ) - echo "FAILED: apt exited with an error code." - exit 1 -esac - -TestFile "./class/AndAhTwoClass.class" -TestFile "./class/AhOne.class" - -# --------------------------------------------------------------- - -echo "Verifying -XclassesAsDecls works with all source files" - -rm -Rf ./src/* -rm -Rf ./class/* -rm -Rf ./tmp/classes - -mkdir -p ./tmp/classes - -${JAVAC} -d ./tmp/classes ${TESTSRC}/src/Round1Class.java ${TESTSRC}/src/AndAhTwoClass.java - -RESULT=$? -case "$RESULT" in - 0 ) - ;; - - * ) - echo "FAILED: javac failed to succesfully compile." - exit 1 -esac - -printf "%s\n" "-factorypath ${TESTCLASSES}" > options7c -printf "%s\n" "-factory ClassDeclApf2" >> options7c -printf "%s\n" "-s ./src" >> options7c -printf "%s\n" "-d ./class" >> options7c -printf "%s\n" "-sourcepath ${TESTSRC}" >> options7c -printf "%s\n" "${TESTSRC}/HelloAnnotation.java" >> options7c -printf "%s\n" "${TESTSRC}/HelloWorld.java" >> options7c -printf "%s\n" "${TESTSRC}/Dummy1.java" >> options7c -printf "%s\n" "-XPrintAptRounds" >> options7c -printf "%s\n" "-XclassesAsDecls" >> options7c -printf "%s\n" "-cp ${TESTCLASSES}" >> options7c -${APT} @options7c - -RESULT=$? -case "$RESULT" in - 0 ) - ;; - - * ) - echo "FAILED: apt exited with an error code." - exit 1 -esac - -TestFile "./class/AndAhTwoClass.class" -TestFile "./class/AhOne.class" -TestFile "./class/HelloWorld.class" - -# --------------------------------------------------------------- - -echo "Verifying -XclassesAsDecls works with mixed class and source files" - -rm -Rf ./src/* -rm -Rf ./class/* -rm -Rf ./tmp/classes - -mkdir -p ./tmp/classes - -${JAVAC} -d ./tmp/classes ${TESTSRC}/src/Round1Class.java ${TESTSRC}/src/AndAhTwoClass.java - -RESULT=$? -case "$RESULT" in - 0 ) - ;; - - * ) - echo "FAILED: javac failed to succesfully compile." - exit 1 -esac - -printf "%s\n" "-factorypath ${TESTCLASSES}" > options7d -printf "%s\n" "-factory ClassDeclApf2" >> options7d -printf "%s\n" "-s ./src" >> options7d -printf "%s\n" "-XclassesAsDecls" >> options7d -printf "%s\n" "ClassDeclApf" >> options7d -printf "%s\n" "-d ./class" >> options7d -printf "%s\n" "ErrorAPF" >> options7d -printf "%s\n" "-XPrintAptRounds" >> options7d -printf "%s\n" "${TESTSRC}/HelloWorld.java" >> options7d -printf "%s\n" "-cp ${TESTCLASSES}" >> options7d -${APT} @options7d - -RESULT=$? -case "$RESULT" in - 0 ) - ;; - - * ) - echo "FAILED: apt exited with an error code." - exit 1 -esac - -TestFile "./class/AndAhTwoClass.class" -TestFile "./class/AhOne.class" -TestFile "./class/HelloWorld.class" - -# --------------------------------------------------------------- - -echo "Testing productive factories are called on subsequent rounds" - -rm -Rf ./src/* -rm -Rf ./class/* - -rm -Rf META-INF/services/* -cp ${TESTSRC}/servicesRound1 META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory -cp ${TESTCLASSES}/Round1Apf*.class . -${JAR} cf0 round1Apf.jar Round1Apf*.class META-INF - -rm -Rf META-INF/services/* -cp ${TESTSRC}/servicesRound2 META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory -cp ${TESTCLASSES}/Round2Apf*.class . -${JAR} cf0 round2Apf.jar Round2Apf*.class META-INF - -rm -Rf META-INF/services/* -cp ${TESTSRC}/servicesRound3 META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory -cp ${TESTCLASSES}/Round3Apf*.class . -${JAR} cf0 round3Apf.jar Round3Apf*.class META-INF - -rm -Rf META-INF/services/* -cp ${TESTSRC}/servicesRound4 META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory -cp ${TESTCLASSES}/Round4Apf*.class . -${JAR} cf0 round4Apf.jar Round4Apf*.class META-INF - -cp ${TESTCLASSES}/Round?.class . -${JAR} cf0 rounds.jar Round?.class - -# cleanup file to prevent accidental discovery in current directory -rm -Rf META-INF/services/* - -printf "%s\n" "-factorypath round1Apf.jar${SEP}round2Apf.jar${SEP}round3Apf.jar${SEP}round4Apf.jar" > options8 -printf "%s\n" "-classpath rounds.jar" >> options8 -printf "%s\n" "-s ./src" >> options8 -printf "%s\n" "-d ./class" >> options8 -#printf "%s\n" "-XPrintFactoryInfo" >> options8 -#printf "%s\n" "-XPrintAptRounds" >> options8 -printf "%s\n" "${TESTSRC}/Dummy1.java" >> options8 -${APT} @options8 > multiRoundOutput 2> multiRoundError - -diff ${DIFFOPTS} multiRoundOutput ${TESTSRC}/goldenFactory.txt - -RESULT=$? -case "$RESULT" in - 0 ) - ;; - - * ) - echo "FAILED: unexpected factory state" - exit 1 -esac - -TestFile "./class/Dummy5.class" - -# --------------------------------------------------------------- - -echo "Verifying static state with programmatic apt entry; no factory options" -rm -Rf ./src/* -rm -Rf ./class/* -${JAVA} -cp ${TESTJAVA}/lib/tools.jar${SEP}${TESTCLASSES} WrappedStaticApf -s ./src -d ./class -XPrintAptRounds -TestFile "./class/AndAhTwo.class" - -echo "Verifying static state with programmatic apt entry; -factory" -rm -Rf ./src/* -rm -Rf ./class/* -${JAVA} -cp ${TESTJAVA}/lib/tools.jar${SEP}${TESTCLASSES} WrappedStaticApf -factory ErrorAPF -s ./src -d ./class -XPrintAptRounds -TestFile "./class/AndAhTwo.class" - -echo "Verifying static state with programmatic apt entry; -factorypath" -rm -Rf ./src/* -rm -Rf ./class/* -${JAVA} -cp ${TESTJAVA}/lib/tools.jar${SEP}${TESTCLASSES} WrappedStaticApf -factorypath round1Apf.jar -s ./src -d ./class -XPrintAptRounds -TestFile "./class/AndAhTwo.class" - -echo "Verifying static state with programmatic apt entry; -factory and -factorypath" -rm -Rf ./src/* -rm -Rf ./class/* -${JAVA} -cp ${TESTJAVA}/lib/tools.jar${SEP}${TESTCLASSES} WrappedStaticApf -factorypath round1Apf.jar -factory Round1Apf -s ./src -d ./class -XPrintAptRounds -TestFile "./class/AndAhTwo.class" - -exit 0 diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Compile/golden.txt --- a/langtools/test/tools/apt/Compile/golden.txt Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -error: It's a mad, mad, mad, mad world -error: Something wicked this way comes -HelloWorld.java:2: error: Boring class name -public class HelloWorld { - ^ -3 errors diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Compile/goldenFactory.txt --- a/langtools/test/tools/apt/Compile/goldenFactory.txt Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -Round1Apf: 1 - [final round: false, error raised: false, source files created: true, class files created: true] -Round1Apf: 1 complete -Round1Apf: 2 -Round2Apf: 1 - [final round: false, error raised: false, source files created: true, class files created: true] -Round1Apf: 2 complete -Round1Apf: 3 -Round2Apf: 2 -Round3Apf: 1 - [final round: false, error raised: false, source files created: true, class files created: false] -Round1Apf: 3 complete -Round1Apf: 4 -Round2Apf: 3 -Round3Apf: 2 -Round4Apf: 1 - [final round: false, error raised: false, source files created: true, class files created: false] -Round1Apf: 4 complete - [final round: false, error raised: false, source files created: true, class files created: false] -Round4Apf: 1 complete -Round1Apf: 5 -Round2Apf: 4 -Round3Apf: 3 -Round4Apf: 2 - [final round: true, error raised: false, source files created: false, class files created: false] -Round1Apf: 5 complete - [final round: true, error raised: false, source files created: false, class files created: false] -Round4Apf: 2 complete -Valediction diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Compile/goldenWarn.txt --- a/langtools/test/tools/apt/Compile/goldenWarn.txt Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -warning: Beware the ides of March! -HelloAnnotation.java:6: Note: You are about to be warned -@interface HelloAnnotation { - ^ -HelloAnnotation.java:6: warning: Strange class name -@interface HelloAnnotation { - ^ -Note: MIRROR HelloAnnotation.java:6 -Note: VALUE HelloAnnotation.java:6 -Note: MIRROR HelloAnnotation.java:6 -Note: VALUE HelloAnnotation.java:6 -Note: MIRROR HelloAnnotation.java:6 -Note: VALUE HelloAnnotation.java:5 -2 warnings diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Compile/servicesRound1 --- a/langtools/test/tools/apt/Compile/servicesRound1 Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -Round1Apf diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Compile/servicesRound2 --- a/langtools/test/tools/apt/Compile/servicesRound2 Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -Round2Apf diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Compile/servicesRound3 --- a/langtools/test/tools/apt/Compile/servicesRound3 Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -Round3Apf diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Compile/servicesRound4 --- a/langtools/test/tools/apt/Compile/servicesRound4 Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -Round4Apf diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Compile/servicesStaticApf --- a/langtools/test/tools/apt/Compile/servicesStaticApf Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -StaticApf diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Compile/src/AhOneClass.java --- a/langtools/test/tools/apt/Compile/src/AhOneClass.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -public class AhOneClass {} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Compile/src/AndAhTwoClass.java --- a/langtools/test/tools/apt/Compile/src/AndAhTwoClass.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -public class AndAhTwoClass {} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Compile/src/Round1Class.java --- a/langtools/test/tools/apt/Compile/src/Round1Class.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -public class Round1Class {} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Discovery/Dee.java --- a/langtools/test/tools/apt/Discovery/Dee.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 com.sun.mirror.apt.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - -import java.util.Collection; -import java.util.Set; -import java.util.Arrays; -import java.util.Collections; - -public class Dee implements AnnotationProcessorFactory { - static class DeeProc implements AnnotationProcessor { - DeeProc(AnnotationProcessorEnvironment ape) {} - - public void process() { - return; - } - } - - static Collection supportedTypes; - static { - String types[] = {"dum"}; - supportedTypes = Collections.unmodifiableCollection(Arrays.asList(types)); - } - - static Collection supportedOptions; - static { - String options[] = {""}; - supportedOptions = Collections.unmodifiableCollection(Arrays.asList(options)); - } - - public Collection supportedOptions() { - return supportedOptions; - } - - public Collection supportedAnnotationTypes() { - return supportedTypes; - } - - /* - * Return the same processor independent of what annotations are - * present, if any. - */ - public AnnotationProcessor getProcessorFor(Set atds, - AnnotationProcessorEnvironment env) { - return new DeeProc(env); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Discovery/Dum.java --- a/langtools/test/tools/apt/Discovery/Dum.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 com.sun.mirror.apt.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - -import java.util.Collection; -import java.util.Set; -import java.util.Arrays; -import java.util.Collections; - -public class Dum implements AnnotationProcessorFactory { - static class DumProc implements AnnotationProcessor { - DumProc(AnnotationProcessorEnvironment ape) {} - - public void process() { - return; - } - } - - static Collection supportedTypes; - static { - String types[] = {"dee"}; - supportedTypes = Collections.unmodifiableCollection(Arrays.asList(types)); - } - - static Collection supportedOptions; - static { - String options[] = {""}; - supportedOptions = Collections.unmodifiableCollection(Arrays.asList(options)); - } - - public Collection supportedOptions() { - return supportedOptions; - } - - public Collection supportedAnnotationTypes() { - return supportedTypes; - } - - /* - * Return the same processor independent of what annotations are - * present, if any. - */ - public AnnotationProcessor getProcessorFor(Set atds, - AnnotationProcessorEnvironment env) { - return new DumProc(env); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Discovery/Empty.java --- a/langtools/test/tools/apt/Discovery/Empty.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -public class Empty { -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Discovery/PhantomTouch.java --- a/langtools/test/tools/apt/Discovery/PhantomTouch.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 com.sun.mirror.apt.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - -import java.util.Collection; -import java.util.Set; -import java.util.Arrays; -import java.util.Collections; -import java.io.*; - -public class PhantomTouch implements AnnotationProcessorFactory { - static class PhantomTouchProc implements AnnotationProcessor { - AnnotationProcessorEnvironment ape; - PhantomTouchProc(AnnotationProcessorEnvironment ape) { - this.ape = ape; - } - - public void process() { - // Only run the processor on the initial apt invocation - if (ape.getSpecifiedTypeDeclarations().size() == 0) { - boolean result; - try { - // Create temporary file - java.io.File f = new java.io.File("touched"); - result = f.createNewFile(); - - if (result) { - // Create new source file - PrintWriter pw = ape.getFiler().createSourceFile("HelloWorld"); - pw.println("public class HelloWorld {"); - pw.println(" // Phantom hello world"); - pw.println(" public static void main(String argv[]) {"); - pw.println(" System.out.println(\"Hello World\");"); - pw.println(" }"); - pw.println("}"); - } else - throw new RuntimeException("touched file already exists!"); - } catch (java.io.IOException e) { - result = false; - } - } - } - } - - static final Collection supportedOptions; - static final Collection supportedTypes; - - static { - String options[] = {""}; - supportedOptions = Collections.unmodifiableCollection(Arrays.asList(options)); - - String types[] = {"*"}; - supportedTypes = Collections.unmodifiableCollection(Arrays.asList(types)); - } - - public Collection supportedAnnotationTypes() {return supportedTypes;} - public Collection supportedOptions() {return supportedOptions;} - - - /* - * Return the same processor independent of what annotations are - * present, if any. - */ - public AnnotationProcessor getProcessorFor(Set atds, - AnnotationProcessorEnvironment env) { - return new PhantomTouchProc(env); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Discovery/PhantomUpdate.java --- a/langtools/test/tools/apt/Discovery/PhantomUpdate.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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. - */ - - -/* - * JSR 269 annotation processor to test combined apt + JSR 269 - * annotation processor file generation and option passing. - */ - -import javax.annotation.processing.*; -import static javax.lang.model.SourceVersion.*; -import javax.lang.model.element.*; -import javax.lang.model.type.*; -import javax.lang.model.util.*; -import java.util.*; -import java.io.*; - -@SupportedAnnotationTypes("*") // Process all annotations -@SupportedSourceVersion(RELEASE_6) -public class PhantomUpdate extends AbstractProcessor { - boolean firstRound = true; - - public boolean process(Set annotations, - RoundEnvironment roundEnv) { - if (firstRound) { - verifyOptions(); - printGoodbyeWorld(); - firstRound = false; - } - return true; // Claim all annotations - } - - /* - * Expected options are "foo" and "bar=baz". - */ - private void verifyOptions() { - Map actualOptions = processingEnv.getOptions(); - Map expectedOptions = new LinkedHashMap(); - expectedOptions.put("foo", null); - expectedOptions.put("bar", "baz"); - - if (!actualOptions.equals(expectedOptions) ) { - System.err.println("Expected options " + expectedOptions + - "\n but got " + actualOptions); - throw new RuntimeException("Options mismatch"); - } - } - - private void printGoodbyeWorld() { - try { - // Create new source file - PrintWriter pw = new PrintWriter(processingEnv.getFiler().createSourceFile("GoodbyeWorld").openWriter()); - pw.println("public class GoodbyeWorld {"); - pw.println(" // PhantomUpdate Goodbye world"); - pw.println(" public static void main(String argv[]) {"); - pw.println(" System.out.println(\"Goodbye World\");"); - pw.println(" }"); - pw.println("}"); - pw.close(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Discovery/Touch.java --- a/langtools/test/tools/apt/Discovery/Touch.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 com.sun.mirror.apt.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - -import java.util.Collection; -import java.util.Set; -import java.util.Arrays; -import java.util.Collections; -import java.io.*; - -public class Touch implements AnnotationProcessorFactory { - static class TouchProc implements AnnotationProcessor { - AnnotationProcessorEnvironment ape; - TouchProc(AnnotationProcessorEnvironment ape) { - this.ape = ape; - } - - public void process() { - boolean result; - // Only run the processor on the initial apt invocation - Collection tdecls = ape.getSpecifiedTypeDeclarations(); - - if (tdecls.size() == 1) { - for(TypeDeclaration decl: tdecls) { - if (! decl.getSimpleName().equals("Touch") ) - return; - } - - try { - // Create temporary file - java.io.File f = new java.io.File("touched"); - result = f.createNewFile(); - - - Filer filer = ape.getFiler(); - - // Create new source file - PrintWriter pw = filer.createSourceFile("HelloWorld"); - pw.println("public class HelloWorld {"); - pw.println(" public static void main(String argv[]) {"); - pw.println(" System.out.println(\"Hello World\");"); - pw.println(" }"); - pw.println("}"); - - // Create new class file and copy Empty.class - OutputStream os = filer.createClassFile("Empty"); - FileInputStream fis = new FileInputStream("Empty.clazz"); - int datum; - while((datum = fis.read()) != -1) - os.write(datum); - - } catch (java.io.IOException e) { - result = false; - } - if (!result) - throw new RuntimeException("touched file already exists or other error"); - } - - } - - } - - static Collection supportedTypes; - static { - String types[] = {"*"}; - supportedTypes = Collections.unmodifiableCollection(Arrays.asList(types)); - } - - static Collection supportedOptions; - static { - String options[] = {""}; - supportedOptions = Collections.unmodifiableCollection(Arrays.asList(options)); - } - - public Collection supportedOptions() { - return supportedOptions; - } - - public Collection supportedAnnotationTypes() { - return supportedTypes; - } - - /* - * Return the same processor independent of what annotations are - * present, if any. - */ - public AnnotationProcessor getProcessorFor(Set atds, - AnnotationProcessorEnvironment env) { - return new TouchProc(env); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Discovery/discovery.sh --- a/langtools/test/tools/apt/Discovery/discovery.sh Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,410 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute 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 4984412 4985113 4908512 4990905 4998007 4998218 5002340 5023882 6370261 6363481 -# @run shell ../verifyVariables.sh -# @compile PhantomUpdate.java -# @run shell discovery.sh -# @summary Test consistency of annotation discovery -# @author Joseph D. Darcy - - -# If the file does not exist, exit with an error -TestFile() { - if [ ! -f ${1} ]; then - printf "%s\n" "File ${1} not found." - exit 1 - fi -} - -OS=`uname -s`; -case "${OS}" in - Windows* | CYGWIN* ) - SEP=";" - ;; - - * ) - SEP=":" - ;; -esac - -TOOLSJAR=${TESTJAVA}/lib/tools.jar - -OLDCP=${CLASSPATH} - -JARCP=tweedle.jar${SEP}touch.jar${SEP}${TOOLSJAR} -SOURCEP=${TESTSRC} -FULLCP=${JARCP}${SEP}${SOURCEP} -BADCP=tweedle.jar${SEP}badTouch.jar${SEP}${TOOLSJAR} - -# Construct path to apt executable -APT="${TESTJAVA}/bin/apt ${TESTTOOLVMOPTS} " - - -# Construct path to apt executable, no compilation -APTNC="${APT} -nocompile " - - -printf "%s\n" "APT = ${APT}" - -# Construct path to javac executable -JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TOOLSJAR} -d . " -JAR="${TESTJAVA}/bin/jar " - -$JAVAC ${TESTSRC}/Dee.java ${TESTSRC}/Dum.java ${TESTSRC}/Touch.java ${TESTSRC}/PhantomTouch.java ${TESTSRC}/Empty.java -RESULT=$? - -case "${RESULT}" in - 0 ) - ;; - - * ) - echo "Compilation failed." - exit 1 -esac - -mv Empty.class Empty.clazz - -echo "Making services directory and copying services information." -mkdir -p META-INF/services -mkdir -p phantom - -rm -f touch.jar -rm -f badTouch.jar - -cp ${TESTSRC}/servicesTweedle META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory - -${JAR} cf0 tweedle.jar Dee*.class Dum*.class META-INF - -rm -f META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory -cp ${TESTSRC}/servicesTouch ./META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory - -${JAR} cf0 touch.jar Touch*.class META-INF - -rm -f META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory -cp ${TESTSRC}/servicesPhantomTouch ./META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory - -${JAR} cf0 phantom/phantom.jar PhantomTouch*.class META-INF - -# cleanup file to prevent accidental discovery in current directory -rm -f META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory - -# Jar files created; verify right output file is touched - -#--------------------------------------------------------- - -# Test different combinations of classpath, sourcepath, and -# destination directories - - -# -# Classpath on commandline; no output directories -# - -rm -f touched -rm -f HelloWorld.java -rm -f Empty.class - -unset CLASSPATH -printf "%s\n" "-classpath ${JARCP}" > options1 -printf "%s\n" "-sourcepath ${SOURCEP}" >> options1 -printf "%s\n" "${TESTSRC}/Touch.java" >> options1 - -${APTNC} @options1 - -echo "Testing case 1" -TestFile "touched" -TestFile "HelloWorld.java" -TestFile "Empty.class" - -# -# Class path set through environment variable -# - -rm -f touched -rm -f HelloWorld.java -rm -f Empty.class - -unset CLASSPATH -CLASSPATH=${JARCP} -export CLASSPATH -printf "%s\n" "-sourcepath ${SOURCEP}" > options2 -printf "%s\n" "${TESTSRC}/Touch.java" >> options2 - -${APTNC} @options2 - -echo "Testing case 2" -TestFile "touched" -TestFile "HelloWorld.java" -TestFile "Empty.class" - -# -# No explicit source path -# - -rm -f touched -rm -f HelloWorld.java -rm -f Empty.class - -unset CLASSPATH -CLASSPATH=${FULLCP} -export CLASSPATH -printf "%s\n" "${TESTSRC}/Touch.java" > options3 - -${APTNC} @options3 - -echo "Testing case 3" -TestFile "touched" -TestFile "HelloWorld.java" -TestFile "Empty.class" - - -# -# Classpath on commandline; class output directory -# - -rm -f touched -rm -f HelloWorld.java -rm -Rf classes/Empty.class - -unset CLASSPATH -printf "%s\n" "-classpath ${JARCP}" > options4 -printf "%s\n" "-sourcepath ${SOURCEP}" >> options4 -printf "%s\n" "-d classes" >> options4 -printf "%s\n" "${TESTSRC}/Touch.java" >> options4 - -${APTNC} @options4 - -echo "Testing case 4" -TestFile "touched" -TestFile "HelloWorld.java" -TestFile "classes/Empty.class" - -# -# Classpath on commandline; source output directory -# - -rm -f touched -rm -Rf src -rm -f Empty.class - -unset CLASSPATH -printf "%s\n" "-classpath ${JARCP}" > options5 -printf "%s\n" "-sourcepath ${SOURCEP}" >> options5 -printf "%s\n" "-s src" >> options5 -printf "%s\n" "${TESTSRC}/Touch.java" >> options5 - -${APTNC} @options5 - -echo "Testing case 5" -TestFile "touched" -TestFile "src/HelloWorld.java" -TestFile "Empty.class" - - -# -# Classpath on commandline; class and source output directory -# - -rm -f touched -rm -Rf src -rm -Rf classes - -unset CLASSPATH -printf "%s\n" "-classpath ${JARCP}" > options6 -printf "%s\n" "-sourcepath ${SOURCEP}" >> options6 -printf "%s\n" "-d classes" >> options6 -printf "%s\n" "-s src" >> options6 -printf "%s\n" "${TESTSRC}/Touch.java" >> options6 - -${APTNC} @options6 - -echo "Testing case 6" -TestFile "touched" -TestFile "src/HelloWorld.java" -TestFile "classes/Empty.class" - -# -# Classpath appended to bootclasspath; no output directories -# - -rm -f touched -rm -f HelloWorld.java -rm -f Empty.class - -unset CLASSPATH -printf "%s\n" "-Xbootclasspath/a:${JARCP}" > options7 -printf "%s\n" "-classpath /dev/null" >> options7 -printf "%s\n" "${TESTSRC}/Touch.java" >> options7 - -${APTNC} @options7 - -echo "Testing case 7" -TestFile "touched" -TestFile "HelloWorld.java" -TestFile "Empty.class" - -# -# Classpath in extdirs; no output directories -# - -rm -f touched -rm -f HelloWorld.java -rm -f Empty.class - -unset CLASSPATH -printf "%s\n" "-extdirs ." > options8 -printf "%s\n" "-classpath ${TOOLSJAR}" >> options8 -printf "%s\n" "${TESTSRC}/Touch.java" >> options8 - -${APTNC} @options8 - -echo "Testing case 8" -TestFile "touched" -TestFile "HelloWorld.java" -TestFile "Empty.class" - -# -# Classpath in extdirs, take 2; no output directories -# - -rm -f touched -rm -f HelloWorld.java -rm -f Empty.class - -unset CLASSPATH -printf "%s\n" "-Djava.ext.dirs=." > options9 -printf "%s\n" "-classpath ${TOOLSJAR}" >> options9 -printf "%s\n" "${TESTSRC}/Touch.java" >> options9 - -${APTNC} @options9 - -echo "Testing case 9" -TestFile "touched" -TestFile "HelloWorld.java" -TestFile "Empty.class" - -# -# Classpath in -endorseddirs; no output directories -# - -rm -f touched -rm -f HelloWorld.java -rm -f Empty.class - -unset CLASSPATH -printf "%s\n" "-endorseddirs ." > options10 -printf "%s\n" "-classpath ${TOOLSJAR}" >> options10 -printf "%s\n" "${TESTSRC}/Touch.java" >> options10 - -${APTNC} @options10 - -echo "Testing case 10" -TestFile "touched" -TestFile "HelloWorld.java" -TestFile "Empty.class" - -# -# Testing apt invocation with no command line options -# - -rm -f touched -rm -f HelloWorld.java -rm -f Empty.class - -unset CLASSPATH -CLASSPATH=./phantom/phantom.jar -export CLASSPATH - -${APT} - -echo "Testing empty command line" -TestFile "touched" -TestFile "HelloWorld.java" - - -# -# Verify apt and JSR 269 annotation processors can be run from same -# invocation and both use the output directories -# - -rm -f touched -rm -f src/HelloWorld.java -rm -f src/GoodbyeWorld.java -rm -f classes/HelloWorld.class -rm -f classes/GoodbyeWorld.class - -unset CLASSPATH - - -printf "%s\n" "-classpath ./phantom/phantom.jar" > options11 -printf "%s\n" "-sourcepath ${SOURCEP}" >> options11 -printf "%s\n" "-factory PhantomTouch " >> options11 -printf "%s\n" "-s src" >> options11 -printf "%s\n" "-d classes" >> options11 -printf "%s\n" "-A" >> options11 -printf "%s\n" "-Afoo" >> options11 -printf "%s\n" "-Abar=baz" >> options11 -printf "%s\n" "-processorpath $TESTCLASSES" >> options11 -printf "%s\n" "-processor PhantomUpdate" >> options11 - -${APT} @options11 - -echo "Testing combined apt and JSR 269 processing" -TestFile touched -TestFile "src/HelloWorld.java" -TestFile "src/GoodbyeWorld.java" -TestFile "classes/HelloWorld.class" -TestFile "classes/GoodbyeWorld.class" - -# -# Verify running with badTouch doesn't exit successfully -# - -rm -f ./META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory -cp ${TESTSRC}/servicesBadTouch ./META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory - -${JAR} cf0 badTouch.jar Touch*.class META-INF - - -unset CLASSPATH -printf "%s\n" "-classpath ${BADCP}" > optionsBad -printf "%s\n" "-sourcepath ${SOURCEP}" >> optionsBad -printf "%s\n" "${TESTSRC}/Touch.java" >> optionsBad - -${APTNC} @optionsBad 2> /dev/null - -RESULT=$? - -case "${RESULT}" in - 0 ) - echo "Improper exit zero with bad services information." - exit 1 - ;; -esac - - -exit 0; diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Discovery/servicesBadTouch --- a/langtools/test/tools/apt/Discovery/servicesBadTouch Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -Touche diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Discovery/servicesPhantomTouch --- a/langtools/test/tools/apt/Discovery/servicesPhantomTouch Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -PhantomTouch diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Discovery/servicesTouch --- a/langtools/test/tools/apt/Discovery/servicesTouch Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -Touch diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Discovery/servicesTweedle --- a/langtools/test/tools/apt/Discovery/servicesTweedle Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -Dee -Dum diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Misc/Marked.java --- a/langtools/test/tools/apt/Misc/Marked.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -class Marked { - - @Marker - class marked1 {}; - - - class Unmarked1 {}; - - @Marker - class marked2 {}; - - - class Unmarked2 {}; - - @Marker - class marked3 {}; - - - class Unmarked3 {}; - - @Marker - class marked4 {}; - - - class Unmarked4 {}; - -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Misc/Marker.java --- a/langtools/test/tools/apt/Misc/Marker.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -public @interface Marker {} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Misc/Misc.java --- a/langtools/test/tools/apt/Misc/Misc.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 com.sun.mirror.apt.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - -import java.util.Collection; -import java.util.Set; -import java.util.HashSet; -import java.util.Map; -import java.util.Arrays; -import java.util.Collections; - -public class Misc implements AnnotationProcessorFactory { - static class MiscCheck implements AnnotationProcessor { - AnnotationProcessorEnvironment ape; - MiscCheck(AnnotationProcessorEnvironment ape) { - this.ape = ape; - } - - public void process() { - Collection decls = ape. - getDeclarationsAnnotatedWith((AnnotationTypeDeclaration) - ape.getTypeDeclaration("Marker")); - - // Should write more robust test that examines the - // annotation mirrors for the declaration in question. - for(Declaration decl: decls) { - if (!decl.getSimpleName().startsWith("marked") ) - throw new RuntimeException(); - } - } - } - - - static Collection supportedTypes; - static { - String types[] = {"*"}; - supportedTypes = Collections.unmodifiableCollection(Arrays.asList(types)); - } - - Collection supportedOptions = - Collections.unmodifiableCollection(new HashSet()); - - public Collection supportedOptions() { - return supportedOptions; - } - - public Collection supportedAnnotationTypes() { - return supportedTypes; - } - - /* - * Return the same processor independent of what annotations are - * present, if any. - */ - public AnnotationProcessor getProcessorFor(Set atds, - AnnotationProcessorEnvironment ape) { - return new MiscCheck(ape); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Misc/misc.sh --- a/langtools/test/tools/apt/Misc/misc.sh Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute 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 5007250 -# @run shell ../verifyVariables.sh -# @run shell misc.sh -# @summary Miscelleneous tests -# @author Joseph D. Darcy - -OS=`uname -s`; -case "${OS}" in - Windows* | CYGWIN* ) - SEP=";" - ;; - - * ) - SEP=":" - ;; -esac - -JARCP=misc.jar -SOURCEP=${TESTSRC} - -# Construct path to apt executable -APT="${TESTJAVA}/bin/apt ${TESTTOOLVMOPTS} -nocompile " - -printf "%s\n" "APT = ${APT}" - -# Construct path to javac executable -JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TESTJAVA}/lib/tools.jar -d . " -JAR="${TESTJAVA}/bin/jar " - -${JAVAC} ${TESTSRC}/Misc.java ${TESTSRC}/Marked.java -RESULT=$? - -case "${RESULT}" in - 0 ) - ;; - - * ) - echo "Compilation failed." - exit 1 -esac - - -echo "Making services directory and copying services information." -mkdir -p META-INF/services - -cp ${TESTSRC}/servicesMisc META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory - -${JAR} cf0 misc.jar Misc*.class META-INF - -# Jar files created; verify options properly present on both initial -# and recursive apt runs - -#--------------------------------------------------------- - -unset CLASSPATH - -printf "%s\n" "-classpath ${JARCP}" > options -printf "%s\n" "-sourcepath ${SOURCEP}" >> options -printf "%s\n" "${TESTSRC}/Marked.java" >> options - -${APT} @options - -RESULT=$? -case "${RESULT}" in - 0 ) - ;; - - * ) - echo "Problem with result" - exit 1 - ;; -esac - -exit 0; diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Misc/servicesMisc --- a/langtools/test/tools/apt/Misc/servicesMisc Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -Misc - diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Options/Marked.java --- a/langtools/test/tools/apt/Options/Marked.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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. - */ - - -@Marker -class Marked { -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Options/Marker.java --- a/langtools/test/tools/apt/Options/Marker.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -public @interface Marker {} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Options/OptionChecker.java --- a/langtools/test/tools/apt/Options/OptionChecker.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 com.sun.mirror.apt.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - -import java.util.Collection; -import java.util.Set; -import java.util.Map; -import java.util.Arrays; -import java.util.Collections; - -public class OptionChecker implements AnnotationProcessorFactory { - static class OptionCheck implements AnnotationProcessor { - AnnotationProcessorEnvironment ape; - OptionCheck(AnnotationProcessorEnvironment ape) { - this.ape = ape; - } - - public void process() { - Map options = ape.getOptions(); - if (options.containsKey("-Afoo") && - options.containsKey("-Abar") && - options.containsKey("-classpath") ) { - System.out.println("Expected options found."); - return; // All is well - } else { - System.err.println("Unexpected options values: " + options); - throw new RuntimeException(); - } - } - } - - static class HelloWorld implements AnnotationProcessor { - AnnotationProcessorEnvironment ape; - HelloWorld(AnnotationProcessorEnvironment ape) { - this.ape = ape; - } - - public void process() { - java.io.PrintWriter pw; - try { - pw = ape.getFiler().createSourceFile("HelloWorld"); - } catch (Exception e) { - throw new RuntimeException(e); - } - - pw.println("public class HelloWorld {"); - pw.println(" public static void main (String argv[]) {"); - pw.println(" System.out.println(\"Hello apt world.\");"); - pw.println(" }"); - pw.println("}"); - } - } - - - static Collection supportedTypes; - static { - String types[] = {"*"}; - supportedTypes = Collections.unmodifiableCollection(Arrays.asList(types)); - } - - static Collection supportedOptions; - static { - String options[] = {"-Afoo", "-Abar"}; - supportedOptions = Collections.unmodifiableCollection(Arrays.asList(options)); - } - - public Collection supportedOptions() { - return supportedOptions; - } - - public Collection supportedAnnotationTypes() { - return supportedTypes; - } - - /* - * Return the same processor independent of what annotations are - * present, if any. - */ - public AnnotationProcessor getProcessorFor(Set atds, - AnnotationProcessorEnvironment ape) { - - if (atds.contains(ape.getTypeDeclaration("Marker"))) { - System.out.println("Returning composite processor."); - return AnnotationProcessors.getCompositeAnnotationProcessor(new OptionCheck(ape), - new HelloWorld(ape)); - } - else { - System.out.println("Returning single processor."); - return new OptionCheck(ape); - } - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Options/options.sh --- a/langtools/test/tools/apt/Options/options.sh Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,116 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute 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 4993950 4993277 -# @run shell ../verifyVariables.sh -# @run shell options.sh -# @summary Test availabilty of command line options in processors -# @author Joseph D. Darcy - -OS=`uname -s`; -case "${OS}" in - Windows* | CYGWIN* ) - SEP=";" - ;; - - * ) - SEP=":" - ;; -esac - -JARCP=option.jar -SOURCEP=${TESTSRC} - - -# Construct path to apt executable -APT="${TESTJAVA}/bin/apt ${TESTTOOLVMOPTS} -nocompile " - -printf "%s\n" "APT = ${APT}" - -# Construct path to javac executable -JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TESTJAVA}/lib/tools.jar -d . " -JAR="${TESTJAVA}/bin/jar " - -${JAVAC} ${TESTSRC}/OptionChecker.java -RESULT=$? - -case "${RESULT}" in - 0 ) - ;; - - * ) - echo "Compilation failed." - exit 1 -esac - - -echo "Making services directory and copying services information." -mkdir -p META-INF/services - -cp ${TESTSRC}/servicesOptions META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory - -${JAR} cf0 option.jar OptionChecker*.class META-INF - -# Jar files created; verify options properly present on both initial -# and recursive apt runs - -#--------------------------------------------------------- - -unset CLASSPATH - -printf "%s\n" "-classpath ${JARCP}" > options -printf "%s\n" "-sourcepath ${SOURCEP}" >> options -printf "%s\n" "${TESTSRC}/Marked.java" >> options - -${APT} @options - -RESULT=$? -case "${RESULT}" in - 0 ) - echo "Failed to indentify missing options" - exit 1 - ;; - - * ) - ;; -esac - -printf "%s\n" "-Afoo -Abar" >> options - -${APT} @options - -RESULT=$? -case "${RESULT}" in - 0 ) - ;; - - * ) - echo "Options not found properly." - exit 1 - ;; -esac - -exit 0; diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Options/servicesOptions --- a/langtools/test/tools/apt/Options/servicesOptions Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -OptionChecker diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Scanners/Counter.java --- a/langtools/test/tools/apt/Scanners/Counter.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 com.sun.mirror.apt.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - -import java.util.Collection; -import java.util.Set; -import java.util.Arrays; - -import static java.util.Collections.*; -import static com.sun.mirror.util.DeclarationVisitors.*; - -/* - * Used to verify counts from different kinds of declaration scanners. - */ -public class Counter implements AnnotationProcessorFactory { - static class CounterProc implements AnnotationProcessor { - static class CountingVisitor extends SimpleDeclarationVisitor { - int count; - int count() { - return count; - } - - CountingVisitor() { - count = 0; - } - - public void visitDeclaration(Declaration d) { - count++; - System.out.println(d.getSimpleName()); - } - } - - AnnotationProcessorEnvironment env; - CounterProc(AnnotationProcessorEnvironment env) { - this.env = env; - } - - public void process() { - for(TypeDeclaration td: env.getSpecifiedTypeDeclarations() ) { - CountingVisitor sourceOrder = new CountingVisitor(); - CountingVisitor someOrder = new CountingVisitor(); - - System.out.println("Source Order Scanner"); - td.accept(getSourceOrderDeclarationScanner(sourceOrder, - NO_OP)); - - System.out.println("\nSome Order Scanner"); - td.accept(getDeclarationScanner(someOrder, - NO_OP)); - - if (sourceOrder.count() != someOrder.count() ) - throw new RuntimeException("Counts from different scanners don't agree"); - } - - } - } - - static Collection supportedTypes; - static { - String types[] = {"*"}; - supportedTypes = unmodifiableCollection(Arrays.asList(types)); - } - - static Collection supportedOptions; - static { - String options[] = {""}; - supportedOptions = unmodifiableCollection(Arrays.asList(options)); - } - - public Collection supportedOptions() { - return supportedOptions; - } - - public Collection supportedAnnotationTypes() { - return supportedTypes; - } - - public AnnotationProcessor getProcessorFor(Set atds, - AnnotationProcessorEnvironment env) { - return new CounterProc(env); - } - -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Scanners/MemberOrderApf.java --- a/langtools/test/tools/apt/Scanners/MemberOrderApf.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 com.sun.mirror.apt.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - -import java.util.Collection; -import java.util.Set; -import java.util.Arrays; - -import static java.util.Collections.*; -import static com.sun.mirror.util.DeclarationVisitors.*; - -/* - * The processor of this factory verifies class members are returned - * in source-code order. - */ -public class MemberOrderApf implements AnnotationProcessorFactory { - // Process any set of annotations - private static final Collection supportedAnnotations - = unmodifiableCollection(Arrays.asList("*")); - - // No supported options - private static final Collection supportedOptions = emptySet(); - - public Collection supportedAnnotationTypes() { - return supportedAnnotations; - } - - public Collection supportedOptions() { - return supportedOptions; - } - - public AnnotationProcessor getProcessorFor( - Set atds, - AnnotationProcessorEnvironment env) { - return new MemberOrderAp(env); - } - - private static class MemberOrderAp implements AnnotationProcessor { - private final AnnotationProcessorEnvironment env; - MemberOrderAp(AnnotationProcessorEnvironment env) { - this.env = env; - } - - private void verifyOrder(Collection decls) { - int count = 0; - for(Declaration decl: decls) { - VisitOrder order = decl.getAnnotation(VisitOrder.class); - if (order.value() <= count) - throw new RuntimeException("Out of order declarations"); - count = order.value(); - } - } - - public void process() { - for(TypeDeclaration td: env.getSpecifiedTypeDeclarations()) { - verifyOrder(td.getFields()); - verifyOrder(td.getMethods()); - } - } - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Scanners/Order.java --- a/langtools/test/tools/apt/Scanners/Order.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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. - */ - - - -@VisitOrder(1) -public class Order { - @VisitOrder(2) - static double d; - - @VisitOrder(3) - private Order() {} - - @VisitOrder(4) - int i; - - @VisitOrder(5) - static class InnerOrder { - @VisitOrder(6) - InnerOrder(){} - - @VisitOrder(7) - String toString() {return "";} - } - - @VisitOrder(8) - String toString() {return "";} - - @VisitOrder(9) - InnerOrder io; - - @VisitOrder(10) - String foo() {return toString();} -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Scanners/Scanner.java --- a/langtools/test/tools/apt/Scanners/Scanner.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 com.sun.mirror.apt.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - -import java.util.Collection; -import java.util.Set; -import java.util.Map; -import java.util.Arrays; -import java.util.Collections; - - -public class Scanner implements AnnotationProcessorFactory { - static class ScannerProc implements AnnotationProcessor { - AnnotationProcessorEnvironment env; - ScannerProc(AnnotationProcessorEnvironment env) { - this.env = env; - } - - static class CountingVisitor extends SimpleDeclarationVisitor { - int count; - CountingVisitor() { - count = 0; - } - - public void visitDeclaration(Declaration d) { - count++; - - Collection ams = d.getAnnotationMirrors(); - if (ams == null) - throw new RuntimeException("Declaration " + d + - " not annotated with visit order."); - else { - if (ams.size() != 1) - throw new RuntimeException("Declaration " + d + - " has wrong number of declarations."); - else { - for(AnnotationMirror am: ams) { - Map elementValues = am.getElementValues(); - for(AnnotationTypeElementDeclaration atmd: elementValues.keySet()) { - if (!atmd.getDeclaringType().toString().equals("VisitOrder")) - throw new RuntimeException("Annotation " + atmd + - " is the wrong type."); - else { - AnnotationValue av = - elementValues.get(atmd); - Integer value = (Integer) av.getValue(); - if (value.intValue() != count) - throw new RuntimeException("Expected declaration " + d + - " to be in position " + count + - " instead of " + value.intValue()); - - System.out.println("Declaration " + d + - ": visit order " + value.intValue()); - } - } - - } - } - } - - } - } - - public void process() { - for(TypeDeclaration td: env.getSpecifiedTypeDeclarations() ) { - td.accept(DeclarationVisitors.getSourceOrderDeclarationScanner(new CountingVisitor(), - DeclarationVisitors.NO_OP)); - } - } - } - - - static Collection supportedTypes; - static { - String types[] = {"*"}; - supportedTypes = Collections.unmodifiableCollection(Arrays.asList(types)); - } - - static Collection supportedOptions; - static { - String options[] = {""}; - supportedOptions = Collections.unmodifiableCollection(Arrays.asList(options)); - } - - public Collection supportedOptions() { - return supportedOptions; - } - - public Collection supportedAnnotationTypes() { - return supportedTypes; - } - - public AnnotationProcessor getProcessorFor(Set atds, - AnnotationProcessorEnvironment env) { - return new ScannerProc(env); - } - -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Scanners/TestEnum.java --- a/langtools/test/tools/apt/Scanners/TestEnum.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -public enum TestEnum { - QUIZ, - EXAM, - MIDTERM, - FINAL, - QUALIFIER; -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Scanners/VisitOrder.java --- a/langtools/test/tools/apt/Scanners/VisitOrder.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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. - */ - - -/* - * Integer to indicate what order a declaration is expected to be - * visited in by a DeclarationScanner. - */ - -@interface VisitOrder { - int value(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Scanners/scanner.sh --- a/langtools/test/tools/apt/Scanners/scanner.sh Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,146 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute 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 4989093 5009164 5023880 5029482 6206786 -# @run shell ../verifyVariables.sh -# @run shell scanner.sh -# @summary Test source order scanner -# @author Joseph D. Darcy - -OS=`uname -s`; -case "${OS}" in - Windows* | CYGWIN* ) - SEP=";" - ;; - - * ) - SEP=":" - ;; -esac - -JARCP=scanner.jar - -# Construct path to apt executable -APT="${TESTJAVA}/bin/apt ${TESTTOOLVMOPTS} -nocompile " - -printf "%s\n" "APT = ${APT}" - -# Construct path to javac executable -JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TESTJAVA}/lib/tools.jar -d . " -JAR="${TESTJAVA}/bin/jar " - -${JAVAC} ${TESTSRC}/Scanner.java ${TESTSRC}/VisitOrder.java ${TESTSRC}/Counter.java ${TESTSRC}/MemberOrderApf.java -RESULT=$? - -case "${RESULT}" in - 0 ) - ;; - - * ) - echo "Compilation failed." - exit 1 -esac - - -echo "Making services directory and copying services information." -mkdir -p META-INF/services - -cp ${TESTSRC}/servicesScanner META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory - -${JAR} cf0 scanner.jar Scanner*.class META-INF - -# Jar files created; verify options properly present on both initial -# and recursive apt runs - -#--------------------------------------------------------- - -unset CLASSPATH - -printf "%s\n" "-classpath ${JARCP}" > options -printf "%s\n" "-sourcepath ${TESTSRC}" >> options -printf "%s\n" "${TESTSRC}/Order.java" >> options - -${APT} @options - -RESULT=$? -case "${RESULT}" in - 0 ) - ;; - - * ) - echo "Program elements visited in wrong order" - exit 1 - ;; -esac - -#--------------------------------------------------------- - -# Verify that plain decl' scanner and source order decl' scanner -# record the same number of elements for an enum - -printf "%s\n" "-factorypath ." > options2 -printf "%s\n" "-factory Counter" >> options2 -printf "%s\n" "-sourcepath ${TESTSRC}" >> options2 -printf "%s\n" "${TESTSRC}/TestEnum.java" >> options2 - - -$APT @options2 - -RESULT=$? -case "${RESULT}" in - 0 ) - ;; - - * ) - echo "Improper counts" - exit 1 - ;; -esac - -#--------------------------------------------------------- - -# Verify that members happen to be returned in source order - -printf "%s\n" "-factorypath ." > options3 -printf "%s\n" "-factory MemberOrderApf" >> options3 -printf "%s\n" "-sourcepath ${TESTSRC}" >> options3 -printf "%s\n" "${TESTSRC}/Order.java" >> options3 - -$APT @options3 - -RESULT=$? -case "${RESULT}" in - 0 ) - ;; - - * ) - echo "Improper counts" - exit 1 - ;; -esac - - -exit 0; diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/Scanners/servicesScanner --- a/langtools/test/tools/apt/Scanners/servicesScanner Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -Scanner diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/lib/Ignore.java --- a/langtools/test/tools/apt/lib/Ignore.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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.lang.annotation.*; - -/** - * An annotation used to indicate that a test -- a method annotated - * with @Test -- should not be executed. - * - * @author Scott Seligman - */ -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -public @interface Ignore { - - /** - * Reason for ignoring this test. - */ - String value() default ""; -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/lib/Test.java --- a/langtools/test/tools/apt/lib/Test.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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.lang.annotation.*; - -/** - * An annotation used to indicate that a method constitutes a test, - * and which provides the expected result. The method must take no parameters. - * - * @author Scott Seligman - */ -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -public @interface Test { - - /** - * An array containing the method's expected result (or - * elements of the result if the return type is a Collection). - * Value is ignored if return type is void. - * Entries are converted to strings via {@link String#valueOf(Object)}. - */ - String[] result() default {}; - - /** - * True if the order of the elements in result() is significant. - */ - boolean ordered() default false; -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/lib/TestProcessor.java --- a/langtools/test/tools/apt/lib/TestProcessor.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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.lang.reflect.Method; -import java.util.*; -import com.sun.mirror.apt.*; - - -/** - * Annotation processor for the @Test annotation. - * Invokes each method so annotated, and verifies the result. - * Throws an Error on failure. - * - * @author Scott Seligman - */ -public class TestProcessor implements AnnotationProcessor { - - AnnotationProcessorEnvironment env; - - // The tester that's running. - Tester tester = Tester.activeTester; - - TestProcessor(AnnotationProcessorEnvironment env, - Tester tester) { - this.env = env; - this.tester = tester; - } - - - /** - * Reflectively invoke the @Test-annotated methods of the live - * tester. Those methods perform the actual exercising of the - * mirror API. Then back here to verify the results by - * reading the live annotations. Convoluted, you say? - */ - public void process() { - System.out.printf("\n> Processing %s\n", tester.getClass()); - - boolean failed = false; // true if a test returns wrong result - - for (Method m : tester.getClass().getDeclaredMethods()) { - Test anno = m.getAnnotation(Test.class); - Ignore ignore = m.getAnnotation(Ignore.class); - if (anno != null) { - if (ignore == null) { - System.out.println(">> Invoking test " + m.getName()); - Object result; - try { - result = m.invoke(tester); - } catch (Exception e) { - throw new Error("Test invocation failed", e); - } - boolean ok = true; // result of this test - if (Collection.class.isAssignableFrom(m.getReturnType())) { - ok = verifyResults((Collection) result, - anno.result(), anno.ordered()); - } else if (m.getReturnType() != void.class) { - ok = verifyResult(result, anno.result()); - } - if (!ok) { - System.out.println(">>> Expected: " + anno); - System.out.println(">>> Got: " + result); - failed = true; - } - } else { - System.out.println(">> Ignoring test " + m.getName()); - if (ignore.value().length() > 0) { - System.out.println(">>> Reason: " + ignore.value()); - } - } - } - } - if (failed) { - throw new Error("Test(s) returned unexpected result"); - } - } - - /** - * Verify that a single-valued (non-Collection) result matches - * its expected value. - */ - private boolean verifyResult(Object result, String[] expected) { - assert expected.length == 1 : - "Single-valued test expecting " + expected.length + " results"; - return expected[0].equals(String.valueOf(result)); - } - - /** - * Verify that a multi-valued result (a Collection) matches - * its expected values. - */ - private boolean verifyResults(Collection result, - String[] expected, boolean ordered) { - if (result.size() != expected.length) { - return false; - } - - // Convert result to an array of strings. - String[] res = new String[result.size()]; - int i = 0; - for (Object e : result) { - res[i++] = String.valueOf(e); - } - - if (!ordered) { - Arrays.sort(res); - Arrays.sort(expected); - } - return Arrays.equals(res, expected); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/lib/TestProcessorFactory.java --- a/langtools/test/tools/apt/lib/TestProcessorFactory.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -import java.util.*; -import com.sun.mirror.apt.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.util.*; - - -/** - * A factory for generating the TestProcessor annotation processor, which - * processes the @Test annotation. - * - * @author Scott Seligman - */ -public class TestProcessorFactory implements AnnotationProcessorFactory { - - public Collection supportedOptions() { - return new ArrayList(); - } - - public Collection supportedAnnotationTypes() { - ArrayList res = new ArrayList(); - res.add("Test"); - res.add("Ignore"); - return res; - } - - public AnnotationProcessor getProcessorFor( - Set as, - AnnotationProcessorEnvironment env) { - // The tester that's running. - Tester tester = Tester.activeTester; - - try { - // Find the tester's class declaration. - ClassDeclaration testerDecl = null; - for (TypeDeclaration decl : env.getSpecifiedTypeDeclarations()) { - if (decl.getQualifiedName().equals( - tester.getClass().getName())) { - testerDecl = (ClassDeclaration) decl; - break; - } - } - - // Give the tester access to its own declaration and to the env. - tester.thisClassDecl = testerDecl; - tester.env = env; - - // Initializer the tester. - tester.init(); - - return new TestProcessor(env, tester); - - } catch (Exception e) { - throw new Error("Couldn't create test annotation processor", e); - } - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/lib/Tester.java --- a/langtools/test/tools/apt/lib/Tester.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,160 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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. - */ - - -/* - * A utility used to invoke and test the apt tool. - * Tests should subclass Tester, and invoke run(). - * - * @author Scott Seligman - */ - -import java.io.*; -import java.util.*; -import com.sun.mirror.apt.*; -import com.sun.mirror.declaration.*; - - -public abstract class Tester { - - /** - * The declaration corresponding to this tester's class. Set by - * TestProcessorFactory after the constructor completes, and - * before init() is invoked. - */ - ClassDeclaration thisClassDecl; - - /** - * The environment for this apt run. Set by TestProcessorFactory - * after the constructor completes, and before init() is invoked. - */ - AnnotationProcessorEnvironment env; - - - // TestProcessorFactory looks here to find the tester that's running - // when it's invoked. - static Tester activeTester; - - private static final String[] DEFAULT_ARGS = { - "-nocompile", - "-XPrintAptRounds", - "-XListDeclarations", - }; - private static final String[] NO_STRINGS = {}; - - // Force processor and factory to be compiled - private static Class dummy = TestProcessorFactory.class; - - private final String testSrc = System.getProperty("test.src", "."); - private final String testClasses = System.getProperty("test.classes", "."); - - // apt command-line args - private String[] args; - - - static { - // Enable assertions in the unnamed package. - ClassLoader loader = Tester.class.getClassLoader(); - if (loader != null) { - loader.setPackageAssertionStatus(null, true); - } - } - - - protected Tester(String... additionalArgs) { - String sourceFile = testSrc + File.separator + - getClass().getName() + ".java"; - - ArrayList as = new ArrayList(); - Collections.addAll(as, DEFAULT_ARGS); - as.add("-sourcepath"); as.add(testSrc); - as.add("-factory"); as.add(TestProcessorFactory.class.getName()); - Collections.addAll(as, additionalArgs); - as.add(sourceFile); - args = as.toArray(NO_STRINGS); - } - - /** - * Run apt. - */ - protected void run() { - activeTester = this; - if (com.sun.tools.apt.Main.process(args) != 0) { - throw new Error("apt errors encountered."); - } - } - - /** - * Called after thisClassDecl and env have been set, but before any - * tests are run, to allow the tester subclass to perform any - * needed initialization. - */ - protected void init() { - } - - /** - * Returns the declaration of a named method in this class. If this - * method name is overloaded, one method is chosen arbitrarily. - * Returns null if no method is found. - */ - protected MethodDeclaration getMethod(String methodName) { - for (MethodDeclaration m : thisClassDecl.getMethods()) { - if (methodName.equals(m.getSimpleName())) { - return m; - } - } - return null; - } - - /** - * Returns the declaration of a named field in this class. - * Returns null if no field is found. - */ - protected FieldDeclaration getField(String fieldName) { - for (FieldDeclaration f : thisClassDecl.getFields()) { - if (fieldName.equals(f.getSimpleName())) { - return f; - } - } - return null; - } - - /** - * Returns the annotation mirror of a given type on a named method - * in this class. If this method name is overloaded, one method is - * chosen arbitrarily. Returns null if no appropriate annotation - * is found. - */ - protected AnnotationMirror getAnno(String methodName, String annoType) { - MethodDeclaration m = getMethod(methodName); - if (m != null) { - TypeDeclaration at = env.getTypeDeclaration(annoType); - for (AnnotationMirror a : m.getAnnotationMirrors()) { - if (at == a.getAnnotationType().getDeclaration()) { - return a; - } - } - } - return null; - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/declaration/AnnoMirror.java --- a/langtools/test/tools/apt/mirror/declaration/AnnoMirror.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 4853450 5014539 - * @summary Tests AnnotationMirror and AnnotationValue methods. - * @library ../../lib - * @compile -source 1.5 AnnoMirror.java - * @run main/othervm AnnoMirror - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; - - -public class AnnoMirror extends Tester { - - public static void main(String[] args) { - (new AnnoMirror()).run(); - } - - - @Test(result={"AT1"}) - @AT1 - AnnotationType getAnnotationType() { - AnnotationMirror anno = getAnno("getAnnotationType", "AT1"); - return anno.getAnnotationType(); - } - - @Test(result={}) - @AT1 - Set getElementValuesNone() { - AnnotationMirror anno = getAnno("getElementValuesNone", "AT1"); - return anno.getElementValues().entrySet(); - } - - - // The seemingly out-of-place parens in the following "result" - // entry are needed due to the shortcut of having the test return - // the entry set directly. - @Test(result={"i()=2", - "b()=true", - "k()=java.lang.Boolean.class", - "a()=@AT1"}) - @AT2(i = 1+1, - b = true, - k = Boolean.class, - a = @AT1) - Set getElementValues() { - AnnotationMirror anno = getAnno("getElementValues", "AT2"); - return anno.getElementValues().entrySet(); - } - - @Test(result={"@AT1(\"zax\")", - "@AT2(i=2, b=true, k=java.lang.Boolean.class, a=@AT1)", - "@AT3(arr={1})", - "@AT4({2, 3, 4})"}) - Collection toStringTests() { - for (MethodDeclaration m : thisClassDecl.getMethods()) { - if (m.getSimpleName().equals("toStringTestsHelper")) { - return m.getAnnotationMirrors(); - } - } - throw new AssertionError(); - } - - @AT1("zax") - @AT2(i = 1+1, - b = true, - k = Boolean.class, - a = @AT1) - @AT3(arr={1}) - @AT4({2,3,4}) - private void toStringTestsHelper() { - } -} - - -/* - * Annotations used for testing. - */ - -@interface AT1 { - String value() default ""; -} - -@interface AT2 { - int i(); - boolean b(); - Class k(); - AT1 a(); -} - -@interface AT3 { - int[] arr(); -} - -@interface AT4 { - int[] value(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/declaration/AnnoTypeDecl.java --- a/langtools/test/tools/apt/mirror/declaration/AnnoTypeDecl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 4853450 5014539 - * @summary AnnotationTypeDeclaration tests - * @library ../../lib - * @compile -source 1.5 AnnoTypeDecl.java - * @run main/othervm AnnoTypeDecl - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -public class AnnoTypeDecl extends Tester { - - public static void main(String[] args) { - (new AnnoTypeDecl()).run(); - } - - - private AnnotationTypeDeclaration at; - - protected void init() { - at = (AnnotationTypeDeclaration) env.getTypeDeclaration("AT"); - } - - - // Declaration methods - - @Test(result="annotation type") - Collection accept() { - final Collection res = new ArrayList(); - - at.accept(new SimpleDeclarationVisitor() { - public void visitTypeDeclaration(TypeDeclaration t) { - res.add("type"); - } - public void visitClassDeclaration(ClassDeclaration c) { - res.add("class"); - } - public void visitInterfaceDeclaration(InterfaceDeclaration i) { - res.add("interface"); - } - public void visitAnnotationTypeDeclaration( - AnnotationTypeDeclaration a) { - res.add("annotation type"); - } - }); - return res; - } - - - // AnnotationTypeDeclaration methods - - @Test(result={"s()"}) - Collection getMethods() { - return at.getMethods(); - } -} - - -// An annotation type to use for testing. - -@interface AT { - String s(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/declaration/AnnoTypeElemDecl.java --- a/langtools/test/tools/apt/mirror/declaration/AnnoTypeElemDecl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,194 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 4853450 4993299 5010385 5014539 - * @summary AnnotationTypeElementDeclaration tests - * @library ../../lib - * @compile -source 1.5 AnnoTypeElemDecl.java - * @run main/othervm AnnoTypeElemDecl - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -public class AnnoTypeElemDecl extends Tester { - - public static void main(String[] args) { - (new AnnoTypeElemDecl()).run(); - } - - - // Some annotation type elements to use. - private AnnotationTypeElementDeclaration elem1 = null; // s() - private AnnotationTypeElementDeclaration elem2 = null; // i() - private AnnotationTypeElementDeclaration elem3 = null; // b() - - protected void init() { - for (TypeDeclaration at : thisClassDecl.getNestedTypes()) { - for (MethodDeclaration meth : at.getMethods()) { - AnnotationTypeElementDeclaration elem = - (AnnotationTypeElementDeclaration) meth; - if (elem.getSimpleName().equals("s")) { - elem1 = elem; // s() - } else if (elem.getSimpleName().equals("i")) { - elem2 = elem; // i() - } else { - elem3 = elem; // b() - } - } - } - } - - - // Declaration methods - - @Test(result="anno type element") - Collection accept() { - final Collection res = new ArrayList(); - - elem1.accept(new SimpleDeclarationVisitor() { - public void visitTypeDeclaration(TypeDeclaration t) { - res.add("type"); - } - public void visitExecutableDeclaration(ExecutableDeclaration e) { - res.add("executable"); - } - public void visitMethodDeclaration(MethodDeclaration m) { - res.add("method"); - } - public void visitAnnotationTypeElementDeclaration( - AnnotationTypeElementDeclaration a) { - res.add("anno type element"); - } - }); - return res; - } - - @Test(result={"@AnnoTypeElemDecl.AT2"}) - Collection getAnnotationMirrors() { - return elem1.getAnnotationMirrors(); - } - - @Test(result=" Sed Quis custodiet ipsos custodes?\n") - String getDocComment() { - return elem1.getDocComment(); - } - - @Test(result={"public", "abstract"}) - Collection getModifiers() { - return elem1.getModifiers(); - } - - @Test(result="AnnoTypeElemDecl.java") - String getPosition() { - return elem1.getPosition().file().getName(); - } - - @Test(result="s") - String getSimpleName() { - return elem1.getSimpleName(); - } - - - // MemberDeclaration method - - @Test(result="AnnoTypeElemDecl.AT1") - TypeDeclaration getDeclaringType() { - return elem1.getDeclaringType(); - } - - - // ExecutableDeclaration methods - - @Test(result={}) - Collection getFormalTypeParameters() { - return elem1.getFormalTypeParameters(); - } - - @Test(result={}) - Collection getParameters() { - return elem1.getParameters(); - } - - @Test(result={}) - Collection getThrownTypes() { - return elem1.getThrownTypes(); - } - - @Test(result="false") - Boolean isVarArgs() { - return elem1.isVarArgs(); - } - - - // AnnotationTypeElementDeclaration method - - @Test(result="\"default\"") - AnnotationValue getDefaultValue1() { - return elem1.getDefaultValue(); - } - - @Test(result="null") - AnnotationValue getDefaultValue2() { - return elem2.getDefaultValue(); - } - - // 5010385: getValue() returns null for boolean type elements - @Test(result="false") - Boolean getDefaultValue3() { - return (Boolean) elem3.getDefaultValue().getValue(); - } - - - // toString - - @Test(result="s()") - String toStringTest() { - return elem1.toString(); - } - - - // Declarations used by tests. - - @interface AT1 { - /** - * Sed Quis custodiet ipsos custodes? - */ - @AT2 - String s() default "default"; - - int i(); - - boolean b() default false; - } - - @interface AT2 { - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/declaration/AnnoVal.java --- a/langtools/test/tools/apt/mirror/declaration/AnnoVal.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,200 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 4853450 5014539 5034991 - * @summary Tests AnnotationValue methods. - * @library ../../lib - * @compile -source 1.5 AnnoVal.java - * @run main/othervm AnnoVal - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; - - -public class AnnoVal extends Tester { - - public static void main(String[] args) { - (new AnnoVal()).run(); - } - - @Test(result={ - "i Integer 2", - "l Long 4294967296", - "d Double 3.14", - "b Boolean true", - "c Character @", - "s String sigh", - // The following results reflect some implementation details. - "k ClassTypeImpl java.lang.Boolean", - "kb PrimitiveTypeImpl boolean", - "ka ArrayTypeImpl java.lang.Boolean[]", - "kab ArrayTypeImpl int[][]", - "w ClassTypeImpl java.lang.Long", - "e EnumConstantDeclarationImpl TYPE", - "sa ArrayList [\"up\", \"down\"]", - "a AnnotationMirrorImpl @AT1"}) - @AT2(i = 1 + 1, - l = 1024 * 1024 * 1024 * 4L, - d = 3.14, - b = true, - c = '@', - s = "sigh", - k = Boolean.class, - kb = boolean.class, - ka = Boolean[].class, // bugid 5020899 - kab = int[][].class, // " - w = Long.class, - e = java.lang.annotation.ElementType.TYPE, - sa = {"up", "down"}, - a = @AT1) - Collection getValue() { - Collection res = new ArrayList(); - AnnotationMirror anno = getAnno("getValue", "AT2"); - - for (Map.Entry e : - anno.getElementValues().entrySet()) { - Object val = e.getValue().getValue(); - res.add(String.format("%s %s %s", - e.getKey().getSimpleName(), - simpleClassName(val), - val)); - } - return res; - } - - @Test(result={ - "int i 2", - "long l 4294967296L", - "double d 3.14", - "boolean b true", - "char c '@'", - "java.lang.String s \"sigh\"", - "java.lang.Class k java.lang.Boolean.class", - "java.lang.Class kb boolean.class", - "java.lang.Class ka java.lang.Boolean[].class", - "java.lang.Class kab int[][].class", - "java.lang.Class w java.lang.Long.class", - "java.lang.annotation.ElementType e java.lang.annotation.ElementType.TYPE", - "java.lang.String[] sa {\"up\", \"down\"}", - "AT1 a @AT1"}) - Collection toStringTests() { - Collection res = new ArrayList(); - AnnotationMirror anno = getAnno("getValue", "AT2"); - - for (Map.Entry e : - anno.getElementValues().entrySet()) { - res.add(String.format("%s %s %s", - e.getKey().getReturnType(), - e.getKey().getSimpleName(), - e.getValue().toString())); - } - return res; - } - - @Test(result={ - "byte b 0x0b", - "float f 3.0f", - "double nan 0.0/0.0", - "double hi 1.0/0.0", - "float lo -1.0f/0.0f", - "char newline '\\n'", - "char ff '\\u00ff'", - "java.lang.String s \"\\\"high\\tlow\\\"\"", - "java.lang.String smiley \"\\u263a\""}) - @AT3(b = 11, - f = 3, - nan = 0.0/0.0, - hi = 1.0/0.0, - lo = -1.0f/0.0f, - newline = '\n', - ff = '\u00FF', - s = "\"high\tlow\"", - smiley = "\u263A") - Collection toStringFancy() { - Collection res = new ArrayList(); - AnnotationMirror anno = getAnno("toStringFancy", "AT3"); - - for (Map.Entry e : - anno.getElementValues().entrySet()) { - res.add(String.format("%s %s %s", - e.getKey().getReturnType(), - e.getKey().getSimpleName(), - e.getValue().toString())); - } - return res; - } - - - /** - * Returns the simple name of an object's class. - */ - private String simpleClassName(Object o) { - return (o == null) - ? "null" - : o.getClass().getName().replaceFirst(".*\\.", ""); - } -} - - -/* - * Annotations used for testing. - */ - -@interface AT1 { - String value() default ""; -} - -@interface AT2 { - int i(); - long l(); - double d(); - boolean b(); - char c(); - String s(); - Class k(); - Class kb(); - Class ka(); - Class kab(); - Class w(); - java.lang.annotation.ElementType e(); - String[] sa(); - AT1 a(); -} - -@interface AT3 { - byte b(); - float f(); - double nan(); - double hi(); - float lo(); - char newline(); - char ff(); - String s(); - String smiley(); -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/declaration/ClassDecl.java --- a/langtools/test/tools/apt/mirror/declaration/ClassDecl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,250 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 4853450 4997614 - * @summary ClassDeclaration tests - * @library ../../lib - * @compile -source 1.5 ClassDecl.java - * @run main/othervm ClassDecl - */ - - -import java.io.Serializable; -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -/** - * Sed Quis custodiet ipsos custodes? - */ -@AT1 -@AT2 -public class ClassDecl extends Tester { - - public static void main(String[] args) { - (new ClassDecl()).run(); - } - - - private ClassDeclaration nested = null; // a nested type - private ClassDeclaration object = null; // java.lang.object - - // A constructor to be found - private ClassDecl() { - } - - // Another constructor to be found - private ClassDecl(int i) { - this(); - } - - // An extra field to be found - static int i; - - // Static initializer isn't among this class's methods. - static { - i = 7; - } - - // A nested class with some accoutrements - private static strictfp class NestedClass implements Serializable { - void m1() {} - void m2() {} - void m2(int i) {} - } - - protected void init() { - nested = (ClassDeclaration) - thisClassDecl.getNestedTypes().iterator().next(); - object = (ClassDeclaration) - env.getTypeDeclaration("java.lang.Object"); - } - - - // Declaration methods - - @Test(result="class") - Collection accept() { - final Collection res = new ArrayList(); - - thisClassDecl.accept(new SimpleDeclarationVisitor() { - public void visitTypeDeclaration(TypeDeclaration t) { - res.add("type"); - } - public void visitClassDeclaration(ClassDeclaration c) { - res.add("class"); - } - public void visitEnumDeclaration(EnumDeclaration e) { - res.add("enum"); - } - }); - return res; - } - - @Test(result={"@AT1", "@AT2"}) - Collection getAnnotationMirrors() { - return thisClassDecl.getAnnotationMirrors(); - } - - @Test(result=" Sed Quis custodiet ipsos custodes?\n") - String getDocComment() { - return thisClassDecl.getDocComment(); - } - - @Test(result={"public"}) - Collection getModifiers1() { - return thisClassDecl.getModifiers(); - } - - // Check that static nested class has "static" modifier, even though - // the VM doesn't set that bit. - @Test(result={"private", "static", "strictfp"}) - Collection getModifiers2() { - return nested.getModifiers(); - } - - @Test(result="ClassDecl.java") - String getPosition() { - return thisClassDecl.getPosition().file().getName(); - } - - @Test(result="ClassDecl") - String getSimpleName1() { - return thisClassDecl.getSimpleName(); - } - - @Test(result="NestedClass") - String getSimpleName2() { - return nested.getSimpleName(); - } - - - // MemberDeclaration method - - @Test(result="null") - TypeDeclaration getDeclaringType1() { - return thisClassDecl.getDeclaringType(); - } - - @Test(result="ClassDecl") - TypeDeclaration getDeclaringType2() { - return nested.getDeclaringType(); - } - - - // TypeDeclaration methods - - @Test(result={"nested", "object", "i"}) - Collection getFields() { - return thisClassDecl.getFields(); - } - - @Test(result={}) - Collection getFormalTypeParameters1() { - return thisClassDecl.getFormalTypeParameters(); - } - - @Test(result="T") - Collection getFormalTypeParameters2() { - return nested.getFormalTypeParameters(); - } - - @Test(result="ClassDecl.NestedClass") - Collection getNestedTypes() { - return thisClassDecl.getNestedTypes(); - } - - @Test(result="") - PackageDeclaration getPackage1() { - return thisClassDecl.getPackage(); - } - - @Test(result="java.lang") - PackageDeclaration getPackage2() { - return object.getPackage(); - } - - @Test(result="ClassDecl") - String getQualifiedName1() { - return thisClassDecl.getQualifiedName(); - } - - @Test(result="ClassDecl.NestedClass") - String getQualifiedName2() { - return nested.getQualifiedName(); - } - - @Test(result="java.lang.Object") - String getQualifiedName3() { - return object.getQualifiedName(); - } - - @Test(result="java.io.Serializable") - Collection getSuperinterfaces() { - return nested.getSuperinterfaces(); - } - - - // ClassDeclaration methods - - @Test(result={"ClassDecl()", "ClassDecl(int)"}) - Collection getConstructors1() { - return thisClassDecl.getConstructors(); - } - - // Check for default constructor. - // 4997614: visitConstructionDeclaration reports info when there is no ctor - @Test(result={"NestedClass()"}) - Collection getConstructors2() { - return nested.getConstructors(); - } - - @Test(result={"m1()", "m2()", "m2(int)"}) - Collection getMethods() { - return nested.getMethods(); - } - - @Test(result={"Tester"}) - ClassType getSuperclass() { - return thisClassDecl.getSuperclass(); - } - - @Test(result={"null"}) - ClassType objectHasNoSuperclass() { - return object.getSuperclass(); - } -} - - -// Annotations used for testing. - -@interface AT1 { -} - -@interface AT2 { -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/declaration/ConstExpr.java --- a/langtools/test/tools/apt/mirror/declaration/ConstExpr.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 5027675 5048535 - * @summary Tests FieldDeclaration.getConstantExpression method - * @library ../../lib - * @compile -source 1.5 ConstExpr.java - * @run main/othervm ConstExpr - */ - - -import java.math.RoundingMode; -import java.util.*; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - -import static java.math.RoundingMode.UP; - -import static com.sun.mirror.util.DeclarationVisitors.*; - - -public class ConstExpr extends Tester { - - public static void main(String[] args) { - (new ConstExpr()).run(); - } - - - // Declarations used by tests - - public static final byte B = (byte) 0xBE; - public static final short S = (short) 32767; - public static final int I = -4; - public static final long l = 4294967296L; - public static final float f = 3.5f; - public static final double PI = Math.PI; - public static final char C = 'C'; - public static final String STR = "cheese"; - - public static final char SMILEY = '\u263A'; - public static final String TWOLINES = "ab\ncd"; - - public static final double D1 = Double.POSITIVE_INFINITY; - public static final double D2 = Double.NEGATIVE_INFINITY; - public static final double D3 = Double.NaN; - public static final float F1 = Float.POSITIVE_INFINITY; - public static final float F2 = Float.NEGATIVE_INFINITY; - public static final float F3 = Float.NaN; - - public static final String NOSTR = null; // not a compile-time constant - public static final RoundingMode R = UP; // not a compile-time constant - - - @Test(result={ - "0xbe", - "32767", - "-4", - "4294967296L", - "3.5f", - "3.141592653589793", - "'C'", - "\"cheese\"", - - "'\\u263a'", - "\"ab\\ncd\"", - - "1.0/0.0", - "-1.0/0.0", - "0.0/0.0", - "1.0f/0.0f", - "-1.0f/0.0f", - "0.0f/0.0f", - - "null", - "null" - }, - ordered=true) - Collection getConstantExpression() { - final Collection res = new ArrayList(); - - thisClassDecl.accept( - DeclarationVisitors.getSourceOrderDeclarationScanner( - NO_OP, - new SimpleDeclarationVisitor() { - public void visitFieldDeclaration(FieldDeclaration f) { - res.add(f.getConstantExpression()); - } - })); - return res; - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/declaration/ConstructorDecl.java --- a/langtools/test/tools/apt/mirror/declaration/ConstructorDecl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,199 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 4853450 4993299 - * @summary ConstructorDeclaration tests - * @library ../../lib - * @compile -source 1.5 ConstructorDecl.java - * @run main/othervm ConstructorDecl - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -public class ConstructorDecl extends Tester { - - /** - * Sed Quis custodiet ipsos custodes? - */ - @AT1 - public ConstructorDecl() { - } - - - public static void main(String[] args) { - (new ConstructorDecl()).run(); - } - - - private ConstructorDeclaration ctor = null; // a constructor - private ConstructorDeclaration ctorDef = null; // a default c'tor - private ConstructorDeclaration ctorInner = null; // an inner class c'tor - - protected void init() { - ctor = getAConstructor(thisClassDecl); - ctorDef = getAConstructor((ClassDeclaration) - env.getTypeDeclaration("C1")); - ctorInner = getAConstructor((ClassDeclaration) - env.getTypeDeclaration("C1.C2")); - } - - // Return a constructor of a class. - private ConstructorDeclaration getAConstructor(ClassDeclaration c) { - return c.getConstructors().iterator().next(); - } - - - // Declaration methods - - @Test(result="constructor") - Collection accept() { - final Collection res = new ArrayList(); - - ctor.accept(new SimpleDeclarationVisitor() { - public void visitTypeDeclaration(TypeDeclaration t) { - res.add("type"); - } - public void visitExecutableDeclaration(ExecutableDeclaration e) { - res.add("executable"); - } - public void visitConstructorDeclaration(ConstructorDeclaration c) { - res.add("constructor"); - } - }); - return res; - } - - @Test(result={"@AT1"}) - Collection getAnnotationMirrors() { - return ctor.getAnnotationMirrors(); - } - - @Test(result=" Sed Quis custodiet ipsos custodes?\n") - String getDocComment() { - return ctor.getDocComment(); - } - - @Test(result={"public"}) - Collection getModifiers() { - return ctor.getModifiers(); - } - - @Test(result="ConstructorDecl.java") - String getPosition() { - return ctor.getPosition().file().getName(); - } - - @Test(result="ConstructorDecl.java") - String getPositionDefault() { - return ctorDef.getPosition().file().getName(); - } - - @Test(result="ConstructorDecl") - String getSimpleName() { - return ctor.getSimpleName(); - } - - @Test(result="C2") - String getSimpleNameInner() { - return ctorInner.getSimpleName(); - } - - - // MemberDeclaration method - - @Test(result="ConstructorDecl") - TypeDeclaration getDeclaringType() { - return ctor.getDeclaringType(); - } - - - // ExecutableDeclaration methods - - @Test(result={}) - Collection getFormalTypeParameters1() { - return ctor.getFormalTypeParameters(); - } - - @Test(result={"N extends java.lang.Number"}) - Collection getFormalTypeParameters2() { - return ctorInner.getFormalTypeParameters(); - } - - @Test(result={}) - Collection getParameters1() { - return ctor.getParameters(); - } - - // 4993299: verify synthetic parameters to inner class constructors - // aren't visible - @Test(result={"N n1", "N n2", "java.lang.String[] ss"}, - ordered=true) - Collection getParameters2() { - return ctorInner.getParameters(); - } - - @Test(result={"java.lang.Throwable"}) - Collection getThrownTypes() { - return ctorInner.getThrownTypes(); - } - - @Test(result="false") - Boolean isVarArgs1() { - return ctor.isVarArgs(); - } - - @Test(result="true") - Boolean isVarArgs2() { - return ctorInner.isVarArgs(); - } - - - // toString - - @Test(result=" C2(N, N, String...)") - @Ignore("This is what it would be nice to see.") - String toStringTest() { - return ctorInner.toString(); - } -} - - -// Classes and interfaces used for testing. - -class C1 { - class C2 { - C2(N n1, N n2, String... ss) throws Throwable { - } - } -} - -@interface AT1 { -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/declaration/EnumDecl.java --- a/langtools/test/tools/apt/mirror/declaration/EnumDecl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 4853450 4989987 5010050 - * @summary EnumDeclaration tests - * @library ../../lib - * @compile -source 1.5 EnumDecl.java - * @run main/othervm EnumDecl - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -public class EnumDecl extends Tester { - - public static void main(String[] args) { - (new EnumDecl()).run(); - } - - - private EnumDeclaration eDecl; - - protected void init() { - eDecl = (EnumDeclaration) env.getTypeDeclaration("E"); - } - - - // Declaration methods - - @Test(result="enum") - Collection accept() { - final Collection res = new ArrayList(); - - eDecl.accept(new SimpleDeclarationVisitor() { - public void visitTypeDeclaration(TypeDeclaration t) { - res.add("type"); - } - public void visitClassDeclaration(ClassDeclaration c) { - res.add("class"); - } - public void visitEnumDeclaration(EnumDeclaration e) { - res.add("enum"); - } - }); - return res; - } - - - // ClassDeclaration methods - - // 4989987: Verify synthetic enum constructor parameters are not visible - @Test(result={"E(java.lang.String)"}) - Collection getConstructors() { - return eDecl.getConstructors(); - } - - // 4989987: Verify synthetic enum constructor parameters are not visible - @Test(result={"java.lang.String color"}) - Collection getConstructorParams() { - return eDecl.getConstructors().iterator().next().getParameters(); - } - - @Test(result={"values()", "valueOf(java.lang.String)"}) - Collection getMethods() { - return eDecl.getMethods(); - } - - // 5010050: Cannot find parameter names for valueOf(String name) method... - @Test(result={"java.lang.String name"}) - Collection getMethodParams() { - for (MethodDeclaration m : eDecl.getMethods()) { - if (m.getSimpleName().equals("valueOf")) { - return m.getParameters(); - } - } - throw new AssertionError(); - } - - - // EnumDeclaration methods - - @Test(result={"stop", "slow", "go"}) - Collection getEnumConstants() { - return eDecl.getEnumConstants(); - } -} - - -// An enum to use for testing. - -enum E { - stop("red"), - slow("amber"), - go("green"); - - private String color; - E(String color) { - this.color = color; - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/declaration/FieldDecl.java --- a/langtools/test/tools/apt/mirror/declaration/FieldDecl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 4853450 5008309 - * @summary FieldDeclaration tests - * @library ../../lib - * @compile -source 1.5 FieldDecl.java - * @run main/othervm FieldDecl - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -public class FieldDecl extends Tester { - - public static void main(String[] args) { - (new FieldDecl()).run(); - } - - - private FieldDeclaration f1 = null; // a field - private FieldDeclaration f2 = null; // a static field - private FieldDeclaration f3 = null; // a constant field - - protected void init() { - f1 = getField("aField"); - f2 = getField("aStaticField"); - f3 = getField("aConstantField"); - } - - - // Declaration methods - - @Test(result="field") - Collection accept() { - final Collection res = new ArrayList(); - - f1.accept(new SimpleDeclarationVisitor() { - public void visitTypeDeclaration(TypeDeclaration t) { - res.add("type"); - } - public void visitFieldDeclaration(FieldDeclaration f) { - res.add("field"); - } - public void visitEnumConstantDeclaration( - EnumConstantDeclaration e) { - res.add("enum const"); - } - }); - return res; - } - - @Test(result={"@FieldDecl.AT1"}) - Collection getAnnotationMirrors() { - return f1.getAnnotationMirrors(); - } - - @Test(result=" Sed Quis custodiet ipsos custodes?\n") - String getDocComment() { - return f1.getDocComment(); - } - - @Test(result={"public"}) - Collection getModifiers() { - return f1.getModifiers(); - } - - @Test(result="FieldDecl.java") - String getPosition() { - return f1.getPosition().file().getName(); - } - - @Test(result="aField") - String getSimpleName() { - return f1.getSimpleName(); - } - - - // MemberDeclaration method - - @Test(result="FieldDecl") - TypeDeclaration getDeclaringType() { - return f1.getDeclaringType(); - } - - - // FieldDeclaration methods - - @Test(result="java.util.List") - TypeMirror getType1() { - return f1.getType(); - } - - @Test(result="int") - TypeMirror getType2() { - return f2.getType(); - } - - @Test(result="null") - Object getConstantValue1() { - return f1.getConstantValue(); - } - - // 5008309: FieldDeclaration.getConstantValue() doesn't return anything - @Test(result="true") - Object getConstantValue2() { - return f3.getConstantValue(); - } - - - // toString - - @Test(result="aField") - String toStringTest() { - return f1.toString(); - } - - - // Declarations used by tests. - - /** - * Sed Quis custodiet ipsos custodes? - */ - @AT1 - public List aField = new ArrayList(); - - static int aStaticField; - - public static final boolean aConstantField = true; - - - @interface AT1 { - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/declaration/GetAnno.java --- a/langtools/test/tools/apt/mirror/declaration/GetAnno.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 4989091 5050782 5051962 - * @summary Tests Declaration.getAnnotation method - * @library ../../lib - * @compile -source 1.5 GetAnno.java - * @run main/othervm GetAnno - */ - - -import java.lang.annotation.*; -import java.util.*; - -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; - -import static java.lang.annotation.RetentionPolicy.*; - - -public class GetAnno extends Tester { - - public static void main(String[] args) { - (new GetAnno()).run(); - } - - - // Annotations used by tests - - @Retention(RUNTIME) - @interface AT1 { - long l(); - String s(); - RetentionPolicy e(); - String[] sa(); - AT2 a(); - } - - @Inherited - @interface AT2 { - } - - @interface AT3 { - Class value() default String.class; - } - - // Array-valued elements of various kinds. - @interface AT4 { - boolean[] bs(); - long[] ls(); - String[] ss(); - RetentionPolicy[] es(); - AT2[] as(); - } - - - @Test(result="@GetAnno$AT1(l=7, s=sigh, e=CLASS, sa=[in, out], " + - "a=@GetAnno$AT2())") - @AT1(l=7, s="sigh", e=CLASS, sa={"in", "out"}, a=@AT2) - public Annotation getAnnotation() { - MethodDeclaration m = getMethod("getAnnotation"); - AT1 a = m.getAnnotation(AT1.class); - if (a.l() != 7 || !a.s().equals("sigh") || a.e() != CLASS) - throw new AssertionError(); - return a; - } - - @Test(result="null") - public Annotation getAnnotationNotThere() { - return thisClassDecl.getAnnotation(Deprecated.class); - } - - @Test(result="@GetAnno$AT4(bs=[true, false], " + - "ls=[9, 8], " + - "ss=[black, white], " + - "es=[CLASS, SOURCE], " + - "as=[@GetAnno$AT2(), @GetAnno$AT2()])") - @AT4(bs={true, false}, - ls={9, 8}, - ss={"black", "white"}, - es={CLASS, SOURCE}, - as={@AT2, @AT2}) - public AT4 getAnnotationArrayValues() { - MethodDeclaration m = getMethod("getAnnotationArrayValues"); - return m.getAnnotation(AT4.class); - } - - @Test(result="@GetAnno$AT3(value=java.lang.String)") - @AT3(String.class) - public AT3 getAnnotationWithClass1() { - MethodDeclaration m = getMethod("getAnnotationWithClass1"); - return m.getAnnotation(AT3.class); - } - - @Test(result="java.lang.String") - public TypeMirror getAnnotationWithClass2() { - AT3 a = getAnnotationWithClass1(); - try { - Class c = a.value(); - throw new AssertionError(); - } catch (MirroredTypeException e) { - return e.getTypeMirror(); - } - } - - @Test(result="boolean") - @AT3(boolean.class) - public TypeMirror getAnnotationWithPrim() { - MethodDeclaration m = getMethod("getAnnotationWithPrim"); - AT3 a = m.getAnnotation(AT3.class); - try { - Class c = a.value(); - throw new AssertionError(); - } catch (MirroredTypeException e) { - return e.getTypeMirror(); - } - } - - // 5050782 - @Test(result="null") - public AT2 getInheritedAnnotation() { - return thisClassDecl.getAnnotation(AT2.class); - } - - /** - * Verify that an annotation created by Declaration.getAnnotation() - * has the same hash code as a like annotation created by core - * reflection. - */ - @Test(result="true") - @AT1(l=7, s="sigh", e=CLASS, sa={"in", "out"}, a=@AT2) - public boolean getAnnotationHashCode() { - MethodDeclaration m1 = getMethod("getAnnotationHashCode"); - AT1 a1 = m1.getAnnotation(AT1.class); - java.lang.reflect.Method m2 = null; - try { - m2 = this.getClass().getMethod("getAnnotationHashCode"); - } catch (NoSuchMethodException e) { - assert false; - } - AT1 a2 = m2.getAnnotation(AT1.class); - return a1.hashCode() == a2.hashCode(); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/declaration/InterfaceDecl.java --- a/langtools/test/tools/apt/mirror/declaration/InterfaceDecl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,243 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 4853450 4993303 5004618 5010746 - * @summary InterfaceDeclaration tests - * @library ../../lib - * @compile -source 1.5 InterfaceDecl.java - * @run main/othervm InterfaceDecl - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -/** - * Sed Quis custodiet ipsos custodes? - */ -@AT1 -@AT2 -public class InterfaceDecl extends Tester { - - public static void main(String[] args) { - (new InterfaceDecl()).run(); - } - - - private InterfaceDeclaration iDecl = null; // an interface - private InterfaceDeclaration nested = null; // a nested interface - - protected void init() { - iDecl = (InterfaceDeclaration) env.getTypeDeclaration("I"); - nested = (InterfaceDeclaration) - iDecl.getNestedTypes().iterator().next(); - } - - - // Declaration methods - - @Test(result="interface") - Collection accept() { - final Collection res = new ArrayList(); - - iDecl.accept(new SimpleDeclarationVisitor() { - public void visitTypeDeclaration(TypeDeclaration t) { - res.add("type"); - } - public void visitClassDeclaration(ClassDeclaration c) { - res.add("class"); - } - public void visitInterfaceDeclaration(InterfaceDeclaration e) { - res.add("interface"); - } - public void visitAnnotationTypeDeclaration( - AnnotationTypeDeclaration e) { - res.add("annotation type"); - } - }); - return res; - } - - @Test(result="true") - boolean equals1() { - return iDecl.equals(iDecl); - } - - @Test(result="false") - boolean equals2() { - return iDecl.equals(nested); - } - - @Test(result="true") - boolean equals3() { - return iDecl.equals(env.getTypeDeclaration("I")); - } - - - @Test(result={"@AT1", "@AT2"}) - Collection getAnnotationMirrors() { - return iDecl.getAnnotationMirrors(); - } - - @Test(result=" Sed Quis custodiet ipsos custodes?\n") - String getDocComment() { - return iDecl.getDocComment(); - } - - // Check that interface has "abstract" modifier, even though it's implict - // in the source code. - @Test(result={"abstract"}) - Collection getModifiers1() { - return iDecl.getModifiers(); - } - - // Check that nested interface has "static" modifier, even though - // it's implicit in the source code and the VM doesn't set that bit. - @Test(result={"public", "abstract", "static"}) - Collection getModifiers2() { - return nested.getModifiers(); - } - - @Test(result="InterfaceDecl.java") - String getPosition() { - return iDecl.getPosition().file().getName(); - } - - @Test(result="I") - String getSimpleName1() { - return iDecl.getSimpleName(); - } - - @Test(result="Nested") - String getSimpleName2() { - return nested.getSimpleName(); - } - - - // MemberDeclaration method - - @Test(result="null") - TypeDeclaration getDeclaringType1() { - return iDecl.getDeclaringType(); - } - - @Test(result="I") - TypeDeclaration getDeclaringType2() { - return nested.getDeclaringType(); - } - - - // TypeDeclaration methods - - @Test(result={"i"}) - Collection getFields() { - return iDecl.getFields(); - } - - @Test(result={"T extends java.lang.Number"}) - Collection getFormalTypeParameters1() { - return iDecl.getFormalTypeParameters(); - } - - @Test(result={}) - Collection getFormalTypeParameters2() { - return nested.getFormalTypeParameters(); - } - - // 4993303: verify policy on Object methods being visible - @Test(result={"m()", "toString()"}) - Collection getMethods() { - return nested.getMethods(); - } - - @Test(result="I.Nested") - Collection getNestedTypes() { - return iDecl.getNestedTypes(); - } - - @Test(result="") - PackageDeclaration getPackage1() { - return iDecl.getPackage(); - } - - @Test(result="java.util") - PackageDeclaration getPackage2() { - InterfaceDeclaration set = - (InterfaceDeclaration) env.getTypeDeclaration("java.util.Set"); - return set.getPackage(); - } - - @Test(result="I") - String getQualifiedName1() { - return iDecl.getQualifiedName(); - } - - @Test(result="I.Nested") - String getQualifiedName2() { - return nested.getQualifiedName(); - } - - @Test(result="java.util.Set") - String getQualifiedName3() { - InterfaceDeclaration set = - (InterfaceDeclaration) env.getTypeDeclaration("java.util.Set"); - return set.getQualifiedName(); - } - - @Test(result="java.lang.Runnable") - Collection getSuperinterfaces() { - return iDecl.getSuperinterfaces(); - } -} - - -// Interfaces used for testing. - -/** - * Sed Quis custodiet ipsos custodes? - */ -@AT1 -@AT2 -interface I extends Runnable { - int i = 6; - void m1(); - void m2(); - void m2(int j); - - interface Nested { - void m(); - String toString(); - } -} - -@interface AT1 { -} - -@interface AT2 { -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/declaration/MethodDecl.java --- a/langtools/test/tools/apt/mirror/declaration/MethodDecl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,244 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 4853450 5010746 - * @summary MethodDeclaration tests - * @library ../../lib - * @compile -source 1.5 MethodDecl.java - * @run main/othervm MethodDecl - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -public class MethodDecl extends Tester { - - public static void main(String[] args) { - (new MethodDecl()).run(); - } - - - private MethodDeclaration meth1 = null; // a method - private MethodDeclaration meth2 = null; // another method - - protected void init() { - meth1 = getMethod("m1"); - meth2 = getMethod("m2"); - } - - - // Declaration methods - - @Test(result="method") - Collection accept() { - final Collection res = new ArrayList(); - - meth1.accept(new SimpleDeclarationVisitor() { - public void visitTypeDeclaration(TypeDeclaration t) { - res.add("type"); - } - public void visitExecutableDeclaration(ExecutableDeclaration e) { - res.add("executable"); - } - public void visitMethodDeclaration(MethodDeclaration m) { - res.add("method"); - } - public void visitAnnotationTypeElementDeclaration( - AnnotationTypeElementDeclaration a) { - res.add("anno type element"); - } - }); - return res; - } - - @Test(result={"@AT1"}) - Collection getAnnotationMirrors() { - return meth1.getAnnotationMirrors(); - } - - @Test(result=" Sed Quis custodiet ipsos custodes?\n") - String getDocComment() { - return meth1.getDocComment(); - } - - @Test(result={"private", "static", "strictfp"}) - Collection getModifiers() { - return meth1.getModifiers(); - } - - // Interface methods are implicitly public and abstract. - @Test(result={"public", "abstract"}) - Collection getModifiersInterface() { - for (TypeDeclaration t : thisClassDecl.getNestedTypes()) { - for (MethodDeclaration m : t.getMethods()) { - return m.getModifiers(); - } - } - throw new AssertionError(); - } - - @Test(result="MethodDecl.java") - String getPosition() { - return meth1.getPosition().file().getName(); - } - - @Test(result="m2") - String getSimpleName() { - return meth2.getSimpleName(); - } - - - // MemberDeclaration method - - @Test(result="MethodDecl") - TypeDeclaration getDeclaringType() { - return meth1.getDeclaringType(); - } - - - // ExecutableDeclaration methods - - @Test(result={}) - Collection getFormalTypeParameters1() { - return meth1.getFormalTypeParameters(); - } - - @Test(result={"T", "N extends java.lang.Number"}, - ordered=true) - Collection getFormalTypeParameters2() { - return meth2.getFormalTypeParameters(); - } - - @Test(result={}) - Collection getParameters1() { - return meth1.getParameters(); - } - - @Test(result={"N n", "java.lang.String[] ss"}, - ordered=true) - Collection getParameters2() { - return meth2.getParameters(); - } - - @Test(result="true") - boolean parameterEquals1() { - ParameterDeclaration p1 = - getMethod("m3").getParameters().iterator().next(); - ParameterDeclaration p2 = - getMethod("m3").getParameters().iterator().next(); - return p1.equals(p2); - } - - @Test(result="false") - boolean parameterEquals2() { - ParameterDeclaration p1 = - getMethod("m3").getParameters().iterator().next(); - ParameterDeclaration p2 = - getMethod("m4").getParameters().iterator().next(); - return p1.equals(p2); - } - - @Test(result="true") - boolean parameterHashCode() { - ParameterDeclaration p1 = - getMethod("m3").getParameters().iterator().next(); - ParameterDeclaration p2 = - getMethod("m3").getParameters().iterator().next(); - return p1.hashCode() == p2.hashCode(); - } - - @Test(result={"java.lang.Throwable"}) - Collection getThrownTypes() { - return meth2.getThrownTypes(); - } - - @Test(result="false") - Boolean isVarArgs1() { - return meth1.isVarArgs(); - } - - @Test(result="true") - Boolean isVarArgs2() { - return meth2.isVarArgs(); - } - - - // MethodDeclaration methods - - @Test(result="void") - TypeMirror getReturnType1() { - return meth1.getReturnType(); - } - - @Test(result="N") - TypeMirror getReturnType2() { - return meth2.getReturnType(); - } - - - // toString - - @Test(result=" m2(N, java.lang.String...)") - @Ignore("This is what it would be nice to see.") - String toStringTest() { - return meth2.toString(); - } - - - // Declarations used by tests. - - /** - * Sed Quis custodiet ipsos custodes? - */ - @AT1 - private static strictfp void m1() { - } - - private N m2(N n, String... ss) throws Throwable { - return null; - } - - private void m3(String s) { - } - - private void m4(String s) { - } - - // A nested interface - interface I { - void m(); - } -} - - -// Annotation type used by tests. - -@interface AT1 { -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/declaration/PackageDecl.java --- a/langtools/test/tools/apt/mirror/declaration/PackageDecl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 4853450 5031168 - * @summary PackageDeclaration tests - * @library ../../lib - * @compile -source 1.5 PackageDecl.java - * @run main/othervm PackageDecl - */ - - -import java.io.File; -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - -import pkg1.pkg2.*; - - -/** - * Sed Quis custodiet ipsos custodes? - */ -public class PackageDecl extends Tester { - - public PackageDecl() { - super(System.getProperty("test.src", ".") + File.separator + - "pkg1" + File.separator + "package-info.java"); - } - - public static void main(String[] args) { - (new PackageDecl()).run(); - } - - - private PackageDeclaration pkg1 = null; // a package - private PackageDeclaration pkg2 = null; // a subpackage - - protected void init() { - pkg1 = env.getPackage("pkg1"); - pkg2 = env.getPackage("pkg1.pkg2"); - } - - - // Declaration methods - - @Test(result="package") - Collection accept() { - final Collection res = new ArrayList(); - - pkg1.accept(new SimpleDeclarationVisitor() { - public void visitTypeDeclaration(TypeDeclaration t) { - res.add("type"); - } - public void visitPackageDeclaration(PackageDeclaration p) { - res.add("package"); - } - }); - return res; - } - - @Test(result={"@pkg1.AnAnnoType"}) - Collection getAnnotationMirrors() { - return pkg1.getAnnotationMirrors(); - } - - @Test(result=" Herein lieth the package comment.\n" + - " A doc comment it be, and wonderous to behold.\n") - String getDocCommentFromPackageInfoFile() { - return pkg1.getDocComment(); - } - - @Test(result="\nHerein lieth the package comment.\n" + - "An HTML file it be, and wonderous to behold.\n\n") - @Ignore("Not yet supported") - String getDocCommentFromHtmlFile() { - return pkg2.getDocComment(); - } - - @Test(result={}) - Collection getModifiers() { - return pkg1.getModifiers(); - } - - @Test(result="null") - SourcePosition getPosition() { - return thisClassDecl.getPackage().getPosition(); - } - - @Test(result="package-info.java") - String getPositionFromPackageInfoFile() { - return pkg1.getPosition().file().getName(); - } - - @Test(result="pkg1/pkg2/package.html") - @Ignore("Not yet supported") - String getPositionFromHtmlFile() { - return pkg2.getPosition().file().getName() - .replace(File.separatorChar, '/'); - } - - @Test(result="pkg1") - String getSimpleName1() { - return pkg1.getSimpleName(); - } - - @Test(result="pkg2") - String getSimpleName2() { - return pkg2.getSimpleName(); - } - - - // PackageDeclaration methods - - @Test(result="pkg1.AnAnnoType") - Collection getAnnotationTypes() { - return pkg1.getAnnotationTypes(); - } - - @Test(result={"pkg1.AClass", "pkg1.AnEnum"}) - Collection getClasses() { - return pkg1.getClasses(); - } - - @Test(result="pkg1.AnEnum") - Collection getEnums() { - return pkg1.getEnums(); - } - - @Test(result={"pkg1.AnInterface", "pkg1.AnAnnoType"}) - Collection getInterfaces() { - return pkg1.getInterfaces(); - } - - @Test(result="pkg1") - String getQualifiedName1() { - return pkg1.getQualifiedName(); - } - - @Test(result="pkg1.pkg2") - String getQualifiedName2() { - return pkg2.getQualifiedName(); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/declaration/ParameterDecl.java --- a/langtools/test/tools/apt/mirror/declaration/ParameterDecl.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 4853450 5031171 - * @summary ParameterDeclaration tests - * @library ../../lib - * @run main/othervm ParameterDecl - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -public class ParameterDecl extends Tester { - - public static void main(String[] args) { - (new ParameterDecl()).run(); - } - - - // Declarations used by tests - - @interface AT1 { - } - - @interface AT2 { - boolean value(); - } - - private void m1(@AT1 @AT2(true) final int p1) { - } - - private void m2(int p1) { - } - - - private ParameterDeclaration p1 = null; // a parameter - - protected void init() { - p1 = getMethod("m1").getParameters().iterator().next(); - } - - - // Declaration methods - - @Test(result="param") - Collection accept() { - final Collection res = new ArrayList(); - - p1.accept(new SimpleDeclarationVisitor() { - public void visitFieldDeclaration(FieldDeclaration f) { - res.add("field"); - } - public void visitParameterDeclaration(ParameterDeclaration p) { - res.add("param"); - } - }); - return res; - } - - @Test(result={"@ParameterDecl.AT1", "@ParameterDecl.AT2(true)"}) - Collection getAnnotationMirrors() { - return p1.getAnnotationMirrors(); - } - - @Test(result={"final"}) - Collection getModifiers() { - return p1.getModifiers(); - } - - @Test(result="ParameterDecl.java") - String getPosition() { - return p1.getPosition().file().getName(); - } - - @Test(result="p1") - String getSimpleName() { - return p1.getSimpleName(); - } - - - // ParameterDeclaration methods - - @Test(result="int") - TypeMirror getType() { - return p1.getType(); - } - - - // toString, equals - - @Test(result="int p1") - String toStringTest() { - return p1.toString(); - } - - @Test(result="true") - boolean equalsTest1() { - ParameterDeclaration p = - getMethod("m1").getParameters().iterator().next(); - return p1.equals(p); - } - - // Not all p1's are equal. - @Test(result="false") - boolean equalsTest2() { - ParameterDeclaration p2 = - getMethod("m2").getParameters().iterator().next(); - return p1.equals(p2); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/declaration/pkg1/AClass.java --- a/langtools/test/tools/apt/mirror/declaration/pkg1/AClass.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 pkg1; - -public class AClass { -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/declaration/pkg1/AnAnnoType.java --- a/langtools/test/tools/apt/mirror/declaration/pkg1/AnAnnoType.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 pkg1; - -public @interface AnAnnoType { -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/declaration/pkg1/AnEnum.java --- a/langtools/test/tools/apt/mirror/declaration/pkg1/AnEnum.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 pkg1; - -enum AnEnum { -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/declaration/pkg1/AnInterface.java --- a/langtools/test/tools/apt/mirror/declaration/pkg1/AnInterface.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 pkg1; - -public interface AnInterface { -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/declaration/pkg1/package-info.java --- a/langtools/test/tools/apt/mirror/declaration/pkg1/package-info.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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. - */ - - -/** - * Herein lieth the package comment. - * A doc comment it be, and wonderous to behold. - */ -@AnAnnoType -package pkg1; diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/declaration/pkg1/pkg2/AnInterface.java --- a/langtools/test/tools/apt/mirror/declaration/pkg1/pkg2/AnInterface.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 pkg1.pkg2; - -public interface AnInterface { -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/declaration/pkg1/pkg2/package.html --- a/langtools/test/tools/apt/mirror/declaration/pkg1/pkg2/package.html Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ - - - - - - - - -Herein lieth the package comment. -An HTML file it be, and wonderous to behold. - - - diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/type/AnnoTyp.java --- a/langtools/test/tools/apt/mirror/type/AnnoTyp.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 4853450 - * @summary AnnotationType tests - * @library ../../lib - * @compile -source 1.5 AnnoTyp.java - * @run main/othervm AnnoTyp - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -public class AnnoTyp extends Tester { - - public static void main(String[] args) { - (new AnnoTyp()).run(); - } - - - // Declaration used by tests - - @interface AT { - } - - - private AnnotationType at; // an annotation type - - @AT - protected void init() { - at = getAnno("init", "AnnoTyp.AT").getAnnotationType(); - } - - - // TypeMirror methods - - @Test(result="anno type") - Collection accept() { - final Collection res = new ArrayList(); - - at.accept(new SimpleTypeVisitor() { - public void visitReferenceType(ReferenceType t) { - res.add("ref type"); - } - public void visitClassType(ClassType t) { - res.add("class"); - } - public void visitInterfaceType(InterfaceType t) { - res.add("interface"); - } - public void visitAnnotationType(AnnotationType t) { - res.add("anno type"); - } - }); - return res; - } - - - // AnnotationType method - - @Test(result="AnnoTyp.AT") - AnnotationTypeDeclaration getDeclaration() { - return at.getDeclaration(); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/type/ArrayTyp.java --- a/langtools/test/tools/apt/mirror/type/ArrayTyp.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 4853450 5009357 - * @summary ArrayType tests - * @library ../../lib - * @compile -source 1.5 ArrayTyp.java - * @run main/othervm ArrayTyp - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -public class ArrayTyp extends Tester { - - public static void main(String[] args) { - (new ArrayTyp()).run(); - } - - - // Declaration used by tests - - private boolean[] bs; - private String[][] bss; - - - private ArrayType arr; // an array type - private ArrayType arrarr; // a multi-dimensional array type - - protected void init() { - arr = (ArrayType) getField("bs").getType(); - arrarr = (ArrayType) getField("bss").getType(); - } - - - // TypeMirror methods - - @Test(result="array") - Collection accept() { - final Collection res = new ArrayList(); - - arr.accept(new SimpleTypeVisitor() { - public void visitTypeMirror(TypeMirror t) { - res.add("type"); - } - public void visitArrayType(ArrayType t) { - res.add("array"); - } - public void visitReferenceType(ReferenceType t) { - res.add("ref type"); - } - }); - return res; - } - - @Test(result="boolean[]") - String toStringTest() { - return arr.toString(); - } - - @Test(result="java.lang.String[][]") - String toStringTestMulti() { - return arrarr.toString(); - } - - - // ArrayType method - - @Test(result="boolean") - TypeMirror getComponentType() { - return (PrimitiveType) arr.getComponentType(); - } - - @Test(result="java.lang.String[]") - TypeMirror getComponentTypeMulti() { - return (ArrayType) arrarr.getComponentType(); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/type/ClassTyp.java --- a/langtools/test/tools/apt/mirror/type/ClassTyp.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,240 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 4853450 5009360 5055963 - * @summary ClassType tests - * @library ../../lib - * @run main/othervm ClassTyp - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -public class ClassTyp extends Tester { - - public static void main(String[] args) { - (new ClassTyp()).run(); - } - - - // Declarations used by tests - - static class C1 extends AbstractSet implements Set { - class C2 { - } - - static class C3 { - class C4 { - } - } - - public Iterator iterator() { - return null; - } - - public int size() { - return 0; - } - } - - - // Generate some class types to test. - private C1 f0; - private C1 f1; - private C1 f2; - private C1.C3 f3; - private C1.C2 f4; - private C1.C2 f5; - private C1 f6; - private C1.C3.C4 f7; - private static final int NUMTYPES = 8; - - // Type mirrors corresponding to the types of the above fields - private ClassType[] t = new ClassType[NUMTYPES]; - - // One more type: our own. - private ClassTyp me = this; - - - protected void init() { - for (int i = 0; i < t.length; i++) { - t[i] = (ClassType) getField("f"+i).getType(); - } - } - - - // TypeMirror methods - - @Test(result="class") - Collection accept() { - final Collection res = new ArrayList(); - - t[0].accept(new SimpleTypeVisitor() { - public void visitReferenceType(ReferenceType t) { - res.add("ref type"); - } - public void visitClassType(ClassType t) { - res.add("class"); - } - public void visitInterfaceType(InterfaceType t) { - res.add("interface"); - } - }); - return res; - } - - @Test(result="true") - boolean equals1() { - return t[0].equals(t[0]); - } - - @Test(result="false") - boolean equals2() { - return t[0].equals(t[1]); - } - - // Raw type is not same as type instantiated with unbounded type var. - @Test(result="false") - boolean equals3() { - return t[0].equals(t[2]); - } - - // C1 is same type as C1 - @Test(result="true") - boolean equals4() { - return t[0].equals(t[6]); - } - - @Test(result={ - "ClassTyp.C1", - "ClassTyp.C1", - "ClassTyp.C1", - "ClassTyp.C1.C3", - "ClassTyp.C1.C2", - "ClassTyp.C1.C2", - "ClassTyp.C1", - "ClassTyp.C1.C3.C4" - }, - ordered=true) - Collection toStringTests() { - Collection res = new ArrayList(); - for (ClassType c : t) { - res.add(c.toString()); - } - return res; - } - - - // DeclaredType methods - - @Test(result={"T1"}) - Collection getActualTypeArguments1() { - return t[0].getActualTypeArguments(); - } - - @Test(result={}) - Collection getActualTypeArguments2() { - return t[2].getActualTypeArguments(); - } - - @Test(result={"T2"}) - Collection getActualTypeArguments3() { - return t[3].getActualTypeArguments(); - } - - @Test(result="null") - DeclaredType getContainingType1() { - ClassType thisType = (ClassType) getField("me").getType(); - return thisType.getContainingType(); - } - - @Test(result="ClassTyp") - DeclaredType getContainingType2() { - return t[0].getContainingType(); - } - - @Test(result="ClassTyp.C1") - DeclaredType getContainingType3() { - return t[3].getContainingType(); - } - - @Test(result="ClassTyp.C1") - DeclaredType getContainingType4() { - return t[4].getContainingType(); - } - - @Test(result={"java.util.Set"}) - Collection getSuperinterfaces() { - return t[0].getSuperinterfaces(); - } - - - // ClassType methods - - @Test(result="ClassTyp.C1") - ClassDeclaration getDeclaration1() { - return t[0].getDeclaration(); - } - - @Test(result="ClassTyp.C1.C3") - ClassDeclaration getDeclaration2() { - return t[3].getDeclaration(); - } - - @Test(result="ClassTyp.C1.C2") - ClassDeclaration getDeclaration3a() { - return t[4].getDeclaration(); - } - - @Test(result="ClassTyp.C1.C2") - ClassDeclaration getDeclaration3b() { - return t[5].getDeclaration(); - } - - @Test(result="true") - boolean getDeclarationEq() { - return t[0].getDeclaration() == t[6].getDeclaration(); - } - - @Test(result="java.util.AbstractSet") - ClassType getSuperclass1() { - return t[0].getSuperclass(); - } - - @Test(result="java.lang.Object") - ClassType getSuperclass2() { - return t[4].getSuperclass(); - } - - @Test(result="null") - ClassType getSuperclassOfObject() { - return t[4].getSuperclass().getSuperclass(); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/type/EnumTyp.java --- a/langtools/test/tools/apt/mirror/type/EnumTyp.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 4853450 - * @summary EnumType tests - * @library ../../lib - * @compile -source 1.5 EnumTyp.java - * @run main/othervm EnumTyp - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -public class EnumTyp extends Tester { - - public static void main(String[] args) { - (new EnumTyp()).run(); - } - - - // Declarations used by tests - - enum Suit { - CIVIL, - CRIMINAL - } - - private Suit s; - - - private EnumType e; // an enum type - - protected void init() { - e = (EnumType) getField("s").getType(); - } - - - // TypeMirror methods - - @Test(result="enum") - Collection accept() { - final Collection res = new ArrayList(); - - e.accept(new SimpleTypeVisitor() { - public void visitTypeMirror(TypeMirror t) { - res.add("type"); - } - public void visitReferenceType(ReferenceType t) { - res.add("ref type"); - } - public void visitClassType(ClassType t) { - res.add("class"); - } - public void visitEnumType(EnumType t) { - res.add("enum"); - } - public void visitInterfaceType(InterfaceType t) { - res.add("interface"); - } - }); - return res; - } - - - // EnumType method - - @Test(result="EnumTyp.Suit") - EnumDeclaration getDeclaration() { - return e.getDeclaration(); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/type/InterfaceTyp.java --- a/langtools/test/tools/apt/mirror/type/InterfaceTyp.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,202 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 4853450 5055963 - * @summary InterfaceType tests - * @library ../../lib - * @run main/othervm InterfaceTyp - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -public class InterfaceTyp extends Tester { - - public static void main(String[] args) { - (new InterfaceTyp()).run(); - } - - - // Declarations used by tests - - interface I1 extends Set { - interface I2 { - } - } - - - // Generate some interface types to test - private I1 f0; - private I1 f1; - private I1 f2; - private I1.I2 f3; - private I1.I2 f4; - private I1 f5; - private I3 f6; - private static final int NUMTYPES = 7; - - // Type mirrors corresponding to the types of the above fields - private InterfaceType[] t = new InterfaceType[NUMTYPES]; - - protected void init() { - for (int i = 0; i < t.length; i++) { - t[i] = (InterfaceType) getField("f"+i).getType(); - } - } - - - // TypeMirror methods - - @Test(result="interface") - Collection accept() { - final Collection res = new ArrayList(); - - t[0].accept(new SimpleTypeVisitor() { - public void visitReferenceType(ReferenceType t) { - res.add("ref type"); - } - public void visitClassType(ClassType t) { - res.add("class"); - } - public void visitInterfaceType(InterfaceType t) { - res.add("interface"); - } - }); - return res; - } - - @Test(result="true") - boolean equals1() { - return t[0].equals(t[0]); - } - - @Test(result="false") - boolean equals2() { - return t[0].equals(t[1]); - } - - // Raw type is not same as type instantiated with unbounded type var. - @Test(result="false") - boolean equals3() { - return t[0].equals(t[2]); - } - - // I1 is same type as I1 - @Test(result="true") - boolean equals4() { - return t[0].equals(t[5]); - } - - @Test(result={ - "InterfaceTyp.I1", - "InterfaceTyp.I1", - "InterfaceTyp.I1", - "InterfaceTyp.I1.I2", - "InterfaceTyp.I1.I2", - "InterfaceTyp.I1", - "I3" - }, - ordered=true) - Collection toStringTests() { - Collection res = new ArrayList(); - for (InterfaceType i : t) { - res.add(i.toString()); - } - return res; - } - - - // DeclaredType methods - - @Test(result={"T1"}) - Collection getActualTypeArguments1() { - return t[0].getActualTypeArguments(); - } - - @Test(result={}) - Collection getActualTypeArguments2() { - return t[2].getActualTypeArguments(); - } - - @Test(result={"java.lang.String"}) - Collection getActualTypeArguments3() { - return t[3].getActualTypeArguments(); - } - - @Test(result="InterfaceTyp") - DeclaredType getContainingType1() { - return t[0].getContainingType(); - } - - @Test(result="InterfaceTyp.I1") - DeclaredType getContainingType2() { - return t[3].getContainingType(); - } - - @Test(result="null") - DeclaredType getContainingTypeTopLevel() { - return t[6].getContainingType(); - } - - @Test(result={"java.util.Set"}) - Collection getSuperinterfaces() { - return t[0].getSuperinterfaces(); - } - - - - // InterfaceType method - - @Test(result="InterfaceTyp.I1") - InterfaceDeclaration getDeclaration1() { - return t[0].getDeclaration(); - } - - @Test(result="InterfaceTyp.I1.I2") - InterfaceDeclaration getDeclaration2a() { - return t[3].getDeclaration(); - } - - @Test(result="InterfaceTyp.I1.I2") - InterfaceDeclaration getDeclaration2b() { - return t[4].getDeclaration(); - } - - @Test(result="true") - boolean getDeclarationCaching() { - return t[0].getDeclaration() == t[5].getDeclaration(); - } -} - - -// A top-level interface used by tests. - -interface I3 { -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/type/PrimitiveTyp.java --- a/langtools/test/tools/apt/mirror/type/PrimitiveTyp.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 4853450 - * @summary PrimitiveType tests - * @library ../../lib - * @compile -source 1.5 PrimitiveTyp.java - * @run main/othervm PrimitiveTyp - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -public class PrimitiveTyp extends Tester { - - public static void main(String[] args) { - (new PrimitiveTyp()).run(); - } - - - // Declaration used by tests - - private boolean b; - - - private PrimitiveType prim; // a primitive type - - protected void init() { - prim = (PrimitiveType) getField("b").getType(); - } - - - // TypeMirror methods - - @Test(result="primitive") - Collection accept() { - final Collection res = new ArrayList(); - - prim.accept(new SimpleTypeVisitor() { - public void visitTypeMirror(TypeMirror t) { - res.add("type"); - } - public void visitPrimitiveType(PrimitiveType t) { - res.add("primitive"); - } - public void visitReferenceType(ReferenceType t) { - res.add("ref type"); - } - }); - return res; - } - - @Test(result="boolean") - String toStringTest() { - return prim.toString(); - } - - - // PrimitiveType method - - @Test(result="BOOLEAN") - PrimitiveType.Kind getKind() { - return prim.getKind(); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/type/TypeVar.java --- a/langtools/test/tools/apt/mirror/type/TypeVar.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 4853450 - * @summary TypeVariable tests - * @library ../../lib - * @compile -source 1.5 TypeVar.java - * @run main/othervm TypeVar - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -public class TypeVar extends Tester { - - public static void main(String[] args) { - (new TypeVar()).run(); - } - - - // Declarations used by tests - - private T t; - private S s; - - - private TypeVariable tvT; // type variable T - private TypeVariable tvS; // type variable S - - protected void init() { - tvT = (TypeVariable) getField("t").getType(); - tvS = (TypeVariable) getField("s").getType(); - } - - - // TypeMirror methods - - @Test(result="type var") - Collection accept() { - final Collection res = new ArrayList(); - - tvT.accept(new SimpleTypeVisitor() { - public void visitTypeMirror(TypeMirror t) { - res.add("type"); - } - public void visitReferenceType(ReferenceType t) { - res.add("ref type"); - } - public void visitTypeVariable(TypeVariable t) { - res.add("type var"); - } - }); - return res; - } - - @Test(result="T") - String toStringTest1() { - return tvT.toString(); - } - - @Test(result="S") - String toStringTest2() { - return tvS.toString(); - } - - - // TypeVariable method - - @Test(result="S extends java.lang.Number & java.lang.Runnable") - TypeParameterDeclaration getDeclaration() { - return tvS.getDeclaration(); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/type/WildcardTyp.java --- a/langtools/test/tools/apt/mirror/type/WildcardTyp.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 4853450 5009396 5010636 5031156 - * @summary WildcardType tests - * @library ../../lib - * @compile -source 1.5 WildcardTyp.java - * @run main/othervm WildcardTyp - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -public class WildcardTyp extends Tester { - - public static void main(String[] args) { - (new WildcardTyp()).run(); - } - - - // Declarations to use for testing - - interface G { - } - - interface G1 { - } - - interface G2> { - } - - // Some wildcard types to test. - private G f0; // unbound - private G f1; // covariant - private G f2; // contravariant - private G f3; // - private G1 f4; // "true" upper bound is an intersection type - private G2 f5; // 'true" upper bound is a recursive F-bound and - // not expressible - private static final int NUMTYPES = 6; - - // Type mirrors corresponding to the wildcard types of the above fields - private WildcardType[] t = new WildcardType[NUMTYPES]; - - - protected void init() { - for (int i = 0; i < t.length; i++) { - DeclaredType type = (DeclaredType) getField("f"+i).getType(); - t[i] = (WildcardType) - type.getActualTypeArguments().iterator().next(); - } - } - - private WildcardType wildcardFor(String field) { - DeclaredType d = (DeclaredType) getField(field).getType(); - return (WildcardType) d.getActualTypeArguments().iterator().next(); - } - - - // TypeMirror methods - - @Test(result="wild thing") - Collection accept() { - final Collection res = new ArrayList(); - - t[0].accept(new SimpleTypeVisitor() { - public void visitTypeMirror(TypeMirror t) { - res.add("type"); - } - public void visitReferenceType(ReferenceType t) { - res.add("ref type"); - } - public void visitWildcardType(WildcardType t) { - res.add("wild thing"); - } - }); - return res; - } - - @Test(result={ - "?", - "? extends java.lang.Number", - "? super java.lang.Number", - "? extends java.lang.Object", - "?", - "?" - }, - ordered=true) - Collection toStringTests() { - Collection res = new ArrayList(); - for (WildcardType w : t) { - res.add(w.toString()); - } - return res; - } - - - // WildcardType methods - - @Test(result={ - "null", - "null", - "java.lang.Number", - "null", - "null", - "null" - }, - ordered=true) - Collection getLowerBounds() { - Collection res = new ArrayList(); - for (WildcardType w : t) { - Collection bounds = w.getLowerBounds(); - int num = bounds.size(); - if (num > 1) { - throw new AssertionError("Bounds abound"); - } - res.add((num > 0) ? bounds.iterator().next() : null); - } - return res; - } - - @Test(result={ - "null", - "java.lang.Number", - "null", - "java.lang.Object", - "null", - "null" - }, - ordered=true) - Collection getUpperBounds() { - Collection res = new ArrayList(); - for (WildcardType w : t) { - Collection bounds = w.getUpperBounds(); - int num = bounds.size(); - if (num > 1) { - throw new AssertionError("Bounds abound"); - } - res.add((num > 0) ? bounds.iterator().next() : null); - } - return res; - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/util/Overrides.java --- a/langtools/test/tools/apt/mirror/util/Overrides.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 5037165 - * @summary Test the Declarations.overrides method - * @library ../../lib - * @run main/othervm Overrides - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - - -public class Overrides extends Tester { - - public static void main(String[] args) { - (new Overrides()).run(); - } - - - // Declarations used by tests - - static class A { - void m1(int i) {}; // does not override itself - void m2(int i) {}; - static void m3(int i) {}; - } - - static class B extends A { - void m1(int j) {}; // overrides A.m1 - void m1(String i) {}; // does not override A.m1 - void m4(int i) {}; // does not override A.m1 - } - - static class C extends B { - void m1(int i) {}; // overrides A.m1 and B.m1 - void m2(int i) {}; // overrides A.m2 - } - - static class D extends A { - static void m3(int i) {}; // does not override A.m3 - } - - static class E { - void m1(int i) {}; // does not override A.m1 - } - - - - private Declarations decls; - - private TypeDeclaration A; - private TypeDeclaration B; - private TypeDeclaration C; - private TypeDeclaration D; - private TypeDeclaration E; - private MethodDeclaration Am1; - private MethodDeclaration Am2; - private MethodDeclaration Am3; - private MethodDeclaration Bm1; - private MethodDeclaration Bm1b; - private MethodDeclaration Bm4; - private MethodDeclaration Cm1; - private MethodDeclaration Cm2; - private MethodDeclaration Dm3; - private MethodDeclaration Em1; - - protected void init() { - decls = env.getDeclarationUtils(); - - A = env.getTypeDeclaration("Overrides.A"); - B = env.getTypeDeclaration("Overrides.B"); - C = env.getTypeDeclaration("Overrides.C"); - D = env.getTypeDeclaration("Overrides.D"); - E = env.getTypeDeclaration("Overrides.E"); - - Am1 = getMethod(A, "m1", "i"); - Am2 = getMethod(A, "m2", "i"); - Am3 = getMethod(A, "m3", "i"); - Bm1 = getMethod(B, "m1", "j"); - Bm1b = getMethod(B, "m1", "i"); - Bm4 = getMethod(B, "m4", "i"); - Cm1 = getMethod(C, "m1", "i"); - Cm2 = getMethod(C, "m2", "i"); - Dm3 = getMethod(D, "m3", "i"); - Em1 = getMethod(E, "m1", "i"); - } - - private MethodDeclaration getMethod(TypeDeclaration t, - String methodName, String paramName) { - for (MethodDeclaration m : t.getMethods()) { - if (methodName.equals(m.getSimpleName()) && - paramName.equals(m.getParameters().iterator().next() - .getSimpleName())) { - return m; - } - } - throw new AssertionError(); - } - - - // Declarations methods - - @Test(result={"false", - "true", - "false", - "false", - "true", - "true", - "true", - "false", - "false"}, - ordered=true) - List overrides() { - return Arrays.asList( - decls.overrides(Am1, Am1), - decls.overrides(Bm1, Am1), - decls.overrides(Bm1b,Am1), - decls.overrides(Bm4, Am1), - decls.overrides(Cm1, Am1), - decls.overrides(Cm1, Bm1), - decls.overrides(Cm2, Am2), - decls.overrides(Dm3, Am3), - decls.overrides(Em1, Am1)); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/apt/mirror/util/TypeCreation.java --- a/langtools/test/tools/apt/mirror/util/TypeCreation.java Fri Feb 17 10:18:50 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 5033381 - * @summary Test the type creation methods in Types. - * @library ../../lib - * @run main/othervm TypeCreation - */ - - -import java.util.*; -import com.sun.mirror.declaration.*; -import com.sun.mirror.type.*; -import com.sun.mirror.util.*; - -import static com.sun.mirror.type.PrimitiveType.Kind.*; - - -public class TypeCreation extends Tester { - - public static void main(String[] args) { - (new TypeCreation()).run(); - } - - - // Declarations used by tests - - class A { - } - - class O { - class I { - } - } - - - private Types types; - - private TypeDeclaration A; - private TypeDeclaration O; - private TypeDeclaration I; - - private DeclaredType AType; - - protected void init() { - types = env.getTypeUtils(); - A = env.getTypeDeclaration("TypeCreation.A"); - O = env.getTypeDeclaration("TypeCreation.O"); - I = env.getTypeDeclaration("TypeCreation.O.I"); - - AType = types.getDeclaredType(A); - } - - - @Test(result="boolean") - PrimitiveType getPrimitiveType() { - return types.getPrimitiveType(BOOLEAN); - } - - @Test(result="void") - VoidType getVoidType() { - return types.getVoidType(); - } - - @Test(result="boolean[]") - ArrayType getArrayType1() { - return types.getArrayType( - types.getPrimitiveType(BOOLEAN)); - } - - @Test(result="TypeCreation.A[]") - ArrayType getArrayType2() { - return types.getArrayType(AType); - } - - @Test(result="? extends TypeCreation.A") - WildcardType getWildcardType() { - Collection uppers = new ArrayList(); - Collection downers = new ArrayList(); - uppers.add(AType); - return types.getWildcardType(uppers, downers); - } - - @Test(result="TypeCreation.O") - DeclaredType getDeclaredType1() { - TypeDeclaration stringDecl = env.getTypeDeclaration("java.lang.String"); - DeclaredType stringType = types.getDeclaredType(stringDecl); - return types.getDeclaredType(O, stringType); - } - - @Test(result="TypeCreation.O.I") - DeclaredType getDeclaredType2() { - TypeDeclaration numDecl = env.getTypeDeclaration("java.lang.Number"); - DeclaredType numType = types.getDeclaredType(numDecl); - DeclaredType OType = getDeclaredType1(); - return types.getDeclaredType(OType, I, numType); - } -} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/javac/7142086/T7142086.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/7142086/T7142086.java Wed Feb 22 10:17:57 2012 -0800 @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7142086 + * @summary performance problem in Check.checkOverrideClashes(...) + * @run main/timeout=10 T7142086 + */ + +import com.sun.source.util.JavacTask; +import java.net.URI; +import java.util.List; +import java.util.ArrayList; +import java.util.Locale; +import javax.tools.Diagnostic; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +public class T7142086 { + + final static int N_METHODS = 1000; + + static class TestClass extends SimpleJavaFileObject { + + String methTemplate = "abstract void m(A#N p);"; + String classTemplate = "abstract class Test { #M }"; + + String source; + + public TestClass() { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + StringBuilder buf = new StringBuilder(); + for (int i = 0 ; i < N_METHODS ; i++) { + buf.append(methTemplate.replace("#N", String.valueOf(i))); + buf.append("\n"); + } + source = classTemplate.replace("#M", buf.toString()); + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return source; + } + } + + static class AnSource extends SimpleJavaFileObject { + + String classTemplate = "abstract class A#N { }"; + + String source; + + public AnSource(int n) { + super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); + source = classTemplate.replace("#N", String.valueOf(n)); + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return source; + } + } + + public static void main(String... args) throws Exception { + ArrayList sources = new ArrayList<>(); + for (int i = 0 ; i < N_METHODS ; i++) { + sources.add(new AnSource(i)); + } + sources.add(new TestClass()); + new T7142086().run(sources); + } + + void run(List sources) throws Exception { + DiagnosticChecker dc = new DiagnosticChecker(); + JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); + JavacTask ct = (JavacTask)comp.getTask(null, fm, dc, + null, null, sources); + ct.analyze(); + } + + static class DiagnosticChecker implements javax.tools.DiagnosticListener { + + boolean errorFound; + + public void report(Diagnostic diagnostic) { + if (diagnostic.getKind() == Diagnostic.Kind.ERROR) { + throw new AssertionError("unexpected diagnostic: " + diagnostic.getMessage(Locale.getDefault())); + } + } + } +} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/javac/T7142672/AnnoProcessor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/T7142672/AnnoProcessor.java Wed Feb 22 10:17:57 2012 -0800 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.Set; +import javax.annotation.processing.*; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.TypeElement; + +@SupportedAnnotationTypes("Anno") +public class AnnoProcessor extends AbstractProcessor { + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } + + @Override + public boolean process(Set set, RoundEnvironment re) { + System.out.println("RUNNING..."); + if(set.isEmpty()) { + return false; + } + return false; + } +} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/javac/T7142672/Bug.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/T7142672/Bug.java Wed Feb 22 10:17:57 2012 -0800 @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 7142672 + * @summary Problems with the value passed to the 'classes' param of JavaCompiler.CompilationTask.getTask(...) + * @author holmlund + * @compile AnnoProcessor.java Bug.java Test3.java + * @run main Bug Test2.java + * @run main Bug Test2.foo + * @run main Bug Test3.java + */ +import java.io.*; +import java.util.*; +import javax.tools.*; + +// Each run should output the 'could not find class file' message, and not throw an AssertError. +public class Bug { + public static void main(String... arg) throws Throwable { + String name = arg[0]; + final String expectedMsg = "error: Could not find class file for '" + name + "'."; + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + JavaCompiler.CompilationTask task2; + StringWriter sw = new StringWriter(); + final PrintWriter pw = new PrintWriter(sw); + + + DiagnosticListener dl = + new DiagnosticListener() { + public void report(Diagnostic message) { + pw.print("Diagnostic:\n"+ message.toString()+"\n"); + if (!message.toString().equals(expectedMsg)){ + System.err.println("Diagnostic:\n"+ message.toString()+"\n"); + System.err.println("--Failed: Unexpected diagnostic"); + System.exit(1); + } + } + }; + + StandardJavaFileManager sjfm = javac.getStandardFileManager(dl,null,null); + + List opts = new ArrayList(); + opts.add("-proc:only"); + opts.add("-processor"); + opts.add("AnnoProcessor"); + + boolean xxx; + + System.err.println("\n-- " + name); + task2 = javac.getTask(pw, sjfm, dl, opts, Arrays.asList(name), null); + xxx = task2.call(); + + String out = sw.toString(); + System.err.println(out); + if (out.contains("Assert")) { + System.err.println("--Failed: Assertion failure"); + System.exit(1); + } + if (!out.contains(expectedMsg)) { + System.err.println("--Failed: Expected diagnostic not found"); + System.exit(1); + } + } +} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/javac/T7142672/Test2.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/T7142672/Test2.java Wed Feb 22 10:17:57 2012 -0800 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +class Test2 { +} diff -r eab1e4be8495 -r 09f5d262e329 langtools/test/tools/javac/T7142672/Test3.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/T7142672/Test3.java Wed Feb 22 10:17:57 2012 -0800 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +class Test3 { +}